diff options
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/mainwindow.cpp')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/mainwindow.cpp | 79 |
1 files changed, 51 insertions, 28 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/mainwindow.cpp b/SQLiteStudio3/guiSQLiteStudio/mainwindow.cpp index 2b6463a..57c7d35 100644 --- a/SQLiteStudio3/guiSQLiteStudio/mainwindow.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/mainwindow.cpp @@ -38,7 +38,9 @@ #include "common/widgetcover.h" #include "dialogs/cssdebugdialog.h" #include "themetuner.h" +#include "style.h" #include "services/codeformatter.h" +#include "common/compatibility.h" #include <QMdiSubWindow> #include <QDebug> #include <QStyleFactory> @@ -48,6 +50,7 @@ #include <QLabel> #include <QStyle> #include <QApplication> +#include <QToolTip> CFG_KEYS_DEFINE(MainWindow) MainWindow* MainWindow::instance = nullptr; @@ -126,13 +129,15 @@ void MainWindow::init() } #ifdef PORTABLE_CONFIG - connect(UPDATES, SIGNAL(updatesAvailable(QList<UpdateManager::UpdateEntry>)), this, SLOT(updatesAvailable(QList<UpdateManager::UpdateEntry>))); + connect(UPDATES, SIGNAL(updateAvailable(QString, QString)), this, SLOT(updateAvailable(QString, QString))); connect(UPDATES, SIGNAL(noUpdatesAvailable()), this, SLOT(noUpdatesAvailable())); #endif connect(statusField, SIGNAL(linkActivated(QString)), this, SLOT(statusFieldLinkClicked(QString))); connect(CFG_CORE.General.Language, SIGNAL(changed(QVariant)), this, SLOT(notifyAboutLanguageChange())); + connect(CFG_UI.General.AllowMultipleSessions, SIGNAL(changed(QVariant)), this, SLOT(updateMultipleSessionsSetting(QVariant))); + updateMultipleSessionsSetting(); fixFonts(); } @@ -257,14 +262,15 @@ void MainWindow::createActions() createAction(OPEN_DEBUG_CONSOLE, tr("Open Debug Console"), this, SLOT(openDebugConsole()), this); createAction(OPEN_CSS_CONSOLE, tr("Open CSS Console"), this, SLOT(openCssConsole()), this); createAction(REPORT_BUG, ICONS.BUG, tr("Report a &bug"), this, SLOT(reportBug()), this); + createAction(DONATE, ICONS.DONATE, tr("D&onate"), this, SLOT(donate()), this); createAction(FEATURE_REQUEST, ICONS.FEATURE_REQUEST, tr("Propose a new &feature"), this, SLOT(requestFeature()), this); createAction(ABOUT, ICONS.SQLITESTUDIO_APP16, tr("&About"), this, SLOT(aboutSqlitestudio()), this); createAction(LICENSES, ICONS.LICENSES, tr("&Licenses"), this, SLOT(licenses()), this); createAction(HOMEPAGE, ICONS.HOMEPAGE, tr("Open home &page"), this, SLOT(homepage()), this); - createAction(FORUM, ICONS.OPEN_FORUM, tr("Open fo&rum page"), this, SLOT(forum()), this); createAction(USER_MANUAL, ICONS.USER_MANUAL, tr("User &Manual"), this, SLOT(userManual()), this); createAction(SQLITE_DOCS, ICONS.SQLITE_DOCS, tr("SQLite &documentation"), this, SLOT(sqliteDocs()), this); createAction(BUG_REPORT_HISTORY, ICONS.BUG_LIST, tr("Bugs and feature &requests"), this, SLOT(reportHistory()), this); + createAction(QUIT, ICONS.QUIT, tr("Quit"), this, SLOT(quit()), this); #ifdef PORTABLE_CONFIG createAction(CHECK_FOR_UPDATES, ICONS.GET_UPDATE, tr("Check for &updates"), this, SLOT(checkForUpdates()), this); #endif @@ -276,26 +282,10 @@ void MainWindow::createActions() ui->dbToolbar->addAction(dbTree->getAction(DbTree::DISCONNECT_FROM_DB)); ui->dbToolbar->addSeparator(); ui->dbToolbar->addAction(dbTree->getAction(DbTree::ADD_DB)); - ui->dbToolbar->addAction(dbTree->getAction(DbTree::EDIT_DB)); - ui->dbToolbar->addAction(dbTree->getAction(DbTree::DELETE_DB)); - ui->dbToolbar->addSeparator(); ui->dbToolbar->addAction(dbTree->getAction(DbTree::REFRESH_SCHEMA)); ui->structureToolbar->addAction(dbTree->getAction(DbTree::ADD_TABLE)); - ui->structureToolbar->addAction(dbTree->getAction(DbTree::EDIT_TABLE)); - ui->structureToolbar->addAction(dbTree->getAction(DbTree::DEL_TABLE)); - ui->structureToolbar->addSeparator(); - ui->structureToolbar->addAction(dbTree->getAction(DbTree::ADD_INDEX)); - ui->structureToolbar->addAction(dbTree->getAction(DbTree::EDIT_INDEX)); - ui->structureToolbar->addAction(dbTree->getAction(DbTree::DEL_INDEX)); - ui->structureToolbar->addSeparator(); - ui->structureToolbar->addAction(dbTree->getAction(DbTree::ADD_TRIGGER)); - ui->structureToolbar->addAction(dbTree->getAction(DbTree::EDIT_TRIGGER)); - ui->structureToolbar->addAction(dbTree->getAction(DbTree::DEL_TRIGGER)); - ui->structureToolbar->addSeparator(); ui->structureToolbar->addAction(dbTree->getAction(DbTree::ADD_VIEW)); - ui->structureToolbar->addAction(dbTree->getAction(DbTree::EDIT_VIEW)); - ui->structureToolbar->addAction(dbTree->getAction(DbTree::DEL_VIEW)); ui->taskBar->initContextMenu(this); } @@ -315,12 +305,15 @@ void MainWindow::initMenuBar() dbMenu->addAction(dbTree->getAction(DbTree::DELETE_DB)); dbMenu->addSeparator(); dbMenu->addAction(dbTree->getAction(DbTree::EXPORT_DB)); - dbMenu->addAction(dbTree->getAction(DbTree::CONVERT_DB)); dbMenu->addAction(dbTree->getAction(DbTree::VACUUM_DB)); dbMenu->addAction(dbTree->getAction(DbTree::INTEGRITY_CHECK)); dbMenu->addSeparator(); dbMenu->addAction(dbTree->getAction(DbTree::REFRESH_SCHEMA)); dbMenu->addAction(dbTree->getAction(DbTree::REFRESH_SCHEMAS)); +#ifndef Q_OS_MACX + dbMenu->addSeparator(); + dbMenu->addAction(actionMap[QUIT]); +#endif // Structure menu structMenu = new QMenu(this); @@ -395,7 +388,6 @@ void MainWindow::initMenuBar() sqlitestudioMenu->addAction(actionMap[USER_MANUAL]); sqlitestudioMenu->addAction(actionMap[SQLITE_DOCS]); sqlitestudioMenu->addAction(actionMap[HOMEPAGE]); - sqlitestudioMenu->addAction(actionMap[FORUM]); sqlitestudioMenu->addSeparator(); #ifdef PORTABLE_CONFIG if (UPDATES->isPlatformEligibleForUpdate()) @@ -409,6 +401,7 @@ void MainWindow::initMenuBar() sqlitestudioMenu->addAction(actionMap[BUG_REPORT_HISTORY]); sqlitestudioMenu->addSeparator(); sqlitestudioMenu->addAction(actionMap[LICENSES]); + sqlitestudioMenu->addAction(actionMap[DONATE]); sqlitestudioMenu->addAction(actionMap[ABOUT]); } @@ -450,6 +443,7 @@ void MainWindow::restoreSession() if (sessionValue.size() == 0) { THEME_TUNER->tuneCurrentTheme(); + restoreState(saveState()); // workaround for probable Qt bug (?), reported in #3421 return; } @@ -463,6 +457,8 @@ void MainWindow::restoreSession() if (sessionValue.contains("state")) restoreState(sessionValue["state"].toByteArray()); + else + restoreState(saveState()); // workaround for probable Qt bug (?), reported in #3421 if (sessionValue.contains("dbTree")) dbTree->restoreSession(sessionValue["dbTree"]); @@ -550,13 +546,14 @@ void MainWindow::setStyle(const QString& styleName) notifyWarn(tr("Could not set style: %1", "main window").arg(styleName)); return; } - QApplication::setStyle(style); - THEME_TUNER->tuneTheme(styleName); + + STYLE->setStyle(style, styleName); + statusField->refreshColors(); } QString MainWindow::currentStyle() const { - return QApplication::style()->objectName(); + return STYLE->name(); } EditorWindow* MainWindow::openSqlEditor(Db* dbToSet, const QString& sql) @@ -606,7 +603,7 @@ void MainWindow::refreshMdiWindows() nameToAction[action->text()] = action; } - qSort(actionNames); + sSort(actionNames); for (const QString& name : actionNames) mdiMenu->addAction(nameToAction[name]); @@ -744,9 +741,9 @@ void MainWindow::homepage() QDesktopServices::openUrl(QUrl(SQLITESTUDIO->getHomePage())); } -void MainWindow::forum() +void MainWindow::githubReleases() { - QDesktopServices::openUrl(QUrl(SQLITESTUDIO->getForumPage())); + QDesktopServices::openUrl(QUrl(SQLITESTUDIO->getGitHubReleases())); } void MainWindow::userManual() @@ -764,6 +761,11 @@ void MainWindow::reportHistory() QDesktopServices::openUrl(QUrl(SQLITESTUDIO->getIssuesPage())); } +void MainWindow::donate() +{ + QDesktopServices::openUrl(QUrl(SQLITESTUDIO->getDonatePage())); +} + void MainWindow::statusFieldLinkClicked(const QString& link) { #ifdef PORTABLE_CONFIG @@ -775,12 +777,29 @@ void MainWindow::statusFieldLinkClicked(const QString& link) #endif } +void MainWindow::quit() +{ + close(); +} + +void MainWindow::updateMultipleSessionsSetting(const QVariant& newValue) +{ + QSettings sett; + sett.setValue(ALLOW_MULTIPLE_SESSIONS_SETTING, newValue); +} + +void MainWindow::updateMultipleSessionsSetting() +{ + QSettings sett; + sett.setValue(ALLOW_MULTIPLE_SESSIONS_SETTING, CFG_UI.General.AllowMultipleSessions.get()); +} + #ifdef PORTABLE_CONFIG -void MainWindow::updatesAvailable(const QList<UpdateManager::UpdateEntry>& updates) +void MainWindow::updateAvailable(const QString& version, const QString& url) { manualUpdatesChecking = false; newVersionDialog = new NewVersionDialog(this); - newVersionDialog->setUpdates(updates); + newVersionDialog->setUpdate(version, url); notifyInfo(tr("New updates are available. <a href=\"%1\">Click here for details</a>.").arg(openUpdatesUrl)); } @@ -820,7 +839,11 @@ void MainWindow::messageFromSecondaryInstance(quint32 instanceId, QByteArray mes { UNUSED(instanceId); QApplication::setActiveWindow(this); + if (isMinimized()) + showMaximized(); + raise(); + activateWindow(); QString dbToOpen = deserializeFromBytes(message).toString(); if (!dbToOpen.isNull()) openDb(dbToOpen); |
