diff --git a/CMakeLists.txt b/CMakeLists.txt index e6d4270ca..3708667a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -# Copyright (C) 2010 Felix Geyer # Copyright (C) 2017 KeePassXC Team +# Copyright (C) 2010 Felix Geyer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,10 +41,17 @@ option(WITH_COVERAGE "Use to build with coverage tests (GCC only)." OFF) option(WITH_APP_BUNDLE "Enable Application Bundle for macOS" ON) option(WITH_XC_AUTOTYPE "Include Auto-Type." ON) -option(WITH_XC_HTTP "Include KeePassHTTP and Custom Icon Downloads." OFF) +option(WITH_XC_NETWORKING "Include networking code (e.g. for downlading website icons)." OFF) +option(WITH_XC_BROWSER "Include browser integration with keepassxc-browser." OFF) +option(WITH_XC_HTTP "Include KeePassHTTP-compatible browser integration (deprecated, implies WITH_NETWORKING)." OFF) option(WITH_XC_YUBIKEY "Include YubiKey support." OFF) option(WITH_XC_SSHAGENT "Include SSH agent support." OFF) -option(WITH_XC_BROWSER "Include browser extension support." OFF) + +if(WITH_XC_HTTP) + message(WARNING "KeePassHTTP support has been deprecated and will be removed in a future version. Please use WITH_XC_BROWSER instead!\n" + "For enabling / disabling network access code, WITH_XC_HTTP has been replaced by WITH_XC_NETWORKING.") + set(WITH_XC_NETWORKING ON CACHE BOOL "Include networking code (e.g. for downlading website icons)." FORCE) +endif() # Process ui files automatically from source files set(CMAKE_AUTOUIC ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6a9638959..7abbfc823 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -187,15 +187,21 @@ set(keepassx_SOURCES_MAINEXE main.cpp ) -add_feature_info(AutoType WITH_XC_AUTOTYPE "Automatic password typing") -add_feature_info(KeePassHTTP WITH_XC_HTTP "Browser integration compatible with ChromeIPass and PassIFox") -add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response") +add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing") +add_feature_info(Networking WITH_XC_NETWORKING "Compile KeePassXC with network access code (e.g. for downloading website icons)") +add_feature_info(keepassxc-browser WITH_XC_BROWSER "Browser integration with keepassxc-browser") +add_feature_info(KeePassHTTP WITH_XC_HTTP "Browser integration compatible with ChromeIPass and PassIFox (deprecated, implies Networking)") add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent") -add_feature_info(keepassxc-browser WITH_XC_BROWSER "KeePassXC browser support with keepassxc-browser") +add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response") + -add_subdirectory(http) if(WITH_XC_HTTP) - set(keepasshttp_LIB keepasshttp qhttp Qt5::Network) + add_subdirectory(http) + set(keepasshttp_LIB keepasshttp) +endif() +if(WITH_XC_NETWORKING) + add_subdirectory(http/qhttp) + set(keepassxcnetwork_LIB qhttp Qt5::Network) endif() set(BROWSER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/browser) @@ -247,8 +253,9 @@ add_library(keepassx_core STATIC ${keepassx_SOURCES}) set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE) target_link_libraries(keepassx_core - ${keepasshttp_LIB} ${keepassxcbrowser_LIB} + ${keepasshttp_LIB} + ${keepassxcnetwork_LIB} ${autotype_LIB} ${sshagent_LIB} ${YUBIKEY_LIBRARIES} diff --git a/src/browser/BrowserOptionDialog.cpp b/src/browser/BrowserOptionDialog.cpp index 9a876ac45..c97ccdfd5 100755 --- a/src/browser/BrowserOptionDialog.cpp +++ b/src/browser/BrowserOptionDialog.cpp @@ -23,6 +23,7 @@ #include "core/FilePath.h" #include +#include BrowserOptionDialog::BrowserOptionDialog(QWidget* parent) : QWidget(parent), @@ -32,15 +33,18 @@ 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->setIcon(FilePath::instance()->icon("status", "dialog-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); m_ui->tabWidget->setEnabled(m_ui->enableBrowserSupport->isChecked()); connect(m_ui->enableBrowserSupport, SIGNAL(toggled(bool)), m_ui->tabWidget, SLOT(setEnabled(bool))); m_ui->customProxyLocation->setEnabled(m_ui->useCustomProxy->isChecked()); + m_ui->customProxyLocationBrowseButton->setEnabled(m_ui->useCustomProxy->isChecked()); connect(m_ui->useCustomProxy, SIGNAL(toggled(bool)), m_ui->customProxyLocation, SLOT(setEnabled(bool))); + connect(m_ui->useCustomProxy, SIGNAL(toggled(bool)), m_ui->customProxyLocationBrowseButton, SLOT(setEnabled(bool))); + connect(m_ui->customProxyLocationBrowseButton, SIGNAL(clicked()), this, SLOT(showProxyLocationFileDialog())); } BrowserOptionDialog::~BrowserOptionDialog() @@ -57,6 +61,11 @@ void BrowserOptionDialog::loadSettings() m_ui->unlockDatabase->setChecked(settings.unlockDatabase()); m_ui->matchUrlScheme->setChecked(settings.matchUrlScheme()); + // hide unimplemented options + // TODO: fix this + m_ui->showNotification->hide(); + m_ui->bestMatchOnly->hide(); + if (settings.sortByUsername()) { m_ui->sortByUsername->setChecked(true); } else { @@ -102,3 +111,16 @@ void BrowserOptionDialog::saveSettings() settings.setFirefoxSupport(m_ui->firefoxSupport->isChecked()); settings.setVivaldiSupport(m_ui->vivaldiSupport->isChecked()); } + +void BrowserOptionDialog::showProxyLocationFileDialog() +{ +#ifdef Q_OS_WIN + QString fileTypeFilter(tr("Executable Files (*.exe);;All Files (*.*)")); +#else + QString fileTypeFilter(tr("Executable Files (*.*)")); +#endif + auto proxyLocation = QFileDialog::getOpenFileName(this, tr("Select custom proxy location"), + QFileInfo(QCoreApplication::applicationDirPath()).filePath(), + fileTypeFilter); + m_ui->customProxyLocation->setText(proxyLocation); +} diff --git a/src/browser/BrowserOptionDialog.h b/src/browser/BrowserOptionDialog.h index 798d215d6..b562f6c18 100755 --- a/src/browser/BrowserOptionDialog.h +++ b/src/browser/BrowserOptionDialog.h @@ -43,6 +43,9 @@ signals: void removeSharedEncryptionKeys(); void removeStoredPermissions(); +private slots: + void showProxyLocationFileDialog(); + private: QScopedPointer m_ui; }; diff --git a/src/browser/BrowserOptionDialog.ui b/src/browser/BrowserOptionDialog.ui index 81eaa229d..e5352b0fa 100755 --- a/src/browser/BrowserOptionDialog.ui +++ b/src/browser/BrowserOptionDialog.ui @@ -6,8 +6,8 @@ 0 0 - 577 - 404 + 456 + 385 @@ -32,7 +32,7 @@ This is required for accessing your databases with keepassxc-browser - Enable KeepassXC browser extension + Enable KeepassXC browser integration @@ -47,22 +47,93 @@ - - - Sh&ow a notification when credentials are requested - - - true + + + Enable integration for these browsers: + + + 40 + + + + + &Google Chrome + + + false + + + + + + + &Firefox + + + false + + + + + + + Qt::Horizontal + + + + 179 + 20 + + + + + + + + &Chromium + + + false + + + + + + + &Vivaldi + + + false + + + + - - - Only returns the best matches for a specific URL instead of all entries for the whole domain. + + + Qt::Vertical + + QSizePolicy::Fixed + + + + 20 + 4 + + + + + + - &Return only best-matching entries + Show a &notification when credentials are requested + + + true @@ -82,117 +153,82 @@ Only entries with the same scheme (http://, https://, ...) are returned. - &Match URL schemes + &Match URL scheme (e.g., https://...) - + + + Only returns the best matches for a specific URL instead of all entries for the whole domain. + - Sort matching entries by &username + &Return only best-matching credentials - Sort &matching entries by title + Sort &matching credentials by title - + - R&emove all shared encryption keys from active database + Sort matching credentials by &username - - - Re&move all stored permissions from entries in active database - - - - - + Qt::Vertical + + QSizePolicy::Fixed + 20 - 40 + 10 - - - - - Supported browsers - - - - - - Native messaging requires certain .json files to be installed. Already installed browsers are automatically detected. - - - true - - - - - - - Enable KeePassXC native messaging extension for these browsers: - - - - - - - Chrome - - - false - - - - - - - Chromium - - - false - - - - - - - Firefox - - - false - - - - - - - Vivaldi - - - false - - - - + + + + + + 0 + 0 + + + + &Disconnect all browsers + + + + + + + + 0 + 0 + + + + Forget all remembered &permissions + + + + + + + Qt::Vertical @@ -224,14 +260,14 @@ - Always allow &access to entries + Never &ask before accessing credentials - Always allow &updating entries + Never ask before &updating credentials @@ -241,7 +277,7 @@ Only the selected database has to be connected with a client. - Searc&h in all opened databases for matching entries + Searc&h in all opened databases for matching credentials @@ -261,7 +297,7 @@ Updates KeePassXC or keepassxc-proxy binary path automatically to native messaging scripts on startup. - &Update KeePassXC binary path automatically to native messaging scripts on startup + Update &native messaging manifest files at startup @@ -271,7 +307,7 @@ Support a proxy application between KeePassXC and browser extension. - &Enable support for proxy application between KeePassXC and browser extension + Use a &proxy application between KeePassXC and browser extension @@ -281,19 +317,30 @@ Use a custom proxy location if you installed a proxy manually. - &Use a custom proxy location + Use a &custom proxy location - - - 999 - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - + + + + + 999 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Browse... + + + + diff --git a/src/browser/BrowserSettings.h b/src/browser/BrowserSettings.h index 8d08eef71..eb59fa5ac 100755 --- a/src/browser/BrowserSettings.h +++ b/src/browser/BrowserSettings.h @@ -34,7 +34,7 @@ public: static void setShowNotification(bool showNotification); static bool bestMatchOnly(); //TODO!! static void setBestMatchOnly(bool bestMatchOnly); - static bool unlockDatabase(); //TODO!! + static bool unlockDatabase(); static void setUnlockDatabase(bool unlockDatabase); static bool matchUrlScheme(); static void setMatchUrlScheme(bool matchUrlScheme); diff --git a/src/config-keepassx.h.cmake b/src/config-keepassx.h.cmake index 5a00a5dba..e98830b09 100644 --- a/src/config-keepassx.h.cmake +++ b/src/config-keepassx.h.cmake @@ -12,11 +12,12 @@ #define KEEPASSX_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}" #define KEEPASSX_DATA_DIR "${DATA_INSTALL_DIR}" -#cmakedefine WITH_XC_HTTP #cmakedefine WITH_XC_AUTOTYPE +#cmakedefine WITH_XC_NETWORKING +#cmakedefine WITH_XC_BROWSER +#cmakedefine WITH_XC_HTTP #cmakedefine WITH_XC_YUBIKEY #cmakedefine WITH_XC_SSHAGENT -#cmakedefine WITH_XC_BROWSER #cmakedefine KEEPASSXC_DIST #cmakedefine KEEPASSXC_DIST_TYPE "@KEEPASSXC_DIST_TYPE@" diff --git a/src/gui/AboutDialog.cpp b/src/gui/AboutDialog.cpp index 44ab895e8..9ce3eda5d 100644 --- a/src/gui/AboutDialog.cpp +++ b/src/gui/AboutDialog.cpp @@ -78,20 +78,20 @@ AboutDialog::AboutDialog(QWidget* parent) #endif QString extensions; -#ifdef WITH_XC_HTTP - extensions += "\n- KeePassHTTP"; -#endif #ifdef WITH_XC_AUTOTYPE extensions += "\n- Auto-Type"; #endif -#ifdef WITH_XC_YUBIKEY - extensions += "\n- YubiKey"; +#ifdef WITH_XC_BROWSER + extensions += "\n- Browser Integration"; +#endif +#ifdef WITH_XC_HTTP + extensions += "\n- Legacy Browser Integration (KeePassHTTP)"; #endif #ifdef WITH_XC_SSHAGENT extensions += "\n- SSH Agent"; #endif -#ifdef WITH_XC_BROWSER - extensions += "\n- Native messaging browser extension"; +#ifdef WITH_XC_YUBIKEY + extensions += "\n- YubiKey"; #endif if (extensions.isEmpty()) diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp index 7c01b31f1..3ff036e35 100644 --- a/src/gui/EditWidgetIcons.cpp +++ b/src/gui/EditWidgetIcons.cpp @@ -30,7 +30,7 @@ #include "gui/IconModels.h" #include "gui/MessageBox.h" -#ifdef WITH_XC_HTTP +#ifdef WITH_XC_NETWORKING #include "http/qhttp/qhttpclient.hpp" #include "http/qhttp/qhttpclientresponse.hpp" @@ -49,11 +49,13 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent) , m_database(nullptr) , m_defaultIconModel(new DefaultIconModel(this)) , m_customIconModel(new CustomIconModel(this)) - #ifdef WITH_XC_HTTP +#ifdef WITH_XC_NETWORKING , m_fallbackToGoogle(true) , m_redirectCount(0) +#endif +#ifdef WITH_XC_HTTP , m_httpClient(nullptr) - #endif +#endif { m_ui->setupUi(this); @@ -146,7 +148,7 @@ void EditWidgetIcons::load(const Uuid& currentUuid, Database* database, const Ic void EditWidgetIcons::setUrl(const QString& url) { -#ifdef WITH_XC_HTTP +#ifdef WITH_XC_NETWORKING m_url = url; m_ui->faviconButton->setVisible(!url.isEmpty()); resetFaviconDownload(); @@ -158,14 +160,14 @@ void EditWidgetIcons::setUrl(const QString& url) void EditWidgetIcons::downloadFavicon() { -#ifdef WITH_XC_HTTP +#ifdef WITH_XC_NETWORKING QUrl url = QUrl(m_url); url.setPath("/favicon.ico"); fetchFavicon(url); #endif } -#ifdef WITH_XC_HTTP +#ifdef WITH_XC_NETWORKING void EditWidgetIcons::fetchFavicon(const QUrl& url) { if (nullptr == m_httpClient) { diff --git a/src/gui/EditWidgetIcons.h b/src/gui/EditWidgetIcons.h index 5c27ffe29..0c155f7d9 100644 --- a/src/gui/EditWidgetIcons.h +++ b/src/gui/EditWidgetIcons.h @@ -32,7 +32,7 @@ class Database; class DefaultIconModel; class CustomIconModel; -#ifdef WITH_XC_HTTP +#ifdef WITH_XC_NETWORKING namespace qhttp { namespace client { class QHttpClient; @@ -73,7 +73,7 @@ signals: private slots: void downloadFavicon(); -#ifdef WITH_XC_HTTP +#ifdef WITH_XC_NETWORKING void fetchFavicon(const QUrl& url); void fetchFaviconFromGoogle(const QString& domain); void resetFaviconDownload(bool clearRedirect = true); @@ -93,7 +93,7 @@ private: QString m_url; DefaultIconModel* const m_defaultIconModel; CustomIconModel* const m_customIconModel; -#ifdef WITH_XC_HTTP +#ifdef WITH_XC_NETWORKING QUrl m_redirectUrl; bool m_fallbackToGoogle; unsigned short m_redirectCount; diff --git a/src/gui/KMessageWidget.cpp b/src/gui/KMessageWidget.cpp index 7f4cb94f4..910f0c91b 100644 --- a/src/gui/KMessageWidget.cpp +++ b/src/gui/KMessageWidget.cpp @@ -33,6 +33,7 @@ #include #include #include +#include //--------------------------------------------------------------------- // KMessageWidgetPrivate @@ -49,6 +50,7 @@ public: QToolButton *closeButton; QTimeLine *timeLine; QIcon icon; + QPixmap closeButtonPixmap; KMessageWidget::MessageType messageType; bool wordWrap; @@ -95,10 +97,11 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr) closeAction->setIcon(FilePath::instance()->icon("actions", "message-close", false)); QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(animatedHide())); - + closeButton = new QToolButton(content); closeButton->setAutoRaise(true); closeButton->setDefaultAction(closeAction); + closeButtonPixmap = QPixmap(closeButton->icon().pixmap(closeButton->icon().actualSize(QSize(16, 16)))); #ifdef Q_OS_MAC closeButton->setStyleSheet("QToolButton { background: transparent;" "border-radius: 2px; padding: 3px; }" @@ -256,49 +259,42 @@ KMessageWidget::MessageType KMessageWidget::messageType() const return d->messageType; } -static QColor darkShade(QColor c) -{ - qreal contrast = 0.7; // taken from kcolorscheme for the dark shade - - qreal darkAmount; - if (c.lightnessF() < 0.006) { /* too dark */ - darkAmount = 0.02 + 0.40 * contrast; - } else if (c.lightnessF() > 0.93) { /* too bright */ - darkAmount = -0.06 - 0.60 * contrast; - } else { - darkAmount = (-c.lightnessF()) * (0.55 + contrast * 0.35); - } - - qreal v = c.lightnessF() + darkAmount; - v = v > 0.0 ? (v < 1.0 ? v : 1.0) : 0.0; - c.setHsvF(c.hslHueF(), c.hslSaturationF(), v); - return c; -} - void KMessageWidget::setMessageType(KMessageWidget::MessageType type) { d->messageType = type; - QColor bg0, bg1, bg2, border, fg; + QColor bg0, bg1, bg2, border; + QColor fg = palette().light().color(); switch (type) { - case Positive: - bg1.setRgb(0, 110, 40); // values taken from kcolorscheme.cpp (Positive) - break; - case Information: - bg1 = palette().highlight().color(); - break; - case Warning: - bg1.setRgb(181, 102, 0); // values taken from kcolorscheme.cpp (Neutral) - break; - case Error: - bg1.setRgb(191, 3, 3); // values taken from kcolorscheme.cpp (Negative) - break; + case Positive: + bg1.setRgb(37, 163, 83); + break; + case Information: + bg1.setRgb(24, 187, 242); + break; + case Warning: + bg1.setRgb(252, 193, 57); + fg = palette().foreground().color(); + break; + case Error: + bg1.setRgb(198, 69, 21); + break; } - + // Colors - fg = palette().light().color(); - bg0 = bg1.lighter(110); - bg2 = bg1.darker(110); - border = darkShade(bg1); + bg0 = bg1.lighter(105); + bg2 = bg1.darker(105); + border = bg1.darker(115); + + // Tint close icon + auto closeButtonPixmap = d->closeButtonPixmap; + QPixmap mask(closeButtonPixmap); + QPainter painter; + painter.begin(&closeButtonPixmap); + painter.setRenderHints(QPainter::HighQualityAntialiasing); + painter.setCompositionMode(QPainter::CompositionMode_SourceIn); + painter.fillRect(QRect(0, 0, 16, 16), fg); + painter.end(); + d->closeButton->setIcon(closeButtonPixmap); d->content->setStyleSheet( QString(QLatin1String(".QFrame {" @@ -306,10 +302,10 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type) " stop: 0 %1," " stop: 0.1 %2," " stop: 1.0 %3);" - "border-radius: 5px;" - "border: 1px solid %4;" - "margin: %5px;" - "padding: 5px;" + " border-radius: 2px;" + " border: 1px solid %4;" + " margin: %5px;" + " padding: 5px;" "}" ".QLabel { color: %6; }" )) @@ -317,8 +313,9 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type) .arg(bg1.name()) .arg(bg2.name()) .arg(border.name()) - // DefaultFrameWidth returns the size of the external margin + border width. We know our border is 1px, so we subtract this from the frame normal QStyle FrameWidth to get our margin - .arg(style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this) - 1) + // DefaultFrameWidth returns the size of the external margin + border width. We know our border is 1px, + // so we subtract this from the frame normal QStyle FrameWidth to get our margin + .arg(style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, this) - 1) .arg(fg.name()) ); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 9c0fe1dfb..915676e3c 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -77,7 +77,7 @@ public: QString name() override { - return QObject::tr("Browser Integration"); + return QObject::tr("Legacy Browser Integration"); } QIcon icon() override @@ -125,7 +125,7 @@ class BrowserPlugin: public ISettingsPage QString name() override { - return QObject::tr("Browser extension with native messaging"); + return QObject::tr("Browser Integration"); } QIcon icon() override @@ -182,19 +182,22 @@ MainWindow::MainWindow() m_countDefaultAttributes = m_ui->menuEntryCopyAttribute->actions().size(); restoreGeometry(config()->get("GUI/MainWindowGeometry").toByteArray()); - #ifdef WITH_XC_HTTP +#ifdef WITH_XC_BROWSER + m_ui->settingsWidget->addSettingsPage(new BrowserPlugin(m_ui->tabWidget)); +#endif +#ifdef WITH_XC_HTTP m_ui->settingsWidget->addSettingsPage(new HttpPlugin(m_ui->tabWidget)); - #endif - #ifdef WITH_XC_SSHAGENT +#endif +#ifdef WITH_XC_SSHAGENT SSHAgent::init(this); m_ui->settingsWidget->addSettingsPage(new AgentSettingsPage(m_ui->tabWidget)); - #endif - #ifdef WITH_XC_BROWSER - m_ui->settingsWidget->addSettingsPage(new BrowserPlugin(m_ui->tabWidget)); - #endif +#endif setWindowIcon(filePath()->applicationIcon()); m_ui->globalMessageWidget->setHidden(true); + 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())); m_clearHistoryAction = new QAction(tr("Clear history"), m_ui->menuFile); m_lastDatabasesActions = new QActionGroup(m_ui->menuRecentDatabases); @@ -407,13 +410,32 @@ MainWindow::MainWindow() m_ui->globalMessageWidget->showMessage( 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", 0).toInt() < 3) { + // show message after tab widget dismissed all messages + connect(m_ui->tabWidget, SIGNAL(messageDismissGlobal()), this, SLOT(showKeePassHTTPDeprecationNotice())); + } +#endif } 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, " + "visit our " + "migration guide (warning %1 of 3).

