Ref T156, allow to interactively resolve setup issues

* interactivelySynchronizeSetup
* utility function parseAndSynchronizeSetup, explicit loading of setup
* removed m_startSetupReader;
This commit is contained in:
Klaus Basan
2017-09-24 19:44:06 +01:00
committed by Mathew Sutcliffe
parent 409a50e8a5
commit fedcd76a05
8 changed files with 138 additions and 51 deletions

View File

@@ -9,11 +9,13 @@
#include "blackconfig/buildconfig.h"
#include "blackcore/context/contextnetwork.h"
#include "blackcore/setupreader.h"
#include "blackcore/data/globalsetup.h"
#include "blackcore/webdataservices.h"
#include "blackgui/components/applicationclosedialog.h"
#include "blackgui/components/downloadandinstalldialog.h"
#include "blackgui/components/aboutdialog.h"
#include "blackgui/components/setuploadingdialog.h"
#include "blackgui/guiapplication.h"
#include "blackgui/guiutility.h"
#include "blackgui/registermetadata.h"
@@ -82,6 +84,7 @@ namespace BlackGui
{
CGuiApplication::registerMetadata();
CApplication::init(false); // base class without metadata
if (this->hasSetupReader()) { this->getSetupReader()->setCheckCmdLineBootstrapUrl(false); } // no connect checks on setup reader (handled with interactive setup loading)
CGuiApplication::adjustPalette();
this->setWindowIcon(icon);
this->settingsChanged();
@@ -207,9 +210,9 @@ namespace BlackGui
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
}
void CGuiApplication::startupCompleted()
void CGuiApplication::onStartUpCompleted()
{
CApplication::startupCompleted();
CApplication::onStartUpCompleted();
if (this->m_splashScreen)
{
this->m_splashScreen->close();
@@ -597,6 +600,44 @@ namespace BlackGui
return m_styleSheetUtility.resetFont();
}
bool CGuiApplication::interactivelySynchronizeSetup(int timeoutMs)
{
bool ok = false;
do
{
const CStatusMessageList msgs = this->synchronizeSetup(timeoutMs);
if (msgs.hasErrorMessages())
{
static const QString style = sGui->getStyleSheetUtility().styles(
{
CStyleSheetUtility::fileNameFonts(),
CStyleSheetUtility::fileNameStandardWidget()
});
CSetupLoadingDialog dialog(msgs, this->mainApplicationWindow());
dialog.setStyleSheet(style);
const int r = dialog.exec();
if (r == QDialog::Rejected)
{
ok = false;
break;
}
}
else
{
ok = true;
break;
}
}
while (true);
return ok;
}
bool CGuiApplication::parseAndSynchronizeSetup(int timeoutMs)
{
if (!this->parseAndStartupCheck()) return false;
return this->interactivelySynchronizeSetup(timeoutMs);
}
QDialog::DialogCode CGuiApplication::showCloseDialog(QMainWindow *mainWindow, QCloseEvent *closeEvent)
{
const bool needsDialog = this->hasUnsavedSettings();

View File

@@ -19,6 +19,7 @@
#include "blackgui/settings/guisettings.h"
#include "blackgui/settings/updatenotification.h"
#include "blackgui/stylesheetutility.h"
#include "blackmisc/network/networkutils.h"
#include "blackmisc/icons.h"
#include "blackmisc/statusmessage.h"
@@ -162,6 +163,14 @@ namespace BlackGui
//! Reset the font to default
bool resetFont();
//! Wait for setup, in case it fails display a dialog how to continue
bool interactivelySynchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs());
//! Combined function
//! \see parseAndStartupCheck
//! \see interactivelySynchronizeSetup
virtual bool parseAndSynchronizeSetup(int timeoutMs = BlackMisc::Network::CNetworkUtils::getLongTimeoutMs()) override;
//! Show close dialog
QDialog::DialogCode showCloseDialog(QMainWindow *mainWindow, QCloseEvent *closeEvent);
@@ -194,7 +203,7 @@ namespace BlackGui
protected slots:
//! Startup competed
virtual void startupCompleted() override;
virtual void onStartUpCompleted() override;
protected:
//! \name print messages generated during parsing / cmd handling
@@ -214,15 +223,15 @@ namespace BlackGui
private:
QPixmap m_windowIcon;
BlackGui::Components::CDownloadAndInstallDialog *m_installDialog = nullptr; //!< software installation dialog
QCommandLineOption m_cmdWindowStateMinimized { "empty" }; //!< window state (minimized)
QCommandLineOption m_cmdWindowMode { "empty" }; //!< window mode (flags: frameless ...)
CStyleSheetUtility m_styleSheetUtility{{}, this}; //!< style sheet utility
bool m_uiSetupCompleted = false; //!< ui setup completed
QScopedPointer<QSplashScreen> m_splashScreen; //!< splash screen
BlackGui::Components::CApplicationCloseDialog *m_closeDialog = nullptr; //!< close dialog (no QScopedPointer because I need to set parent)
BlackMisc::CSettingReadOnly<BlackGui::Settings::TGeneralGui> m_guiSettings{ this, &CGuiApplication::settingsChanged };
BlackMisc::CSettingReadOnly<BlackGui::Settings::TUpdateNotificationSettings> m_updateSetting { this }; //!< update notification settings
Components::CDownloadAndInstallDialog *m_installDialog = nullptr; //!< software installation dialog
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::TUpdateNotificationSettings> m_updateSetting { this }; //!< update notification settings
//! Qt help message to formatted HTML
static QString beautifyHelpMessage(const QString &helpText);