diff options
author | Janek Bevendorff <janek@jbev.net> | 2020-05-15 21:17:40 +0300 |
---|---|---|
committer | Janek Bevendorff <janek@jbev.net> | 2020-05-19 00:57:24 +0300 |
commit | 3dc8b7a5d0ed8ea2cad2ef09f6802a755e22ac88 (patch) | |
tree | ee25a7099cb239a3b64096165dc34cd60a57566a /src | |
parent | e367c6df9584e6a45c9e462fdfa31603a2e21cde (diff) |
Add button to hide pre-release warning for this release.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/Config.cpp | 3 | ||||
-rw-r--r-- | src/core/Config.h | 1 | ||||
-rw-r--r-- | src/gui/MainWindow.cpp | 46 | ||||
-rw-r--r-- | src/gui/MainWindow.ui | 29 |
4 files changed, 40 insertions, 39 deletions
diff --git a/src/core/Config.cpp b/src/core/Config.cpp index b027fa2d5..154453765 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -202,7 +202,8 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = { // Messages {Config::Messages_NoLegacyKeyFileWarning, {QS("Messages/NoLegacyKeyFileWarning"), Roaming, false}}, - {Config::Messages_Qt55CompatibilityWarning, {QS("Messages/Messages_Qt55CompatibilityWarning"), Local, false}}}; + {Config::Messages_Qt55CompatibilityWarning, {QS("Messages/Qt55CompatibilityWarning"), Local, false}}, + {Config::Messages_HidePreReleaseWarning, {QS("Messages/HidePreReleaseWarning"), Local, {}}}}; // clang-format on diff --git a/src/core/Config.h b/src/core/Config.h index 1beff9a92..c221a1d42 100644 --- a/src/core/Config.h +++ b/src/core/Config.h @@ -179,6 +179,7 @@ public: Messages_NoLegacyKeyFileWarning, Messages_Qt55CompatibilityWarning, + Messages_HidePreReleaseWarning, // Special internal value Deleted diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 476a675fa..d232a91ac 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -185,12 +185,8 @@ MainWindow::MainWindow() #endif setWindowIcon(resources()->applicationIcon()); - m_ui->globalMessageWidget->setHidden(true); - // clang-format off + m_ui->globalMessageWidget->hideMessage(); connect(m_ui->globalMessageWidget, &MessageWidget::linkActivated, &MessageWidget::openHttpUrl); - connect(m_ui->globalMessageWidget, SIGNAL(showAnimationStarted()), m_ui->globalMessageWidgetContainer, SLOT(show())); - connect(m_ui->globalMessageWidget, SIGNAL(hideAnimationFinished()), m_ui->globalMessageWidgetContainer, SLOT(hide())); - // clang-format on m_clearHistoryAction = new QAction(tr("Clear history"), m_ui->menuFile); m_lastDatabasesActions = new QActionGroup(m_ui->menuRecentDatabases); @@ -508,19 +504,37 @@ MainWindow::MainWindow() MessageWidget::Error); } +#if defined(KEEPASSXC_BUILD_TYPE_SNAPSHOT) || defined(KEEPASSXC_BUILD_TYPE_PRE_RELEASE) + auto* hidePreRelWarn = new QAction(tr("Don't show again for this version"), m_ui->globalMessageWidget); + m_ui->globalMessageWidget->addAction(hidePreRelWarn); + auto hidePreRelWarnConn = QSharedPointer<QMetaObject::Connection>::create(); + *hidePreRelWarnConn = connect(m_ui->globalMessageWidget, &KMessageWidget::hideAnimationFinished, [=] { + m_ui->globalMessageWidget->removeAction(hidePreRelWarn); + disconnect(*hidePreRelWarnConn); + hidePreRelWarn->deleteLater(); + }); + connect(hidePreRelWarn, &QAction::triggered, [=] { + m_ui->globalMessageWidget->animatedHide(); + config()->set(Config::Messages_HidePreReleaseWarning, KEEPASSXC_VERSION); + }); +#endif #if defined(KEEPASSXC_BUILD_TYPE_SNAPSHOT) - m_ui->globalMessageWidget->showMessage( - tr("WARNING: You are using an unstable build of KeePassXC!\n" - "There is a high risk of corruption, maintain a backup of your databases.\n" - "This version is not meant for production use."), - MessageWidget::Warning, - -1); + if (config()->get(Config::Messages_HidePreReleaseWarning) != KEEPASSXC_VERSION) { + m_ui->globalMessageWidget->showMessage( + tr("WARNING: You are using an unstable build of KeePassXC!\n" + "There is a high risk of corruption, maintain a backup of your databases.\n" + "This version is not meant for production use."), + MessageWidget::Warning, + -1); + } #elif defined(KEEPASSXC_BUILD_TYPE_PRE_RELEASE) - m_ui->globalMessageWidget->showMessage( - tr("NOTE: You are using a pre-release version of KeePassXC!\n" - "Expect some bugs and minor issues, this version is not meant for production use."), - MessageWidget::Information, - 15000); + if (config()->get(Config::Messages_HidePreReleaseWarning) != KEEPASSXC_VERSION) { + m_ui->globalMessageWidget->showMessage( + tr("NOTE: You are using a pre-release version of KeePassXC!\n" + "Expect some bugs and minor issues, this version is not meant for production use."), + MessageWidget::Information, + -1); + } #elif (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) && QT_VERSION < QT_VERSION_CHECK(5, 6, 0)) if (!config()->get(Config::Messages_Qt55CompatibilityWarning).toBool()) { m_ui->globalMessageWidget->showMessage( diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index bc8aa48de..aa4dd7dd1 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -37,28 +37,13 @@ <number>0</number> </property> <item> - <widget class="QWidget" name="globalMessageWidgetContainer" native="true"> - <layout class="QVBoxLayout" name="globalMessageWidgetLayout"> - <property name="spacing"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="MessageWidget" name="globalMessageWidget" native="true"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="styleSheet"> - <string notr="true">MessageWidget {margin: 90px}</string> - </property> - </widget> - </item> - </layout> + <widget class="MessageWidget" name="globalMessageWidget" native="true"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> </widget> </item> <item> |