mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #693, integrated GUI close dialog
* utility function in CGuiApplication containing the logic (dialog needed, ..) * closeEvent function
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackcore/data/globalsetup.h"
|
||||
#include "blackcore/data/updateinfo.h"
|
||||
#include "blackgui/components/applicationclosedialog.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackgui/registermetadata.h"
|
||||
@@ -23,6 +24,7 @@
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QCloseEvent>
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QCoreApplication>
|
||||
@@ -40,11 +42,13 @@
|
||||
#include <QStyle>
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
#include <QMainWindow>
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackGui::Components;
|
||||
using namespace BlackCore::Data;
|
||||
|
||||
BlackGui::CGuiApplication *sGui = nullptr; // set by constructor
|
||||
@@ -486,12 +490,33 @@ namespace BlackGui
|
||||
return m_styleSheetUtility.updateFonts(fontFamily, fontSize, fontStyle, fontWeight, fontColor);
|
||||
}
|
||||
|
||||
QDialog::DialogCode CGuiApplication::showCloseDialog(QMainWindow *mainWindow, QCloseEvent *closeEvent)
|
||||
{
|
||||
bool needsDialog = this->hasUnsavedSettings();
|
||||
if (!needsDialog) { return QDialog::Accepted; }
|
||||
if (!this->m_closeDialog)
|
||||
{
|
||||
this->m_closeDialog = new CApplicationCloseDialog(mainWindow);
|
||||
if (mainWindow && !mainWindow->windowTitle().isEmpty())
|
||||
{
|
||||
this->setSettingsAutoSave(false); // will be handled by dialog
|
||||
this->m_closeDialog->setWindowTitle(mainWindow->windowTitle());
|
||||
this->m_closeDialog->setModal(true);
|
||||
}
|
||||
}
|
||||
const QDialog::DialogCode c = static_cast<QDialog::DialogCode>(this->m_closeDialog->exec());
|
||||
if (c == QDialog::Rejected)
|
||||
{
|
||||
if (closeEvent) { closeEvent->ignore(); }
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
void CGuiApplication::cmdLineHelpMessage()
|
||||
{
|
||||
if (CBuildConfig::isRunningOnWindowsNtPlatform())
|
||||
{
|
||||
QMessageBox::information(nullptr,
|
||||
QGuiApplication::applicationDisplayName(),
|
||||
QMessageBox::information(nullptr, QGuiApplication::applicationDisplayName(),
|
||||
"<html><head/><body><pre>" + this->m_parser.helpText() + "</pre></body></html>");
|
||||
}
|
||||
else
|
||||
@@ -504,8 +529,7 @@ namespace BlackGui
|
||||
{
|
||||
if (CBuildConfig::isRunningOnWindowsNtPlatform())
|
||||
{
|
||||
QMessageBox::information(nullptr,
|
||||
QGuiApplication::applicationDisplayName(),
|
||||
QMessageBox::information(nullptr, QGuiApplication::applicationDisplayName(),
|
||||
QGuiApplication::applicationDisplayName() + ' ' + QCoreApplication::applicationVersion());
|
||||
}
|
||||
else
|
||||
@@ -518,5 +542,4 @@ namespace BlackGui
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "blackmisc/statusmessage.h"
|
||||
|
||||
#include <QCommandLineOption>
|
||||
#include <QDialog>
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QScopedPointer>
|
||||
@@ -30,9 +31,10 @@
|
||||
class QMenu;
|
||||
class QSplashScreen;
|
||||
class QWidget;
|
||||
class QMainWindow;
|
||||
|
||||
namespace BlackMisc { class CLogCategoryList; }
|
||||
|
||||
namespace BlackGui { namespace Components { class CApplicationCloseDialog; }}
|
||||
namespace BlackGui
|
||||
{
|
||||
/*!
|
||||
@@ -138,6 +140,9 @@ namespace BlackGui
|
||||
//! Update the fonts
|
||||
bool updateFonts(const QString &fontFamily, const QString &fontSize, const QString &fontStyle, const QString &fontWeight, const QString &fontColor);
|
||||
|
||||
//! Show close dialog
|
||||
QDialog::DialogCode showCloseDialog(QMainWindow *mainWindow, QCloseEvent *closeEvent);
|
||||
|
||||
//! Set icon
|
||||
//! \note Pixmap requires a valid QApplication, so it cannot be passed as constructor parameter
|
||||
static void setWindowIcon(const QPixmap &icon);
|
||||
@@ -184,8 +189,9 @@ namespace BlackGui
|
||||
QCommandLineOption m_cmdWindowStateMinimized { "empty" }; //!< window state (minimized)
|
||||
QCommandLineOption m_cmdWindowMode { "empty" }; //!< window mode (flags: frameless ...)
|
||||
CStyleSheetUtility m_styleSheetUtility{{}, this}; //!< style sheet utility
|
||||
QScopedPointer<QSplashScreen> m_splashScreen; //!< splash screen
|
||||
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)
|
||||
|
||||
//! Qt help message to formatted HTML
|
||||
static QString beautifyHelpMessage(const QString &helpText);
|
||||
|
||||
Reference in New Issue
Block a user