diff --git a/src/GUI/AddCatalogDialog.cxx b/src/GUI/AddCatalogDialog.cxx deleted file mode 100644 index a0bd19b0f..000000000 --- a/src/GUI/AddCatalogDialog.cxx +++ /dev/null @@ -1,259 +0,0 @@ -// AddCatalogDialog.cxx - part of GUI launcher using Qt5 -// -// Written by James Turner, started March 2015. -// -// Copyright (C) 2015 James Turner -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -#include "AddCatalogDialog.hxx" -#include "ui_AddCatalogDialog.h" - -#include -#include - -#include -#include - -#include
-#include -#include - -using namespace simgear::pkg; - -class AddCatalogDialog::AddCatalogDelegate : public simgear::pkg::Delegate -{ -public: - AddCatalogDelegate(AddCatalogDialog* outer) : p(outer) {} - - void catalogRefreshed(CatalogRef catalog, StatusCode) override - { - p->onCatalogStatusChanged(catalog); - } - - void startInstall(InstallRef) override {} - void installProgress(InstallRef, unsigned int, unsigned int) override {} - void finishInstall(InstallRef, StatusCode ) override {} -private: - AddCatalogDialog* p = nullptr; -}; - -AddCatalogDialog::AddCatalogDialog(QWidget *parent, RootRef root) : - QDialog(parent, Qt::Dialog - | Qt::CustomizeWindowHint - | Qt::WindowTitleHint - | Qt::WindowSystemMenuHint - | Qt::WindowContextHelpButtonHint - | Qt::MSWindowsFixedSizeDialogHint), - ui(new Ui::AddCatalogDialog), - m_packageRoot(root) -{ - ui->setupUi(this); - - connect(ui->urlEdit, &QLineEdit::textEdited, - this, &AddCatalogDialog::onUrlTextChanged); - - updateUi(); -} - -AddCatalogDialog::~AddCatalogDialog() -{ - if (m_delegate) { - m_packageRoot->removeDelegate(m_delegate.get()); - } - delete ui; -} - -CatalogRef AddCatalogDialog::addedCatalog() -{ - return m_result; -} - -void AddCatalogDialog::setNonInteractiveMode() -{ - m_nonInteractiveMode = true; - ui->buttonBox->hide(); -} - -void AddCatalogDialog::setUpdatingExistingCatalog() -{ - m_updatingExistingCatalog = true; -} - -void AddCatalogDialog::setUrlAndDownload(QUrl url) -{ - m_catalogUrl = url; - startDownload(); -} - -void AddCatalogDialog::onUrlTextChanged() -{ - m_catalogUrl = QUrl::fromUserInput(ui->urlEdit->text()); - updateUi(); -} - -void AddCatalogDialog::updateUi() -{ - QPushButton* b = ui->buttonBox->button(QDialogButtonBox::Ok); - - switch (m_state) { - case STATE_START: - b->setText(tr("Next")); - b->setEnabled(m_catalogUrl.isValid() && !m_catalogUrl.isRelative()); - break; - - case STATE_DOWNLOADING: - b->setEnabled(false); - break; - - case STATE_DOWNLOAD_FAILED: - b->setEnabled(false); - break; - - case STATE_FINISHED: - b->setEnabled(true); - b->setText(tr("Okay")); - break; - } - - if (m_state == STATE_FINISHED) { - QString catDesc = QString::fromStdString(m_result->name()); - QString s = tr("Successfully retrieved aircraft information from '%1'. " - "%2 aircraft are included in this hangar.").arg(catDesc).arg(m_result->packages().size()); - ui->resultsSummaryLabel->setText(s); - } else if (m_state == STATE_DOWNLOAD_FAILED) { - Delegate::StatusCode code = m_result->status(); - QString s; - switch (code) { - case Delegate::FAIL_DOWNLOAD: - s = tr("Failed to download aircraft descriptions from '%1'. " - "Check the address (URL) and your network connection.").arg(m_catalogUrl.toString()); - break; - - case Delegate::FAIL_NOT_FOUND: - s = tr("Failed to download aircraft descriptions at '%1'. " - "Check the URL is correct.").arg(m_catalogUrl.toString()); - break; - - case Delegate::FAIL_VERSION: - s = tr("The provided hangar is for a different version of FlightGear. " - "(This is version %1)").arg(QString::fromUtf8(FLIGHTGEAR_VERSION)); - break; - - default: - s = tr("Unknown error occured trying to set up the hangar."); - } - - ui->resultsSummaryLabel->setText(s); - } -} - -void AddCatalogDialog::startDownload() -{ - Q_ASSERT(m_catalogUrl.isValid()); - - m_delegate.reset(new AddCatalogDelegate{this}); - m_packageRoot->addDelegate(m_delegate.get()); - m_result = Catalog::createFromUrl(m_packageRoot, m_catalogUrl.toString().toStdString()); - m_state = STATE_DOWNLOADING; - updateUi(); - ui->stack->setCurrentIndex(STATE_DOWNLOADING); -} - -void AddCatalogDialog::accept() -{ - switch (m_state) { - case STATE_START: - startDownload(); - break; - - case STATE_DOWNLOADING: - case STATE_DOWNLOAD_FAILED: - // can't happen, button is disabled - break; - - case STATE_FINISHED: - QDialog::accept(); - break; - } -} - -void AddCatalogDialog::reject() -{ - // user may have successfully download the catalog, but choosen - // not to add it. so remove it here - - // however, if we got in here as part of re-validating an existing - // disabled catalog, *but* the re-validation also failed, we do not - // want to remove it here. - - if (m_result && !m_result->id().empty()) - { - if (m_updatingExistingCatalog) { - qWarning() << "cancelled add, but existing catalog so not removing:" - << QString::fromStdString(m_result->id()); - } else { - qWarning() << "removed cancelled catalog:" - << QString::fromStdString(m_result->id()); - m_packageRoot->removeCatalogById(m_result->id()); - } - } - - QDialog::reject(); -} - -void AddCatalogDialog::onCatalogStatusChanged(Catalog* cat) -{ - if (cat != m_result) { - return; - } - - Delegate::StatusCode s = cat->status(); - switch (s) { - case Delegate::STATUS_REFRESHED: - m_state = STATE_FINISHED; - break; - - case Delegate::STATUS_IN_PROGRESS: - // don't jump to STATE_FINISHED - return; - - case Delegate::FAIL_NOT_FOUND: - { - FGHTTPClient* http = globals->get_subsystem(); - if (cat->url() == http->getDefaultCatalogUrl()) { - cat->setUrl(http->getDefaultCatalogFallbackUrl()); - cat->refresh(); // and trigger another refresh - return; - } - - m_state = STATE_DOWNLOAD_FAILED; - break; - } - - // all the actual failure codes - default: - m_state = STATE_DOWNLOAD_FAILED; - break; - } - - ui->stack->setCurrentIndex(STATE_FINISHED); - if (m_nonInteractiveMode) { - QDialog::accept(); // we're done - } - - updateUi(); -} - diff --git a/src/GUI/AddCatalogDialog.hxx b/src/GUI/AddCatalogDialog.hxx deleted file mode 100644 index da5f2cda1..000000000 --- a/src/GUI/AddCatalogDialog.hxx +++ /dev/null @@ -1,96 +0,0 @@ -// AddCatalogDialog.hxx - part of GUI launcher using Qt5 -// -// Written by James Turner, started March 2015. -// -// Copyright (C) 2015 James Turner -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -#ifndef FG_GUI_ADDCATALOGDIALOG_HXX -#define FG_GUI_ADDCATALOGDIALOG_HXX - -#include - -#include -#include - -#include -#include - -namespace Ui { -class AddCatalogDialog; -} - - -class AddCatalogDialog : public QDialog -{ - Q_OBJECT - -public: - explicit AddCatalogDialog(QWidget *parent, - simgear::pkg::RootRef root); - ~AddCatalogDialog(); - - simgear::pkg::CatalogRef addedCatalog(); - - /** - * @brief setNonInteractiveMode - display progres but don't wait for user - * interaction at all. (Hides the buttons, closes autoamtically on success - * or failure) - */ - void setNonInteractiveMode(); - - /** - * @brief setUpdatingExistingCatalog - indicate that this is an update or - * fix of an existing catalog, in which case we will treat failures / - * cancellation differently. - */ - void setUpdatingExistingCatalog(); - - void setUrlAndDownload(QUrl url); -private slots: - virtual void reject(); - virtual void accept(); - - void onUrlTextChanged(); -private: - class AddCatalogDelegate; - friend class AddCatalogDelegate; - - void startDownload(); - void updateUi(); - - void onCatalogStatusChanged(simgear::pkg::Catalog* cat); - - enum State { - STATE_START = 0, // awaiting user input on first screen - STATE_DOWNLOADING = 1, // in-progress, showing progress page - STATE_FINISHED = 2, // catalog added ok, showing summary page - STATE_DOWNLOAD_FAILED // download checks failed for some reason - - }; - - State m_state = STATE_START; - - Ui::AddCatalogDialog *ui; - simgear::pkg::RootRef m_packageRoot; - QUrl m_catalogUrl; - simgear::pkg::CatalogRef m_result; - bool m_nonInteractiveMode = false; - bool m_updatingExistingCatalog = false; - std::unique_ptr m_delegate; -}; - -#endif // FG_GUI_ADDCATALOGDIALOG_HXX diff --git a/src/GUI/AddCatalogDialog.ui b/src/GUI/AddCatalogDialog.ui deleted file mode 100644 index 549939958..000000000 --- a/src/GUI/AddCatalogDialog.ui +++ /dev/null @@ -1,158 +0,0 @@ - - - AddCatalogDialog - - - - 0 - 0 - 500 - 200 - - - - Add aircraft hangar - - - - :/app-icon-large:/app-icon-large - - - - - - 0 - - - - - - - Enter the URL of an aircraft hangar: - - - - - - - http://www.somesite.com/flightgear-aircraft.xml - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - 0 - 0 - - - - Please wait, downloading and checking the hangar information. - - - - - - - - 0 - 0 - - - - 0 - - - -1 - - - - - - - - - - - Lorem Ipsum - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - buttonBox - accepted() - AddCatalogDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - AddCatalogDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/GUI/CMakeLists.txt b/src/GUI/CMakeLists.txt index 7125664f3..4f9d18bce 100644 --- a/src/GUI/CMakeLists.txt +++ b/src/GUI/CMakeLists.txt @@ -69,8 +69,6 @@ endif() if (HAVE_QT) qt5_wrap_ui(uic_sources Launcher.ui SetupRootDialog.ui - AddCatalogDialog.ui - PathsDialog.ui LocationWidget.ui InstallSceneryDialog.ui ) diff --git a/src/GUI/PathsDialog.cxx b/src/GUI/PathsDialog.cxx deleted file mode 100644 index 940a5ea8a..000000000 --- a/src/GUI/PathsDialog.cxx +++ /dev/null @@ -1,323 +0,0 @@ -#include "PathsDialog.hxx" -#include "ui_PathsDialog.h" - -#include -#include -#include -#include -#include - -#include "CatalogListModel.hxx" -#include "AddCatalogDialog.hxx" -#include "AircraftModel.hxx" -#include "InstallSceneryDialog.hxx" -#include "QtLauncher.hxx" -#include "LocalAircraftCache.hxx" - -#include
-#include
-#include - -AddOnsPage::AddOnsPage(QWidget *parent, simgear::pkg::RootRef root) : - QWidget(parent), - m_ui(new Ui::AddOnsPage), - m_packageRoot(root) -{ - m_ui->setupUi(this); - - m_catalogsModel = new CatalogListModel(this, m_packageRoot); - m_ui->catalogsList->setModel(m_catalogsModel); - connect(m_ui->catalogsList, &QListView::doubleClicked, - this, &AddOnsPage::onCatalogDoubleClicked); - // enable drag-drop to re-order the paths - m_ui->sceneryPathsList->setDragEnabled(true); - m_ui->sceneryPathsList->setDragDropMode(QAbstractItemView::InternalMove); - m_ui->sceneryPathsList->setDropIndicatorShown(true); - - m_ui->aircraftPathsList->setDragEnabled(true); - m_ui->aircraftPathsList->setDragDropMode(QAbstractItemView::InternalMove); - m_ui->aircraftPathsList->setDropIndicatorShown(true); - - connect(m_ui->addCatalog, &QToolButton::clicked, - this, &AddOnsPage::onAddCatalog); - connect(m_ui->addDefaultCatalogButton, &QPushButton::clicked, - this, &AddOnsPage::onAddDefaultCatalog); - connect(m_ui->removeCatalog, &QToolButton::clicked, - this, &AddOnsPage::onRemoveCatalog); - - connect(m_ui->addSceneryPath, &QToolButton::clicked, - this, &AddOnsPage::onAddSceneryPath); - connect(m_ui->removeSceneryPath, &QToolButton::clicked, - this, &AddOnsPage::onRemoveSceneryPath); - - connect(m_ui->addAircraftPath, &QToolButton::clicked, - this, &AddOnsPage::onAddAircraftPath); - connect(m_ui->removeAircraftPath, &QToolButton::clicked, - this, &AddOnsPage::onRemoveAircraftPath); - - connect(m_ui->installSceneryButton, &QPushButton::clicked, - this, &AddOnsPage::onInstallScenery); - - m_ui->sceneryPathsList->setToolTip( - tr("After changing this list, please restart the launcher to avoid " - "possibly inconsistent behavior.")); - m_ui->installSceneryButton->setToolTip( - tr("After installing scenery, you may have to restart the launcher " - "to avoid inconsistent behavior.")); - - QSettings settings; - - QStringList sceneryPaths = settings.value("scenery-paths").toStringList(); - m_ui->sceneryPathsList->addItems(sceneryPaths); - - connect(m_ui->sceneryPathsList->model(), &QAbstractItemModel::rowsMoved, - this, &AddOnsPage::saveSceneryPaths); - - QStringList aircraftPaths = settings.value("aircraft-paths").toStringList(); - m_ui->aircraftPathsList->addItems(aircraftPaths); - - connect(m_ui->aircraftPathsList->model(), &QAbstractItemModel::rowsMoved, - this, &AddOnsPage::saveAircraftPaths); - - updateUi(); -} - -AddOnsPage::~AddOnsPage() -{ - delete m_ui; -} - -void AddOnsPage::onAddSceneryPath() -{ - QString path = QFileDialog::getExistingDirectory(this, tr("Choose scenery folder")); - if (!path.isEmpty()) { - // validation - - SGPath p(path.toStdString()); - bool isValid = false; - - for (const auto& dir: {"Objects", "Terrain", "Buildings", "Roads", - "Pylons", "NavData"}) { - if ((p / dir).exists()) { - isValid = true; - break; - } - } - - if (!isValid) { - QMessageBox mb; - mb.setText(tr("The folder '%1' doesn't appear to contain scenery - add anyway?").arg(path)); - mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - mb.setDefaultButton(QMessageBox::No); - mb.setInformativeText(tr("Added scenery should contain at least one of the following " - "folders: Objects, Terrain, Buildings, Roads, Pylons, NavData.")); - mb.exec(); - - if (mb.result() == QMessageBox::No) { - return; - } - } - - m_ui->sceneryPathsList->addItem(path); - saveSceneryPaths(); - } -} - -void AddOnsPage::onRemoveSceneryPath() -{ - if (m_ui->sceneryPathsList->currentItem()) { - delete m_ui->sceneryPathsList->currentItem(); - saveSceneryPaths(); - } -} - -void AddOnsPage::onAddAircraftPath() -{ - QString path = QFileDialog::getExistingDirectory(this, tr("Choose aircraft folder")); - if (!path.isEmpty()) { - // the user might add a directory containing an 'Aircraft' subdir. Let's attempt - // to check for that case and handle it gracefully. - bool pathOk = false; - - if (LocalAircraftCache::isCandidateAircraftPath(path)) { - m_ui->aircraftPathsList->addItem(path); - pathOk = true; - } else { - // no aircraft in speciied path, look for Aircraft/ subdir - QDir d(path); - if (d.exists("Aircraft")) { - QString p2 = d.filePath("Aircraft"); - if (LocalAircraftCache::isCandidateAircraftPath(p2)) { - m_ui->aircraftPathsList->addItem(p2); - pathOk = true; - } - } - } - - if (!pathOk) { - QMessageBox mb; - mb.setText(tr("No aircraft found in the folder '%1' - add anyway?").arg(path)); - mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - mb.setDefaultButton(QMessageBox::No); - mb.exec(); - - if (mb.result() == QMessageBox::Yes) { - m_ui->aircraftPathsList->addItem(path); - } - } - - saveAircraftPaths(); - } -} - -void AddOnsPage::onRemoveAircraftPath() -{ - if (m_ui->aircraftPathsList->currentItem()) { - delete m_ui->aircraftPathsList->currentItem(); - saveAircraftPaths(); - } -} - -void AddOnsPage::saveAircraftPaths() -{ - QSettings settings; - QStringList paths; - - for (int i=0; iaircraftPathsList->count(); ++i) { - paths.append(m_ui->aircraftPathsList->item(i)->text()); - } - - settings.setValue("aircraft-paths", paths); - emit aircraftPathsChanged(); -} - -void AddOnsPage::saveSceneryPaths() -{ - QSettings settings; - QStringList paths; - for (int i=0; isceneryPathsList->count(); ++i) { - paths.append(m_ui->sceneryPathsList->item(i)->text()); - } - - settings.setValue("scenery-paths", paths); - - emit sceneryPathsChanged(); -} - -bool AddOnsPage::haveSceneryPath(QString path) const -{ - for (int i=0; isceneryPathsList->count(); ++i) { - if (m_ui->sceneryPathsList->item(i)->text() == path) { - return true; - } - } - - return false; -} - -void AddOnsPage::onAddCatalog() -{ - QScopedPointer dlg(new AddCatalogDialog(this, m_packageRoot)); - dlg->exec(); - if (dlg->result() == QDialog::Accepted) { - m_catalogsModel->refresh(); - } -} - -void AddOnsPage::onAddDefaultCatalog() -{ - addDefaultCatalog(this, false /* not silent */); - - m_catalogsModel->refresh(); - updateUi(); -} - -void AddOnsPage::addDefaultCatalog(QWidget* pr, bool silent) -{ - // check it's not a duplicate somehow - FGHTTPClient* http = globals->get_subsystem(); - if (http->isDefaultCatalogInstalled()) - return; - - QScopedPointer dlg(new AddCatalogDialog(pr, globals->packageRoot())); - QUrl url(QString::fromStdString(http->getDefaultCatalogUrl())); - if (silent) { - dlg->setNonInteractiveMode(); - } - dlg->setUrlAndDownload(url); - dlg->exec(); -} - -void AddOnsPage::onCatalogsRefreshed() -{ - m_catalogsModel->refresh(); - updateUi(); -} - -void AddOnsPage::onRemoveCatalog() -{ - QModelIndex mi = m_ui->catalogsList->currentIndex(); - FGHTTPClient* http = globals->get_subsystem(); - - if (mi.isValid()) { - QString s = tr("Remove aircraft hangar '%1'? All installed aircraft from this " - "hangar will be removed."); - QString pkgId = mi.data(CatalogIdRole).toString(); - - if (pkgId.toStdString() == http->getDefaultCatalogId()) { - s = tr("Remove the default aircraft hangar? " - "This hangar contains all the default aircraft included with FlightGear. " - "If you change your mind in the future, click the 'restore' button."); - } else { - s = s.arg(mi.data(Qt::DisplayRole).toString()); - } - - QMessageBox mb; - mb.setText(s); - mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - mb.setDefaultButton(QMessageBox::No); - mb.exec(); - - if (mb.result() == QMessageBox::Yes) { - m_packageRoot->removeCatalogById(pkgId.toStdString()); - } - } - - updateUi(); -} - -void AddOnsPage::onCatalogDoubleClicked(const QModelIndex& index) -{ - if ((index.flags() & Qt::ItemIsEnabled) == false) { - // re-validate existing catalog - QScopedPointer dlg(new AddCatalogDialog(this, m_packageRoot)); - dlg->setUpdatingExistingCatalog(); - dlg->setUrlAndDownload(index.data(CatalogUrlRole).toUrl()); - dlg->exec(); - m_catalogsModel->refresh(); - } -} - -void AddOnsPage::onInstallScenery() -{ - QSettings settings; - QString downloadDir = settings.value("download-dir").toString(); - InstallSceneryDialog dlg(this, downloadDir); - if (dlg.exec() == QDialog::Accepted) { - if (!haveSceneryPath(dlg.sceneryPath())) { - m_ui->sceneryPathsList->addItem(dlg.sceneryPath()); - saveSceneryPaths(); - } - } -} - -void AddOnsPage::updateUi() -{ - FGHTTPClient* http = globals->get_subsystem(); - m_ui->addDefaultCatalogButton->setEnabled(!http->isDefaultCatalogInstalled()); -} - -void AddOnsPage::onDraggedAircraftList() -{ - qWarning() << "did drag aircraft list"; -} diff --git a/src/GUI/PathsDialog.hxx b/src/GUI/PathsDialog.hxx deleted file mode 100644 index 896bf7c7d..000000000 --- a/src/GUI/PathsDialog.hxx +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef PATHSDIALOG_HXX -#define PATHSDIALOG_HXX - -#include - -#include - - -namespace Ui { -class AddOnsPage; -} - -class CatalogListModel; - -class AddOnsPage : public QWidget -{ - Q_OBJECT - -public: - explicit AddOnsPage(QWidget *parent, simgear::pkg::RootRef root); - ~AddOnsPage(); - - static void addDefaultCatalog(QWidget* pr, bool silent); - -public slots: - void onCatalogsRefreshed(); - -signals: - void sceneryPathsChanged(); - void aircraftPathsChanged(); - -private slots: - void onAddSceneryPath(); - void onRemoveSceneryPath(); - - void onAddAircraftPath(); - void onRemoveAircraftPath(); - - void onAddCatalog(); - void onRemoveCatalog(); - void onAddDefaultCatalog(); - - void onInstallScenery(); - - void onDraggedAircraftList(); - - void saveAircraftPaths(); - void saveSceneryPaths(); - - void onCatalogDoubleClicked(const QModelIndex& index); -private: - void updateUi(); - - bool haveSceneryPath(QString path) const; - - Ui::AddOnsPage* m_ui; - CatalogListModel* m_catalogsModel; - simgear::pkg::RootRef m_packageRoot; - -}; - -#endif // PATHSDIALOG_HXX diff --git a/src/GUI/PathsDialog.ui b/src/GUI/PathsDialog.ui deleted file mode 100644 index d2143f7bd..000000000 --- a/src/GUI/PathsDialog.ui +++ /dev/null @@ -1,329 +0,0 @@ - - - AddOnsPage - - - - 0 - 0 - 608 - 617 - - - - Configure add-ons - - - - 4 - - - 4 - - - 4 - - - 4 - - - 4 - - - - - - - Install downloaded scenery... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Additional scenery locations - - - - 6 - - - 6 - - - 6 - - - 6 - - - 0 - - - - - - 0 - 0 - - - - - 20 - 20 - - - - + - - - - - - - - 0 - 0 - - - - - 20 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 567 - 20 - - - - - - - - - 11 - - - - Drag to re-order - - - - - - - - - - - - - Aircraft hangar locations - - - - 6 - - - 6 - - - 6 - - - 6 - - - 0 - - - - - - 0 - 0 - - - - - 20 - 20 - - - - - - - - - - - - - 0 - 0 - - - - - 20 - 20 - - - - + - - - - - - - Qt::Horizontal - - - - 567 - 20 - - - - - - - - Restore default aircraft hangar - - - - - - - true - - - - - - - - - - Additional aircraft locations - - - - 6 - - - 6 - - - 6 - - - 6 - - - 0 - - - - - Qt::Horizontal - - - - 567 - 20 - - - - - - - - - 0 - 0 - - - - - 20 - 20 - - - - + - - - - - - - - 0 - 0 - - - - - 20 - 20 - - - - - - - - - - - - - 11 - - - - Drag to re-order - - - - - - - - - - - - - - diff --git a/src/GUI/SettingsSection.cxx b/src/GUI/SettingsSection.cxx deleted file mode 100644 index e158a44be..000000000 --- a/src/GUI/SettingsSection.cxx +++ /dev/null @@ -1,118 +0,0 @@ -#include "SettingsSection.hxx" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "AdvancedSettingsButton.h" -#include "SettingsWidgets.hxx" -#include "LaunchConfig.hxx" - -SettingsSection::SettingsSection(QWidget* pr) : - QFrame(pr) -{ - m_titleLabel = new QLabel; - QFont titleFont = m_titleLabel->font(); - titleFont.setPointSize(14); - titleFont.setBold(true); - m_titleLabel->setFont(titleFont); - - QPalette pal = palette(); - pal.setColor(QPalette::Normal, QPalette::WindowText, Qt::white); - m_titleLabel->setPalette(pal); - - if (!layout()) { - QVBoxLayout* vbox = new QVBoxLayout(this); - vbox->setMargin(4); - vbox->setSpacing(4); - setLayout(vbox); - } -} - -void SettingsSection::setLaunchConfig(LaunchConfig* config) -{ - connect(config, &LaunchConfig::collect, this, &SettingsSection::doApply); -} - -void SettingsSection::setShowAdvanced(bool showAdvanced) -{ - if (m_showAdvanced == showAdvanced) - return; - - m_showAdvanced = showAdvanced; - internalUpdateAdvanced(); - emit showAdvancedChanged(showAdvanced); -} - -void SettingsSection::setTitle(QString title) -{ - if (m_title == title) - return; - - m_title = title; - m_titleLabel->setText(m_title); - emit titleChanged(title); -} - -void SettingsSection::toggleShowAdvanced() -{ - setShowAdvanced(!m_showAdvanced); -} - -void SettingsSection::insertSettingsHeader() -{ - QVBoxLayout* topLevelVBox = qobject_cast(layout()); - Q_ASSERT(topLevelVBox); - - topLevelVBox->setMargin(0); - - QFrame* headerPanel = new QFrame(this); - headerPanel->setFrameStyle(QFrame::Box); - headerPanel->setAutoFillBackground(true); - - QPalette p = headerPanel->palette(); - p.setColor(QPalette::Normal, QPalette::Background, QColor(0x7f, 0x7f, 0x7f)); - p.setColor(QPalette::Normal, QPalette::Foreground, Qt::black); - p.setColor(QPalette::Normal, QPalette::WindowText, Qt::white); - headerPanel->setPalette(p); - - topLevelVBox->insertWidget(0, headerPanel); - - QHBoxLayout* hbox = new QHBoxLayout(headerPanel); - hbox->setContentsMargins(32, 0, 32, 0); - headerPanel->setLayout(hbox); - - hbox->addWidget(m_titleLabel); - hbox->addStretch(1); - - m_advancedModeToggle = new AdvancedSettingsButton; - connect(m_advancedModeToggle, &QPushButton::toggled, this, &SettingsSection::toggleShowAdvanced); - hbox->addWidget(m_advancedModeToggle); - - updateShowAdvanced(); - internalUpdateAdvanced(); -} - -void SettingsSection::internalUpdateAdvanced() -{ -} - - -void SettingsSection::saveState(QSettings &settings) const -{ - Q_UNUSED(settings) -} - -void SettingsSection::restoreState(QSettings &settings) -{ - Q_UNUSED(settings) -} - -void SettingsSection::updateShowAdvanced() -{ -} diff --git a/src/GUI/SettingsSection.hxx b/src/GUI/SettingsSection.hxx deleted file mode 100644 index 56cbfa9c4..000000000 --- a/src/GUI/SettingsSection.hxx +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef SETTINGSSECTION_H -#define SETTINGSSECTION_H - -#include -#include - -class AdvancedSettingsButton; -class QSettings; -class LaunchConfig; - -class SettingsSection : public QFrame -{ - Q_OBJECT - - Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) - - Q_PROPERTY(bool showAdvanced READ showAdvanced WRITE setShowAdvanced NOTIFY showAdvancedChanged) - -public: - SettingsSection(QWidget* pr = nullptr); - - virtual void setLaunchConfig(LaunchConfig* config); - - virtual bool showAdvanced() const - { - return m_showAdvanced; - } - - QString title() const - { - return m_title; - } - - void insertSettingsHeader(); - - virtual void saveState(QSettings& settings) const; - - virtual void restoreState(QSettings& settings); - - virtual void doApply() = 0; - - virtual QString summary() const = 0; - -public slots: - void setShowAdvanced(bool showAdvanced); - - void setTitle(QString title); - - void toggleShowAdvanced(); - -signals: - void showAdvancedChanged(bool showAdvanced); - - void titleChanged(QString title); - - void summaryChanged(QString summary); - -protected: - virtual void internalUpdateAdvanced(); - virtual void updateShowAdvanced(); - - QString m_title; - bool m_showAdvanced = false; - - QLabel* m_titleLabel; - AdvancedSettingsButton* m_advancedModeToggle; -}; - -#endif // SETTINGSSECTION_H