2017-12-12 03:15:23 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Francois Ferrand
|
|
|
|
* Copyright (C) 2017 Sami Vänttinen <sami.vanttinen@protonmail.com>
|
|
|
|
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "BrowserOptionDialog.h"
|
|
|
|
#include "BrowserSettings.h"
|
2018-03-31 16:01:30 -04:00
|
|
|
#include "config-keepassx.h"
|
2017-12-12 03:15:23 -05:00
|
|
|
#include "core/FilePath.h"
|
2018-03-31 16:01:30 -04:00
|
|
|
#include "ui_BrowserOptionDialog.h"
|
2017-12-12 03:15:23 -05:00
|
|
|
|
2018-01-16 18:56:47 -05:00
|
|
|
#include <QFileDialog>
|
2018-03-31 16:01:30 -04:00
|
|
|
#include <QMessageBox>
|
2017-12-12 03:15:23 -05:00
|
|
|
|
2018-03-31 16:01:30 -04:00
|
|
|
BrowserOptionDialog::BrowserOptionDialog(QWidget* parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
, m_ui(new Ui::BrowserOptionDialog())
|
2017-12-12 03:15:23 -05:00
|
|
|
{
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
connect(m_ui->removeSharedEncryptionKeys, SIGNAL(clicked()), this, SIGNAL(removeSharedEncryptionKeys()));
|
|
|
|
connect(m_ui->removeStoredPermissions, SIGNAL(clicked()), this, SIGNAL(removeStoredPermissions()));
|
|
|
|
|
2018-07-27 12:32:58 -04:00
|
|
|
m_ui->extensionLabel->setOpenExternalLinks(true);
|
|
|
|
m_ui->extensionLabel->setText(tr("KeePassXC-Browser is needed for the browser integration to work. <br />Download it for %1 and %2.").arg(
|
|
|
|
"<a href=\"https://addons.mozilla.org/en-US/firefox/addon/keepassxc-browser/\">Firefox</a>",
|
|
|
|
"<a href=\"https://chrome.google.com/webstore/detail/keepassxc-browser/oboonakemofpalcgghocfoadofidjkkk\">Google Chrome / Chromium / Vivaldi</a>"));
|
|
|
|
|
2018-01-19 14:32:23 -05:00
|
|
|
m_ui->warningWidget->showMessage(tr("<b>Warning:</b> The following options can be dangerous!"), MessageWidget::Warning);
|
2017-12-12 03:15:23 -05:00
|
|
|
m_ui->warningWidget->setCloseButtonVisible(false);
|
2018-01-16 18:56:47 -05:00
|
|
|
m_ui->warningWidget->setAutoHideTimeout(-1);
|
2017-12-12 03:15:23 -05:00
|
|
|
|
|
|
|
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());
|
2018-01-16 15:45:31 -05:00
|
|
|
m_ui->customProxyLocationBrowseButton->setEnabled(m_ui->useCustomProxy->isChecked());
|
2017-12-12 03:15:23 -05:00
|
|
|
connect(m_ui->useCustomProxy, SIGNAL(toggled(bool)), m_ui->customProxyLocation, SLOT(setEnabled(bool)));
|
2018-01-16 15:45:31 -05:00
|
|
|
connect(m_ui->useCustomProxy, SIGNAL(toggled(bool)), m_ui->customProxyLocationBrowseButton, SLOT(setEnabled(bool)));
|
|
|
|
connect(m_ui->customProxyLocationBrowseButton, SIGNAL(clicked()), this, SLOT(showProxyLocationFileDialog()));
|
2018-02-25 18:26:28 -05:00
|
|
|
|
2018-08-03 06:36:11 -04:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
// Vivaldi uses Chrome's registry settings
|
|
|
|
m_ui->vivaldiSupport->setHidden(true);
|
|
|
|
m_ui->chromeSupport->setText("Chrome and Vivaldi");
|
|
|
|
#endif
|
2018-02-25 19:34:16 -05:00
|
|
|
m_ui->browserGlobalWarningWidget->setVisible(false);
|
2017-12-12 03:15:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
BrowserOptionDialog::~BrowserOptionDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserOptionDialog::loadSettings()
|
|
|
|
{
|
|
|
|
BrowserSettings settings;
|
|
|
|
m_ui->enableBrowserSupport->setChecked(settings.isEnabled());
|
|
|
|
|
|
|
|
m_ui->showNotification->setChecked(settings.showNotification());
|
|
|
|
m_ui->bestMatchOnly->setChecked(settings.bestMatchOnly());
|
|
|
|
m_ui->unlockDatabase->setChecked(settings.unlockDatabase());
|
|
|
|
m_ui->matchUrlScheme->setChecked(settings.matchUrlScheme());
|
|
|
|
|
2018-01-16 15:45:31 -05:00
|
|
|
// hide unimplemented options
|
|
|
|
// TODO: fix this
|
|
|
|
m_ui->showNotification->hide();
|
|
|
|
|
2017-12-12 03:15:23 -05:00
|
|
|
if (settings.sortByUsername()) {
|
|
|
|
m_ui->sortByUsername->setChecked(true);
|
|
|
|
} else {
|
|
|
|
m_ui->sortByTitle->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ui->alwaysAllowAccess->setChecked(settings.alwaysAllowAccess());
|
|
|
|
m_ui->alwaysAllowUpdate->setChecked(settings.alwaysAllowUpdate());
|
|
|
|
m_ui->searchInAllDatabases->setChecked(settings.searchInAllDatabases());
|
|
|
|
m_ui->supportKphFields->setChecked(settings.supportKphFields());
|
|
|
|
m_ui->supportBrowserProxy->setChecked(settings.supportBrowserProxy());
|
|
|
|
m_ui->useCustomProxy->setChecked(settings.useCustomProxy());
|
|
|
|
m_ui->customProxyLocation->setText(settings.customProxyLocation());
|
|
|
|
m_ui->updateBinaryPath->setChecked(settings.updateBinaryPath());
|
|
|
|
m_ui->chromeSupport->setChecked(settings.chromeSupport());
|
|
|
|
m_ui->chromiumSupport->setChecked(settings.chromiumSupport());
|
|
|
|
m_ui->firefoxSupport->setChecked(settings.firefoxSupport());
|
|
|
|
m_ui->vivaldiSupport->setChecked(settings.vivaldiSupport());
|
2018-02-25 19:34:16 -05:00
|
|
|
|
|
|
|
#if defined(KEEPASSXC_DIST_APPIMAGE)
|
|
|
|
m_ui->supportBrowserProxy->setChecked(true);
|
|
|
|
m_ui->supportBrowserProxy->setEnabled(false);
|
|
|
|
#elif defined(KEEPASSXC_DIST_SNAP)
|
|
|
|
m_ui->enableBrowserSupport->setChecked(false);
|
|
|
|
m_ui->enableBrowserSupport->setEnabled(false);
|
|
|
|
m_ui->browserGlobalWarningWidget->showMessage(
|
2018-03-31 16:01:30 -04:00
|
|
|
tr("We're sorry, but KeePassXC-Browser is not supported for Snap releases at the moment."),
|
|
|
|
MessageWidget::Warning);
|
2018-02-25 19:34:16 -05:00
|
|
|
m_ui->browserGlobalWarningWidget->setCloseButtonVisible(false);
|
|
|
|
m_ui->browserGlobalWarningWidget->setAutoHideTimeout(-1);
|
|
|
|
#endif
|
2017-12-12 03:15:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserOptionDialog::saveSettings()
|
|
|
|
{
|
|
|
|
BrowserSettings settings;
|
|
|
|
settings.setEnabled(m_ui->enableBrowserSupport->isChecked());
|
|
|
|
settings.setShowNotification(m_ui->showNotification->isChecked());
|
|
|
|
settings.setBestMatchOnly(m_ui->bestMatchOnly->isChecked());
|
|
|
|
settings.setUnlockDatabase(m_ui->unlockDatabase->isChecked());
|
|
|
|
settings.setMatchUrlScheme(m_ui->matchUrlScheme->isChecked());
|
|
|
|
settings.setSortByUsername(m_ui->sortByUsername->isChecked());
|
|
|
|
|
|
|
|
settings.setSupportBrowserProxy(m_ui->supportBrowserProxy->isChecked());
|
|
|
|
settings.setUseCustomProxy(m_ui->useCustomProxy->isChecked());
|
|
|
|
settings.setCustomProxyLocation(m_ui->customProxyLocation->text());
|
|
|
|
|
|
|
|
settings.setUpdateBinaryPath(m_ui->updateBinaryPath->isChecked());
|
|
|
|
settings.setAlwaysAllowAccess(m_ui->alwaysAllowAccess->isChecked());
|
|
|
|
settings.setAlwaysAllowUpdate(m_ui->alwaysAllowUpdate->isChecked());
|
|
|
|
settings.setSearchInAllDatabases(m_ui->searchInAllDatabases->isChecked());
|
|
|
|
settings.setSupportKphFields(m_ui->supportKphFields->isChecked());
|
|
|
|
|
|
|
|
settings.setChromeSupport(m_ui->chromeSupport->isChecked());
|
|
|
|
settings.setChromiumSupport(m_ui->chromiumSupport->isChecked());
|
|
|
|
settings.setFirefoxSupport(m_ui->firefoxSupport->isChecked());
|
|
|
|
settings.setVivaldiSupport(m_ui->vivaldiSupport->isChecked());
|
|
|
|
}
|
2018-01-16 15:45:31 -05:00
|
|
|
|
|
|
|
void BrowserOptionDialog::showProxyLocationFileDialog()
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_WIN
|
2018-03-13 15:55:37 -04:00
|
|
|
QString fileTypeFilter(QString("%1 (*.exe);;%2 (*.*)").arg(tr("Executable Files"), tr("All Files")));
|
2018-01-16 15:45:31 -05:00
|
|
|
#else
|
2018-03-13 15:55:37 -04:00
|
|
|
QString fileTypeFilter(QString("%1 (*)").arg(tr("Executable Files")));
|
2018-01-16 15:45:31 -05:00
|
|
|
#endif
|
2018-03-31 16:01:30 -04:00
|
|
|
auto proxyLocation = QFileDialog::getOpenFileName(this,
|
|
|
|
tr("Select custom proxy location"),
|
2018-01-16 15:45:31 -05:00
|
|
|
QFileInfo(QCoreApplication::applicationDirPath()).filePath(),
|
|
|
|
fileTypeFilter);
|
|
|
|
m_ui->customProxyLocation->setText(proxyLocation);
|
|
|
|
}
|