Rework browser integration settings

This commit is contained in:
Janek Bevendorff 2018-01-16 21:45:31 +01:00
parent 780608894e
commit f2b3181735
No known key found for this signature in database
GPG Key ID: 2FDEB0D40BCA5E11
5 changed files with 189 additions and 117 deletions

View File

@ -23,6 +23,7 @@
#include "core/FilePath.h" #include "core/FilePath.h"
#include <QMessageBox> #include <QMessageBox>
#include <QtWidgets/QFileDialog>
BrowserOptionDialog::BrowserOptionDialog(QWidget* parent) : BrowserOptionDialog::BrowserOptionDialog(QWidget* parent) :
QWidget(parent), QWidget(parent),
@ -40,7 +41,10 @@ BrowserOptionDialog::BrowserOptionDialog(QWidget* parent) :
connect(m_ui->enableBrowserSupport, SIGNAL(toggled(bool)), m_ui->tabWidget, SLOT(setEnabled(bool))); connect(m_ui->enableBrowserSupport, SIGNAL(toggled(bool)), m_ui->tabWidget, SLOT(setEnabled(bool)));
m_ui->customProxyLocation->setEnabled(m_ui->useCustomProxy->isChecked()); 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->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() BrowserOptionDialog::~BrowserOptionDialog()
@ -57,6 +61,11 @@ void BrowserOptionDialog::loadSettings()
m_ui->unlockDatabase->setChecked(settings.unlockDatabase()); m_ui->unlockDatabase->setChecked(settings.unlockDatabase());
m_ui->matchUrlScheme->setChecked(settings.matchUrlScheme()); m_ui->matchUrlScheme->setChecked(settings.matchUrlScheme());
// hide unimplemented options
// TODO: fix this
m_ui->showNotification->hide();
m_ui->bestMatchOnly->hide();
if (settings.sortByUsername()) { if (settings.sortByUsername()) {
m_ui->sortByUsername->setChecked(true); m_ui->sortByUsername->setChecked(true);
} else { } else {
@ -102,3 +111,16 @@ void BrowserOptionDialog::saveSettings()
settings.setFirefoxSupport(m_ui->firefoxSupport->isChecked()); settings.setFirefoxSupport(m_ui->firefoxSupport->isChecked());
settings.setVivaldiSupport(m_ui->vivaldiSupport->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);
}

View File

@ -43,6 +43,9 @@ signals:
void removeSharedEncryptionKeys(); void removeSharedEncryptionKeys();
void removeStoredPermissions(); void removeStoredPermissions();
private slots:
void showProxyLocationFileDialog();
private: private:
QScopedPointer<Ui::BrowserOptionDialog> m_ui; QScopedPointer<Ui::BrowserOptionDialog> m_ui;
}; };

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>577</width> <width>456</width>
<height>404</height> <height>385</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -32,7 +32,7 @@
<string>This is required for accessing your databases with keepassxc-browser</string> <string>This is required for accessing your databases with keepassxc-browser</string>
</property> </property>
<property name="text"> <property name="text">
<string>Enable KeepassXC browser extension</string> <string>Enable KeepassXC browser integration</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -47,22 +47,93 @@
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QCheckBox" name="showNotification"> <widget class="QGroupBox" name="browsersGroupBox">
<property name="title">
<string>Enable integration for these browsers:</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>40</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="chromeSupport">
<property name="text"> <property name="text">
<string>Sh&amp;ow a notification when credentials are requested</string> <string>&amp;Google Chrome</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QCheckBox" name="bestMatchOnly"> <widget class="QCheckBox" name="firefoxSupport">
<property name="toolTip">
<string>Only returns the best matches for a specific URL instead of all entries for the whole domain.</string>
</property>
<property name="text"> <property name="text">
<string>&amp;Return only best-matching entries</string> <string>&amp;Firefox</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>179</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="chromiumSupport">
<property name="text">
<string>&amp;Chromium</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="vivaldiSupport">
<property name="text">
<string>&amp;Vivaldi</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>4</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="showNotification">
<property name="text">
<string>Show a &amp;notification when credentials are requested</string>
</property>
<property name="checked">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -82,38 +153,80 @@
<string>Only entries with the same scheme (http://, https://, ...) are returned.</string> <string>Only entries with the same scheme (http://, https://, ...) are returned.</string>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Match URL schemes</string> <string>&amp;Match URL scheme (e.g., https://...)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="sortByUsername"> <widget class="QCheckBox" name="bestMatchOnly">
<property name="toolTip">
<string>Only returns the best matches for a specific URL instead of all entries for the whole domain.</string>
</property>
<property name="text"> <property name="text">
<string>Sort matching entries by &amp;username</string> <string>&amp;Return only best-matching credentials</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="sortByTitle"> <widget class="QRadioButton" name="sortByTitle">
<property name="text"> <property name="text">
<string>Sort &amp;matching entries by title</string> <string>Sort &amp;matching credentials by title</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="removeSharedEncryptionKeys"> <widget class="QRadioButton" name="sortByUsername">
<property name="text"> <property name="text">
<string>R&amp;emove all shared encryption keys from active database</string> <string>Sort matching credentials by &amp;username</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="removeSharedEncryptionKeys">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Disconnect all browsers</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="removeStoredPermissions"> <widget class="QPushButton" name="removeStoredPermissions">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Re&amp;move all stored permissions from entries in active database</string> <string>Forget all remembered &amp;permissions</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
@ -129,83 +242,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Supported browsers</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="browserLabel1">
<property name="text">
<string>Native messaging requires certain .json files to be installed. Already installed browsers are automatically detected.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="browserLabel2">
<property name="text">
<string>Enable KeePassXC native messaging extension for these browsers:</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chromeSupport">
<property name="text">
<string>Chrome</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chromiumSupport">
<property name="text">
<string>Chromium</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="firefoxSupport">
<property name="text">
<string>Firefox</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="vivaldiSupport">
<property name="text">
<string>Vivaldi</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2"> <widget class="QWidget" name="tab_2">
<attribute name="title"> <attribute name="title">
<string>Advanced</string> <string>Advanced</string>
@ -224,14 +260,14 @@
<item> <item>
<widget class="QCheckBox" name="alwaysAllowAccess"> <widget class="QCheckBox" name="alwaysAllowAccess">
<property name="text"> <property name="text">
<string>Always allow &amp;access to entries</string> <string>Never &amp;ask before accessing credentials</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="alwaysAllowUpdate"> <widget class="QCheckBox" name="alwaysAllowUpdate">
<property name="text"> <property name="text">
<string>Always allow &amp;updating entries</string> <string>Never ask before &amp;updating credentials</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -241,7 +277,7 @@
<string>Only the selected database has to be connected with a client.</string> <string>Only the selected database has to be connected with a client.</string>
</property> </property>
<property name="text"> <property name="text">
<string>Searc&amp;h in all opened databases for matching entries</string> <string>Searc&amp;h in all opened databases for matching credentials</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -261,7 +297,7 @@
<string>Updates KeePassXC or keepassxc-proxy binary path automatically to native messaging scripts on startup.</string> <string>Updates KeePassXC or keepassxc-proxy binary path automatically to native messaging scripts on startup.</string>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Update KeePassXC binary path automatically to native messaging scripts on startup</string> <string>Update &amp;native messaging manifest files at startup</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -271,7 +307,7 @@
<string>Support a proxy application between KeePassXC and browser extension.</string> <string>Support a proxy application between KeePassXC and browser extension.</string>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Enable support for proxy application between KeePassXC and browser extension</string> <string>Use a &amp;proxy application between KeePassXC and browser extension</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -281,10 +317,12 @@
<string>Use a custom proxy location if you installed a proxy manually.</string> <string>Use a custom proxy location if you installed a proxy manually.</string>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Use a custom proxy location</string> <string>Use a &amp;custom proxy location</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLineEdit" name="customProxyLocation"> <widget class="QLineEdit" name="customProxyLocation">
<property name="maxLength"> <property name="maxLength">
@ -295,6 +333,15 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="customProxyLocationBrowseButton">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<spacer name="verticalSpacer_4"> <spacer name="verticalSpacer_4">
<property name="orientation"> <property name="orientation">

View File

@ -34,7 +34,7 @@ public:
static void setShowNotification(bool showNotification); static void setShowNotification(bool showNotification);
static bool bestMatchOnly(); //TODO!! static bool bestMatchOnly(); //TODO!!
static void setBestMatchOnly(bool bestMatchOnly); static void setBestMatchOnly(bool bestMatchOnly);
static bool unlockDatabase(); //TODO!! static bool unlockDatabase();
static void setUnlockDatabase(bool unlockDatabase); static void setUnlockDatabase(bool unlockDatabase);
static bool matchUrlScheme(); static bool matchUrlScheme();
static void setMatchUrlScheme(bool matchUrlScheme); static void setMatchUrlScheme(bool matchUrlScheme);

View File

@ -77,7 +77,7 @@ public:
QString name() override QString name() override
{ {
return QObject::tr("Browser Integration"); return QObject::tr("Browser Integration (old)");
} }
QIcon icon() override QIcon icon() override
@ -125,7 +125,7 @@ class BrowserPlugin: public ISettingsPage
QString name() override QString name() override
{ {
return QObject::tr("Browser extension with native messaging"); return QObject::tr("Browser Integration");
} }
QIcon icon() override QIcon icon() override
@ -182,6 +182,9 @@ MainWindow::MainWindow()
m_countDefaultAttributes = m_ui->menuEntryCopyAttribute->actions().size(); m_countDefaultAttributes = m_ui->menuEntryCopyAttribute->actions().size();
restoreGeometry(config()->get("GUI/MainWindowGeometry").toByteArray()); restoreGeometry(config()->get("GUI/MainWindowGeometry").toByteArray());
#ifdef WITH_XC_BROWSER
m_ui->settingsWidget->addSettingsPage(new BrowserPlugin(m_ui->tabWidget));
#endif
#ifdef WITH_XC_HTTP #ifdef WITH_XC_HTTP
m_ui->settingsWidget->addSettingsPage(new HttpPlugin(m_ui->tabWidget)); m_ui->settingsWidget->addSettingsPage(new HttpPlugin(m_ui->tabWidget));
#endif #endif
@ -189,9 +192,6 @@ MainWindow::MainWindow()
SSHAgent::init(this); SSHAgent::init(this);
m_ui->settingsWidget->addSettingsPage(new AgentSettingsPage(m_ui->tabWidget)); m_ui->settingsWidget->addSettingsPage(new AgentSettingsPage(m_ui->tabWidget));
#endif #endif
#ifdef WITH_XC_BROWSER
m_ui->settingsWidget->addSettingsPage(new BrowserPlugin(m_ui->tabWidget));
#endif
setWindowIcon(filePath()->applicationIcon()); setWindowIcon(filePath()->applicationIcon());
m_ui->globalMessageWidget->setHidden(true); m_ui->globalMessageWidget->setHidden(true);