Ref T125, use XSwiftBus download component

* as dialog in distribution component
* in wizard
This commit is contained in:
Klaus Basan
2017-08-16 13:24:06 +02:00
committed by Mathew Sutcliffe
parent 76c1b0307c
commit 73556492fd
9 changed files with 289 additions and 36 deletions

View File

@@ -23,6 +23,7 @@ namespace BlackGui
ui->wp_CopyCaches->setConfigComponent(ui->comp_CopyCaches);
ui->wp_CopySettings->setConfigComponent(ui->comp_CopySettings);
ui->wp_Simulator->setConfigComponent(ui->comp_Simulator);
ui->wp_XSwiftBus->setConfigComponent(ui->comp_XSwiftBus);
ui->wp_DataLoad->setConfigComponent(ui->comp_DataLoad);
ui->wp_Hotkeys->setConfigComponent(ui->comp_Hotkeys);
ui->comp_Hotkeys->registerDummyPttEntry();

View File

@@ -35,6 +35,7 @@ namespace BlackGui
CopySettings,
CopyCaches,
ConfigSimulator,
XSwiftBus,
DataLoad,
ConfigHotkeys
};

View File

@@ -130,7 +130,45 @@
</item>
</layout>
</widget>
<widget class="BlackGui::Components::CInstallXSwiftBusWizardPage" name="wp_XSwiftBus">
<property name="title">
<string>XSwiftBus</string>
</property>
<property name="subTitle">
<string>Install XSwiftBus (X-Plane only)</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<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 row="0" column="0">
<widget class="BlackGui::Components::CInstallXSwiftBusComponent" name="comp_XSwiftBus">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="BlackGui::Components::CInitialDataLoadWizardPage" name="wp_DataLoad">
<property name="title">
<string>Data loading</string>
</property>
<property name="subTitle">
<string>Caches model and ICAO data</string>
</property>
<layout class="QVBoxLayout" name="vl_DataLoad">
<property name="leftMargin">
<number>4</number>
@@ -231,6 +269,18 @@
<header>blackgui/components/settingshotkeycomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CInstallXSwiftBusComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/installxswiftbuscomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CInstallXSwiftBusWizardPage</class>
<extends>QWizardPage</extends>
<header>blackgui/components/installxswiftbuscomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -9,11 +9,12 @@
#include "distributioninfocomponent.h"
#include "ui_distributioninfocomponent.h"
#include "blackconfig/buildconfig.h"
#include "installxswiftbusdialog.h"
#include "blackgui/guiapplication.h"
#include "blackmisc/network/networkutils.h"
#include "blackmisc/db/distributionlist.h"
#include "blackmisc/logmessage.h"
#include "blackconfig/buildconfig.h"
using namespace BlackConfig;
using namespace BlackCore::Application;
@@ -35,15 +36,20 @@ namespace BlackGui
ui->lbl_NewVersionUrl->setOpenExternalLinks(true);
// use version signal as trigger for completion
connect(sGui, &CGuiApplication::distributionInfoAvailable, this, &CDistributionInfoComponent::ps_loadedDistributionInfo);
const int time = this->m_distributionInfo.get().isEmpty() ? 10 * 1000 : 500;
QTimer::singleShot(time, this, [ = ]
if (!m_distributionInfo.get().isEmpty())
{
// use this as timeout failover with cached data
if (m_distributionsLoaded) { return; }
this->ps_loadedDistributionInfo(true);
});
// we have at least cached data:
// in case CGuiApplication::distributionInfoAvailable never comes/was already sent
QTimer::singleShot(10 * 1000, this, [ = ]
{
// use this as timeout failover with cached data
if (m_distributionsLoaded) { return; }
this->ps_loadedDistributionInfo(true);
});
}
connect(sGui, &CGuiApplication::distributionInfoAvailable, this, &CDistributionInfoComponent::ps_loadedDistributionInfo);
connect(ui->pb_CheckForUpdates, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_loadSetup);
connect(ui->pb_InstallXSwiftBus, &QPushButton::pressed, this, &CDistributionInfoComponent::ps_installXSwiftBusDialog);
}
CDistributionInfoComponent::~CDistributionInfoComponent()
@@ -71,13 +77,16 @@ namespace BlackGui
void CDistributionInfoComponent::ps_loadedDistributionInfo(bool success)
{
ui->pb_CheckForUpdates->setToolTip("");
if (!success)
{
m_distributionsLoaded = false;
ui->pb_CheckForUpdates->setToolTip("");
CLogMessage(this).warning("Loading setup or distribution information failed");
return;
}
// only emit once
if (m_distributionsLoaded) { return; }
m_distributionsLoaded = true;
this->ps_channelChanged();
ui->pb_CheckForUpdates->setToolTip(sApp->getLastSuccesfulDistributionUrl());
@@ -91,12 +100,22 @@ namespace BlackGui
this->ps_loadedDistributionInfo(true);
}
void CDistributionInfoComponent::ps_installXSwiftBusDialog()
{
if (!m_installXSwiftBusDialog)
{
m_installXSwiftBusDialog.reset(new CInstallXSwiftBusDialog(this));
m_installXSwiftBusDialog->setModal(true);
}
m_installXSwiftBusDialog->show();
}
void CDistributionInfoComponent::saveSettings()
{
const QString channel = ui->cb_Channels->currentText();
const QString currentPlatform = ui->cb_Platforms->currentText();
const QStringList settings({ channel, currentPlatform });
const CStatusMessage m = this->m_distributionSettings.setAndSave(settings);
const CStatusMessage m = m_distributionSettings.setAndSave(settings);
if (m.isFailure())
{
CLogMessage(this).preformatted(m);
@@ -152,7 +171,7 @@ namespace BlackGui
ui->lbl_NewVersionInfo->setText("Nothing new");
ui->lbl_NewVersionInfo->setStyleSheet("background-color: green");
ui->lbl_NewVersionUrl->clear();
this->m_newVersionAvailable.clear();
m_newVersionAvailable.clear();
const QString currentPlatform = ui->cb_Platforms->currentText();
if (!currentPlatform.isEmpty())
@@ -170,7 +189,7 @@ namespace BlackGui
ui->lbl_NewVersionInfo->setText("New version!");
ui->lbl_NewVersionInfo->setToolTip("New version '" + latestVersionStr + "'");
ui->lbl_NewVersionInfo->setStyleSheet("background-color: red");
this->m_newVersionAvailable = latestVersionStr;
m_newVersionAvailable = latestVersionStr;
}
if (!downloadUrl.isEmpty())

View File

@@ -22,6 +22,8 @@ namespace BlackGui
{
namespace Components
{
class CInstallXSwiftBusDialog;
/**
* Update info (distributions etc.)
*/
@@ -68,8 +70,12 @@ namespace BlackGui
//! Cache values have been changed
void ps_changedDistributionCache();
//! Install XSwiftBus dialog
void ps_installXSwiftBusDialog();
private:
QScopedPointer<Ui::CDistributionInfoComponent> ui;
QScopedPointer<CInstallXSwiftBusDialog> m_installXSwiftBusDialog; //!< dialog, install XSwiftXBus
bool m_distributionsLoaded = false; //!< distribution info loaded
QString m_newVersionAvailable; //!< new version number if any
BlackMisc::Db::CDistribution m_currentDistribution; //!< current distribution

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>307</width>
<height>90</height>
<height>106</height>
</rect>
</property>
<property name="minimumSize">
@@ -32,16 +32,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lbl_CurrentVersion">
<property name="text">
<string>This version:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QComboBox" name="cb_Platforms"/>
</item>
<item row="0" column="2">
<widget class="QLabel" name="lbl_LatestVersion">
<property name="text">
@@ -56,6 +46,13 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_CurrentVersion">
<property name="text">
<string>This version:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Channel">
<property name="text">
@@ -63,6 +60,16 @@
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QComboBox" name="cb_Platforms"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="lbl_Platforms">
<property name="text">
<string>Platform:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="le_CurrentVersion">
<property name="readOnly">
@@ -70,37 +77,44 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cb_Channels"/>
</item>
<item row="1" column="2">
<widget class="QLabel" name="lbl_Platforms">
<property name="text">
<string>Platform:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<item row="4" column="3">
<widget class="QPushButton" name="pb_CheckForUpdates">
<property name="text">
<string>check again</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="1" column="1">
<widget class="QComboBox" name="cb_Channels"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_NewVersionInfo">
<property name="text">
<string>Nothing new</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="lbl_NewVersionUrl">
<property name="text">
<string>URL goes here</string>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="pb_InstallXSwiftBus">
<property name="text">
<string>install</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QLabel" name="lbl_XSwiftBus">
<property name="text">
<string>XSwiftBus (XPlane only):</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>

View File

@@ -0,0 +1,27 @@
/* Copyright (C) 2017
* swift project Community / Contributors
*
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
#include "installxswiftbusdialog.h"
#include "ui_installxswiftbusdialog.h"
namespace BlackGui
{
namespace Components
{
CInstallXSwiftBusDialog::CInstallXSwiftBusDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CInstallXSwiftBusDialog)
{
ui->setupUi(this);
}
CInstallXSwiftBusDialog::~CInstallXSwiftBusDialog()
{ }
} // ns
} // ns

View File

@@ -0,0 +1,42 @@
/* Copyright (C) 2017
* swift project Community / Contributors
*
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKGUI_COMPONENTS_INSTALLXSWIFTBUSDIALOG_H
#define BLACKGUI_COMPONENTS_INSTALLXSWIFTBUSDILAOG_H
#include <QDialog>
namespace Ui { class CInstallXSwiftBusDialog; }
namespace BlackGui
{
namespace Components
{
/**
* CInstallXSwiftBusComponent as dialog
*/
class CInstallXSwiftBusDialog : public QDialog
{
Q_OBJECT
public:
//! Constructor
explicit CInstallXSwiftBusDialog(QWidget *parent = nullptr);
//! Dtor
virtual ~CInstallXSwiftBusDialog();
private:
QScopedPointer<Ui::CInstallXSwiftBusDialog> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CInstallXSwiftBusDialog</class>
<widget class="QDialog" name="CInstallXSwiftBusDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>350</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>350</height>
</size>
</property>
<property name="windowTitle">
<string>Install XSwiftBus dialog</string>
</property>
<layout class="QVBoxLayout" name="vl_XSiwftBusDialog">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="BlackGui::Components::CInstallXSwiftBusComponent" name="comp_InstallXSwiftBus"/>
</item>
<item>
<widget class="QDialogButtonBox" name="bb_Dialog">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CInstallXSwiftBusComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/installxswiftbuscomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>bb_Dialog</sender>
<signal>accepted()</signal>
<receiver>CInstallXSwiftBusDialog</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>bb_Dialog</sender>
<signal>rejected()</signal>
<receiver>CInstallXSwiftBusDialog</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>