Ref T203, renamed to CUpdateInfoDialog

This commit is contained in:
Klaus Basan
2017-12-12 19:43:36 +01:00
parent f0cf15a572
commit 18fe389303
5 changed files with 38 additions and 38 deletions

View File

@@ -7,8 +7,8 @@
* contained in the LICENSE file. * contained in the LICENSE file.
*/ */
#include "downloadandinstalldialog.h" #include "updateinfodialog.h"
#include "ui_downloadandinstalldialog.h" #include "ui_updateinfodialog.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include <QPushButton> #include <QPushButton>
#include <QDesktopServices> #include <QDesktopServices>
@@ -19,28 +19,28 @@ namespace BlackGui
{ {
namespace Components namespace Components
{ {
CDownloadAndInstallDialog::CDownloadAndInstallDialog(QWidget *parent) : CUpdateInfoDialog::CUpdateInfoDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::CDownloadAndInstallDialog) ui(new Ui::CUpdateInfoDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->bb_DownloadInstallDialog->button(QDialogButtonBox::Ok)->setText(" Download and install "); ui->bb_UpdateInfolDialog->button(QDialogButtonBox::Ok)->setText(" Download and install ");
ui->cb_DontShowAgain->setChecked(!m_setting.get()); ui->cb_DontShowAgain->setChecked(!m_setting.get());
this->selectionChanged(); this->selectionChanged();
connect(ui->comp_UpdateInfo, &CUpdateInfoComponent::selectionChanged, this, &CDownloadAndInstallDialog::selectionChanged); connect(ui->comp_UpdateInfo, &CUpdateInfoComponent::selectionChanged, this, &CUpdateInfoDialog::selectionChanged);
connect(ui->cb_DontShowAgain, &QCheckBox::toggled, this, &CDownloadAndInstallDialog::onDontShowAgain); connect(ui->cb_DontShowAgain, &QCheckBox::toggled, this, &CUpdateInfoDialog::onDontShowAgain);
} }
CDownloadAndInstallDialog::~CDownloadAndInstallDialog() CUpdateInfoDialog::~CUpdateInfoDialog()
{ } { }
bool CDownloadAndInstallDialog::isNewVersionAvailable() const bool CUpdateInfoDialog::isNewVersionAvailable() const
{ {
const bool newVersion = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable(); const bool newVersion = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable();
return newVersion; return newVersion;
} }
int CDownloadAndInstallDialog::exec() int CUpdateInfoDialog::exec()
{ {
const int r = QDialog::exec(); const int r = QDialog::exec();
if (r != QDialog::Accepted) { return r; } if (r != QDialog::Accepted) { return r; }
@@ -54,25 +54,25 @@ namespace BlackGui
return QDialog::Rejected; return QDialog::Rejected;
} }
bool CDownloadAndInstallDialog::event(QEvent *event) bool CUpdateInfoDialog::event(QEvent *event)
{ {
if (event->type() != QEvent::EnterWhatsThisMode) { return QDialog::event(event); } if (event->type() != QEvent::EnterWhatsThisMode) { return QDialog::event(event); }
QTimer::singleShot(0, this, &CDownloadAndInstallDialog::requestHelp); QTimer::singleShot(0, this, &CUpdateInfoDialog::requestHelp);
return true; return true;
} }
void CDownloadAndInstallDialog::onDontShowAgain(bool dontShowAgain) void CUpdateInfoDialog::onDontShowAgain(bool dontShowAgain)
{ {
m_setting.setAndSave(!dontShowAgain); m_setting.setAndSave(!dontShowAgain);
} }
void CDownloadAndInstallDialog::selectionChanged() void CUpdateInfoDialog::selectionChanged()
{ {
const bool nv = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable(); const bool nv = ui->comp_UpdateInfo->isNewPilotClientVersionAvailable();
ui->bb_DownloadInstallDialog->button(QDialogButtonBox::Ok)->setEnabled(nv); ui->bb_UpdateInfolDialog->button(QDialogButtonBox::Ok)->setVisible(nv);
} }
void CDownloadAndInstallDialog::requestHelp() void CUpdateInfoDialog::requestHelp()
{ {
if (sGui) { sGui->showHelp(this); } if (sGui) { sGui->showHelp(this); }
} }

View File

@@ -9,14 +9,14 @@
//! \file //! \file
#ifndef BLACKGUI_COMPONENTS_DOWNLOADANDINSTALLDIALOG_H #ifndef BLACKGUI_COMPONENTS_UPDATEINFODIALOG_H
#define BLACKGUI_COMPONENTS_DOWNLOADANDINSTALLDIALOG_H #define BLACKGUI_COMPONENTS_UPDATEINFODIALOG_H
#include "blackgui/settings/updatenotification.h" #include "blackgui/settings/updatenotification.h"
#include "blackgui/blackguiexport.h" #include "blackgui/blackguiexport.h"
#include <QDialog> #include <QDialog>
namespace Ui { class CDownloadAndInstallDialog; } namespace Ui { class CUpdateInfoDialog; }
namespace BlackGui namespace BlackGui
{ {
namespace Components namespace Components
@@ -24,16 +24,16 @@ namespace BlackGui
/** /**
* Download and install swift * Download and install swift
*/ */
class BLACKGUI_EXPORT CDownloadAndInstallDialog : public QDialog class BLACKGUI_EXPORT CUpdateInfoDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
//! Constructor //! Constructor
explicit CDownloadAndInstallDialog(QWidget *parent = nullptr); explicit CUpdateInfoDialog(QWidget *parent = nullptr);
//! Destructor //! Destructor
virtual ~CDownloadAndInstallDialog(); virtual ~CUpdateInfoDialog();
//! A new version existing? //! A new version existing?
bool isNewVersionAvailable() const; bool isNewVersionAvailable() const;
@@ -45,7 +45,7 @@ namespace BlackGui
virtual bool event(QEvent *event) override; virtual bool event(QEvent *event) override;
private: private:
QScopedPointer<Ui::CDownloadAndInstallDialog> ui; QScopedPointer<Ui::CUpdateInfoDialog> ui;
BlackMisc::CSetting<BlackGui::Settings::TUpdateNotificationSettings> m_setting { this }; //!< show again? BlackMisc::CSetting<BlackGui::Settings::TUpdateNotificationSettings> m_setting { this }; //!< show again?
//! Toggled checkbox //! Toggled checkbox

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>CDownloadAndInstallDialog</class> <class>CUpdateInfoDialog</class>
<widget class="QDialog" name="CDownloadAndInstallDialog"> <widget class="QDialog" name="CUpdateInfoDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@@ -68,7 +68,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="bb_DownloadInstallDialog"> <widget class="QDialogButtonBox" name="bb_UpdateInfolDialog">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
@@ -93,9 +93,9 @@
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
<sender>bb_DownloadInstallDialog</sender> <sender>bb_UpdateInfolDialog</sender>
<signal>accepted()</signal> <signal>accepted()</signal>
<receiver>CDownloadAndInstallDialog</receiver> <receiver>CUpdateInfoDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
@@ -109,9 +109,9 @@
</hints> </hints>
</connection> </connection>
<connection> <connection>
<sender>bb_DownloadInstallDialog</sender> <sender>bb_UpdateInfolDialog</sender>
<signal>rejected()</signal> <signal>rejected()</signal>
<receiver>CDownloadAndInstallDialog</receiver> <receiver>CUpdateInfoDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">

View File

@@ -13,7 +13,7 @@
#include "blackcore/data/globalsetup.h" #include "blackcore/data/globalsetup.h"
#include "blackcore/webdataservices.h" #include "blackcore/webdataservices.h"
#include "blackgui/components/applicationclosedialog.h" #include "blackgui/components/applicationclosedialog.h"
#include "blackgui/components/downloadandinstalldialog.h" #include "blackgui/components/updateinfodialog.h"
#include "blackgui/components/aboutdialog.h" #include "blackgui/components/aboutdialog.h"
#include "blackgui/components/setuploadingdialog.h" #include "blackgui/components/setuploadingdialog.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
@@ -746,14 +746,14 @@ namespace BlackGui
void CGuiApplication::checkNewVersion(bool onlyIfNew) void CGuiApplication::checkNewVersion(bool onlyIfNew)
{ {
if (!m_installDialog) if (!m_updateDialog)
{ {
// without parent stylesheet is not inherited // without parent stylesheet is not inherited
m_installDialog = new CDownloadAndInstallDialog(this->mainApplicationWindow()); m_updateDialog = new CUpdateInfoDialog(this->mainApplicationWindow());
} }
if (onlyIfNew && !m_installDialog->isNewVersionAvailable()) return; if (onlyIfNew && !m_updateDialog->isNewVersionAvailable()) return;
const int result = m_installDialog->exec(); const int result = m_updateDialog->exec();
if (result != QDialog::Accepted) { return; } if (result != QDialog::Accepted) { return; }
} }
@@ -762,7 +762,7 @@ namespace BlackGui
if (!m_updateSetting.get()) { return; } if (!m_updateSetting.get()) { return; }
QTimer::singleShot(delayedMs, this, [ = ] QTimer::singleShot(delayedMs, this, [ = ]
{ {
if (m_installDialog) { return; } if (m_updateDialog) { return; }
this->checkNewVersion(true); this->checkNewVersion(true);
}); });
} }

View File

@@ -42,7 +42,7 @@ namespace BlackGui
namespace Components namespace Components
{ {
class CApplicationCloseDialog; class CApplicationCloseDialog;
class CDownloadAndInstallDialog; class CUpdateInfoDialog;
} }
} }
namespace BlackGui namespace BlackGui
@@ -240,7 +240,7 @@ namespace BlackGui
CStyleSheetUtility m_styleSheetUtility {{}, this}; //!< style sheet utility CStyleSheetUtility m_styleSheetUtility {{}, this}; //!< style sheet utility
bool m_uiSetupCompleted = false; //!< ui setup completed bool m_uiSetupCompleted = false; //!< ui setup completed
QScopedPointer<QSplashScreen> m_splashScreen; //!< splash screen QScopedPointer<QSplashScreen> m_splashScreen; //!< splash screen
Components::CDownloadAndInstallDialog *m_installDialog = nullptr; //!< software installation dialog Components::CUpdateInfoDialog *m_updateDialog = nullptr; //!< software installation dialog
Components::CApplicationCloseDialog *m_closeDialog = nullptr; //!< close dialog (no QScopedPointer because I need to set parent) Components::CApplicationCloseDialog *m_closeDialog = nullptr; //!< close dialog (no QScopedPointer because I need to set parent)
BlackMisc::CSettingReadOnly<Settings::TGeneralGui> m_guiSettings { this, &CGuiApplication::settingsChanged }; BlackMisc::CSettingReadOnly<Settings::TGeneralGui> m_guiSettings { this, &CGuiApplication::settingsChanged };
BlackMisc::CSettingReadOnly<Settings::TUpdateNotificationSettings> m_updateSetting { this }; //!< update notification settings BlackMisc::CSettingReadOnly<Settings::TUpdateNotificationSettings> m_updateSetting { this }; //!< update notification settings