diff --git a/src/browser/BrowserOptionDialog.cpp b/src/browser/BrowserOptionDialog.cpp index d93fa647b..c97ccdfd5 100755 --- a/src/browser/BrowserOptionDialog.cpp +++ b/src/browser/BrowserOptionDialog.cpp @@ -33,7 +33,7 @@ BrowserOptionDialog::BrowserOptionDialog(QWidget* parent) : connect(m_ui->removeSharedEncryptionKeys, SIGNAL(clicked()), this, SIGNAL(removeSharedEncryptionKeys())); connect(m_ui->removeStoredPermissions, SIGNAL(clicked()), this, SIGNAL(removeStoredPermissions())); - m_ui->warningWidget->showMessage(tr("The following options can be dangerous!\nChange them only if you know what you are doing."), MessageWidget::Warning); + m_ui->warningWidget->showMessage(tr("Warning: The following options can be dangerous!"), MessageWidget::Warning); m_ui->warningWidget->setCloseButtonVisible(false); m_ui->warningWidget->setAutoHideTimeout(-1); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index ee7b20021..915676e3c 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(QT_NO_DBUS) #include @@ -78,7 +77,7 @@ public: QString name() override { - return QObject::tr("Browser Integration (old)"); + return QObject::tr("Legacy Browser Integration"); } QIcon icon() override @@ -196,7 +195,7 @@ MainWindow::MainWindow() setWindowIcon(filePath()->applicationIcon()); m_ui->globalMessageWidget->setHidden(true); - connect(m_ui->globalMessageWidget, SIGNAL(linkActivated(const QString&)), this, SLOT(openLink(const QString&))); + 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())); @@ -412,7 +411,7 @@ MainWindow::MainWindow() tr("Access error for config file %1").arg(config()->getFileName()), MessageWidget::Error); } #ifdef WITH_XC_HTTP - if (config()->get("Http/Enabled", false).toBool() && !config()->get("Http/DeprecationNoticeShown", false).toBool()) { + if (config()->get("Http/Enabled", false).toBool() && config()->get("Http/DeprecationNoticeShown", 0).toInt() < 3) { // show message after tab widget dismissed all messages connect(m_ui->tabWidget, SIGNAL(messageDismissGlobal()), this, SLOT(showKeePassHTTPDeprecationNotice())); } @@ -425,30 +424,18 @@ MainWindow::~MainWindow() void MainWindow::showKeePassHTTPDeprecationNotice() { + int warningNum = config()->get("Http/DeprecationNoticeShown", 0).toInt(); displayGlobalMessage(tr("

It looks like you are using KeePassHTTP for browser integration. " "This feature has been deprecated and will be removed in the future.
" - "Please switch to keepassxc-browser instead! For help with migration, " + "Please switch to KeePassXC-Browser instead! For help with migration, " "visit our " - "keepassxc-browser migration guide.

"), + "migration guide (warning %1 of 3).

