7 #include <QApplication>
9 #include <QCommandLineParser>
10 #include <QDesktopServices>
14 #include <QGuiApplication>
16 #include <QKeySequence>
17 #include <QMainWindow>
19 #include <QMessageBox>
21 #include <QStringBuilder>
22 #include <QStringList>
24 #include <QStyleFactory>
43 #include "gui/registermetadata.h"
56 using namespace swift::config;
58 using namespace swift::misc::db;
59 using namespace swift::misc::network;
63 using namespace swift::core::context;
69 CGuiApplication *CGuiApplication::instance() {
return qobject_cast<CGuiApplication *>(CApplication::instance()); }
71 const QStringList &CGuiApplication::getLogCategories()
73 static const QStringList l(CApplication::getLogCategories() + QStringList { CLogCategories::guiComponent() });
77 const QString &CGuiApplication::settingsOrganization()
79 static const QString o(
"swift-project.org");
83 bool CGuiApplication::removeAllWindowsSwiftRegistryEntries()
93 QSettings s1(
"HKEY_CURRENT_USER\\Software\\" + settingsOrganization(), QSettings::NativeFormat);
96 QSettings s2(
"HKEY_LOCAL_MACHINE\\Software\\" + settingsOrganization(), QSettings::NativeFormat);
116 CApplication::init(
false);
117 CGuiApplication::adjustPalette();
119 this->settingsChanged();
120 this->setCurrentFontValues();
124 &CGuiApplication::onStyleSheetsChanged, Qt::QueuedConnection);
126 Qt::QueuedConnection);
134 CApplication::registerMetadata();
140 m_cmdWindowMode = QCommandLineOption(
141 {
"w",
"window" }, QCoreApplication::translate(
"main",
"Windows: (n)ormal, (f)rameless, (t)ool."),
148 m_cmdWindowSizeReset = QCommandLineOption(
149 { {
"r",
"resetsize" }, QCoreApplication::translate(
"main",
"Reset window size (ignore saved values).") });
157 m_cmdWindowScaleSize =
158 QCommandLineOption(
"scale", QCoreApplication::translate(
"main",
"Scale: number."),
"scalevalue");
164 m_cmdWindowStateMinimized = QCommandLineOption(
165 { {
"m",
"minimized" }, QCoreApplication::translate(
"main",
"Start minimized in system tray.") });
171 if (m_cmdWindowStateMinimized.valueName() ==
"empty") {
return Qt::WindowNoState; }
172 if (
m_parser.isSet(m_cmdWindowStateMinimized)) {
return Qt::WindowMinimized; }
173 return Qt::WindowNoState;
183 else {
return CEnableForFramelessWindow::WindowNormal; }
190 m_splashScreen.reset();
194 splashFont.setFamily(
"Arial");
196 splashFont.setPointSize(10);
197 splashFont.setStretch(100);
199 m_splashScreen.reset(
new CSplashScreen(pixmap.scaled(256, 256), splashFont));
200 m_splashScreen->show();
201 m_splashScreen->showStatusMessage(
"Version " + CBuildConfig::getVersionString());
207 QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
219 if (this->
getGlobalSetup().isSwiftVersionMinimumMappingVersion()) {
return true; }
222 QStringLiteral(
"Your are using swift version: '%1'.\nCreating mappings requires at least '%2'.")
223 .arg(CBuildConfig::getVersionString(), this->
getGlobalSetup().getMappingMinimumVersionString());
241 if (!mainWidget) {
return; }
242 if (m_uiSetupCompleted) {
return; }
243 m_uiSetupCompleted =
true;
246 mainWidget->setObjectName(QCoreApplication::applicationName());
247 mainWidget->setWindowIcon(m_windowIcon);
248 mainWidget->setWindowIconText(name);
259 Qt::WindowFlags windowFlags = maw->windowFlags();
260 windowFlags |= flags;
261 maw->setWindowFlags(windowFlags);
265 QPointer<CGuiApplication> myself(
this);
267 if (!myself) {
return; }
276 if (!extraInfo.isEmpty()) { name = extraInfo % u
' ' % name; }
277 if (!mainWindowWidget) {
return name; }
278 mainWindowWidget->setWindowTitle(name);
285 QApplication::setWindowIcon(icon);
295 if (sf.contains(
'/'))
298 sf = sfd < 0 ?
"1.0" : QString::number(sfd,
'f', 8);
304 QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
306 const QByteArray sfa = sf.toLatin1();
307 qputenv(
"QT_SCALE_FACTOR", sfa);
315 if (!w)
return QGuiApplication::primaryScreen();
317 const QWindow *win = w->windowHandle();
319 if (!win)
return QGuiApplication::primaryScreen();
321 QScreen *screen = win->screen();
323 return screen ? screen : QGuiApplication::primaryScreen();
329 if (s)
return s->geometry();
335 if (!QGuiApplication::modalWindow()) {
return; }
336 QGuiApplication::modalWindow()->raise();
339 const QString &CGuiApplication::fileForWindowGeometryAndStateSettings()
341 static const QString filename = [] {
343 CFileUtils::appendFilePaths(CSwiftDirectories::normalizedApplicationDataDirectory(),
"settings/qgeom");
344 return CFileUtils::appendFilePaths(
345 dir, QFileInfo(QCoreApplication::applicationFilePath()).completeBaseName() +
".ini");
350 int CGuiApplication::hashForStateSettingsSchema(
const QMainWindow *window)
353 for (
auto obj : window->findChildren<QToolBar *>(QString(), Qt::FindDirectChildrenOnly))
355 hash ^=
qHash(obj->objectName());
357 for (
auto obj : window->findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly))
359 hash ^=
qHash(obj->objectName());
361 return static_cast<int>((hash & 0xffff) ^ (hash >> 16));
366 if (!window) {
return false; }
367 QSettings settings(fileForWindowGeometryAndStateSettings(), QSettings::IniFormat);
368 settings.setValue(
"geometry", window->saveGeometry());
369 settings.setValue(
"windowState", window->saveState(hashForStateSettingsSchema(window)));
376 QSettings settings(fileForWindowGeometryAndStateSettings(), QSettings::IniFormat);
377 settings.setValue(
"geometry", ba);
378 settings.setValue(
"windowState", ba);
383 if (!window) {
return false; }
384 const QSettings settings(fileForWindowGeometryAndStateSettings(), QSettings::IniFormat);
385 const QString location = settings.fileName();
388 const QByteArray g = settings.value(
"geometry").toByteArray();
389 const QByteArray s = settings.value(
"windowState").toByteArray();
390 if (g.isEmpty() || s.isEmpty()) {
return false; }
395 const QString parameter = m_cmdWindowSizeReset.names().first();
400 QStringLiteral(
"Restoring the window state/geometry failed!\n"
401 "You need to reset the window size (command -%1).\n\n"
402 "Original msg: %2\n\n"
403 "We can try to reset the values and restart\n"
404 "Do you want to try?")
406 QMessageBox::Yes | QMessageBox::No);
407 if (ret == QMessageBox::Yes)
416 window->restoreGeometry(g);
417 window->restoreState(s, hashForStateSettingsSchema(window));
424 CApplication::onStartUpCompleted();
425 this->setCurrentFontValues();
431 if (m_minWidthChars > 0 || m_minHeightChars > 0)
438 QSize cs = mw->size();
439 if (m_minWidthChars > 0) { cs.setWidth(qRound(fontMetricEstSize.width())); }
440 if (m_minHeightChars > 0) { cs.setHeight(qRound(fontMetricEstSize.height())); }
444 if (m_saveMainWidgetState && !this->
isSet(m_cmdWindowSizeReset))
446 const Qt::KeyboardModifiers km = QGuiApplication::queryKeyboardModifiers();
447 const bool shiftAlt = km.testFlag(Qt::ShiftModifier) && km.testFlag(Qt::AltModifier);
453 m_splashScreen->close();
454 m_splashScreen.reset();
460 for (
int i = 1; i < argc; ++i)
462 if (qstrcmp(argv[i],
"--scale") == 0 || qstrcmp(argv[i],
"-scale") == 0)
464 if (i + 1 >= argc) {
return -1.0; }
465 const QString factor(argv[i + 1]);
467 const double f = factor.toDouble(&ok);
468 return ok ? f : -1.0;
476 for (
int i = 1; i < argc; ++i)
478 if (qstrcmp(argv[i],
"--scale") == 0 || qstrcmp(argv[i],
"-scale") == 0)
480 if (i + 1 >= argc) {
return QString(); }
481 const QString factor(argv[i + 1]);
482 return factor.trimmed();
490 if (!CBuildConfig::isRunningOnWindowsNtPlatform()) {
return "1.0"; }
507 QMessageBox errorBox(QMessageBox::Critical, QGuiApplication::applicationDisplayName(),
"<b>" + text +
"</b>");
508 if (informativeText.length() < 300)
509 errorBox.setInformativeText(informativeText);
511 errorBox.setDetailedText(informativeText);
513 errorBox.addButton(QMessageBox::Abort);
520 if (msgs.
isEmpty()) {
return; }
524 { CStatusMessage::IndexSeverityAsString, CStatusMessage::IndexMessage });
525 const QString msgsHtml = msgs.
toHtml(msgs.
size() > 1 ? propertiesMulti : propertiesSingle);
526 QMessageBox::critical(
nullptr, QGuiApplication::applicationDisplayName(),
527 "<html><head><body>" + msgsHtml +
"</body></html>", QMessageBox::Abort,
528 QMessageBox::NoButton);
537 if (!m) {
return false; }
543 if (message.
isEmpty()) {
return false; }
552 if (messages.
isEmpty()) {
return false; }
561 if (html.isEmpty()) {
return false; }
570 QMenu *sm = menu.addMenu(CIcons::appSettings16(),
"Settings");
571 sm->setIcon(CIcons::appSettings16());
572 QAction *a = sm->addAction(CIcons::disk16(),
"Settings directory");
573 bool c = connect(a, &QAction::triggered,
this, [=]() {
575 const QString path(QDir::toNativeSeparators(CSettingsCache::persistentStore()));
576 if (QDir(path).exists()) { QDesktopServices::openUrl(QUrl::fromLocalFile(path)); }
578 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
580 a = sm->addAction(
"Reset settings");
581 c = connect(a, &QAction::triggered,
this, [=] {
583 CSettingsCache::instance()->clearAllValues();
586 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
588 a = sm->addAction(
"List settings files");
589 c = connect(a, &QAction::triggered,
this, [=]() {
591 const QStringList files(CSettingsCache::instance()->enumerateStore());
594 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
596 sm = menu.addMenu(
"Cache");
597 sm->setIcon(CIcons::appSettings16());
598 a = sm->addAction(CIcons::disk16(),
"Cache directory");
599 c = connect(a, &QAction::triggered,
this, [=]() {
600 const QString path(QDir::toNativeSeparators(CDataCache::persistentStore()));
601 if (QDir(path).exists()) { QDesktopServices::openUrl(QUrl::fromLocalFile(path)); }
603 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
605 a = sm->addAction(
"Reset cache");
606 c = connect(a, &QAction::triggered,
this, [=]() {
608 const QStringList files = CApplication::clearCaches();
609 CLogMessage(
this).info(u
"Cleared caches! " % QString::number(files.size()) +
" files");
611 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
613 a = sm->addAction(
"List cache files");
614 c = connect(a, &QAction::triggered,
this, [=]() {
616 const QStringList files(CDataCache::instance()->enumerateStore());
619 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
621 a = menu.addAction(CIcons::disk16(),
"Log directory");
622 c = connect(a, &QAction::triggered,
this, [=]() {
624 this->openStandardLogDirectory();
626 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
628 a = menu.addAction(CIcons::disk16(),
"Crash dumps directory");
629 c = connect(a, &QAction::triggered,
this, [=]() {
631 this->openStandardCrashDumpDirectory();
633 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
635 a = menu.addAction(CIcons::swift24(),
"Check for updates");
636 c = connect(a, &QAction::triggered,
this, &CGuiApplication::checkNewVersionMenu);
637 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
643 QMenu *sm = menu.addMenu(
"Style sheet");
644 QAction *aReload = sm->addAction(CIcons::refresh16(),
"Reload");
645 bool c = connect(aReload, &QAction::triggered,
this, [=]() {
647 this->reloadStyleSheets();
649 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
651 QAction *aOpen = sm->addAction(CIcons::text16(),
"Open qss file");
652 c = connect(aOpen, &QAction::triggered,
this, [=]() {
654 this->openStandardWidgetStyleSheet();
656 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
664 QAction *a =
nullptr;
668 a = menu.addAction(
"E&xit");
671 a, &QAction::triggered,
this,
682 Qt::QueuedConnection);
683 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
689 QMenu *sm = menu.addMenu(
"JSON files/Templates");
690 QAction *a = sm->addAction(
"JSON bootstrap");
692 a, &QAction::triggered,
this,
698 Qt::QueuedConnection);
699 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
701 a = sm->addAction(
"JSON version update info (for info only)");
703 a, &QAction::triggered,
this,
709 Qt::QueuedConnection);
710 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
714 a = menu.addAction(
"Services log.(console)");
716 a, &QAction::triggered,
this,
721 Qt::QueuedConnection);
722 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
724 a = sm->addAction(
"JSON DB info (for info only)");
726 a, &QAction::triggered,
this,
733 Qt::QueuedConnection);
734 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
736 a = sm->addAction(
"JSON shared info (for info only)");
738 a, &QAction::triggered,
this,
745 Qt::QueuedConnection);
746 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
749 a = menu.addAction(
"Metadata (slow)");
751 a, &QAction::triggered,
this,
756 Qt::QueuedConnection);
757 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
765 const QSize iconSize = CIcons::empty16().size();
766 static QPixmap iconEmpty;
768 QPixmap icon = w->style()->standardIcon(QStyle::SP_TitleBarMaxButton).pixmap(iconSize);
769 QAction *a = menu.addAction(icon.isNull() ? iconEmpty : icon.scaled(iconSize),
"Fullscreen");
770 bool c = connect(a, &QAction::triggered,
this, [=]() {
774 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
776 icon = w->style()->standardIcon(QStyle::SP_TitleBarMinButton).pixmap(iconSize);
777 a = menu.addAction(icon.isNull() ? iconEmpty : icon.scaled(iconSize),
"Minimize");
778 c = connect(a, &QAction::triggered,
this, [=]() {
782 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
784 icon = w->style()->standardIcon(QStyle::SP_TitleBarNormalButton).pixmap(iconSize);
785 a = menu.addAction(icon.isNull() ? iconEmpty : icon.scaled(iconSize),
"Normal");
786 c = connect(a, &QAction::triggered,
this, [=]() {
790 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
792 a = menu.addAction(
"Toggle stay on top");
793 c = connect(a, &QAction::triggered,
this, [=]() {
797 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
799 a = menu.addAction(
"Toggle to front or back");
801 Q_ASSERT_X(c, Q_FUNC_INFO,
"connect failed");
803 a = menu.addAction(
"Window to front");
805 Q_ASSERT_X(c, Q_FUNC_INFO,
"connect failed");
807 a = menu.addAction(
"Window to back");
809 Q_ASSERT_X(c, Q_FUNC_INFO,
"connect failed");
811 a = menu.addAction(
"Toggle normal or minimized");
812 c = connect(a, &QAction::triggered,
this, [=]() {
816 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
822 if (url.
isEmpty() || this->isShuttingDown()) {
return; }
823 QDesktopServices::openUrl(url);
830 QAction *a = menu.addAction(w->style()->standardIcon(QStyle::SP_TitleBarContextHelpButton),
"Online help");
832 bool c = connect(a, &QAction::triggered,
this, [=]() {
836 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
838 a = menu.addAction(QApplication::windowIcon(),
"About swift");
839 c = connect(a, &QAction::triggered,
this, [=]() {
844 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
848 a = menu.addAction(QApplication::style()->standardIcon(QStyle::SP_TitleBarMenuButton),
"About Qt");
849 c = connect(a, &QAction::triggered,
this, []() { QApplication::aboutQt(); });
850 Q_ASSERT_X(c, Q_FUNC_INFO,
"Connect failed");
864 QDesktopServices::openUrl(helpPage);
870 if (!qObject || qObject->objectName().isEmpty()) { this->
showHelp(); }
871 else { this->
showHelp(qObject->objectName()); }
876 if (!widget) {
return false; }
877 if (!event) {
return false; }
878 const QEvent::Type t =
event->type();
879 if (t != QEvent::EnterWhatsThisMode) {
return false; }
880 QWhatsThis::leaveWhatsThisMode();
882 if (!widget->isVisible()) {
return true; }
883 const QPointer<const QWidget> wp(widget);
895 QString currentWidgetStyle(QApplication::style()->metaObject()->
className());
896 if (currentWidgetStyle.startsWith(
'Q')) { currentWidgetStyle.remove(0, 1); }
897 return currentWidgetStyle.replace(
"Style",
"");
905 return QDesktopServices::openUrl(QUrl::fromLocalFile(fn));
910 const QString path(QDir::toNativeSeparators(CSwiftDirectories::logDirectory()));
911 if (!QDir(path).exists()) {
return false; }
912 return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
917 const QString path(QDir::toNativeSeparators(CSwiftDirectories::crashpadDatabaseDirectory()));
918 if (!QDir(path).exists()) {
return false; }
919 return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
923 const QString &fontWeight,
const QString &fontColor)
925 return m_styleSheetUtility.
updateFont(fontFamily, fontSize, fontStyle, fontWeight, fontColor);
934 m_minWidthChars = widthChars;
935 m_minHeightChars = heightChars;
947 dialog.setStyleSheet(style);
958 if (!needsDialog) {
return QDialog::Accepted; }
962 if (mainWindow && !mainWindow->windowTitle().isEmpty())
964 m_closeDialog->setWindowTitle(mainWindow->windowTitle());
965 m_closeDialog->setModal(
true);
970 const auto c =
static_cast<QDialog::DialogCode
>(m_closeDialog->exec());
975 case QDialog::Rejected:
976 if (closeEvent) { closeEvent->ignore(); }
999 const int result = m_updateDialog->
exec();
1000 if (result != QDialog::Accepted) {
return; }
1006 if (!w) {
return QStringLiteral(
"Font info not available"); }
1007 return QStringLiteral(
"Family: '%1', average width: %2")
1008 .arg(w->font().family())
1009 .arg(w->fontMetrics().averageCharWidth());
1015 if (!w) {
return false; }
1017 CLogMessage(w).
info(onTop ? QStringLiteral(
"Window on top") : QStringLiteral(
"Window not always on top"));
1019 m_frontBack = onTop;
1034 w->activateWindow();
1043 m_frontBack =
false;
1057 if (w->isMinimized())
1062 if (w->isMaximized())
1082 if (m_normalizeMinimize) { w->showMinimized(); }
1089 m_normalizeMinimize = !m_normalizeMinimize;
1094 if (!m_updateSetting.get()) {
return; }
1097 if (m_updateDialog) {
return; }
1107 CLogMessage(
this).
info(u
"Graceful shutdown of GUI application started");
1108 if (m_saveMainWidgetState)
1115 CApplication::gracefulShutdown();
1119 if (modals.count() > 0)
1122 CLogMessage(
this).
info(u
"Graceful shutdown, still %1 modal widget(s), closed: %2")
1123 << modals.count() << modals.join(
", ");
1128 const QStringList docks =
1130 if (docks.count() > 0)
1133 CLogMessage(
this).
warning(u
"Graceful shutdown, still %1 floating dock widget(s), closed: %2")
1134 << docks.count() << docks.join(
", ");
1138 void CGuiApplication::settingsChanged()
1141 const QString widgetStyle = m_guiSettings.get().getWidgetStyle();
1143 Q_ASSERT_X(CThreadUtils::thisIsMainThread(), Q_FUNC_INFO,
"Wrong thread");
1144 if (!
stringCompare(widgetStyle, currentWidgetStyle, Qt::CaseInsensitive))
1146 const QStringList availableStyles = QStyleFactory::keys();
1147 if (availableStyles.contains(widgetStyle))
1157 QStyle *style = QStyleFactory::create(widgetStyle);
1159 QApplication::setStyle(style);
1163 << style->objectName() << widgetStyle;
1165 else {
CLogMessage(
this).
error(u
"Unable to set requested style '%1'") << widgetStyle; }
1171 void CGuiApplication::checkNewVersionMenu() { this->
checkNewVersion(
false); }
1173 void CGuiApplication::adjustPalette()
1178 QPalette newPalette(qApp->palette());
1179 const QColor linkColor(135, 206, 250);
1180 newPalette.setColor(QPalette::Link, linkColor);
1181 newPalette.setColor(QPalette::LinkVisited, linkColor);
1182 qApp->setPalette(newPalette);
1185 void CGuiApplication::onStyleSheetsChanged()
1188 if (f.pointSize() != m_fontPointSize || f.family() != m_fontFamily)
1196 void CGuiApplication::setCurrentFontValues()
1199 m_fontFamily = font.family();
1200 m_fontPointSize = font.pointSize();
static constexpr bool isRunningOnWindowsNtPlatform()
Running on Windows NT platform?
QString getParserValue(const QString &option) const
Delegates to QCommandLineParser::value.
std::atomic_bool m_shutdown
Is being shutdown?
void restartApplication(const QStringList &newArguments={}, const QStringList &removeArguments={})
Stop and restart application.
bool isParserOptionSet(const QString &option) const
Delegates to QCommandLineParser::isSet.
data::CGlobalSetup getGlobalSetup() const
Global setup.
QCommandLineParser m_parser
cmd parser
bool hasUnsavedSettings() const
Unsaved settings.
bool hasWebDataServices() const
Web data services available?
const context::IContextNetwork * getIContextNetwork() const
Direct access to contexts if a CCoreFacade has been initialized.
bool addParserOption(const QCommandLineOption &option)
bool isShuttingDown() const
Is application shutting down?
bool isSet(const QCommandLineOption &option) const
Flag set or explicitly set to true.
std::atomic_bool m_shutdownInProgress
shutdown in progress?
const QString & getApplicationNameVersionDetailed() const
Version, name beta and dev info.
CWebDataServices * getWebDataServices() const
Get the web data services.
const QString & getApplicationNameAndVersion() const
Application name and version.
void saveSettingsOnShutdown(bool saveSettings)
Save settings on shutdown.
void startUpCompleted(bool success)
Startup has been completed Will be triggered shortly before starting the event loop.
swift::core::db::CInfoDataReader * getDbInfoDataReader() const
DB info data reader.
swift::core::db::CInfoDataReader * getSharedInfoDataReader() const
Shared info data reader.
Global settings for readers, debug flags, etc.
swift::misc::network::CUrl getHelpPageUrl(const QString &context={}) const
Help page URL.
swift::misc::db::CDbInfoList getInfoObjects() const
Get info list (either shared or from DB)
static WindowMode stringToWindowMode(const QString &s)
String to window mode.
GUI application, a specialized version of swift::core::CApplication for GUI applications.
bool openStandardWidgetStyleSheet()
Opens the standard stylesheet.
static void modalWindowToFront()
Bring any modal dialog to front.
bool isCmdWindowSizeResetSet() const
Window size reset mode set.
QString setExtraWindowTitle(const QString &extraInfo, QWidget *mainWindowWidget=mainApplicationWidget()) const
Set window title.
QString getFontInfo() const
Info about font.
static swift::gui::IMainWindowAccess * mainWindowAccess()
Main window access interface.
void onCoreFacadeStarted()
Called when facade/contexts have been started.
void registerMainApplicationWidget(QWidget *mainWidget)
Register main application window widget if this is known.
void addWindowResetSizeOption()
CMD line arguments (reset size store)
void addWindowStateOption()
CMD line arguments.
void processEventsToRefreshGui() const
Allow the GUI to refresh by processing events, call the event loop.
Qt::WindowState getWindowState() const
Window state.
static QString scaleFactor(int argc, char *argv[])
Get the scale factor.
bool hasMinimumMappingVersion() const
Minimum mapping version check.
void addWindowModeOption()
CMD line arguments.
static QRect currentScreenGeometry()
Current screen resolution.
void triggerNewVersionCheck(int delayedMs)
Trigger new version check.
bool openStandardCrashDumpDirectory()
Opens the standard dumps directory.
static CGuiApplication * instance()
Similar to.
void windowToFront()
Window to front/back.
CEnableForFramelessWindow::WindowMode getWindowMode() const
Window mode (window flags)
void addMenuHelp(QMenu &menu)
Help operations.
void addMenuForStyleSheets(QMenu &menu)
Add menu for style sheets.
~CGuiApplication()
Destructor.
bool reloadStyleSheets()
Reload style sheets.
void cmdLineErrorMessage(const QString &text, const QString &informativeText) const
print messages generated during parsing / cmd handling
static void exit(int retcode=0)
Exit application, perform graceful shutdown and exit.
void addMenuFile(QMenu &menu)
File menu.
void addMenuInternals(QMenu &menu)
Internals menu.
bool displayInOverlayWindow(const swift::misc::CStatusMessage &message, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
direct access to main application window
void checkNewVersion(bool onlyIfNew)
Check for a new version (update)
void splashScreen(const QPixmap &pixmap)
Add a splash screen based on resource, empty means remove splash screen.
void addWindowScaleSizeOption()
CMD line arguments (scale size on DPI screens)
bool restoreWindowGeometryAndState(QMainWindow *window=CGuiApplication::mainApplicationWindow())
Restore widget's geometry and state.
void fontChanged()
Font has been changed.
const CStyleSheetUtility & getStyleSheetUtility() const
Style sheet handling.
bool saveWindowGeometryAndState(const QMainWindow *window=CGuiApplication::mainApplicationWindow()) const
Save widget's geometry and state.
QDialog::DialogCode showCloseDialog(QMainWindow *mainWindow, QCloseEvent *closeEvent)
Show close dialog.
void windowToBack()
Window to front/back.
void gracefulShutdown()
Graceful shutdown.
void onStartUpCompleted()
Startup completed.
bool toggleStayOnTop()
Toggle stay on top.
void windowToFrontBackToggle()
Window to front/back.
static bool triggerShowHelp(const QWidget *widget, QEvent *event)
Static version used with dialogs.
static void registerMetadata()
Register metadata.
static void setWindowIcon(const QPixmap &icon)
Set icon.
bool resetFont()
Reset the font to default.
void displaySetupLoadFailure(swift::misc::CStatusMessageList msgs)
Display the failures caused by loading the setup file.
void windowMinimizeNormalToggle()
Window minimize/normalize.
void addMenuForSettingsAndCache(QMenu &menu)
Add menu items for settings and cache.
bool updateFont(const QString &fontFamily, const QString &fontSize, const QString &fontStyle, const QString &fontWeight, const QString &fontColor)
Update the fonts.
bool displayInStatusBar(const swift::misc::CStatusMessage &message)
direct access to main application window
void alwaysOnTop(bool onTop)
always on top
static double parseScaleFactor(int argc, char *argv[])
Parse scale factor if any.
static QWidget * mainApplicationWidget()
Main application window widget.
static QMainWindow * mainApplicationWindow()
Main application window.
bool parsingHookIn()
Handle parsing of special GUI cmd arguments.
void uiObjectTreeReady()
Object tree ready (means ui->setupUi() completed)
void openUrl(const swift::misc::network::CUrl &url)
Open a given URL.
bool openStandardLogDirectory()
Opens the standard log directory.
static bool isUsingHighDpiScreenSupport()
Uses the high DPI support?
void addMenuWindow(QMenu &menu)
Window operations.
void initMainApplicationWidget(QWidget *mainWidget)
Init the main application window based on information in this application.
static QScreen * currentScreen()
Current screen.
void showHelp(const QString &context={}) const
Show help page (online help)
void addWindowFlags(Qt::WindowFlags flags)
Set window flag on main application window.
QString getWidgetStyle() const
Current widget style.
void styleSheetsChanged()
Style sheet changed.
static QString defaultScaleFactorString()
Get a default scale factor.
static void highDpiScreenSupport(const QString &scaleFactor={})
Support for high DPI screens.
void setMinimumSizeInCharacters(int widthChars, int heightChars)
Set minimum width/height in characters.
void resetWindowGeometryAndState()
Reset the saved values.
static bool stayOnTop(bool onTop, QWidget *widget)
Window flags / stay on top.
static QStringList deleteLaterAllDockWidgetsGetTitles(QWidget *parent, bool floatingOnly)
"deleteLater" all dock widgets
static bool staysOnTop(QWidget *widget)
Window on top?
static void registerMainApplicationWidget(QWidget *mainWidget)
Register main application window widget if this is known.
static QSizeF fontMetricsEstimateSize(int xCharacters, int yCharacters, bool withRatio=false)
Estimate size based on current font.
static void superviseMainWindowMinSizes(qreal wRatio=0.85, qreal hRatio=0.85)
Make sure that the min.sizes to not exceed the screen resolution.
static QString metricsInfo()
Some info about font metrics.
static bool isUsingHighDpiScreenSupport()
Using high DPI screen support.
static QWidget * mainApplicationWidget()
Main application window widget.
static QStringList closeAllModalWidgetsGetTitles()
Close all modal widgets and get titles.
static QFont currentFont()
Main window font or default font.
static bool toggleStayOnTop(QWidget *widget)
Toggle window flags / stay on top.
Reads and provides style sheets.
static const QString & fileNameStandardWidget()
File name for standard widgets.
bool updateFont(const QFont &font)
Update the fonts.
static void setQSysInfoProperties(QWidget *widget, bool withChildWidgets)
Set QSysInfo properties for given widget (which can be used in stylesheet)
bool read()
Read the *.qss files.
static const QString & fileNameAndPathStandardWidget()
Full file path and name for standard widgets.
void styleSheetsChanged()
Sheets have been changed.
QString styles(const QStringList &fileNames) const
Multiple styles concatenated.
bool resetFont()
Reset font.
static const QString & fileNameFonts()
File name fonts.qss.
Direct acccess to main window`s status bar, info bar and such.
virtual bool displayInOverlayWindow(const swift::misc::CStatusMessage &message, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Display in overlay window.
virtual bool displayInStatusBar(const swift::misc::CStatusMessage &message)
Display in status bar.
Close dialog for application.
Setup dialog, if loading the boostrap file fails.
Download and install swift.
bool isNewVersionAvailable() const
A new version existing?
Application
Enumeration of application roles.
QString toJsonString(QJsonDocument::JsonFormat format=QJsonDocument::Indented) const
Convenience function JSON as string.
Class for emitting a log message.
Value class for matching log messages based on their categories.
CLogPattern withSeverity(CStatusMessage::StatusSeverity severity) const
Returns a CLogPattern which will match the same messages as this one, but only with a given severity.
A helper class for subscribing to log messages matching a particular pattern, with the ability to cha...
void changeSubscription(const CLogPattern &pattern)
Change the pattern which you want to subscribe to.
Derived & warning(const char16_t(&format)[N])
Set the severity to warning, providing a format string.
bool isEmpty() const
Message empty.
Derived & validationError(const char16_t(&format)[N])
Set the severity to error, providing a format string, and adding the validation category.
Derived & error(const char16_t(&format)[N])
Set the severity to error, providing a format string.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
Value object encapsulating a list of property indexes.
size_type size() const
Returns number of elements in the sequence.
bool isEmpty() const
Synonym for empty.
Streamable status message, e.g.
QString getMessage() const
Message.
Status messages, e.g. from Core -> GUI.
QString toHtml(const CPropertyIndexList &indexes=simpleHtmlOutput()) const
Specialized version to convert to HTML.
bool hasErrorMessages() const
Error messages.
Value object encapsulating a list of info objects.
Update info, i.e. artifacts and distributions.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
bool isEmpty() const
Empty.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Core data traits (aka cached values) and classes.
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
void registerMetadata()
Register metadata for GUI.
Free functions in swift::misc.
QString getAllUserMetatypesTypes(const QString &separator)
Get all user metatypes.
SWIFT_MISC_EXPORT QString cleanNumber(const QString &number)
Remove leading 0, trailing 0, " ", and "." from a number.
QMetaObject::Connection connectOnce(T *sender, F signal, U *receiver, G &&slot, Qt::ConnectionType type=Qt::AutoConnection)
Wrapper around QObject::connect which disconnects after the signal has been emitted once.
SWIFT_MISC_EXPORT double parseFraction(const QString &fraction, double failDefault=std::numeric_limits< double >::quiet_NaN())
Parse a fraction like 2/3.
SWIFT_MISC_EXPORT bool stringCompare(const QString &c1, const QString &c2, Qt::CaseSensitivity cs)
String compare.
QString className(const QObject *object)
Class name as from QMetaObject::className with namespace.
QString applicationName()
Get application name.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...
#define SWIFT_VERIFY_X(COND, WHERE, WHAT)
A weaker kind of assert.