Launcher: update all aircraft UI.
Replaces more complex previous attempt, which was also not hooked up properly, ooops.
This commit is contained in:
parent
c19fc6bc06
commit
95a6d31e18
5 changed files with 38 additions and 99 deletions
|
@ -78,7 +78,6 @@ if (HAVE_QT)
|
|||
LocationWidget.ui
|
||||
NoOfficialHangar.ui
|
||||
InstallSceneryDialog.ui
|
||||
UpdateAllAircraft.ui
|
||||
)
|
||||
qt5_add_resources(qrc_sources resources.qrc)
|
||||
|
||||
|
|
|
@ -443,7 +443,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="aircraftPage">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="0,0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="0,0,0,0">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
|
@ -533,6 +533,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="updateAircraftLabel">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>%1 aircraft have updates available, <a href="action:update"><span style=" text-decoration: underline; color:#0000ff;">click here to update</span></a> (Or <a href="action:hide"><span style=" text-decoration: underline; color:#0000ff;">hide this</span></a>)</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="aircraftList">
|
||||
<property name="verticalScrollMode">
|
||||
|
@ -570,8 +577,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>643</width>
|
||||
<height>644</height>
|
||||
<width>90</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -603,8 +610,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>643</width>
|
||||
<height>644</height>
|
||||
<width>173</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
|
|
|
@ -69,26 +69,6 @@ private:
|
|||
Ui::NoOfficialHangarMessage* m_ui;
|
||||
};
|
||||
|
||||
class UpdateAllAircraftMessage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UpdateAllAircraftMessage() :
|
||||
m_ui(new Ui::UpdateAllAircraftMessage)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
// proxy this signal upwards
|
||||
connect(m_ui->label, &QLabel::linkActivated, this, &UpdateAllAircraftMessage::linkActivated);
|
||||
connect(m_ui->updateAllButton, &QPushButton::clicked, this, &UpdateAllAircraftMessage::updateAll);
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void linkActivated(QUrl link);
|
||||
void updateAll();
|
||||
private:
|
||||
Ui::UpdateAllAircraftMessage* m_ui;
|
||||
};
|
||||
|
||||
#include "LauncherMainWindow.moc"
|
||||
|
||||
QQmlPrivate::AutoParentResult launcher_autoParent(QObject* thing, QObject* parent)
|
||||
|
@ -195,6 +175,8 @@ LauncherMainWindow::LauncherMainWindow() :
|
|||
m_ui->locationHistory->setIcon(historyIcon);
|
||||
|
||||
m_aircraftModel = new AircraftItemModel(this);
|
||||
connect(m_aircraftModel, &AircraftItemModel::packagesNeedUpdating,
|
||||
this, &LauncherMainWindow::onPackagesNeedUpdate);
|
||||
m_aircraftProxy->setSourceModel(m_aircraftModel);
|
||||
|
||||
m_aircraftProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
@ -241,6 +223,9 @@ LauncherMainWindow::LauncherMainWindow() :
|
|||
connect(m_aircraftProxy, &AircraftProxyModel::modelReset,
|
||||
this, &LauncherMainWindow::delayedAircraftModelReset);
|
||||
|
||||
connect(m_ui->updateAircraftLabel, &QLabel::linkActivated,
|
||||
this, &LauncherMainWindow::onUpdateAircraftLink);
|
||||
|
||||
QSettings settings;
|
||||
m_aircraftModel->setPaths(settings.value("aircraft-paths").toStringList());
|
||||
m_aircraftModel->setPackageRoot(globals->packageRoot());
|
||||
|
@ -254,6 +239,7 @@ LauncherMainWindow::LauncherMainWindow() :
|
|||
m_ui->stack->addWidget(m_viewCommandLinePage);
|
||||
|
||||
checkOfficialCatalogMessage();
|
||||
checkUpdateAircraft();
|
||||
restoreSettings();
|
||||
updateSettingsSummary();
|
||||
}
|
||||
|
@ -833,14 +819,6 @@ void LauncherMainWindow::updateSelectedAircraft()
|
|||
}
|
||||
}
|
||||
|
||||
void LauncherMainWindow::onUpdateAllAircraft()
|
||||
{
|
||||
const PackageList& toBeUpdated = globals->packageRoot()->packagesNeedingUpdate();
|
||||
std::for_each(toBeUpdated.begin(), toBeUpdated.end(), [](PackageRef pkg) {
|
||||
globals->packageRoot()->scheduleToUpdate(pkg->install());
|
||||
});
|
||||
}
|
||||
|
||||
void LauncherMainWindow::onPackagesNeedUpdate(bool yes)
|
||||
{
|
||||
Q_UNUSED(yes);
|
||||
|
@ -1034,23 +1012,29 @@ void LauncherMainWindow::onOfficialCatalogMessageLink(QUrl link)
|
|||
|
||||
void LauncherMainWindow::checkUpdateAircraft()
|
||||
{
|
||||
if (shouldShowOfficialCatalogMessage()) {
|
||||
return; // don't interfere
|
||||
const size_t numToUpdate = globals->packageRoot()->packagesNeedingUpdate().size();
|
||||
const bool showUpdateMessage = (numToUpdate > 0);
|
||||
|
||||
static QString originalText = m_ui->updateAircraftLabel->text();
|
||||
const QString t = originalText.arg(numToUpdate);
|
||||
m_ui->updateAircraftLabel->setText(t);
|
||||
m_ui->updateAircraftLabel->setVisible(showUpdateMessage);
|
||||
}
|
||||
|
||||
const bool showUpdateMessage = !globals->packageRoot()->packagesNeedingUpdate().empty();
|
||||
m_aircraftModel->setMessageWidgetVisible(showUpdateMessage);
|
||||
if (showUpdateMessage) {
|
||||
UpdateAllAircraftMessage* messageWidget = new UpdateAllAircraftMessage;
|
||||
// connect(messageWidget, &UpdateAllAircraftMessage::linkActivated,
|
||||
// this, &LauncherMainWindow::onMessageLink);
|
||||
connect(messageWidget, &UpdateAllAircraftMessage::updateAll, this, &LauncherMainWindow::onUpdateAllAircraft);
|
||||
QModelIndex index = m_aircraftProxy->mapFromSource(m_aircraftModel->messageWidgetIndex());
|
||||
m_ui->aircraftList->setIndexWidget(index, messageWidget);
|
||||
void LauncherMainWindow::onUpdateAircraftLink(QUrl link)
|
||||
{
|
||||
QString s = link.toString();
|
||||
if (s == "action:hide") {
|
||||
m_ui->updateAircraftLabel->hide();
|
||||
} else if (s == "action:update") {
|
||||
m_ui->updateAircraftLabel->hide();
|
||||
const PackageList& toBeUpdated = globals->packageRoot()->packagesNeedingUpdate();
|
||||
std::for_each(toBeUpdated.begin(), toBeUpdated.end(), [](PackageRef pkg) {
|
||||
globals->packageRoot()->scheduleToUpdate(pkg->install());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
simgear::pkg::PackageRef LauncherMainWindow::packageForAircraftURI(QUrl uri) const
|
||||
{
|
||||
if (uri.scheme() != "package") {
|
||||
|
|
|
@ -98,8 +98,6 @@ private slots:
|
|||
|
||||
Q_INVOKABLE void onDownloadDirChanged();
|
||||
|
||||
void onUpdateAllAircraft();
|
||||
|
||||
void onPackagesNeedUpdate(bool yes);
|
||||
|
||||
void onClickToolboxButton();
|
||||
|
@ -110,6 +108,7 @@ private slots:
|
|||
void onChangeDataDir();
|
||||
|
||||
void onSettingsSearchChanged();
|
||||
void onUpdateAircraftLink(QUrl link);
|
||||
private:
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>UpdateAllAircraftMessage</class>
|
||||
<widget class="QWidget" name="UpdateAllAircraftMessage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>607</width>
|
||||
<height>44</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/app-icon-large</normaloff>:/app-icon-large</iconset>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>%1 aircraft have updates available. (<a href="action:hide"><span style=" text-decoration: underline; color:#0000ff;">Click</span></a> to hide this)</p></body></html></string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="updateAllButton">
|
||||
<property name="text">
|
||||
<string>Update all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in a new issue