").arg(warningNum + 1), MessageWidget::Warning, true, -1); -// config()->set("Http/DeprecationNoticeShown", true); + config()->set("Http/DeprecationNoticeShown", warningNum + 1); disconnect(m_ui->tabWidget, SIGNAL(messageDismissGlobal()), this, SLOT(showKeePassHTTPDeprecationNotice())); } -/** - * Open a link using the system's default handler. - * Links that are not HTTP(s) links are ignored. - * - * @param link link URL - */ -void MainWindow::openLink(const QString& link) -{ - if (link.startsWith("http://") || link.startsWith("https://")) { - QDesktopServices::openUrl(QUrl(link)); - } -} - void MainWindow::appExit() { m_appExitCalled = true; diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index cfec5e3f5..f3b288003 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -98,7 +98,6 @@ private slots: void hideTabMessage(); void handleScreenLock(); void showKeePassHTTPDeprecationNotice(); - void openLink(const QString& link); private: static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0); diff --git a/src/gui/MessageWidget.cpp b/src/gui/MessageWidget.cpp index 4f722ed6b..f40e5aad0 100644 --- a/src/gui/MessageWidget.cpp +++ b/src/gui/MessageWidget.cpp @@ -18,7 +18,9 @@ #include "MessageWidget.h" -#include "QTimer" +#include +#include +#include const int MessageWidget::DefaultAutoHideTimeout = 6000; const int MessageWidget::DisableAutoHide = -1; @@ -69,3 +71,16 @@ void MessageWidget::setAutoHideTimeout(int autoHideTimeout) m_autoHideTimer->stop(); } } + +/** + * Open a link using the system's default handler. + * Links that are not HTTP(S) links are ignored. + * + * @param link link URL + */ +void MessageWidget::openHttpUrl(const QString& link) +{ + if (link.startsWith("http://") || link.startsWith("https://")) { + QDesktopServices::openUrl(QUrl(link)); + } +} \ No newline at end of file diff --git a/src/gui/MessageWidget.h b/src/gui/MessageWidget.h index 0eb7a20fa..73f0b2108 100644 --- a/src/gui/MessageWidget.h +++ b/src/gui/MessageWidget.h @@ -43,6 +43,7 @@ public slots: void showMessage(const QString& text, MessageWidget::MessageType type, int autoHideTimeout); void hideMessage(); void setAutoHideTimeout(int autoHideTimeout); + static void openHttpUrl(QString const& url); private: QTimer* m_autoHideTimer; diff --git a/src/http/OptionDialog.cpp b/src/http/OptionDialog.cpp index 46eda10b3..dd5a51f73 100644 --- a/src/http/OptionDialog.cpp +++ b/src/http/OptionDialog.cpp @@ -32,14 +32,20 @@ OptionDialog::OptionDialog(QWidget *parent) : connect(m_ui->removeSharedEncryptionKeys, SIGNAL(clicked()), this, SIGNAL(removeSharedEncryptionKeys())); connect(m_ui->removeStoredPermissions, SIGNAL(clicked()), this, SIGNAL(removeStoredPermissions())); - m_ui->warningWidget->showMessage(tr("The following options can be dangerous!\nChange them only if you know what you are doing."), MessageWidget::Warning); + m_ui->warningWidget->showMessage(tr("Warning: The following options can be dangerous!"), MessageWidget::Warning); m_ui->warningWidget->setCloseButtonVisible(false); m_ui->warningWidget->setAutoHideTimeout(MessageWidget::DisableAutoHide); m_ui->tabWidget->setEnabled(m_ui->enableHttpServer->isChecked()); connect(m_ui->enableHttpServer, SIGNAL(toggled(bool)), m_ui->tabWidget, SLOT(setEnabled(bool))); - m_ui->deprecationNotice->setOpenExternalLinks(true); + m_ui->deprecationNotice->showMessage(tr("

KeePassHTTP has been deprecated and will be removed in the future.
" + "Please switch to KeePassXC-Browser instead! For help with migration, visit " + "our " + "migration guide.

"), MessageWidget::Warning); + m_ui->deprecationNotice->setCloseButtonVisible(false); + m_ui->deprecationNotice->setAutoHideTimeout(-1); + connect(m_ui->deprecationNotice, &MessageWidget::linkActivated, &MessageWidget::openHttpUrl); } OptionDialog::~OptionDialog() diff --git a/src/http/OptionDialog.ui b/src/http/OptionDialog.ui index 39b0ce403..54f7bd70c 100644 --- a/src/http/OptionDialog.ui +++ b/src/http/OptionDialog.ui @@ -26,13 +26,6 @@ 0 - - - - <p><b>NOTE:</b> KeePassHTTP has been deprecated and will be removed in the future.<br>Please switch to keepassxc-browser instead! For help with migration, visit our <a href="https://keepassxc.org/docs/keepassxc-browser-migration">keepassxc-browser migration guide</a>.</p> - - - @@ -43,6 +36,9 @@ + + +