mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-10 03:16:09 +08:00
refactor: Fix some clang-tidy warnings
- Mark single argument constructors as explicit - Remove unused functions - Avoid default parameters in virtual functions - Clean up includes - Do not call static methods through an instance - And some more...
This commit is contained in:
@@ -14,33 +14,27 @@
|
||||
#include "blackcore/setupreader.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackcore/inputmanager.h"
|
||||
#include "blackmisc/atomicfile.h"
|
||||
#include "blackmisc/applicationinfo.h"
|
||||
#include "blackmisc/crashhandler.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/swiftdirectories.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/eventloop.h"
|
||||
#include "blackmisc/filelogger.h"
|
||||
#include "blackmisc/logcategories.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/logpattern.h"
|
||||
#include "blackmisc/network/networkutils.h"
|
||||
#include "blackmisc/registermetadata.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/slot.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
#include "blackmisc/threadutils.h"
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QEventLoop>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QHttpMultiPart>
|
||||
#include <QNetworkReply>
|
||||
@@ -54,7 +48,6 @@
|
||||
#include <QStringList>
|
||||
#include <QTemporaryDir>
|
||||
#include <QThread>
|
||||
#include <QTime>
|
||||
#include <QTimer>
|
||||
#include <QTranslator>
|
||||
#include <QWriteLocker>
|
||||
@@ -125,7 +118,7 @@ namespace BlackCore
|
||||
// unit test
|
||||
if (this->getApplicationInfo().getApplication() == CApplicationInfo::UnitTest)
|
||||
{
|
||||
const QString tempPath(this->getTemporaryDirectory());
|
||||
const QString tempPath(CApplication::getTemporaryDirectory());
|
||||
BlackMisc::setMockCacheRootDirectory(tempPath);
|
||||
}
|
||||
m_alreadyRunning = CApplication::getRunningApplications().containsApplication(CApplication::getApplicationInfo().getApplication());
|
||||
@@ -140,7 +133,7 @@ namespace BlackCore
|
||||
// Translations
|
||||
QTranslator translator;
|
||||
if (translator.load("blackmisc_i18n_de", ":blackmisc/translations/")) { CLogMessage(this).debug() << "Translator loaded"; }
|
||||
QCoreApplication::instance()->installTranslator(&translator);
|
||||
QCoreApplication::installTranslator(&translator);
|
||||
|
||||
// main app
|
||||
sApp = this;
|
||||
@@ -212,7 +205,7 @@ namespace BlackCore
|
||||
const QStringList args = this->argumentsJoined(newArguments, removeArguments);
|
||||
this->gracefulShutdown();
|
||||
QProcess::startDetached(prg, args);
|
||||
this->exit(0);
|
||||
CApplication::exit(0);
|
||||
}
|
||||
|
||||
CApplication::~CApplication()
|
||||
@@ -828,7 +821,7 @@ namespace BlackCore
|
||||
return this->startCoreFacade(); // will do nothing if setup is not yet loaded
|
||||
}
|
||||
|
||||
CStatusMessageList CApplication::useWebDataServices(const CWebReaderFlags::WebReader webReaders, const CDatabaseReaderConfigList &dbReaderConfig)
|
||||
CStatusMessageList CApplication::useWebDataServices(CWebReaderFlags::WebReader webReaders, const CDatabaseReaderConfigList &dbReaderConfig)
|
||||
{
|
||||
Q_ASSERT_X(m_webDataServices.isNull(), Q_FUNC_INFO, "Services already started");
|
||||
BLACK_VERIFY_X(QSslSocket::supportsSsl(), Q_FUNC_INFO, "No SSL");
|
||||
@@ -1205,16 +1198,6 @@ namespace BlackCore
|
||||
});
|
||||
}
|
||||
|
||||
void CApplication::severeStartupProblem(const CStatusMessage &message)
|
||||
{
|
||||
CLogMessage::preformatted(message);
|
||||
this->cmdLineErrorMessage(message.getMessage());
|
||||
this->exit(EXIT_FAILURE);
|
||||
|
||||
// if I get here the event loop was not yet running
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
CApplication *BlackCore::CApplication::instance()
|
||||
{
|
||||
return sApp;
|
||||
@@ -1322,7 +1305,7 @@ namespace BlackCore
|
||||
if (m_parsed) { return m_parsed; } // already done
|
||||
|
||||
// we call parse because we also want to display a GUI error message when applicable
|
||||
const QStringList args(QCoreApplication::instance()->arguments());
|
||||
const QStringList args(QCoreApplication::arguments());
|
||||
if (!m_parser.parse(args))
|
||||
{
|
||||
this->cmdLineErrorMessage("Parser error:", m_parser.errorText());
|
||||
@@ -1388,35 +1371,16 @@ namespace BlackCore
|
||||
// Already logged to console
|
||||
}
|
||||
|
||||
bool CApplication::cmdLineWarningMessage(const QString &text, const QString &informativeText) const
|
||||
void CApplication::cmdLineErrorMessage(const QString &text, const QString &informativeText) const
|
||||
{
|
||||
fputs(qPrintable(text + informativeText), stderr);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CApplication::cmdLineErrorMessage(const QString &text, const QString &informativeText, bool retry) const
|
||||
void CApplication::cmdLineErrorMessage(const CStatusMessageList &msgs) const
|
||||
{
|
||||
Q_UNUSED(retry) // only works with UI version
|
||||
fputs(qPrintable(text + informativeText), stderr);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CApplication::cmdLineErrorMessage(const CStatusMessageList &msgs, bool retry) const
|
||||
{
|
||||
Q_UNUSED(retry) // only works with UI version
|
||||
if (msgs.isEmpty()) { return false; }
|
||||
if (!msgs.hasErrorMessages()) { return false; }
|
||||
CApplication::cmdLineErrorMessage(
|
||||
msgs.toQString(true));
|
||||
return false;
|
||||
}
|
||||
|
||||
QString CApplication::cmdLineArgumentsAsString(bool withExecutable)
|
||||
{
|
||||
QStringList args = QCoreApplication::arguments();
|
||||
if (!withExecutable && !args.isEmpty()) args.removeFirst();
|
||||
if (args.isEmpty()) return {};
|
||||
return args.join(' ');
|
||||
if (msgs.isEmpty()) { return; }
|
||||
if (!msgs.hasErrorMessages()) { return; }
|
||||
CApplication::cmdLineErrorMessage(msgs.toQString(true), "");
|
||||
}
|
||||
|
||||
QPointer<ISimulator> CApplication::getISimulator() const
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace BlackCore
|
||||
* it can be used everywhere via QApplication::instance
|
||||
*
|
||||
* - A swift standard cmd line parser is part of the application.
|
||||
* Hence cmd arguments can be optained any time / everywhere when required.
|
||||
* Hence cmd arguments can be obtained any time / everywhere when required.
|
||||
* Also some standard swift cmd arguments do not need to be re-implemented for each swift application.
|
||||
* - The core facade (aka core runtime) is now part of the application. It can be started via cmd line arguments.
|
||||
* - Settings are loaded
|
||||
@@ -104,13 +104,13 @@ namespace BlackCore
|
||||
static const QStringList &getLogCategories();
|
||||
|
||||
//! Constructor
|
||||
CApplication(BlackMisc::CApplicationInfo::Application application, bool init = true);
|
||||
explicit CApplication(BlackMisc::CApplicationInfo::Application application, bool init = true);
|
||||
|
||||
//! Constructor
|
||||
CApplication(const QString &applicationName = executable(), BlackMisc::CApplicationInfo::Application application = BlackMisc::CApplicationInfo::Unknown, bool init = true);
|
||||
explicit CApplication(const QString &applicationName = executable(), BlackMisc::CApplicationInfo::Application application = BlackMisc::CApplicationInfo::Unknown, bool init = true);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CApplication() override;
|
||||
~CApplication() override;
|
||||
|
||||
//! Information about all running apps (including this one only if exec() has already been called)
|
||||
static BlackMisc::CApplicationInfoList getRunningApplications();
|
||||
@@ -240,7 +240,7 @@ namespace BlackCore
|
||||
// ----------------------- cmd line args / parsing ----------------------------------------
|
||||
|
||||
//! Current parameters replaced by new arguments without the cmd line argument
|
||||
virtual QStringList argumentsJoined(const QStringList &newArguments = {}, const QStringList &removeArguments = {}) const;
|
||||
QStringList argumentsJoined(const QStringList &newArguments = {}, const QStringList &removeArguments = {}) const;
|
||||
|
||||
//! Similar to QCoreApplication::arguments
|
||||
static QStringList arguments();
|
||||
@@ -295,17 +295,11 @@ namespace BlackCore
|
||||
//! functions to show error messages and (2) the some command line arguments are added after constructing the object
|
||||
bool parseCommandLineArgsAndLoadSetup();
|
||||
|
||||
//! Display warning message
|
||||
virtual bool cmdLineWarningMessage(const QString &text, const QString &informativeText = "") const;
|
||||
//! Display error message
|
||||
virtual void cmdLineErrorMessage(const QString &text, const QString &informativeText) const;
|
||||
|
||||
//! Display error message
|
||||
virtual bool cmdLineErrorMessage(const QString &text, const QString &informativeText = "", bool retry = false) const;
|
||||
|
||||
//! Display error message
|
||||
virtual bool cmdLineErrorMessage(const BlackMisc::CStatusMessageList &msgs, bool retry = false) const;
|
||||
|
||||
//! cmd line arguments as string
|
||||
virtual QString cmdLineArgumentsAsString(bool withExecutable = true);
|
||||
virtual void cmdLineErrorMessage(const BlackMisc::CStatusMessageList &msgs) const;
|
||||
|
||||
//! @}
|
||||
|
||||
@@ -366,7 +360,7 @@ namespace BlackCore
|
||||
//! Init web data services and start them
|
||||
//! \sa webDataServicesStarted
|
||||
//! \remark requires setup loaded
|
||||
BlackMisc::CStatusMessageList useWebDataServices(const CWebReaderFlags::WebReader webReader, const Db::CDatabaseReaderConfigList &dbReaderConfig);
|
||||
BlackMisc::CStatusMessageList useWebDataServices(CWebReaderFlags::WebReader webReader, const Db::CDatabaseReaderConfigList &dbReaderConfig);
|
||||
|
||||
//! Get the facade
|
||||
CCoreFacade *getCoreFacade() { return m_coreFacade.data(); }
|
||||
@@ -523,7 +517,7 @@ namespace BlackCore
|
||||
QNetworkReply *getFromNetwork(const QNetworkRequest &request, int logId,
|
||||
const CallbackSlot &callback, const ProgressSlot &progress, int maxRedirects = DefaultMaxRedirects);
|
||||
|
||||
//! Request to delete a network ressource from network, supporting BlackMisc::Network::CUrlLog
|
||||
//! Request to delete a network resource from network, supporting BlackMisc::Network::CUrlLog
|
||||
//! \threadsafe
|
||||
QNetworkReply *deleteResourceFromNetwork(const QNetworkRequest &request, int logId,
|
||||
const CallbackSlot &callback,
|
||||
@@ -603,10 +597,6 @@ namespace BlackCore
|
||||
//! Flag set or explicitly set to true
|
||||
bool isSet(const QCommandLineOption &option) const;
|
||||
|
||||
//! Severe issue during startup, most likely it does not make sense to continue
|
||||
//! \note call this here if the parsing stage is over and reaction to a runtime issue is needed
|
||||
[[noreturn]] void severeStartupProblem(const BlackMisc::CStatusMessage &message);
|
||||
|
||||
//! Start the core facade
|
||||
//! \note does nothing when setup is not yet loaded
|
||||
BlackMisc::CStatusMessageList startCoreFacade();
|
||||
@@ -708,7 +698,7 @@ namespace BlackCore
|
||||
bool startupCheck() const;
|
||||
|
||||
//! Loads the setup (bootstrap) and handles/displays warnings and error messages
|
||||
//! \returns true if loading succedded without errors
|
||||
//! \returns true if loading succeeded without errors
|
||||
bool loadSetupAndHandleErrors();
|
||||
|
||||
//! Parses and handles the standard options such as help, version, parse error
|
||||
|
||||
@@ -18,13 +18,11 @@
|
||||
#include "blackmisc/slot.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
#include "blackmisc/swiftdirectories.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
#include "blackmisc/logcategories.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
#include "blackmisc/metadatautils.h"
|
||||
#include "blackmisc/registermetadata.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
@@ -37,29 +35,21 @@
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QEventLoop>
|
||||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QIcon>
|
||||
#include <QFont>
|
||||
#include <QKeySequence>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QRegularExpression>
|
||||
#include <QSettings>
|
||||
#include <QSplashScreen>
|
||||
#include <QMessageBox>
|
||||
#include <QStyleFactory>
|
||||
#include <QStringList>
|
||||
#include <QStringBuilder>
|
||||
#include <QStyle>
|
||||
#include <QSysInfo>
|
||||
#include <QToolBar>
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
#include <QWindow>
|
||||
#include <QMainWindow>
|
||||
#include <QMessageBox>
|
||||
#include <QtGlobal>
|
||||
#include <QWhatsThis>
|
||||
#include <Qt>
|
||||
@@ -127,7 +117,7 @@ namespace BlackGui
|
||||
CGuiApplication::registerMetadata();
|
||||
CApplication::init(false); // base class without metadata
|
||||
CGuiApplication::adjustPalette();
|
||||
this->setWindowIcon(icon);
|
||||
CGuiApplication::setWindowIcon(icon);
|
||||
this->settingsChanged();
|
||||
this->setCurrentFontValues(); // most likely the default font and not any stylesheet font at this time
|
||||
sGui = this;
|
||||
@@ -234,7 +224,7 @@ namespace BlackGui
|
||||
if (this->getGlobalSetup().isSwiftVersionMinimumMappingVersion()) { return true; }
|
||||
|
||||
const QString msg = QStringLiteral("Your are using swift version: '%1'.\nCreating mappings requires at least '%2'.").arg(CBuildConfig::getVersionString(), this->getGlobalSetup().getMappingMinimumVersionString());
|
||||
QMessageBox::warning(this->mainApplicationWindow(), "Version check", msg, QMessageBox::Close);
|
||||
QMessageBox::warning(CGuiApplication::mainApplicationWindow(), "Version check", msg, QMessageBox::Close);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -266,7 +256,7 @@ namespace BlackGui
|
||||
|
||||
void CGuiApplication::addWindowFlags(Qt::WindowFlags flags)
|
||||
{
|
||||
QWidget *maw = this->mainApplicationWidget();
|
||||
QWidget *maw = BlackGui::CGuiApplication::mainApplicationWidget();
|
||||
if (maw)
|
||||
{
|
||||
Qt::WindowFlags windowFlags = maw->windowFlags();
|
||||
@@ -516,14 +506,7 @@ namespace BlackGui
|
||||
return "1.0";
|
||||
}
|
||||
|
||||
bool CGuiApplication::cmdLineWarningMessage(const QString &text, const QString &informativeText) const
|
||||
{
|
||||
QMessageBox warningBox(QMessageBox::Warning, QGuiApplication::applicationDisplayName(), "<b>" + text + "</b>");
|
||||
warningBox.setInformativeText(informativeText);
|
||||
return warningBox.exec();
|
||||
}
|
||||
|
||||
bool CGuiApplication::cmdLineErrorMessage(const QString &text, const QString &informativeText, bool retry) const
|
||||
void CGuiApplication::cmdLineErrorMessage(const QString &text, const QString &informativeText) const
|
||||
{
|
||||
QMessageBox errorBox(QMessageBox::Critical, QGuiApplication::applicationDisplayName(), "<b>" + text + "</b>");
|
||||
if (informativeText.length() < 300)
|
||||
@@ -532,25 +515,20 @@ namespace BlackGui
|
||||
errorBox.setDetailedText(informativeText);
|
||||
|
||||
errorBox.addButton(QMessageBox::Abort);
|
||||
if (retry)
|
||||
errorBox.addButton(QMessageBox::Retry);
|
||||
|
||||
const int r = errorBox.exec();
|
||||
|
||||
return (r == QMessageBox::Retry);
|
||||
errorBox.exec();
|
||||
}
|
||||
|
||||
bool CGuiApplication::cmdLineErrorMessage(const CStatusMessageList &msgs, bool retry) const
|
||||
void CGuiApplication::cmdLineErrorMessage(const CStatusMessageList &msgs) const
|
||||
{
|
||||
if (msgs.isEmpty()) { return false; }
|
||||
if (!msgs.hasErrorMessages()) { return false; }
|
||||
if (msgs.isEmpty()) { return; }
|
||||
if (!msgs.hasErrorMessages()) { return; }
|
||||
static const CPropertyIndexList propertiesSingle({ CStatusMessage::IndexMessage });
|
||||
static const CPropertyIndexList propertiesMulti({ CStatusMessage::IndexSeverityAsString, CStatusMessage::IndexMessage });
|
||||
const QString msgsHtml = msgs.toHtml(msgs.size() > 1 ? propertiesMulti : propertiesSingle);
|
||||
const int r = QMessageBox::critical(nullptr,
|
||||
QGuiApplication::applicationDisplayName(),
|
||||
"<html><head><body>" + msgsHtml + "</body></html>", QMessageBox::Abort, retry ? QMessageBox::Retry : QMessageBox::NoButton);
|
||||
return (r == QMessageBox::Retry);
|
||||
QMessageBox::critical(nullptr,
|
||||
QGuiApplication::applicationDisplayName(),
|
||||
"<html><head><body>" + msgsHtml + "</body></html>", QMessageBox::Abort, QMessageBox::NoButton);
|
||||
}
|
||||
|
||||
bool CGuiApplication::isCmdWindowSizeResetSet() const
|
||||
@@ -734,8 +712,8 @@ namespace BlackGui
|
||||
a, &QAction::triggered, this, [=]() {
|
||||
// a close event might already trigger a shutdown
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (!this->mainApplicationWidget()) { return; }
|
||||
this->mainApplicationWidget()->close();
|
||||
if (!CGuiApplication::mainApplicationWidget()) { return; }
|
||||
CGuiApplication::mainApplicationWidget()->close();
|
||||
|
||||
// T596, do not shutdown here, as close can be canceled
|
||||
// if shutdown is called, there is no way back
|
||||
@@ -1038,7 +1016,7 @@ namespace BlackGui
|
||||
}
|
||||
|
||||
// dialog will handle the saving
|
||||
const QDialog::DialogCode c = static_cast<QDialog::DialogCode>(m_closeDialog->exec());
|
||||
const auto c = static_cast<QDialog::DialogCode>(m_closeDialog->exec());
|
||||
|
||||
// settings already saved when reaching here
|
||||
switch (c)
|
||||
@@ -1070,7 +1048,7 @@ namespace BlackGui
|
||||
if (!m_updateDialog)
|
||||
{
|
||||
// without parent stylesheet is not inherited
|
||||
m_updateDialog = new CUpdateInfoDialog(this->mainApplicationWidget());
|
||||
m_updateDialog = new CUpdateInfoDialog(CGuiApplication::mainApplicationWidget());
|
||||
}
|
||||
|
||||
if (onlyIfNew && !m_updateDialog->isNewVersionAvailable()) { return; }
|
||||
@@ -1080,7 +1058,7 @@ namespace BlackGui
|
||||
|
||||
QString CGuiApplication::getFontInfo() const
|
||||
{
|
||||
const QWidget *w = this->mainApplicationWidget();
|
||||
const QWidget *w = CGuiApplication::mainApplicationWidget();
|
||||
if (!w) { return QStringLiteral("Font info not available"); }
|
||||
return QStringLiteral("Family: '%1', average width: %2").arg(w->font().family()).arg(w->fontMetrics().averageCharWidth());
|
||||
}
|
||||
@@ -1099,7 +1077,7 @@ namespace BlackGui
|
||||
void CGuiApplication::windowToFront()
|
||||
{
|
||||
if (this->isShuttingDown()) { return; }
|
||||
QMainWindow *w = sGui->mainApplicationWindow();
|
||||
QMainWindow *w = CGuiApplication::mainApplicationWindow();
|
||||
if (!w) { return; }
|
||||
|
||||
m_frontBack = true;
|
||||
@@ -1113,7 +1091,7 @@ namespace BlackGui
|
||||
void CGuiApplication::windowToBack()
|
||||
{
|
||||
if (this->isShuttingDown()) { return; }
|
||||
QMainWindow *w = this->mainApplicationWindow();
|
||||
QMainWindow *w = CGuiApplication::mainApplicationWindow();
|
||||
if (!w) { return; }
|
||||
|
||||
m_frontBack = false;
|
||||
@@ -1128,7 +1106,7 @@ namespace BlackGui
|
||||
void CGuiApplication::windowToFrontBackToggle()
|
||||
{
|
||||
if (this->isShuttingDown()) { return; }
|
||||
QMainWindow *w = sGui->mainApplicationWindow();
|
||||
QMainWindow *w = CGuiApplication::mainApplicationWindow();
|
||||
if (!w) { return; }
|
||||
if (w->isMinimized())
|
||||
{
|
||||
@@ -1159,7 +1137,7 @@ namespace BlackGui
|
||||
void CGuiApplication::windowMinimizeNormalToggle()
|
||||
{
|
||||
if (this->isShuttingDown()) { return; }
|
||||
QMainWindow *w = sGui->mainApplicationWindow();
|
||||
QMainWindow *w = CGuiApplication::mainApplicationWindow();
|
||||
if (!w) { return; }
|
||||
if (m_normalizeMinimize)
|
||||
{
|
||||
@@ -1209,7 +1187,7 @@ namespace BlackGui
|
||||
|
||||
//! \todo KB 3-2020 remove as soon as the info status bar blocks shutdown bug is fixed
|
||||
//! ref: https://discordapp.com/channels/539048679160676382/539846348275449887/693848134811517029
|
||||
const QStringList docks = CGuiUtility::deleteLaterAllDockWidgetsGetTitles(this->mainApplicationWidget(), true);
|
||||
const QStringList docks = CGuiUtility::deleteLaterAllDockWidgetsGetTitles(CGuiApplication::mainApplicationWidget(), true);
|
||||
if (docks.count() > 0)
|
||||
{
|
||||
// that should not happen
|
||||
|
||||
@@ -54,14 +54,6 @@ namespace BlackGui
|
||||
* - standard menus
|
||||
* - splash screen support
|
||||
*
|
||||
* Simple example
|
||||
* \snippet swiftlauncher/main.cpp SwiftApplicationDemo
|
||||
*
|
||||
* Derived class example, hence very short (logic in CSwiftGuiStdApplication)
|
||||
* \snippet swiftguistandard/main.cpp SwiftApplicationDemo
|
||||
*
|
||||
* Longer example
|
||||
* \snippet swiftcore/main.cpp SwiftApplicationDemo
|
||||
*/
|
||||
class BLACKGUI_EXPORT CGuiApplication :
|
||||
public BlackCore::CApplication,
|
||||
@@ -84,10 +76,10 @@ namespace BlackGui
|
||||
static bool removeAllWindowsSwiftRegistryEntries();
|
||||
|
||||
//! Constructor
|
||||
CGuiApplication(const QString &applicationName = executable(), BlackMisc::CApplicationInfo::Application application = BlackMisc::CApplicationInfo::Unknown, const QPixmap &icon = BlackMisc::CIcons::swift64());
|
||||
explicit CGuiApplication(const QString &applicationName = executable(), BlackMisc::CApplicationInfo::Application application = BlackMisc::CApplicationInfo::Unknown, const QPixmap &icon = BlackMisc::CIcons::swift64());
|
||||
|
||||
//! Destructor
|
||||
virtual ~CGuiApplication() override;
|
||||
~CGuiApplication() override;
|
||||
|
||||
//! CMD line arguments
|
||||
void addWindowStateOption();
|
||||
@@ -120,13 +112,10 @@ namespace BlackGui
|
||||
//! Set window title
|
||||
QString setExtraWindowTitle(const QString &extraInfo, QWidget *mainWindowWidget = mainApplicationWidget()) const;
|
||||
|
||||
//! print warning message
|
||||
virtual bool cmdLineWarningMessage(const QString &text, const QString &informativeText) const override;
|
||||
|
||||
//! @{
|
||||
//! print messages generated during parsing / cmd handling
|
||||
virtual bool cmdLineErrorMessage(const QString &text, const QString &informativeText = "", bool retry = false) const override;
|
||||
virtual bool cmdLineErrorMessage(const BlackMisc::CStatusMessageList &msgs, bool retry = false) const override;
|
||||
void cmdLineErrorMessage(const QString &text, const QString &informativeText) const override;
|
||||
void cmdLineErrorMessage(const BlackMisc::CStatusMessageList &msgs) const override;
|
||||
//! @}
|
||||
|
||||
//! Window size reset mode set
|
||||
@@ -134,11 +123,11 @@ namespace BlackGui
|
||||
|
||||
//! @{
|
||||
//! direct access to main application window
|
||||
virtual bool displayInStatusBar(const BlackMisc::CStatusMessage &message) override;
|
||||
virtual bool displayTextInConsole(const QString &text) override;
|
||||
virtual bool displayInOverlayWindow(const BlackMisc::CStatusMessage &message, int timeOutMs = -1) override;
|
||||
virtual bool displayInOverlayWindow(const BlackMisc::CStatusMessageList &messages, int timeOutMs = -1) override;
|
||||
virtual bool displayInOverlayWindow(const QString &html, int timeOutMs = -1) override;
|
||||
bool displayInStatusBar(const BlackMisc::CStatusMessage &message) override;
|
||||
bool displayTextInConsole(const QString &text) override;
|
||||
bool displayInOverlayWindow(const BlackMisc::CStatusMessage &message, int timeOutMs = -1) override;
|
||||
bool displayInOverlayWindow(const BlackMisc::CStatusMessageList &messages, int timeOutMs = -1) override;
|
||||
bool displayInOverlayWindow(const QString &html, int timeOutMs = -1) override;
|
||||
//! @}
|
||||
|
||||
// -------- Splash screen related ---------
|
||||
@@ -219,7 +208,7 @@ namespace BlackGui
|
||||
void triggerNewVersionCheck(int delayedMs);
|
||||
|
||||
//! \copydoc BlackCore::CApplication::gracefulShutdown
|
||||
virtual void gracefulShutdown() override;
|
||||
void gracefulShutdown() override;
|
||||
|
||||
//! Toggle stay on top
|
||||
bool toggleStayOnTop();
|
||||
@@ -257,7 +246,7 @@ namespace BlackGui
|
||||
void registerMainApplicationWidget(QWidget *mainWidget);
|
||||
|
||||
//! \copydoc BlackCore::CApplication::hasMinimumMappingVersion
|
||||
virtual bool hasMinimumMappingVersion() const override;
|
||||
bool hasMinimumMappingVersion() const override;
|
||||
|
||||
//! Main application window
|
||||
static QMainWindow *mainApplicationWindow();
|
||||
@@ -310,13 +299,13 @@ namespace BlackGui
|
||||
|
||||
protected:
|
||||
//! Handle parsing of special GUI cmd arguments
|
||||
virtual bool parsingHookIn() override;
|
||||
bool parsingHookIn() override;
|
||||
|
||||
//! \copydoc BlackCore::CApplication::onCoreFacadeStarted
|
||||
virtual void onCoreFacadeStarted() override;
|
||||
void onCoreFacadeStarted() override;
|
||||
|
||||
//! \copydoc BlackCore::CApplication::onStartUpCompleted
|
||||
virtual void onStartUpCompleted() override;
|
||||
void onStartUpCompleted() override;
|
||||
|
||||
//! Check for a new version (update)
|
||||
void checkNewVersion(bool onlyIfNew);
|
||||
@@ -354,7 +343,7 @@ namespace BlackGui
|
||||
//! Check new from menu
|
||||
void checkNewVersionMenu();
|
||||
|
||||
//! Fix the palette for better readibility
|
||||
//! Fix the palette for better readability
|
||||
void adjustPalette();
|
||||
|
||||
//! Style sheets have been changed
|
||||
|
||||
@@ -3,26 +3,22 @@
|
||||
|
||||
#include "blackcore/corefacadeconfig.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackmisc/audio/audioutils.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/crashhandler.h"
|
||||
#include "swiftcore.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include <QApplication>
|
||||
#include <QString>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <Qt>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Audio;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackGui;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//! [SwiftApplicationDemo]
|
||||
CGuiApplication::highDpiScreenSupport(CGuiApplication::scaleFactor(argc, argv));
|
||||
QApplication qa(argc, argv);
|
||||
Q_UNUSED(qa) // init of qa is required, but qa not used
|
||||
@@ -36,18 +32,17 @@ int main(int argc, char *argv[])
|
||||
a.addAudioOptions();
|
||||
if (!a.parseCommandLineArgsAndLoadSetup()) { return EXIT_FAILURE; }
|
||||
|
||||
const QString dBusAdress(a.getCmdDBusAddressValue());
|
||||
a.useContexts(CCoreFacadeConfig::forCoreAllLocalInDBus(dBusAdress));
|
||||
const QString dBusAddress(a.getCmdDBusAddressValue());
|
||||
a.useContexts(CCoreFacadeConfig::forCoreAllLocalInDBus(dBusAddress));
|
||||
if (!a.start())
|
||||
{
|
||||
a.gracefulShutdown();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//! [SwiftApplicationDemo]
|
||||
|
||||
if (!QSystemTrayIcon::isSystemTrayAvailable())
|
||||
{
|
||||
a.cmdLineErrorMessage("I could not detect any system tray on this system.");
|
||||
a.cmdLineErrorMessage("System tray missing", "I could not detect any system tray on this system.");
|
||||
a.gracefulShutdown();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
|
||||
#include "blackcore/webreaderflags.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/crashhandler.h"
|
||||
#include "swiftdata.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include <QApplication>
|
||||
#include <QtGlobal>
|
||||
|
||||
|
||||
@@ -8,14 +8,11 @@
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackmisc/audio/audioutils.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/crashhandler.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTextStream>
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackMisc;
|
||||
@@ -24,7 +21,6 @@ using namespace BlackCore;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//! [SwiftApplicationDemo]
|
||||
CGuiApplication::highDpiScreenSupport(CGuiApplication::scaleFactor(argc, argv));
|
||||
QApplication qa(argc, argv);
|
||||
Q_UNUSED(qa) // application init needed
|
||||
@@ -45,7 +41,6 @@ int main(int argc, char *argv[])
|
||||
a.gracefulShutdown();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//! [SwiftApplicationDemo]
|
||||
|
||||
// show window
|
||||
CEnableForFramelessWindow::WindowMode windowMode = a.getWindowMode();
|
||||
|
||||
@@ -83,7 +83,7 @@ bool CSwiftGuiStdApplication::parsingHookIn()
|
||||
// check if reachable
|
||||
if (!CDBusServer::isDBusAvailable(dBusAddress))
|
||||
{
|
||||
this->cmdLineErrorMessage("DBus server at '" + dBusAddress + "' can not be reached");
|
||||
this->cmdLineErrorMessage("DBus error", "DBus server at '" + dBusAddress + "' can not be reached");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,16 +3,12 @@
|
||||
|
||||
#include "swiftlauncher.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackcore/registermetadata.h"
|
||||
#include "blackcore/db/databasereaderconfig.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/icons.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QProcess>
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
@@ -23,7 +19,6 @@ using namespace BlackCore::Db;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//! [SwiftApplicationDemo]
|
||||
CGuiApplication::highDpiScreenSupport(CGuiApplication::scaleFactor(argc, argv));
|
||||
QApplication qa(argc, argv); // needed
|
||||
Q_UNUSED(qa)
|
||||
@@ -38,7 +33,6 @@ int main(int argc, char *argv[])
|
||||
a.gracefulShutdown();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
//! [SwiftApplicationDemo]
|
||||
|
||||
CSwiftLauncher launcher;
|
||||
const int res = a.exec();
|
||||
|
||||
Reference in New Issue
Block a user