").arg(warningNum + 1), + MessageWidget::Warning, true, -1); + + config()->set("Http/DeprecationNoticeShown", warningNum + 1); + disconnect(m_ui->tabWidget, SIGNAL(messageDismissGlobal()), this, SLOT(showKeePassHTTPDeprecationNotice())); +} + void MainWindow::appExit() { m_appExitCalled = true; diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index b70dd9072..f3b288003 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -97,6 +97,7 @@ private slots: void repairDatabase(); void hideTabMessage(); void handleScreenLock(); + void showKeePassHTTPDeprecationNotice(); private: static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0); diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index c4d782f08..0b39d0b3d 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -21,6 +21,9 @@ true + + 0 + 0 @@ -34,13 +37,28 @@ 0 - - - - 0 - 0 - - + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + MessageWidget {margin: 90px} + + + + diff --git a/src/gui/MessageWidget.cpp b/src/gui/MessageWidget.cpp index 2be298055..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; @@ -47,6 +49,7 @@ void MessageWidget::showMessage(const QString &text, KMessageWidget::MessageType { setMessageType(type); setText(text); + emit showAnimationStarted(); animatedShow(); if (autoHideTimeout > 0) { m_autoHideTimer->start(autoHideTimeout); @@ -68,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 c29c320bf..73f0b2108 100644 --- a/src/gui/MessageWidget.h +++ b/src/gui/MessageWidget.h @@ -35,11 +35,15 @@ public: static const int DefaultAutoHideTimeout; static const int DisableAutoHide; +signals: + void showAnimationStarted(); + public slots: void showMessage(const QString& text, MessageWidget::MessageType type); 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/gui/SettingsWidget.cpp b/src/gui/SettingsWidget.cpp index ce3df3338..7d3f65f81 100644 --- a/src/gui/SettingsWidget.cpp +++ b/src/gui/SettingsWidget.cpp @@ -82,7 +82,7 @@ SettingsWidget::SettingsWidget(QWidget* parent) connect(m_secUi->lockDatabaseIdleCheckBox, SIGNAL(toggled(bool)), m_secUi->lockDatabaseIdleSpinBox, SLOT(setEnabled(bool))); -#ifndef WITH_XC_HTTP +#ifndef WITH_XC_NETWORKING m_secUi->privacy->setVisible(false); #endif } diff --git a/src/http/CMakeLists.txt b/src/http/CMakeLists.txt index 8a3b197ab..db9f5dfb3 100644 --- a/src/http/CMakeLists.txt +++ b/src/http/CMakeLists.txt @@ -1,5 +1,3 @@ -add_subdirectory(qhttp) - if(WITH_XC_HTTP) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/http/OptionDialog.cpp b/src/http/OptionDialog.cpp index 03ae6e9ce..dd5a51f73 100644 --- a/src/http/OptionDialog.cpp +++ b/src/http/OptionDialog.cpp @@ -32,13 +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->setIcon(FilePath::instance()->icon("status", "dialog-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->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 abe994772..54f7bd70c 100644 --- a/src/http/OptionDialog.ui +++ b/src/http/OptionDialog.ui @@ -6,8 +6,8 @@ 0 0 - 577 - 404 + 803 + 433 @@ -36,6 +36,9 @@
+ + +