1
0
Fork 0

Remove obsolete Launcher files

This commit is contained in:
James Turner 2018-04-09 15:48:43 +01:00
parent a94d893124
commit 72f9ff3735
9 changed files with 0 additions and 1416 deletions

View file

@ -1,259 +0,0 @@
// AddCatalogDialog.cxx - part of GUI launcher using Qt5
//
// Written by James Turner, started March 2015.
//
// Copyright (C) 2015 James Turner <zakalawe@mac.com>
//
// 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 <QPushButton>
#include <QDebug>
#include <simgear/package/Package.hxx>
#include <simgear/package/Install.hxx>
#include <Main/globals.hxx>
#include <Network/HTTPClient.hxx>
#include <Include/version.h>
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<FGHTTPClient>();
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();
}

View file

@ -1,96 +0,0 @@
// AddCatalogDialog.hxx - part of GUI launcher using Qt5
//
// Written by James Turner, started March 2015.
//
// Copyright (C) 2015 James Turner <zakalawe@mac.com>
//
// 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 <memory>
#include <QDialog>
#include <QUrl>
#include <simgear/package/Root.hxx>
#include <simgear/package/Catalog.hxx>
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<AddCatalogDelegate> m_delegate;
};
#endif // FG_GUI_ADDCATALOGDIALOG_HXX

View file

@ -1,158 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddCatalogDialog</class>
<widget class="QDialog" name="AddCatalogDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>200</height>
</rect>
</property>
<property name="windowTitle">
<string>Add aircraft hangar</string>
</property>
<property name="windowIcon">
<iconset resource="resources.qrc">
<normaloff>:/app-icon-large</normaloff>:/app-icon-large</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QStackedWidget" name="stack">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0,1">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Enter the URL of an aircraft hangar:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="urlEdit">
<property name="placeholderText">
<string>http://www.somesite.com/flightgear-aircraft.xml</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="0,1">
<item>
<widget class="QLabel" name="downloadDescription">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Please wait, downloading and checking the hangar information.</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="resultsSummaryLabel">
<property name="text">
<string>Lorem Ipsum</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddCatalogDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddCatalogDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -69,8 +69,6 @@ endif()
if (HAVE_QT) if (HAVE_QT)
qt5_wrap_ui(uic_sources Launcher.ui qt5_wrap_ui(uic_sources Launcher.ui
SetupRootDialog.ui SetupRootDialog.ui
AddCatalogDialog.ui
PathsDialog.ui
LocationWidget.ui LocationWidget.ui
InstallSceneryDialog.ui InstallSceneryDialog.ui
) )

View file

@ -1,323 +0,0 @@
#include "PathsDialog.hxx"
#include "ui_PathsDialog.h"
#include <QSettings>
#include <QFileDialog>
#include <QMessageBox>
#include <QDebug>
#include <QProcess>
#include "CatalogListModel.hxx"
#include "AddCatalogDialog.hxx"
#include "AircraftModel.hxx"
#include "InstallSceneryDialog.hxx"
#include "QtLauncher.hxx"
#include "LocalAircraftCache.hxx"
#include <Main/options.hxx>
#include <Main/globals.hxx>
#include <Network/HTTPClient.hxx>
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; i<m_ui->aircraftPathsList->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; i<m_ui->sceneryPathsList->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; i<m_ui->sceneryPathsList->count(); ++i) {
if (m_ui->sceneryPathsList->item(i)->text() == path) {
return true;
}
}
return false;
}
void AddOnsPage::onAddCatalog()
{
QScopedPointer<AddCatalogDialog> 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<FGHTTPClient>();
if (http->isDefaultCatalogInstalled())
return;
QScopedPointer<AddCatalogDialog> 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<FGHTTPClient>();
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<AddCatalogDialog> 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<FGHTTPClient>();
m_ui->addDefaultCatalogButton->setEnabled(!http->isDefaultCatalogInstalled());
}
void AddOnsPage::onDraggedAircraftList()
{
qWarning() << "did drag aircraft list";
}

View file

@ -1,62 +0,0 @@
#ifndef PATHSDIALOG_HXX
#define PATHSDIALOG_HXX
#include <QDialog>
#include <simgear/package/Root.hxx>
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

View file

@ -1,329 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddOnsPage</class>
<widget class="QWidget" name="AddOnsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>608</width>
<height>617</height>
</rect>
</property>
<property name="windowTitle">
<string>Configure add-ons</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="installSceneryButton">
<property name="text">
<string>Install downloaded scenery...</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Additional scenery locations</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="1" column="2">
<widget class="QToolButton" name="addSceneryPath">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QToolButton" name="removeSceneryPath">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>567</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Drag to re-order</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QListWidget" name="sceneryPathsList"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>Aircraft hangar locations</string>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="1" column="3">
<widget class="QToolButton" name="removeCatalog">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="addCatalog">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>567</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="addDefaultCatalogButton">
<property name="text">
<string>Restore default aircraft hangar</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QListView" name="catalogsList">
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Additional aircraft locations</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="1" column="1">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>567</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="addAircraftPath">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QToolButton" name="removeAircraftPath">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Drag to re-order</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QListWidget" name="aircraftPathsList"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -1,118 +0,0 @@
#include "SettingsSection.hxx"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPalette>
#include <QPushButton>
#include <QVariant>
#include <QDebug>
#include <QSettings>
#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<QVBoxLayout*>(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()
{
}

View file

@ -1,69 +0,0 @@
#ifndef SETTINGSSECTION_H
#define SETTINGSSECTION_H
#include <QFrame>
#include <QLabel>
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