1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-15 03:22:11 +01:00
falkonOfficial/src/lib/preferences/preferences.cpp

1065 lines
43 KiB
C++
Raw Normal View History

2011-03-03 18:29:20 +01:00
/* ============================================================
2017-08-25 17:11:29 +02:00
* Falkon - Qt web browser
* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
2011-03-03 18:29:20 +01:00
*
* 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/>.
* ============================================================ */
2011-03-02 16:57:41 +01:00
#include "preferences.h"
#include "ui_preferences.h"
#include "browserwindow.h"
2011-03-02 16:57:41 +01:00
#include "bookmarkstoolbar.h"
#include "history.h"
2011-03-02 16:57:41 +01:00
#include "tabwidget.h"
#include "cookiejar.h"
#include "locationbar.h"
#include "autofillmanager.h"
#include "mainapplication.h"
#include "cookiemanager.h"
#include "pluginproxy.h"
#include "pluginsmanager.h"
2012-12-28 01:17:01 +01:00
#include "jsoptions.h"
2011-04-26 19:47:12 +02:00
#include "networkmanager.h"
#include "desktopnotificationsfactory.h"
#include "desktopnotification.h"
#include "thememanager.h"
#include "acceptlanguage.h"
#include "qztools.h"
#include "autofill.h"
#include "settings.h"
#include "datapaths.h"
#include "tabbedwebview.h"
#include "clearprivatedata.h"
#include "useragentdialog.h"
#include "registerqappassociation.h"
#include "profilemanager.h"
#include "html5permissions/html5permissionsdialog.h"
#include "searchenginesdialog.h"
#include "webscrollbarmanager.h"
#include "../config.h"
2011-03-02 16:57:41 +01:00
#include <QSettings>
#include <QInputDialog>
#include <QFileDialog>
#include <QMessageBox>
2012-08-31 15:19:07 +02:00
#include <QCloseEvent>
#include <QColorDialog>
#include <QDesktopWidget>
#include <QWebEngineProfile>
2015-02-08 11:38:38 +01:00
#include <QWebEngineSettings>
#include <QLibraryInfo>
static QString createLanguageItem(const QString &lang)
{
QLocale locale(lang);
if (locale.language() == QLocale::C) {
return lang;
}
QString country = QLocale::countryToString(locale.country());
QString language = QLocale::languageToString(locale.language());
2014-03-23 13:50:15 +01:00
if (lang == QLatin1String("es_ES")) {
return QString::fromUtf8("Castellano");
}
if (lang == QLatin1String("nqo")) {
return QString("N'ko (nqo)");
}
2014-03-10 19:47:27 +01:00
if (lang == QLatin1String("sr")) {
return QString::fromUtf8("српски екавски");
}
if (lang == QLatin1String("sr@ijekavian")) {
return QString::fromUtf8("српски ијекавски");
}
if (lang == QLatin1String("sr@latin")) {
return QString::fromUtf8("srpski ekavski");
}
if (lang == QLatin1String("sr@ijekavianlatin")) {
return QString::fromUtf8("srpski ijekavski");
}
return QString("%1, %2 (%3)").arg(language, country, lang);
}
Preferences::Preferences(BrowserWindow* window)
2018-02-09 17:49:32 +01:00
: QDialog(window)
, ui(new Ui::Preferences)
, m_window(window)
, m_autoFillManager(0)
, m_pluginsList(0)
2011-03-02 16:57:41 +01:00
{
setAttribute(Qt::WA_DeleteOnClose);
2011-03-02 16:57:41 +01:00
ui->setupUi(this);
QzTools::centerWidgetOnScreen(this);
2011-03-02 16:57:41 +01:00
m_themesManager = new ThemeManager(ui->themesWidget, this);
m_pluginsList = new PluginsManager(this);
ui->pluginsFrame->addWidget(m_pluginsList);
#ifdef DISABLE_CHECK_UPDATES
ui->checkUpdates->setVisible(false);
#endif
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
ui->disableVideoAutoPlay->setVisible(false);
ui->webRTCPublicIpOnly->setVisible(false);
#endif
auto setCategoryIcon = [this](int index, const QIcon &icon) {
ui->listWidget->item(index)->setIcon(QIcon(icon.pixmap(32)));
};
2017-01-21 22:36:51 +01:00
setCategoryIcon(0, QIcon(":/icons/preferences/general.svg"));
setCategoryIcon(1, QIcon(":/icons/preferences/appearance.svg"));
setCategoryIcon(2, QIcon(":/icons/preferences/tabs.svg"));
setCategoryIcon(3, QIcon(":/icons/preferences/browsing.svg"));
setCategoryIcon(4, QIcon(":/icons/preferences/fonts.svg"));
setCategoryIcon(5, QIcon(":/icons/preferences/shortcuts.svg"));
setCategoryIcon(6, QIcon(":/icons/preferences/downloads.svg"));
setCategoryIcon(7, QIcon(":/icons/preferences/passwords.svg"));
setCategoryIcon(8, QIcon(":/icons/preferences/privacy.svg"));
setCategoryIcon(9, QIcon(":/icons/preferences/notifications.svg"));
setCategoryIcon(10, QIcon(":/icons/preferences/extensions.svg"));
setCategoryIcon(11, QIcon(":/icons/preferences/spellcheck.svg"));
setCategoryIcon(12, QIcon(":/icons/preferences/other.svg"));
Settings settings;
2011-03-02 16:57:41 +01:00
//GENERAL URLs
settings.beginGroup("Web-URL-Settings");
2017-08-25 17:11:29 +02:00
m_homepage = settings.value("homepage", QUrl(QSL("falkon:start"))).toUrl();
m_newTabUrl = settings.value("newTabUrl", QUrl(QSL("falkon:speeddial"))).toUrl();
ui->homepage->setText(m_homepage.toEncoded());
ui->newTabUrl->setText(m_newTabUrl.toEncoded());
settings.endGroup();
2015-09-28 14:51:38 +02:00
ui->afterLaunch->setCurrentIndex(mApp->afterLaunch());
2016-04-05 10:18:49 +02:00
ui->checkUpdates->setChecked(settings.value("Web-Browser-Settings/CheckUpdates", true).toBool());
ui->dontLoadTabsUntilSelected->setChecked(settings.value("Web-Browser-Settings/LoadTabsOnActivation", true).toBool());
2014-01-02 15:26:44 +01:00
#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
ui->checkDefaultBrowser->setChecked(settings.value("Web-Browser-Settings/CheckDefaultBrowser", DEFAULT_CHECK_DEFAULTBROWSER).toBool());
if (mApp->associationManager()->isDefaultForAllCapabilities()) {
ui->checkNowDefaultBrowser->setText(tr("Default"));
ui->checkNowDefaultBrowser->setEnabled(false);
}
else {
ui->checkNowDefaultBrowser->setText(tr("Set as default"));
ui->checkNowDefaultBrowser->setEnabled(true);
2017-08-25 17:11:29 +02:00
connect(ui->checkNowDefaultBrowser, SIGNAL(clicked()), this, SLOT(makeFalkonDefault()));
}
2014-01-02 15:26:44 +01:00
#else // No Default Browser settings on non-Windows platform
ui->hSpacerDefaultBrowser->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
ui->hLayoutDefaultBrowser->invalidate();
delete ui->hLayoutDefaultBrowser;
delete ui->checkDefaultBrowser;
delete ui->checkNowDefaultBrowser;
#endif
2014-01-02 15:26:44 +01:00
2011-03-02 16:57:41 +01:00
ui->newTabFrame->setVisible(false);
if (m_newTabUrl.isEmpty() || m_newTabUrl.toString() == QL1S("about:blank")) {
2011-03-02 16:57:41 +01:00
ui->newTab->setCurrentIndex(0);
}
else if (m_newTabUrl == m_homepage) {
2011-03-02 16:57:41 +01:00
ui->newTab->setCurrentIndex(1);
}
2017-08-25 17:11:29 +02:00
else if (m_newTabUrl.toString() == QL1S("falkon:speeddial")) {
2011-03-02 16:57:41 +01:00
ui->newTab->setCurrentIndex(2);
}
else {
ui->newTab->setCurrentIndex(3);
2011-03-02 16:57:41 +01:00
ui->newTabFrame->setVisible(true);
}
afterLaunchChanged(ui->afterLaunch->currentIndex());
connect(ui->afterLaunch, SIGNAL(currentIndexChanged(int)), this, SLOT(afterLaunchChanged(int)));
connect(ui->newTab, SIGNAL(currentIndexChanged(int)), this, SLOT(newTabChanged(int)));
if (m_window) {
connect(ui->useCurrentBut, SIGNAL(clicked()), this, SLOT(useActualHomepage()));
connect(ui->newTabUseCurrent, SIGNAL(clicked()), this, SLOT(useActualNewTab()));
}
else {
ui->useCurrentBut->setEnabled(false);
ui->newTabUseCurrent->setEnabled(false);
}
// PROFILES
QString startingProfile = ProfileManager::startingProfile();
ui->activeProfile->setText("<b>" + ProfileManager::currentProfile() + "</b>");
ui->startProfile->addItem(startingProfile);
foreach (const QString &name, ProfileManager::availableProfiles()) {
if (startingProfile != name) {
ui->startProfile->addItem(name);
}
}
connect(ui->createProfile, SIGNAL(clicked()), this, SLOT(createProfile()));
connect(ui->deleteProfile, SIGNAL(clicked()), this, SLOT(deleteProfile()));
connect(ui->startProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(startProfileIndexChanged(int)));
startProfileIndexChanged(ui->startProfile->currentIndex());
2011-03-02 16:57:41 +01:00
//APPEREANCE
2011-03-02 16:57:41 +01:00
settings.beginGroup("Browser-View-Settings");
2016-01-24 16:29:46 +01:00
ui->showStatusbar->setChecked(settings.value("showStatusBar", false).toBool());
// NOTE: instantBookmarksToolbar and showBookmarksToolbar cannot be both enabled at the same time
ui->instantBookmarksToolbar->setChecked(settings.value("instantBookmarksToolbar", false).toBool());
ui->showBookmarksToolbar->setChecked(settings.value("showBookmarksToolbar", false).toBool());
ui->instantBookmarksToolbar->setDisabled(settings.value("showBookmarksToolbar", false).toBool());
ui->showBookmarksToolbar->setDisabled(settings.value("instantBookmarksToolbar").toBool());
connect(ui->instantBookmarksToolbar, SIGNAL(toggled(bool)), ui->showBookmarksToolbar, SLOT(setDisabled(bool)));
connect(ui->showBookmarksToolbar, SIGNAL(toggled(bool)), ui->instantBookmarksToolbar, SLOT(setDisabled(bool)));
2014-03-13 15:58:39 +01:00
ui->showNavigationToolbar->setChecked(settings.value("showNavigationToolbar", true).toBool());
int currentSettingsPage = settings.value("settingsDialogPage", 0).toInt(0);
2011-03-02 16:57:41 +01:00
settings.endGroup();
//TABS
settings.beginGroup("Browser-Tabs-Settings");
ui->hideTabsOnTab->setChecked(settings.value("hideTabsWithOneTab", false).toBool());
ui->activateLastTab->setChecked(settings.value("ActivateLastTabWhenClosingActual", false).toBool());
ui->openNewTabAfterActive->setChecked(settings.value("newTabAfterActive", true).toBool());
ui->openNewEmptyTabAfterActive->setChecked(settings.value("newEmptyTabAfterActive", false).toBool());
ui->openPopupsInTabs->setChecked(settings.value("OpenPopupsInTabs", false).toBool());
ui->alwaysSwitchTabsWithWheel->setChecked(settings.value("AlwaysSwitchTabsWithWheel", false).toBool());
ui->switchToNewTabs->setChecked(settings.value("OpenNewTabsSelected", false).toBool());
ui->dontCloseOnLastTab->setChecked(settings.value("dontCloseWithOneTab", false).toBool());
ui->askWhenClosingMultipleTabs->setChecked(settings.value("AskOnClosing", false).toBool());
ui->showClosedTabsButton->setChecked(settings.value("showClosedTabsButton", false).toBool());
ui->showCloseOnInactive->setCurrentIndex(settings.value("showCloseOnInactiveTabs", 0).toInt());
2011-03-02 16:57:41 +01:00
settings.endGroup();
2011-03-02 16:57:41 +01:00
//AddressBar
settings.beginGroup("AddressBar");
ui->addressbarCompletion->setCurrentIndex(settings.value("showSuggestions", 0).toInt());
ui->useInlineCompletion->setChecked(settings.value("useInlineCompletion", true).toBool());
ui->completionShowSwitchTab->setChecked(settings.value("showSwitchTab", true).toBool());
ui->alwaysShowGoIcon->setChecked(settings.value("alwaysShowGoIcon", false).toBool());
ui->selectAllOnFocus->setChecked(settings.value("SelectAllTextOnDoubleClick", true).toBool());
ui->selectAllOnClick->setChecked(settings.value("SelectAllTextOnClick", false).toBool());
bool showPBinAB = settings.value("ShowLoadingProgress", false).toBool();
ui->showLoadingInAddressBar->setChecked(showPBinAB);
ui->adressProgressSettings->setEnabled(showPBinAB);
ui->progressStyleSelector->setCurrentIndex(settings.value("ProgressStyle", 0).toInt());
bool pbInABuseCC = settings.value("UseCustomProgressColor", false).toBool();
ui->checkBoxCustomProgressColor->setChecked(pbInABuseCC);
ui->progressBarColorSelector->setEnabled(pbInABuseCC);
QColor pbColor = settings.value("CustomProgressColor", palette().color(QPalette::Highlight)).value<QColor>();
setProgressBarColorIcon(pbColor);
connect(ui->customColorToolButton, SIGNAL(clicked(bool)), SLOT(selectCustomProgressBarColor()));
connect(ui->resetProgressBarcolor, SIGNAL(clicked()), SLOT(setProgressBarColorIcon()));
2011-03-02 16:57:41 +01:00
settings.endGroup();
settings.beginGroup("SearchEngines");
bool searchFromAB = settings.value("SearchFromAddressBar", true).toBool();
ui->searchFromAddressBar->setChecked(searchFromAB);
ui->searchWithDefaultEngine->setEnabled(searchFromAB);
ui->searchWithDefaultEngine->setChecked(settings.value("SearchWithDefaultEngine", false).toBool());
ui->showABSearchSuggestions->setEnabled(searchFromAB);
ui->showABSearchSuggestions->setChecked(settings.value("showSearchSuggestions", true).toBool());
connect(ui->searchFromAddressBar, SIGNAL(toggled(bool)), this, SLOT(searchFromAddressBarChanged(bool)));
settings.endGroup();
// BROWSING
2011-03-02 16:57:41 +01:00
settings.beginGroup("Web-Browser-Settings");
ui->allowPlugins->setChecked(settings.value("allowPlugins", true).toBool());
ui->allowJavaScript->setChecked(settings.value("allowJavaScript", true).toBool());
ui->linksInFocusChain->setChecked(settings.value("IncludeLinkInFocusChain", false).toBool());
2013-04-23 13:31:29 +02:00
ui->spatialNavigation->setChecked(settings.value("SpatialNavigation", false).toBool());
ui->animateScrolling->setChecked(settings.value("AnimateScrolling", true).toBool());
ui->wheelScroll->setValue(settings.value("wheelScrollLines", qApp->wheelScrollLines()).toInt());
ui->xssAuditing->setChecked(settings.value("XSSAuditing", false).toBool());
ui->printEBackground->setChecked(settings.value("PrintElementBackground", true).toBool());
ui->useNativeScrollbars->setChecked(settings.value("UseNativeScrollbars", false).toBool());
ui->disableVideoAutoPlay->setChecked(settings.value("DisableVideoAutoPlay", false).toBool());
ui->webRTCPublicIpOnly->setChecked(settings.value("WebRTCPublicIpOnly", true).toBool());
foreach (int level, WebView::zoomLevels()) {
ui->defaultZoomLevel->addItem(QString("%1%").arg(level));
}
ui->defaultZoomLevel->setCurrentIndex(settings.value("DefaultZoomLevel", WebView::zoomLevels().indexOf(100)).toInt());
ui->closeAppWithCtrlQ->setChecked(settings.value("closeAppWithCtrlQ", true).toBool());
2011-03-02 16:57:41 +01:00
//Cache
ui->allowCache->setChecked(settings.value("AllowLocalCache", true).toBool());
2017-01-27 13:37:56 +01:00
ui->removeCache->setChecked(settings.value("deleteCacheOnClose", false).toBool());
ui->cacheMB->setValue(settings.value("LocalCacheSize", 50).toInt());
ui->cachePath->setText(settings.value("CachePath", QWebEngineProfile::defaultProfile()->cachePath()).toString());
2011-03-02 16:57:41 +01:00
connect(ui->allowCache, SIGNAL(clicked(bool)), this, SLOT(allowCacheChanged(bool)));
connect(ui->changeCachePath, SIGNAL(clicked()), this, SLOT(changeCachePathClicked()));
2011-03-02 16:57:41 +01:00
allowCacheChanged(ui->allowCache->isChecked());
//PASSWORD MANAGER
ui->allowPassManager->setChecked(settings.value("SavePasswordsOnSites", true).toBool());
ui->autoCompletePasswords->setChecked(settings.value("AutoCompletePasswords", true).toBool());
2011-03-02 16:57:41 +01:00
//PRIVACY
//Web storage
ui->saveHistory->setChecked(settings.value("allowHistory", true).toBool());
ui->deleteHistoryOnClose->setChecked(settings.value("deleteHistoryOnClose", false).toBool());
if (!ui->saveHistory->isChecked()) {
2011-03-02 16:57:41 +01:00
ui->deleteHistoryOnClose->setEnabled(false);
}
2011-03-02 16:57:41 +01:00
connect(ui->saveHistory, SIGNAL(toggled(bool)), this, SLOT(saveHistoryChanged(bool)));
// Html5Storage
ui->html5storage->setChecked(settings.value("HTML5StorageEnabled", true).toBool());
ui->deleteHtml5storageOnClose->setChecked(settings.value("deleteHTML5StorageOnClose", false).toBool());
connect(ui->html5storage, SIGNAL(toggled(bool)), this, SLOT(allowHtml5storageChanged(bool)));
// Other
ui->doNotTrack->setChecked(settings.value("DoNotTrack", false).toBool());
//CSS Style
ui->userStyleSheet->setText(settings.value("userStyleSheet", "").toString());
connect(ui->chooseUserStylesheet, SIGNAL(clicked()), this, SLOT(chooseUserStyleClicked()));
settings.endGroup();
2011-03-02 16:57:41 +01:00
//DOWNLOADS
settings.beginGroup("DownloadManager");
ui->downLoc->setText(settings.value("defaultDownloadPath", "").toString());
ui->closeDownManOnFinish->setChecked(settings.value("CloseManagerOnFinish", false).toBool());
if (ui->downLoc->text().isEmpty()) {
2011-03-02 16:57:41 +01:00
ui->askEverytime->setChecked(true);
}
else {
2011-03-02 16:57:41 +01:00
ui->useDefined->setChecked(true);
}
ui->useExternalDownManager->setChecked(settings.value("UseExternalManager", false).toBool());
ui->externalDownExecutable->setText(settings.value("ExternalManagerExecutable", "").toString());
ui->externalDownArguments->setText(settings.value("ExternalManagerArguments", "").toString());
connect(ui->useExternalDownManager, SIGNAL(toggled(bool)), this, SLOT(useExternalDownManagerChanged(bool)));
2011-03-02 16:57:41 +01:00
connect(ui->useDefined, SIGNAL(toggled(bool)), this, SLOT(downLocChanged(bool)));
connect(ui->downButt, SIGNAL(clicked()), this, SLOT(chooseDownPath()));
connect(ui->chooseExternalDown, SIGNAL(clicked()), this, SLOT(chooseExternalDownloadManager()));
2011-03-02 16:57:41 +01:00
downLocChanged(ui->useDefined->isChecked());
useExternalDownManagerChanged(ui->useExternalDownManager->isChecked());
2011-03-02 16:57:41 +01:00
settings.endGroup();
//FONTS
settings.beginGroup("Browser-Fonts");
QWebEngineSettings* webSettings = mApp->webSettings();
2016-05-11 13:33:34 +02:00
auto defaultFont = [&](QWebEngineSettings::FontFamily font) -> const QString {
const QString family = webSettings->fontFamily(font);
if (!family.isEmpty())
return family;
switch (font) {
case QWebEngineSettings::FixedFont:
return QFontDatabase::systemFont(QFontDatabase::FixedFont).family();
case QWebEngineSettings::SerifFont:
// TODO
default:
return QFontDatabase::systemFont(QFontDatabase::GeneralFont).family();
}
};
ui->fontStandard->setCurrentFont(QFont(settings.value("StandardFont", defaultFont(QWebEngineSettings::StandardFont)).toString()));
ui->fontCursive->setCurrentFont(QFont(settings.value("CursiveFont", defaultFont(QWebEngineSettings::CursiveFont)).toString()));
ui->fontFantasy->setCurrentFont(QFont(settings.value("FantasyFont", defaultFont(QWebEngineSettings::FantasyFont)).toString()));
ui->fontFixed->setCurrentFont(QFont(settings.value("FixedFont", defaultFont(QWebEngineSettings::FixedFont)).toString()));
ui->fontSansSerif->setCurrentFont(QFont(settings.value("SansSerifFont", defaultFont(QWebEngineSettings::SansSerifFont)).toString()));
ui->fontSerif->setCurrentFont(QFont(settings.value("SerifFont", defaultFont(QWebEngineSettings::SerifFont)).toString()));
ui->sizeDefault->setValue(settings.value("DefaultFontSize", webSettings->fontSize(QWebEngineSettings::DefaultFontSize)).toInt());
ui->sizeFixed->setValue(settings.value("FixedFontSize", webSettings->fontSize(QWebEngineSettings::DefaultFixedFontSize)).toInt());
ui->sizeMinimum->setValue(settings.value("MinimumFontSize", webSettings->fontSize(QWebEngineSettings::MinimumFontSize)).toInt());
ui->sizeMinimumLogical->setValue(settings.value("MinimumLogicalFontSize", webSettings->fontSize(QWebEngineSettings::MinimumLogicalFontSize)).toInt());
settings.endGroup();
//KEYBOARD SHORTCUTS
settings.beginGroup("Shortcuts");
ui->switchTabsAlt->setChecked(settings.value("useTabNumberShortcuts", true).toBool());
ui->loadSpeedDialsCtrl->setChecked(settings.value("useSpeedDialNumberShortcuts", true).toBool());
ui->singleKeyShortcuts->setChecked(settings.value("useSingleKeyShortcuts", false).toBool());
settings.endGroup();
//NOTIFICATIONS
ui->useNativeSystemNotifications->setEnabled(mApp->desktopNotifications()->supportsNativeNotifications());
DesktopNotificationsFactory::Type notifyType;
settings.beginGroup("Notifications");
ui->notificationTimeout->setValue(settings.value("Timeout", 6000).toInt() / 1000);
#if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
notifyType = settings.value("UseNativeDesktop", true).toBool() ? DesktopNotificationsFactory::DesktopNative : DesktopNotificationsFactory::PopupWidget;
#else
notifyType = DesktopNotificationsFactory::PopupWidget;
#endif
if (ui->useNativeSystemNotifications->isEnabled() && notifyType == DesktopNotificationsFactory::DesktopNative) {
ui->useNativeSystemNotifications->setChecked(true);
}
else {
ui->useOSDNotifications->setChecked(true);
}
connect(ui->notificationPreview, &QPushButton::clicked, this, &Preferences::showNotificationPreview);
ui->doNotUseNotifications->setChecked(!settings.value("Enabled", true).toBool());
m_notifPosition = settings.value("Position", QPoint(10, 10)).toPoint();
settings.endGroup();
//SPELLCHECK
settings.beginGroup(QSL("SpellCheck"));
ui->spellcheckEnabled->setChecked(settings.value(QSL("Enabled"), false).toBool());
2016-12-21 21:53:00 +01:00
const QStringList spellcheckLanguages = settings.value(QSL("Languages")).toStringList();
settings.endGroup();
auto updateSpellCheckEnabled = [this]() {
ui->spellcheckLanguages->setEnabled(ui->spellcheckEnabled->isChecked());
ui->spellcheckNoLanguages->setEnabled(ui->spellcheckEnabled->isChecked());
};
updateSpellCheckEnabled();
connect(ui->spellcheckEnabled, &QCheckBox::toggled, this, updateSpellCheckEnabled);
QStringList dictionariesDirs = {
2016-10-26 11:41:22 +02:00
#ifdef Q_OS_OSX
QDir::cleanPath(QCoreApplication::applicationDirPath() + QL1S("/../Resources/qtwebengine_dictionaries")),
QDir::cleanPath(QCoreApplication::applicationDirPath() + QL1S("/../Frameworks/QtWebEngineCore.framework/Resources/qtwebengine_dictionaries"))
#else
QDir::cleanPath(QCoreApplication::applicationDirPath() + QL1S("/qtwebengine_dictionaries")),
QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::DataPath) + QL1S("/qtwebengine_dictionaries"))
#endif
};
dictionariesDirs.removeDuplicates();
ui->spellcheckDirectories->setText(dictionariesDirs.join(QL1C('\n')));
for (const QString &path : dictionariesDirs) {
QDir dir(path);
const QStringList files = dir.entryList({QSL("*.bdic")});
for (const QString &file : files) {
const QString lang = file.left(file.size() - 5);
const QString langName = createLanguageItem(lang);
if (!ui->spellcheckLanguages->findItems(langName, Qt::MatchExactly).isEmpty()) {
continue;
}
2016-12-21 21:53:00 +01:00
QListWidgetItem *item = new QListWidgetItem;
item->setText(langName);
2016-12-21 21:53:00 +01:00
item->setData(Qt::UserRole, lang);
ui->spellcheckLanguages->addItem(item);
}
}
int topIndex = 0;
for (const QString &lang : spellcheckLanguages) {
const auto items = ui->spellcheckLanguages->findItems(createLanguageItem(lang), Qt::MatchExactly);
if (items.isEmpty()) {
continue;
}
QListWidgetItem *item = items.at(0);
ui->spellcheckLanguages->takeItem(ui->spellcheckLanguages->row(item));
ui->spellcheckLanguages->insertItem(topIndex++, item);
ui->spellcheckLanguages->setCurrentItem(item, QItemSelectionModel::Select);
}
2016-12-21 21:53:00 +01:00
if (ui->spellcheckLanguages->count() == 0) {
ui->spellcheckLanguages->hide();
} else {
ui->spellcheckNoLanguages->hide();
}
// Proxy Configuration
2011-04-26 19:47:12 +02:00
settings.beginGroup("Web-Proxy");
int proxyType = settings.value("ProxyType", 2).toInt();
if (proxyType == 0) {
ui->noProxy->setChecked(true);
} else if (proxyType == 2) {
ui->systemProxy->setChecked(true);
} else if (proxyType == 3) {
ui->manualProxy->setChecked(true);
2015-10-15 14:39:18 +02:00
ui->proxyType->setCurrentIndex(0);
} else {
ui->manualProxy->setChecked(true);
ui->proxyType->setCurrentIndex(1);
}
2011-04-26 19:47:12 +02:00
ui->proxyServer->setText(settings.value("HostName", "").toString());
ui->proxyPort->setText(settings.value("Port", 8080).toString());
ui->proxyUsername->setText(settings.value("Username", "").toString());
ui->proxyPassword->setText(settings.value("Password", "").toString());
settings.endGroup();
2011-03-02 16:57:41 +01:00
setManualProxyConfigurationEnabled(ui->manualProxy->isChecked());
connect(ui->manualProxy, SIGNAL(toggled(bool)), this, SLOT(setManualProxyConfigurationEnabled(bool)));
2011-04-26 19:47:12 +02:00
//CONNECTS
2011-03-02 16:57:41 +01:00
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
connect(ui->cookieManagerBut, SIGNAL(clicked()), this, SLOT(showCookieManager()));
connect(ui->html5permissions, SIGNAL(clicked()), this, SLOT(showHtml5Permissions()));
connect(ui->preferredLanguages, SIGNAL(clicked()), this, SLOT(showAcceptLanguage()));
connect(ui->deleteHtml5storage, SIGNAL(clicked()), this, SLOT(deleteHtml5storage()));
connect(ui->uaManager, SIGNAL(clicked()), this, SLOT(openUserAgentManager()));
2012-12-28 01:17:01 +01:00
connect(ui->jsOptionsButton, SIGNAL(clicked()), this, SLOT(openJsOptions()));
connect(ui->searchEngines, SIGNAL(clicked()), this, SLOT(openSearchEnginesManager()));
2011-03-02 16:57:41 +01:00
connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(showStackedPage(QListWidgetItem*)));
ui->listWidget->setItemSelected(ui->listWidget->itemAt(5, 5), true);
2011-03-02 16:57:41 +01:00
ui->listWidget->setCurrentRow(currentSettingsPage);
QDesktopWidget* desktop = QApplication::desktop();
QSize s = size();
if (desktop->availableGeometry(this).size().width() < s.width()) {
s.setWidth(desktop->availableGeometry(this).size().width() - 50);
}
if (desktop->availableGeometry(this).size().height() < s.height()) {
s.setHeight(desktop->availableGeometry(this).size().height() - 50);
}
resize(s);
settings.beginGroup(QSL("Preferences"));
restoreGeometry(settings.value(QSL("Geometry")).toByteArray());
settings.endGroup();
QzTools::setWmClass("Preferences", this);
2011-03-02 16:57:41 +01:00
}
void Preferences::chooseExternalDownloadManager()
{
QString path = QzTools::getOpenFileName("Preferences-ExternalDownloadManager", this, tr("Choose executable location..."), QDir::homePath());
if (path.isEmpty()) {
return;
}
ui->externalDownExecutable->setText(path);
}
2011-03-17 17:03:04 +01:00
void Preferences::showStackedPage(QListWidgetItem* item)
2011-03-02 16:57:41 +01:00
{
if (!item) {
2011-03-02 16:57:41 +01:00
return;
}
int index = ui->listWidget->currentRow();
ui->caption->setText("<b>" + item->text() + "</b>");
ui->stackedWidget->setCurrentIndex(index);
if (m_notification) {
m_notifPosition = m_notification.data()->pos();
delete m_notification.data();
}
2012-12-06 22:28:12 +01:00
if (index == 10) {
m_pluginsList->load();
}
if (index == 7 && !m_autoFillManager) {
m_autoFillManager = new AutoFillManager(this);
ui->autoFillFrame->addWidget(m_autoFillManager);
}
}
void Preferences::showNotificationPreview()
{
if (ui->useOSDNotifications->isChecked()) {
if (m_notification) {
m_notifPosition = m_notification.data()->pos();
delete m_notification.data();
}
m_notification = new DesktopNotification(true);
m_notification.data()->setHeading(tr("OSD Notification"));
m_notification.data()->setText(tr("Drag it on the screen to place it where you want."));
m_notification.data()->move(m_notifPosition);
m_notification.data()->show();
}
else if (ui->useNativeSystemNotifications->isChecked()) {
mApp->desktopNotifications()->nativeNotificationPreview();
}
2011-03-02 16:57:41 +01:00
}
2017-08-25 17:11:29 +02:00
void Preferences::makeFalkonDefault()
{
2014-01-01 23:15:50 +01:00
#if defined(Q_OS_WIN) && !defined(Q_OS_OS2)
2017-08-25 17:11:29 +02:00
disconnect(ui->checkNowDefaultBrowser, SIGNAL(clicked()), this, SLOT(makeFalkonDefault()));
ui->checkNowDefaultBrowser->setText(tr("Default"));
ui->checkNowDefaultBrowser->setEnabled(false);
if (!mApp->associationManager()->showNativeDefaultAppSettingsUi())
mApp->associationManager()->registerAllAssociation();
#endif
}
2011-03-02 16:57:41 +01:00
void Preferences::allowCacheChanged(bool state)
{
2017-01-27 13:37:56 +01:00
ui->removeCache->setEnabled(state);
2017-01-22 09:22:03 +01:00
ui->maxCacheLabel->setEnabled(state);
2011-03-02 16:57:41 +01:00
ui->cacheMB->setEnabled(state);
ui->storeCacheLabel->setEnabled(state);
ui->cachePath->setEnabled(state);
ui->changeCachePath->setEnabled(state);
2011-03-02 16:57:41 +01:00
}
void Preferences::useActualHomepage()
{
if (!m_window)
return;
ui->homepage->setText(m_window->weView()->url().toString());
2011-03-02 16:57:41 +01:00
}
void Preferences::useActualNewTab()
{
if (!m_window)
return;
ui->newTabUrl->setText(m_window->weView()->url().toString());
2011-03-02 16:57:41 +01:00
}
void Preferences::chooseDownPath()
{
QString userFileName = QzTools::getExistingDirectory("Preferences-ChooseDownPath", this, tr("Choose download location..."), QDir::homePath());
if (userFileName.isEmpty()) {
2011-03-02 16:57:41 +01:00
return;
}
#ifdef Q_OS_WIN //QFileDialog::getExistingDirectory returns path with \ instead of / (??)
userFileName.replace(QLatin1Char('\\'), QLatin1Char('/'));
2011-10-17 09:57:07 +02:00
#endif
userFileName += QLatin1Char('/');
2011-10-17 09:57:07 +02:00
2011-03-02 16:57:41 +01:00
ui->downLoc->setText(userFileName);
}
void Preferences::chooseUserStyleClicked()
{
QString file = QzTools::getOpenFileName("Preferences-UserStyle", this, tr("Choose stylesheet location..."), QDir::homePath(), "*.css");
if (file.isEmpty()) {
return;
}
ui->userStyleSheet->setText(file);
}
void Preferences::deleteHtml5storage()
{
ClearPrivateData::clearLocalStorage();
ui->deleteHtml5storage->setText(tr("Deleted"));
ui->deleteHtml5storage->setEnabled(false);
}
void Preferences::openUserAgentManager()
{
UserAgentDialog* dialog = new UserAgentDialog(this);
dialog->open();
}
2011-03-02 16:57:41 +01:00
void Preferences::downLocChanged(bool state)
{
ui->downButt->setEnabled(state);
ui->downLoc->setEnabled(state);
}
2011-04-26 19:47:12 +02:00
void Preferences::setManualProxyConfigurationEnabled(bool state)
{
ui->proxyType->setEnabled(state);
ui->proxyServer->setEnabled(state);
ui->proxyPort->setEnabled(state);
ui->proxyUsername->setEnabled(state);
ui->proxyPassword->setEnabled(state);
}
void Preferences::searchFromAddressBarChanged(bool stat)
{
ui->searchWithDefaultEngine->setEnabled(stat);
ui->showABSearchSuggestions->setEnabled(stat);
}
2011-03-02 16:57:41 +01:00
void Preferences::saveHistoryChanged(bool stat)
{
ui->deleteHistoryOnClose->setEnabled(stat);
}
void Preferences::allowHtml5storageChanged(bool stat)
{
ui->deleteHtml5storageOnClose->setEnabled(stat);
}
2011-03-02 16:57:41 +01:00
void Preferences::showCookieManager()
{
2018-02-09 17:55:27 +01:00
CookieManager* dialog = new CookieManager(this);
dialog->show();
2011-03-02 16:57:41 +01:00
}
void Preferences::showHtml5Permissions()
{
HTML5PermissionsDialog* dialog = new HTML5PermissionsDialog(this);
dialog->open();
}
2012-12-28 01:17:01 +01:00
void Preferences::openJsOptions()
{
JsOptions* dialog = new JsOptions(this);
dialog->open();
2012-12-28 01:17:01 +01:00
}
void Preferences::useExternalDownManagerChanged(bool state)
{
ui->externalDownExecutable->setEnabled(state);
ui->externalDownArguments->setEnabled(state);
ui->chooseExternalDown->setEnabled(state);
}
void Preferences::openSearchEnginesManager()
{
SearchEnginesDialog* dialog = new SearchEnginesDialog(this);
dialog->open();
}
void Preferences::showAcceptLanguage()
{
AcceptLanguage* dialog = new AcceptLanguage(this);
dialog->open();
}
void Preferences::newTabChanged(int value)
{
ui->newTabFrame->setVisible(value == 3);
}
void Preferences::afterLaunchChanged(int value)
{
ui->dontLoadTabsUntilSelected->setEnabled(value == 3 || value == 4);
}
void Preferences::changeCachePathClicked()
{
QString path = QzTools::getExistingDirectory("Preferences-CachePath", this, tr("Choose cache path..."), ui->cachePath->text());
if (path.isEmpty()) {
return;
}
ui->cachePath->setText(path);
}
2011-03-17 17:03:04 +01:00
void Preferences::buttonClicked(QAbstractButton* button)
2011-03-02 16:57:41 +01:00
{
switch (ui->buttonBox->buttonRole(button)) {
case QDialogButtonBox::ApplyRole:
saveSettings();
break;
case QDialogButtonBox::RejectRole:
close();
break;
case QDialogButtonBox::AcceptRole:
saveSettings();
close();
break;
default:
break;
}
}
void Preferences::createProfile()
{
QString name = QInputDialog::getText(this, tr("New Profile"), tr("Enter the new profile's name:"));
name = QzTools::filterCharsFromFilename(name);
if (name.isEmpty()) {
return;
}
int res = ProfileManager::createProfile(name);
if (res == -1) {
QMessageBox::warning(this, tr("Error!"), tr("This profile already exists!"));
return;
}
if (res != 0) {
QMessageBox::warning(this, tr("Error!"), tr("Cannot create profile directory!"));
return;
}
ui->startProfile->addItem(name);
ui->startProfile->setCurrentIndex(ui->startProfile->count() - 1);
}
void Preferences::deleteProfile()
{
QString name = ui->startProfile->currentText();
QMessageBox::StandardButton button = QMessageBox::warning(this, tr("Confirmation"),
tr("Are you sure you want to permanently delete \"%1\" profile? This action cannot be undone!").arg(name), QMessageBox::Yes | QMessageBox::No);
if (button != QMessageBox::Yes) {
return;
}
ProfileManager::removeProfile(name);
ui->startProfile->removeItem(ui->startProfile->currentIndex());
}
void Preferences::startProfileIndexChanged(int index)
{
const bool current = ui->startProfile->itemText(index) == ProfileManager::currentProfile();
ui->deleteProfile->setEnabled(!current);
ui->cannotDeleteActiveProfileLabel->setText(current ? tr("Note: You cannot delete active profile.") : QString());
}
void Preferences::closeEvent(QCloseEvent* event)
{
Settings settings;
settings.beginGroup("Browser-View-Settings");
settings.setValue("settingsDialogPage", ui->stackedWidget->currentIndex());
settings.endGroup();
event->accept();
}
2011-03-02 16:57:41 +01:00
void Preferences::saveSettings()
{
Settings settings;
2011-03-02 16:57:41 +01:00
//GENERAL URLs
QUrl homepage = QUrl::fromUserInput(ui->homepage->text());
2011-03-02 16:57:41 +01:00
settings.beginGroup("Web-URL-Settings");
settings.setValue("homepage", homepage);
settings.setValue("afterLaunch", ui->afterLaunch->currentIndex());
2011-03-02 16:57:41 +01:00
switch (ui->newTab->currentIndex()) {
case 0:
2017-02-07 10:41:58 +01:00
settings.setValue("newTabUrl", QUrl());
break;
case 1:
settings.setValue("newTabUrl", homepage);
break;
case 2:
2017-08-25 17:11:29 +02:00
settings.setValue("newTabUrl", QUrl(QSL("falkon:speeddial")));
break;
case 3:
settings.setValue("newTabUrl", QUrl::fromUserInput(ui->newTabUrl->text()));
break;
default:
break;
}
2011-03-02 16:57:41 +01:00
settings.endGroup();
//PROFILES
/*
*
*
*
*/
//WINDOW
settings.beginGroup("Browser-View-Settings");
settings.setValue("showStatusBar", ui->showStatusbar->isChecked());
settings.setValue("instantBookmarksToolbar", ui->instantBookmarksToolbar->isChecked());
2011-03-02 16:57:41 +01:00
settings.setValue("showBookmarksToolbar", ui->showBookmarksToolbar->isChecked());
settings.setValue("showNavigationToolbar", ui->showNavigationToolbar->isChecked());
settings.endGroup();
//TABS
settings.beginGroup("Browser-Tabs-Settings");
settings.setValue("hideTabsWithOneTab", ui->hideTabsOnTab->isChecked());
2011-03-02 16:57:41 +01:00
settings.setValue("ActivateLastTabWhenClosingActual", ui->activateLastTab->isChecked());
settings.setValue("newTabAfterActive", ui->openNewTabAfterActive->isChecked());
settings.setValue("newEmptyTabAfterActive", ui->openNewEmptyTabAfterActive->isChecked());
settings.setValue("OpenPopupsInTabs", ui->openPopupsInTabs->isChecked());
settings.setValue("AlwaysSwitchTabsWithWheel", ui->alwaysSwitchTabsWithWheel->isChecked());
settings.setValue("OpenNewTabsSelected", ui->switchToNewTabs->isChecked());
settings.setValue("dontCloseWithOneTab", ui->dontCloseOnLastTab->isChecked());
settings.setValue("AskOnClosing", ui->askWhenClosingMultipleTabs->isChecked());
settings.setValue("showClosedTabsButton", ui->showClosedTabsButton->isChecked());
settings.setValue("showCloseOnInactiveTabs", ui->showCloseOnInactive->currentIndex());
2011-03-02 16:57:41 +01:00
settings.endGroup();
//DOWNLOADS
2011-03-02 16:57:41 +01:00
settings.beginGroup("DownloadManager");
if (ui->askEverytime->isChecked()) {
settings.setValue("defaultDownloadPath", "");
}
else {
2011-10-17 09:57:07 +02:00
settings.setValue("defaultDownloadPath", ui->downLoc->text());
}
settings.setValue("CloseManagerOnFinish", ui->closeDownManOnFinish->isChecked());
settings.setValue("UseExternalManager", ui->useExternalDownManager->isChecked());
settings.setValue("ExternalManagerExecutable", ui->externalDownExecutable->text());
settings.setValue("ExternalManagerArguments", ui->externalDownArguments->text());
2011-03-02 16:57:41 +01:00
settings.endGroup();
//FONTS
settings.beginGroup("Browser-Fonts");
settings.setValue("StandardFont", ui->fontStandard->currentFont().family());
settings.setValue("CursiveFont", ui->fontCursive->currentFont().family());
settings.setValue("FantasyFont", ui->fontFantasy->currentFont().family());
settings.setValue("FixedFont", ui->fontFixed->currentFont().family());
settings.setValue("SansSerifFont", ui->fontSansSerif->currentFont().family());
settings.setValue("SerifFont", ui->fontSerif->currentFont().family());
settings.setValue("DefaultFontSize", ui->sizeDefault->value());
settings.setValue("FixedFontSize", ui->sizeFixed->value());
settings.setValue("MinimumFontSize", ui->sizeMinimum->value());
settings.setValue("MinimumLogicalFontSize", ui->sizeMinimumLogical->value());
settings.endGroup();
//KEYBOARD SHORTCUTS
settings.beginGroup("Shortcuts");
settings.setValue("useTabNumberShortcuts", ui->switchTabsAlt->isChecked());
settings.setValue("useSpeedDialNumberShortcuts", ui->loadSpeedDialsCtrl->isChecked());
settings.setValue("useSingleKeyShortcuts", ui->singleKeyShortcuts->isChecked());
settings.endGroup();
2011-03-02 16:57:41 +01:00
//BROWSING
settings.beginGroup("Web-Browser-Settings");
settings.setValue("allowPlugins", ui->allowPlugins->isChecked());
settings.setValue("allowJavaScript", ui->allowJavaScript->isChecked());
2011-03-02 16:57:41 +01:00
settings.setValue("IncludeLinkInFocusChain", ui->linksInFocusChain->isChecked());
2013-04-23 13:31:29 +02:00
settings.setValue("SpatialNavigation", ui->spatialNavigation->isChecked());
settings.setValue("AnimateScrolling", ui->animateScrolling->isChecked());
2011-03-02 16:57:41 +01:00
settings.setValue("wheelScrollLines", ui->wheelScroll->value());
settings.setValue("DoNotTrack", ui->doNotTrack->isChecked());
2011-10-02 17:39:59 +02:00
settings.setValue("CheckUpdates", ui->checkUpdates->isChecked());
settings.setValue("LoadTabsOnActivation", ui->dontLoadTabsUntilSelected->isChecked());
settings.setValue("DefaultZoomLevel", ui->defaultZoomLevel->currentIndex());
settings.setValue("XSSAuditing", ui->xssAuditing->isChecked());
settings.setValue("PrintElementBackground", ui->printEBackground->isChecked());
settings.setValue("closeAppWithCtrlQ", ui->closeAppWithCtrlQ->isChecked());
settings.setValue("UseNativeScrollbars", ui->useNativeScrollbars->isChecked());
settings.setValue("DisableVideoAutoPlay", ui->disableVideoAutoPlay->isChecked());
settings.setValue("WebRTCPublicIpOnly", ui->webRTCPublicIpOnly->isChecked());
#ifdef Q_OS_WIN
settings.setValue("CheckDefaultBrowser", ui->checkDefaultBrowser->isChecked());
#endif
2011-03-02 16:57:41 +01:00
//Cache
settings.setValue("AllowLocalCache", ui->allowCache->isChecked());
2017-01-27 13:37:56 +01:00
settings.setValue("deleteCacheOnClose", ui->removeCache->isChecked());
2011-03-02 16:57:41 +01:00
settings.setValue("LocalCacheSize", ui->cacheMB->value());
settings.setValue("CachePath", ui->cachePath->text());
//CSS Style
settings.setValue("userStyleSheet", ui->userStyleSheet->text());
2011-03-02 16:57:41 +01:00
//PASSWORD MANAGER
settings.setValue("SavePasswordsOnSites", ui->allowPassManager->isChecked());
settings.setValue("AutoCompletePasswords", ui->autoCompletePasswords->isChecked());
2011-03-02 16:57:41 +01:00
//PRIVACY
//Web storage
settings.setValue("allowHistory", ui->saveHistory->isChecked());
settings.setValue("deleteHistoryOnClose", ui->deleteHistoryOnClose->isChecked());
settings.setValue("HTML5StorageEnabled", ui->html5storage->isChecked());
settings.setValue("deleteHTML5StorageOnClose", ui->deleteHtml5storageOnClose->isChecked());
settings.endGroup();
2011-03-02 16:57:41 +01:00
//NOTIFICATIONS
settings.beginGroup("Notifications");
settings.setValue("Timeout", ui->notificationTimeout->value() * 1000);
settings.setValue("Enabled", !ui->doNotUseNotifications->isChecked());
settings.setValue("UseNativeDesktop", ui->useNativeSystemNotifications->isChecked());
settings.setValue("Position", m_notification.data() ? m_notification.data()->pos() : m_notifPosition);
settings.endGroup();
//SPELLCHECK
settings.beginGroup(QSL("SpellCheck"));
settings.setValue("Enabled", ui->spellcheckEnabled->isChecked());
2016-12-21 21:53:00 +01:00
QStringList languages;
for (int i = 0; i < ui->spellcheckLanguages->count(); ++i) {
QListWidgetItem *item = ui->spellcheckLanguages->item(i);
if (item->isSelected()) {
languages.append(item->data(Qt::UserRole).toString());
}
2016-12-21 21:53:00 +01:00
}
settings.setValue("Languages", languages);
settings.endGroup();
2011-03-02 16:57:41 +01:00
//OTHER
//AddressBar
settings.beginGroup("AddressBar");
settings.setValue("showSuggestions", ui->addressbarCompletion->currentIndex());
settings.setValue("useInlineCompletion", ui->useInlineCompletion->isChecked());
settings.setValue("alwaysShowGoIcon", ui->alwaysShowGoIcon->isChecked());
settings.setValue("showSwitchTab", ui->completionShowSwitchTab->isChecked());
settings.setValue("SelectAllTextOnDoubleClick", ui->selectAllOnFocus->isChecked());
settings.setValue("SelectAllTextOnClick", ui->selectAllOnClick->isChecked());
settings.setValue("ShowLoadingProgress", ui->showLoadingInAddressBar->isChecked());
settings.setValue("ProgressStyle", ui->progressStyleSelector->currentIndex());
settings.setValue("UseCustomProgressColor", ui->checkBoxCustomProgressColor->isChecked());
settings.setValue("CustomProgressColor", ui->customColorToolButton->property("ProgressColor").value<QColor>());
2011-03-02 16:57:41 +01:00
settings.endGroup();
settings.beginGroup("SearchEngines");
settings.setValue("SearchFromAddressBar", ui->searchFromAddressBar->isChecked());
settings.setValue("SearchWithDefaultEngine", ui->searchWithDefaultEngine->isChecked());
settings.setValue("showSearchSuggestions", ui->showABSearchSuggestions->isChecked());
settings.endGroup();
2011-04-26 19:47:12 +02:00
//Proxy Configuration
int proxyType;
if (ui->noProxy->isChecked()) {
proxyType = 0;
} else if (ui->systemProxy->isChecked()) {
proxyType = 2;
} else if (ui->proxyType->currentIndex() == 0) { // Http
proxyType = 3;
} else { // Socks5
proxyType = 4;
}
2011-04-26 19:47:12 +02:00
settings.beginGroup("Web-Proxy");
settings.setValue("ProxyType", proxyType);
settings.setValue("HostName", ui->proxyServer->text());
settings.setValue("Port", ui->proxyPort->text().toInt());
settings.setValue("Username", ui->proxyUsername->text());
settings.setValue("Password", ui->proxyPassword->text());
settings.endGroup();
2011-03-02 16:57:41 +01:00
ProfileManager::setStartingProfile(ui->startProfile->currentText());
2011-03-02 16:57:41 +01:00
m_pluginsList->save();
m_themesManager->save();
2011-03-04 13:59:07 +01:00
mApp->cookieJar()->loadSettings();
mApp->history()->loadSettings();
mApp->reloadSettings();
mApp->desktopNotifications()->loadSettings();
mApp->autoFill()->loadSettings();
2015-10-15 14:39:18 +02:00
mApp->networkManager()->loadSettings();
WebScrollBarManager::instance()->loadSettings();
2011-03-02 16:57:41 +01:00
}
Preferences::~Preferences()
{
Settings().setValue(QSL("Preferences/Geometry"), saveGeometry());
2011-03-02 16:57:41 +01:00
delete ui;
delete m_autoFillManager;
delete m_pluginsList;
delete m_notification.data();
2011-03-02 16:57:41 +01:00
}
void Preferences::setProgressBarColorIcon(QColor color)
{
const int size = style()->pixelMetric(QStyle::PM_ToolBarIconSize);
QPixmap pm(QSize(size, size));
if (!color.isValid()) {
color = palette().color(QPalette::Highlight);
}
pm.fill(color);
ui->customColorToolButton->setIcon(pm);
ui->customColorToolButton->setProperty("ProgressColor", color);
}
void Preferences::selectCustomProgressBarColor()
{
QColor newColor = QColorDialog::getColor(ui->customColorToolButton->property("ProgressColor").value<QColor>(), this, tr("Select Color"));
if (newColor.isValid()) {
setProgressBarColorIcon(newColor);
}
}