2014-02-26 07:41:40 +01:00
|
|
|
// This file is part of RSS Guard.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2011-2014 by Martin Rotter <rotter.martinos@gmail.com>
|
|
|
|
//
|
|
|
|
// RSS Guard 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.
|
|
|
|
//
|
|
|
|
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2013-06-14 22:15:37 +02:00
|
|
|
#include "gui/formsettings.h"
|
2013-12-21 21:08:52 +01:00
|
|
|
|
2013-06-17 20:17:13 +02:00
|
|
|
#include "core/defs.h"
|
2013-12-21 21:08:52 +01:00
|
|
|
#include "core/settings.h"
|
2014-02-08 09:12:00 +01:00
|
|
|
#include "core/databasefactory.h"
|
2013-06-27 19:57:23 +02:00
|
|
|
#include "core/localization.h"
|
2013-06-24 16:18:13 +02:00
|
|
|
#include "core/systemfactory.h"
|
2013-12-23 11:39:24 +01:00
|
|
|
#include "core/feeddownloader.h"
|
2013-06-30 15:22:44 +02:00
|
|
|
#include "core/dynamicshortcuts.h"
|
2013-07-18 17:44:23 +02:00
|
|
|
#include "core/webbrowsernetworkaccessmanager.h"
|
2013-12-23 11:39:24 +01:00
|
|
|
#include "core/silentnetworkaccessmanager.h"
|
2013-12-21 21:08:52 +01:00
|
|
|
#include "gui/iconthemefactory.h"
|
|
|
|
#include "gui/skinfactory.h"
|
|
|
|
#include "gui/systemtrayicon.h"
|
2014-01-13 21:43:35 +01:00
|
|
|
#include "gui/feedmessageviewer.h"
|
|
|
|
#include "gui/feedsview.h"
|
2013-12-21 21:08:52 +01:00
|
|
|
#include "gui/formmain.h"
|
|
|
|
#include "gui/webbrowser.h"
|
2014-01-22 20:29:05 +01:00
|
|
|
#include "gui/messagebox.h"
|
2014-03-01 10:03:00 +01:00
|
|
|
#include "qtsingleapplication/qtsingleapplication.h"
|
2013-12-21 21:08:52 +01:00
|
|
|
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QNetworkProxy>
|
|
|
|
#include <QColorDialog>
|
|
|
|
#include <QFileDialog>
|
2013-06-14 22:15:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormSettings) {
|
|
|
|
m_ui->setupUi(this);
|
2013-06-15 19:48:56 +02:00
|
|
|
|
2013-06-26 19:04:38 +02:00
|
|
|
// Set flags and attributes.
|
2013-06-15 19:48:56 +02:00
|
|
|
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
2014-02-02 10:27:11 +01:00
|
|
|
setWindowIcon(IconThemeFactory::instance()->fromTheme("application-settings"));
|
2013-06-15 19:48:56 +02:00
|
|
|
|
2014-01-29 12:26:50 +01:00
|
|
|
#if !defined(Q_OS_WIN)
|
|
|
|
MessageBox::iconify(m_ui->m_buttonBox);
|
|
|
|
#endif
|
|
|
|
|
2013-06-27 19:57:23 +02:00
|
|
|
// Setup behavior.
|
2014-02-27 18:15:16 +01:00
|
|
|
m_ui->m_listSettings->setCurrentRow(0);
|
2013-06-27 19:57:23 +02:00
|
|
|
m_ui->m_treeLanguages->setColumnCount(5);
|
|
|
|
m_ui->m_treeLanguages->setHeaderHidden(false);
|
2013-09-25 20:21:32 +02:00
|
|
|
m_ui->m_treeLanguages->setHeaderLabels(QStringList()
|
2014-02-26 21:41:13 +01:00
|
|
|
<< /*: Language column of language list. */ tr("Language")
|
|
|
|
<< /*: Lang. code column of language list. */ tr("Code")
|
2013-09-25 20:21:32 +02:00
|
|
|
<< tr("Version")
|
|
|
|
<< tr("Author")
|
|
|
|
<< tr("Email"));
|
|
|
|
|
|
|
|
m_ui->m_treeSkins->setColumnCount(4);
|
|
|
|
m_ui->m_treeSkins->setHeaderHidden(false);
|
|
|
|
m_ui->m_treeSkins->setHeaderLabels(QStringList()
|
2014-02-27 18:15:16 +01:00
|
|
|
<< /*: Skin list name column. */ tr("Name")
|
|
|
|
<< /*: Version column of skin list. */ tr("Version")
|
2013-09-25 20:21:32 +02:00
|
|
|
<< tr("Author")
|
|
|
|
<< tr("Email"));
|
|
|
|
|
2013-08-30 17:40:17 +02:00
|
|
|
#if QT_VERSION >= 0x050000
|
2013-09-20 18:18:49 +02:00
|
|
|
// Setup languages.
|
2013-06-27 19:57:23 +02:00
|
|
|
m_ui->m_treeLanguages->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
|
2013-09-20 18:18:49 +02:00
|
|
|
|
|
|
|
// Setup skins.
|
|
|
|
m_ui->m_treeSkins->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
|
2013-08-30 17:40:17 +02:00
|
|
|
#else
|
2013-09-20 18:18:49 +02:00
|
|
|
// Setup languages.
|
2013-08-30 17:40:17 +02:00
|
|
|
m_ui->m_treeLanguages->header()->setResizeMode(0, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setResizeMode(2, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setResizeMode(3, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setResizeMode(4, QHeaderView::ResizeToContents);
|
2013-09-20 18:18:49 +02:00
|
|
|
|
|
|
|
// Setup skins.
|
|
|
|
m_ui->m_treeSkins->header()->setResizeMode(0, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setResizeMode(2, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setResizeMode(3, QHeaderView::ResizeToContents);
|
2013-08-30 17:40:17 +02:00
|
|
|
#endif
|
|
|
|
|
2013-06-15 19:48:56 +02:00
|
|
|
// Establish needed connections.
|
2013-09-20 18:18:49 +02:00
|
|
|
connect(m_ui->m_buttonBox, SIGNAL(accepted()),
|
|
|
|
this, SLOT(saveSettings()));
|
2013-08-30 17:40:17 +02:00
|
|
|
connect(m_ui->m_cmbProxyType, SIGNAL(currentIndexChanged(int)),
|
|
|
|
this, SLOT(onProxyTypeChanged(int)));
|
|
|
|
connect(m_ui->m_checkShowPassword, SIGNAL(stateChanged(int)),
|
|
|
|
this, SLOT(displayProxyPassword(int)));
|
2013-12-21 21:08:52 +01:00
|
|
|
connect(m_ui->m_btnWebBrowserColorSample, SIGNAL(clicked()),
|
2013-08-30 17:40:17 +02:00
|
|
|
this, SLOT(changeBrowserProgressColor()));
|
2013-09-22 07:38:42 +02:00
|
|
|
connect(m_ui->m_treeSkins, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
|
|
|
|
this, SLOT(onSkinSelected(QTreeWidgetItem*,QTreeWidgetItem*)));
|
2013-12-09 16:05:16 +01:00
|
|
|
connect(m_ui->m_cmbExternalBrowserPreset, SIGNAL(currentIndexChanged(int)),
|
|
|
|
this, SLOT(changeDefaultBrowserArguments(int)));
|
2013-12-11 15:00:15 +01:00
|
|
|
connect(m_ui->m_btnExternalBrowserExecutable, SIGNAL(clicked()),
|
|
|
|
this, SLOT(selectBrowserExecutable()));
|
2014-02-08 09:12:00 +01:00
|
|
|
connect(m_ui->m_txtMysqlUsername->lineEdit(), SIGNAL(textChanged(QString)),
|
|
|
|
this, SLOT(onMysqlUsernameChanged(QString)));
|
|
|
|
connect(m_ui->m_txtMysqlHostname->lineEdit(), SIGNAL(textChanged(QString)),
|
|
|
|
this, SLOT(onMysqlHostnameChanged(QString)));
|
|
|
|
connect(m_ui->m_txtMysqlPassword->lineEdit(), SIGNAL(textChanged(QString)),
|
|
|
|
this, SLOT(onMysqlPasswordChanged(QString)));
|
|
|
|
connect(m_ui->m_btnMysqlTestSetup, SIGNAL(clicked()),
|
|
|
|
this, SLOT(mysqlTestConnection()));
|
2014-02-08 22:13:58 +01:00
|
|
|
connect(m_ui->m_spinMysqlPort, SIGNAL(editingFinished()),
|
|
|
|
this, SLOT(onMysqlDataStorageEdited()));
|
|
|
|
connect(m_ui->m_txtMysqlHostname->lineEdit(), SIGNAL(textEdited(QString)),
|
|
|
|
this, SLOT(onMysqlDataStorageEdited()));
|
|
|
|
connect(m_ui->m_txtMysqlPassword->lineEdit(), SIGNAL(textEdited(QString)),
|
|
|
|
this, SLOT(onMysqlDataStorageEdited()));
|
|
|
|
connect(m_ui->m_txtMysqlUsername->lineEdit(), SIGNAL(textEdited(QString)),
|
|
|
|
this, SLOT(onMysqlDataStorageEdited()));
|
2013-06-15 19:48:56 +02:00
|
|
|
|
|
|
|
// Load all settings.
|
2013-06-24 16:18:13 +02:00
|
|
|
loadGeneral();
|
2014-02-07 21:39:59 +01:00
|
|
|
loadDataStorage();
|
2013-06-30 15:22:44 +02:00
|
|
|
loadShortcuts();
|
2013-06-15 19:48:56 +02:00
|
|
|
loadInterface();
|
2013-07-02 18:57:04 +02:00
|
|
|
loadProxy();
|
2013-07-24 19:06:09 +02:00
|
|
|
loadBrowser();
|
2013-06-27 19:57:23 +02:00
|
|
|
loadLanguage();
|
2013-12-09 16:05:16 +01:00
|
|
|
loadFeedsMessages();
|
2013-06-14 22:15:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FormSettings::~FormSettings() {
|
2013-12-21 21:08:52 +01:00
|
|
|
qDebug("Destroying FormSettings distance.");
|
2013-06-14 22:15:37 +02:00
|
|
|
delete m_ui;
|
|
|
|
}
|
2013-06-15 19:48:56 +02:00
|
|
|
|
2013-12-09 16:05:16 +01:00
|
|
|
void FormSettings::changeDefaultBrowserArguments(int index) {
|
|
|
|
if (index != 0) {
|
|
|
|
m_ui->m_txtExternalBrowserArguments->setText(m_ui->m_cmbExternalBrowserPreset->itemData(index).toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-22 07:38:42 +02:00
|
|
|
void FormSettings::onSkinSelected(QTreeWidgetItem *current,
|
|
|
|
QTreeWidgetItem *previous) {
|
2013-12-12 10:10:17 +01:00
|
|
|
Q_UNUSED(previous)
|
2013-09-22 07:38:42 +02:00
|
|
|
|
|
|
|
if (current != NULL) {
|
|
|
|
Skin skin = current->data(0, Qt::UserRole).value<Skin>();
|
|
|
|
m_ui->m_lblSelectedContents->setText(skin.m_visibleName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-20 21:11:52 +02:00
|
|
|
void FormSettings::changeBrowserProgressColor() {
|
2013-12-21 21:08:52 +01:00
|
|
|
QPointer<QColorDialog> color_dialog = new QColorDialog(m_initialSettings.m_webBrowserProgress,
|
2013-12-26 15:56:37 +01:00
|
|
|
this);
|
2013-12-21 21:08:52 +01:00
|
|
|
color_dialog.data()->setWindowTitle(tr("Select color for web browser progress bar"));
|
2014-02-16 08:24:27 +01:00
|
|
|
color_dialog.data()->setOption(QColorDialog::ShowAlphaChannel, false);
|
2013-12-19 08:54:31 +01:00
|
|
|
|
2013-12-21 21:08:52 +01:00
|
|
|
if (color_dialog.data()->exec() == QDialog::Accepted) {
|
|
|
|
m_initialSettings.m_webBrowserProgress = color_dialog.data()->selectedColor();
|
2013-12-19 08:06:55 +01:00
|
|
|
loadWebBrowserColor(m_initialSettings.m_webBrowserProgress);
|
|
|
|
}
|
2013-12-21 21:08:52 +01:00
|
|
|
|
|
|
|
delete color_dialog.data();
|
2013-07-20 21:11:52 +02:00
|
|
|
}
|
|
|
|
|
2013-12-11 15:00:15 +01:00
|
|
|
void FormSettings::selectBrowserExecutable() {
|
|
|
|
QString executable_file = QFileDialog::getOpenFileName(this,
|
|
|
|
tr("Select web browser executable"),
|
|
|
|
QDir::homePath(),
|
2014-02-27 18:15:16 +01:00
|
|
|
//: File filter for external browser selection dialog.
|
2013-12-11 15:00:15 +01:00
|
|
|
tr("Executables (*.*)"));
|
|
|
|
|
|
|
|
if (!executable_file.isEmpty()) {
|
2013-12-17 18:16:09 +01:00
|
|
|
m_ui->m_txtExternalBrowserExecutable->setText(executable_file);
|
2013-12-11 15:00:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-09 16:05:16 +01:00
|
|
|
void FormSettings::loadFeedsMessages() {
|
2014-02-18 17:15:05 +01:00
|
|
|
m_ui->m_checkKeppMessagesInTheMiddle->setChecked(Settings::instance()->value(APP_CFG_MESSAGES, "keep_cursor_center", false).toBool());
|
2014-02-02 21:04:15 +01:00
|
|
|
m_ui->m_checkRemoveReadMessagesOnExit->setChecked(Settings::instance()->value(APP_CFG_MESSAGES, "clear_read_on_exit", false).toBool());
|
2014-02-03 18:16:48 +01:00
|
|
|
m_ui->m_checkAutoUpdate->setChecked(Settings::instance()->value(APP_CFG_FEEDS, "auto_update_enabled", false).toBool());
|
|
|
|
m_ui->m_spinAutoUpdateInterval->setValue(Settings::instance()->value(APP_CFG_FEEDS, "auto_update_interval", DEFAULT_AUTO_UPDATE_INTERVAL).toInt());
|
2014-02-05 08:51:42 +01:00
|
|
|
m_ui->m_spinFeedUpdateTimeout->setValue(Settings::instance()->value(APP_CFG_FEEDS, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt());
|
2014-02-07 07:33:37 +01:00
|
|
|
m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(Settings::instance()->value(APP_CFG_FEEDS, "feeds_update_on_startup", false).toBool());
|
2013-12-09 16:05:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveFeedsMessages() {
|
2014-02-18 17:15:05 +01:00
|
|
|
Settings::instance()->setValue(APP_CFG_MESSAGES, "keep_cursor_center", m_ui->m_checkKeppMessagesInTheMiddle->isChecked());
|
2014-02-02 21:04:15 +01:00
|
|
|
Settings::instance()->setValue(APP_CFG_MESSAGES, "clear_read_on_exit", m_ui->m_checkRemoveReadMessagesOnExit->isChecked());
|
2014-02-03 18:16:48 +01:00
|
|
|
Settings::instance()->setValue(APP_CFG_FEEDS, "auto_update_enabled", m_ui->m_checkAutoUpdate->isChecked());
|
|
|
|
Settings::instance()->setValue(APP_CFG_FEEDS, "auto_update_interval", m_ui->m_spinAutoUpdateInterval->value());
|
2014-02-05 08:51:42 +01:00
|
|
|
Settings::instance()->setValue(APP_CFG_FEEDS, "feed_update_timeout", m_ui->m_spinFeedUpdateTimeout->value());
|
2014-02-07 07:33:37 +01:00
|
|
|
Settings::instance()->setValue(APP_CFG_FEEDS, "feeds_update_on_startup", m_ui->m_checkUpdateAllFeedsOnStartup->isChecked());
|
2014-02-03 18:16:48 +01:00
|
|
|
|
2014-02-04 10:02:07 +01:00
|
|
|
FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->updateAutoUpdateStatus();
|
2013-12-09 16:05:16 +01:00
|
|
|
}
|
|
|
|
|
2013-07-17 20:42:42 +02:00
|
|
|
void FormSettings::displayProxyPassword(int state) {
|
|
|
|
if (state == Qt::Checked) {
|
|
|
|
m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::Normal);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-20 18:18:49 +02:00
|
|
|
bool FormSettings::doSaveCheck() {
|
|
|
|
bool everything_ok = true;
|
2013-12-07 20:33:41 +01:00
|
|
|
QStringList resulting_information;
|
2013-09-20 18:18:49 +02:00
|
|
|
|
2013-12-07 20:33:41 +01:00
|
|
|
// Setup indication of settings consistence.
|
2013-09-20 18:18:49 +02:00
|
|
|
if (!m_ui->m_shortcuts->areShortcutsUnique()) {
|
2013-12-10 22:06:45 +01:00
|
|
|
everything_ok = false;
|
2013-12-20 16:30:39 +01:00
|
|
|
resulting_information.append(tr("some keyboard shortcuts are not unique"));
|
2013-09-20 18:18:49 +02:00
|
|
|
}
|
|
|
|
|
2014-03-02 18:35:17 +01:00
|
|
|
// User selected custom external browser but did not set its
|
|
|
|
// properties.
|
|
|
|
if (m_ui->m_grpCustomExternalBrowser->isChecked() &&
|
|
|
|
(m_ui->m_txtExternalBrowserExecutable->text().simplified().isEmpty() ||
|
|
|
|
!m_ui->m_txtExternalBrowserArguments->text().simplified().contains("%1"))) {
|
|
|
|
everything_ok = false;
|
|
|
|
resulting_information.append(tr("custom external browser is not set correctly"));
|
|
|
|
}
|
|
|
|
|
2013-09-20 18:18:49 +02:00
|
|
|
if (!everything_ok) {
|
2013-12-20 16:30:39 +01:00
|
|
|
resulting_information.replaceInStrings(QRegExp("^"),
|
|
|
|
QString::fromUtf8(" • "));
|
|
|
|
|
2014-01-22 20:29:05 +01:00
|
|
|
MessageBox::show(this,
|
|
|
|
QMessageBox::Critical,
|
|
|
|
tr("Cannot save settings"),
|
|
|
|
tr("Some critical settings are not set. You must fix these settings in order confirm new settings."),
|
|
|
|
QString(),
|
|
|
|
tr("List of errors:\n%1.").arg(resulting_information.join(",\n")));
|
2013-09-20 18:18:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return everything_ok;
|
|
|
|
}
|
|
|
|
|
2013-12-19 08:06:55 +01:00
|
|
|
void FormSettings::loadWebBrowserColor(const QColor &color) {
|
|
|
|
m_ui->m_btnWebBrowserColorSample->setStyleSheet(QString("QToolButton { background-color: rgba(%1, %2, %3, %4); }").arg(QString::number(color.red()),
|
|
|
|
QString::number(color.green()),
|
|
|
|
QString::number(color.blue()),
|
|
|
|
QString::number(color.alpha())));
|
|
|
|
}
|
|
|
|
|
2013-11-30 22:23:01 +01:00
|
|
|
void FormSettings::promptForRestart() {
|
|
|
|
if (m_changedDataTexts.count() > 0) {
|
2013-12-20 16:30:39 +01:00
|
|
|
QStringList changed_data_texts = m_changedDataTexts;
|
2013-11-30 22:23:01 +01:00
|
|
|
|
2013-12-20 16:30:39 +01:00
|
|
|
changed_data_texts.replaceInStrings(QRegExp("^"),
|
2013-12-26 15:56:37 +01:00
|
|
|
QString::fromUtf8(" • "));
|
2013-12-20 16:30:39 +01:00
|
|
|
|
2014-01-22 20:29:05 +01:00
|
|
|
int question_result = MessageBox::show(this,
|
|
|
|
QMessageBox::Question,
|
|
|
|
tr("Critical settings were changed"),
|
|
|
|
tr("Some critical settings were changed and will be applied after the application gets restarted."),
|
|
|
|
tr("Do you want to restart now?"),
|
|
|
|
tr("List of changes:\n%1.").arg(changed_data_texts.join(",\n")),
|
|
|
|
QMessageBox::Yes | QMessageBox::No,
|
|
|
|
QMessageBox::Yes);
|
2013-11-30 22:23:01 +01:00
|
|
|
|
2013-12-21 21:08:52 +01:00
|
|
|
if (question_result == QMessageBox::Yes) {
|
2013-11-30 22:23:01 +01:00
|
|
|
if (!QProcess::startDetached(qApp->applicationFilePath())) {
|
2014-01-22 20:29:05 +01:00
|
|
|
MessageBox::show(this,
|
|
|
|
QMessageBox::Warning,
|
|
|
|
tr("Problem with application restart"),
|
|
|
|
tr("Application couldn't be restarted. Please, restart it manually for changes to take effect."));
|
2013-11-30 22:23:01 +01:00
|
|
|
}
|
|
|
|
else {
|
2014-03-01 10:03:00 +01:00
|
|
|
QtSingleApplication::instance()->unlock();
|
2013-11-30 22:23:01 +01:00
|
|
|
qApp->quit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-15 19:48:56 +02:00
|
|
|
void FormSettings::saveSettings() {
|
2013-09-20 18:18:49 +02:00
|
|
|
// Make sure everything is saveable.
|
|
|
|
if (!doSaveCheck()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-24 16:18:13 +02:00
|
|
|
// Save all settings.
|
|
|
|
saveGeneral();
|
2014-02-07 21:39:59 +01:00
|
|
|
saveDataStorage();
|
2013-06-30 15:22:44 +02:00
|
|
|
saveShortcuts();
|
2013-06-15 19:48:56 +02:00
|
|
|
saveInterface();
|
2013-07-02 18:57:04 +02:00
|
|
|
saveProxy();
|
2013-07-24 19:06:09 +02:00
|
|
|
saveBrowser();
|
2013-06-27 19:57:23 +02:00
|
|
|
saveLanguage();
|
2013-12-09 16:05:16 +01:00
|
|
|
saveFeedsMessages();
|
2013-06-30 19:02:24 +02:00
|
|
|
|
2014-01-10 09:18:29 +01:00
|
|
|
Settings::instance()->checkSettings();
|
2013-11-30 22:23:01 +01:00
|
|
|
promptForRestart();
|
2013-09-20 18:18:49 +02:00
|
|
|
|
|
|
|
accept();
|
2013-06-27 19:57:23 +02:00
|
|
|
}
|
|
|
|
|
2013-07-02 18:57:04 +02:00
|
|
|
void FormSettings::onProxyTypeChanged(int index) {
|
|
|
|
QNetworkProxy::ProxyType selected_type = static_cast<QNetworkProxy::ProxyType>(m_ui->m_cmbProxyType->itemData(index).toInt());
|
2014-02-14 17:22:20 +01:00
|
|
|
bool is_proxy_selected = selected_type != QNetworkProxy::NoProxy && selected_type != QNetworkProxy::DefaultProxy;
|
2013-07-02 18:57:04 +02:00
|
|
|
|
2013-07-07 15:17:25 +02:00
|
|
|
m_ui->m_txtProxyHost->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_txtProxyPassword->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_txtProxyUsername->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_spinProxyPort->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_checkShowPassword->setEnabled(is_proxy_selected);
|
2013-07-23 20:42:06 +02:00
|
|
|
m_ui->m_lblProxyHost->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_lblProxyInfo->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_lblProxyPassword->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_lblProxyPort->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_lblProxyUsername->setEnabled(is_proxy_selected);
|
2013-07-02 18:57:04 +02:00
|
|
|
}
|
|
|
|
|
2013-07-24 19:06:09 +02:00
|
|
|
void FormSettings::loadBrowser() {
|
2014-01-10 09:18:29 +01:00
|
|
|
Settings *settings = Settings::instance();
|
2013-08-30 17:40:17 +02:00
|
|
|
|
2013-07-24 19:06:09 +02:00
|
|
|
// Load settings of web browser GUI.
|
2014-02-16 08:24:27 +01:00
|
|
|
m_initialSettings.m_webBrowserProgress = QColor(settings->value(APP_CFG_BROWSER,
|
|
|
|
"browser_progress_color",
|
2014-02-16 18:43:33 +01:00
|
|
|
QColor(155, 250, 80)).toString());
|
2013-08-30 17:40:17 +02:00
|
|
|
m_ui->m_checkBrowserProgressColor->setChecked(settings->value(APP_CFG_BROWSER,
|
|
|
|
"browser_colored_progress_enabled",
|
|
|
|
true).toBool());
|
|
|
|
m_ui->m_checkMouseGestures->setChecked(settings->value(APP_CFG_BROWSER,
|
|
|
|
"gestures_enabled",
|
|
|
|
true).toBool());
|
|
|
|
m_ui->m_checkQueueTabs->setChecked(settings->value(APP_CFG_BROWSER,
|
|
|
|
"queue_tabs",
|
|
|
|
true).toBool());
|
2014-02-16 08:24:27 +01:00
|
|
|
m_ui->m_btnWebBrowserColorSample->setMaximumHeight(m_ui->m_checkBrowserProgressColor->sizeHint().height());
|
|
|
|
loadWebBrowserColor(m_initialSettings.m_webBrowserProgress);
|
2014-02-01 17:32:31 +01:00
|
|
|
|
|
|
|
m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), "-nosession %1");
|
|
|
|
m_ui->m_txtExternalBrowserExecutable->setText(settings->value(APP_CFG_BROWSER,
|
|
|
|
"external_browser_executable").toString());
|
|
|
|
m_ui->m_txtExternalBrowserArguments->setText(settings->value(APP_CFG_BROWSER,
|
|
|
|
"external_browser_arguments",
|
|
|
|
"%1").toString());
|
2014-03-02 18:35:17 +01:00
|
|
|
m_ui->m_grpCustomExternalBrowser->setChecked(settings->value(APP_CFG_BROWSER,
|
|
|
|
"custom_external_browser",
|
|
|
|
false).toBool());
|
2013-07-24 19:06:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveBrowser() {
|
2014-01-10 09:18:29 +01:00
|
|
|
Settings *settings = Settings::instance();
|
2013-08-30 17:40:17 +02:00
|
|
|
|
2013-07-24 19:06:09 +02:00
|
|
|
// Save settings of GUI of web browser.
|
2014-03-02 18:35:17 +01:00
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"custom_external_browser",
|
|
|
|
m_ui->m_grpCustomExternalBrowser->isChecked());
|
2013-08-30 17:40:17 +02:00
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"browser_progress_color",
|
2014-02-16 08:24:27 +01:00
|
|
|
m_initialSettings.m_webBrowserProgress.name());
|
2013-08-30 17:40:17 +02:00
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"browser_colored_progress_enabled",
|
|
|
|
m_ui->m_checkBrowserProgressColor->isChecked());
|
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"gestures_enabled",
|
|
|
|
m_ui->m_checkMouseGestures->isChecked());
|
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"queue_tabs",
|
|
|
|
m_ui->m_checkQueueTabs->isChecked());
|
2014-02-01 17:32:31 +01:00
|
|
|
|
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"external_browser_executable",
|
|
|
|
m_ui->m_txtExternalBrowserExecutable->text());
|
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"external_browser_arguments",
|
|
|
|
m_ui->m_txtExternalBrowserArguments->text());
|
2013-07-24 19:06:09 +02:00
|
|
|
}
|
|
|
|
|
2013-07-02 18:57:04 +02:00
|
|
|
void FormSettings::loadProxy() {
|
2014-02-16 08:24:27 +01:00
|
|
|
m_ui->m_cmbProxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy);
|
|
|
|
m_ui->m_cmbProxyType->addItem(tr("System proxy"), QNetworkProxy::DefaultProxy);
|
2013-07-02 18:57:04 +02:00
|
|
|
m_ui->m_cmbProxyType->addItem(tr("Socks5"), QNetworkProxy::Socks5Proxy);
|
|
|
|
m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy);
|
2013-07-17 20:42:42 +02:00
|
|
|
|
|
|
|
// Load the settings.
|
2014-01-10 09:18:29 +01:00
|
|
|
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(Settings::instance()->value(APP_CFG_PROXY,
|
2014-01-12 19:46:20 +01:00
|
|
|
"proxy_type",
|
|
|
|
QNetworkProxy::NoProxy).toInt());
|
2014-01-10 09:18:29 +01:00
|
|
|
Settings *settings = Settings::instance();
|
2013-08-30 17:40:17 +02:00
|
|
|
|
2013-07-17 20:42:42 +02:00
|
|
|
m_ui->m_cmbProxyType->setCurrentIndex(m_ui->m_cmbProxyType->findData(selected_proxy_type));
|
2013-08-30 17:40:17 +02:00
|
|
|
m_ui->m_txtProxyHost->setText(settings->value(APP_CFG_PROXY,
|
|
|
|
"host").toString());
|
|
|
|
m_ui->m_txtProxyUsername->setText(settings->value(APP_CFG_PROXY,
|
|
|
|
"username").toString());
|
|
|
|
m_ui->m_txtProxyPassword->setText(settings->value(APP_CFG_PROXY,
|
|
|
|
"password").toString());
|
|
|
|
m_ui->m_spinProxyPort->setValue(settings->value(APP_CFG_PROXY,
|
|
|
|
"port", 80).toInt());
|
2013-07-02 18:57:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveProxy() {
|
2014-01-10 09:18:29 +01:00
|
|
|
Settings *settings = Settings::instance();
|
2013-08-30 17:40:17 +02:00
|
|
|
|
|
|
|
settings->setValue(APP_CFG_PROXY, "proxy_type",
|
|
|
|
m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex()));
|
|
|
|
settings->setValue(APP_CFG_PROXY, "host",
|
|
|
|
m_ui->m_txtProxyHost->text());
|
|
|
|
settings->setValue(APP_CFG_PROXY, "username",
|
|
|
|
m_ui->m_txtProxyUsername->text());
|
|
|
|
settings->setValue(APP_CFG_PROXY, "password",
|
|
|
|
m_ui->m_txtProxyPassword->text());
|
|
|
|
settings->setValue(APP_CFG_PROXY, "port",
|
|
|
|
m_ui->m_spinProxyPort->value());
|
2013-07-18 17:44:23 +02:00
|
|
|
|
|
|
|
// Reload settings for all network access managers.
|
2014-02-24 10:32:14 +01:00
|
|
|
WebBrowserNetworkAccessManager::instance()->loadSettings();
|
2013-07-02 18:57:04 +02:00
|
|
|
}
|
|
|
|
|
2013-06-27 19:57:23 +02:00
|
|
|
void FormSettings::loadLanguage() {
|
2014-02-17 17:43:37 +01:00
|
|
|
foreach (const Language &language, Localization::instance()->installedLanguages()) {
|
2013-06-27 19:57:23 +02:00
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->m_treeLanguages);
|
2013-12-03 18:38:43 +01:00
|
|
|
item->setText(0, language.m_name);
|
|
|
|
item->setText(1, language.m_code);
|
|
|
|
item->setText(2, language.m_version);
|
|
|
|
item->setText(3, language.m_author);
|
|
|
|
item->setText(4, language.m_email);
|
2014-01-10 09:18:29 +01:00
|
|
|
item->setIcon(0, IconThemeFactory::instance()->fromTheme(language.m_code));
|
2013-06-27 19:57:23 +02:00
|
|
|
}
|
|
|
|
|
2014-02-17 17:43:37 +01:00
|
|
|
QList<QTreeWidgetItem*> matching_items = m_ui->m_treeLanguages->findItems(Localization::instance()->loadedLanguage(),
|
|
|
|
Qt::MatchContains,
|
2013-06-27 19:57:23 +02:00
|
|
|
1);
|
|
|
|
if (!matching_items.isEmpty()) {
|
|
|
|
m_ui->m_treeLanguages->setCurrentItem(matching_items[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveLanguage() {
|
2013-08-30 17:40:17 +02:00
|
|
|
if (m_ui->m_treeLanguages->currentItem() == NULL) {
|
2013-06-29 15:48:15 +02:00
|
|
|
qDebug("No localizations loaded in settings dialog, so no saving for them.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-10 09:18:29 +01:00
|
|
|
Settings *settings = Settings::instance();
|
2014-02-17 17:43:37 +01:00
|
|
|
QString actual_lang = Localization::instance()->loadedLanguage();
|
2013-06-27 19:57:23 +02:00
|
|
|
QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1);
|
|
|
|
|
2013-12-06 15:12:30 +01:00
|
|
|
// Save prompt for restart if language has changed.
|
2013-06-27 19:57:23 +02:00
|
|
|
if (new_lang != actual_lang) {
|
2013-12-20 16:30:39 +01:00
|
|
|
m_changedDataTexts.append(tr("language changed"));
|
2013-08-30 17:40:17 +02:00
|
|
|
settings->setValue(APP_CFG_GEN, "language", new_lang);
|
2013-06-27 19:57:23 +02:00
|
|
|
}
|
2013-06-15 19:48:56 +02:00
|
|
|
}
|
|
|
|
|
2013-06-30 15:22:44 +02:00
|
|
|
void FormSettings::loadShortcuts() {
|
2014-01-13 21:43:35 +01:00
|
|
|
m_ui->m_shortcuts->populate(FormMain::instance()->allActions());
|
2013-06-30 15:22:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveShortcuts() {
|
|
|
|
// Update the actual shortcuts of some actions.
|
|
|
|
m_ui->m_shortcuts->updateShortcuts();
|
|
|
|
|
|
|
|
// Save new shortcuts to the settings.
|
2014-01-13 21:43:35 +01:00
|
|
|
DynamicShortcuts::save(FormMain::instance()->allActions());
|
2013-06-30 15:22:44 +02:00
|
|
|
}
|
|
|
|
|
2014-02-07 21:39:59 +01:00
|
|
|
void FormSettings::loadDataStorage() {
|
2014-02-08 19:23:49 +01:00
|
|
|
onMysqlHostnameChanged(QString());
|
|
|
|
onMysqlUsernameChanged(QString());
|
|
|
|
onMysqlPasswordChanged(QString());
|
|
|
|
|
2014-02-11 17:23:40 +01:00
|
|
|
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Information,
|
2014-02-20 17:08:12 +01:00
|
|
|
tr("No connection test triggered so far."),
|
2014-02-26 17:36:35 +01:00
|
|
|
tr("You did not executed any connection test yet."));
|
2014-02-11 17:23:40 +01:00
|
|
|
|
2014-02-07 21:39:59 +01:00
|
|
|
// Load SQLite.
|
2014-02-08 09:12:00 +01:00
|
|
|
m_ui->m_cmbDatabaseDriver->addItem(
|
|
|
|
tr("SQLite (embedded database)"), APP_DB_DRIVER_SQLITE);
|
2014-02-07 11:49:24 +01:00
|
|
|
|
2014-01-21 07:55:10 +01:00
|
|
|
// Load in-memory database status.
|
2014-02-07 16:57:16 +01:00
|
|
|
m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(Settings::instance()->value(APP_CFG_DB, "use_in_memory_db", false).toBool());
|
2014-02-07 11:49:24 +01:00
|
|
|
|
2014-02-07 14:29:53 +01:00
|
|
|
if (QSqlDatabase::isDriverAvailable(APP_DB_DRIVER_MYSQL)) {
|
2014-02-07 11:49:24 +01:00
|
|
|
// Load MySQL.
|
2014-02-08 09:12:00 +01:00
|
|
|
m_ui->m_cmbDatabaseDriver->addItem(
|
|
|
|
tr("MySQL/MariaDB (dedicated database)"), APP_DB_DRIVER_MYSQL);
|
|
|
|
|
|
|
|
// Setup placeholders.
|
|
|
|
m_ui->m_txtMysqlHostname->lineEdit()->setPlaceholderText(tr("Hostname of your MySQL server"));
|
|
|
|
m_ui->m_txtMysqlUsername->lineEdit()->setPlaceholderText(tr("Username to login with"));
|
|
|
|
m_ui->m_txtMysqlPassword->lineEdit()->setPlaceholderText(tr("Password for your username"));
|
2014-02-07 11:49:24 +01:00
|
|
|
|
2014-02-07 21:39:59 +01:00
|
|
|
m_ui->m_txtMysqlHostname->lineEdit()->setText(Settings::instance()->value(APP_CFG_DB, "mysql_hostname").toString());
|
|
|
|
m_ui->m_txtMysqlUsername->lineEdit()->setText(Settings::instance()->value(APP_CFG_DB, "mysql_username").toString());
|
|
|
|
m_ui->m_txtMysqlPassword->lineEdit()->setText(Settings::instance()->value(APP_CFG_DB, "mysql_password").toString());
|
|
|
|
m_ui->m_spinMysqlPort->setValue(Settings::instance()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt());
|
2014-02-07 11:49:24 +01:00
|
|
|
}
|
|
|
|
|
2014-02-09 17:12:05 +01:00
|
|
|
int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(Settings::instance()->value(APP_CFG_DB,
|
|
|
|
"database_driver",
|
|
|
|
APP_DB_DRIVER_SQLITE).toString());
|
|
|
|
|
|
|
|
if (index_current_backend >= 0) {
|
|
|
|
m_ui->m_cmbDatabaseDriver->setCurrentIndex(index_current_backend);
|
|
|
|
}
|
2013-06-24 16:18:13 +02:00
|
|
|
}
|
|
|
|
|
2014-02-07 21:39:59 +01:00
|
|
|
void FormSettings::saveDataStorage() {
|
2014-01-21 07:55:10 +01:00
|
|
|
// Setup in-memory database status.
|
2014-02-07 16:57:16 +01:00
|
|
|
bool original_inmemory = Settings::instance()->value(APP_CFG_DB, "use_in_memory_db", false).toBool();
|
|
|
|
bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked();
|
2014-01-21 07:55:10 +01:00
|
|
|
|
|
|
|
if (original_inmemory != new_inmemory) {
|
|
|
|
m_changedDataTexts.append(tr("in-memory database switched"));
|
|
|
|
}
|
|
|
|
|
2014-02-07 11:49:24 +01:00
|
|
|
// Save data storage settings.
|
2014-02-07 16:57:16 +01:00
|
|
|
QString original_db_driver = Settings::instance()->value(APP_CFG_DB, "database_driver", APP_DB_DRIVER_SQLITE).toString();
|
2014-02-07 11:49:24 +01:00
|
|
|
QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(m_ui->m_cmbDatabaseDriver->currentIndex()).toString();
|
|
|
|
|
|
|
|
// Save SQLite.
|
2014-02-07 16:57:16 +01:00
|
|
|
Settings::instance()->setValue(APP_CFG_DB, "use_in_memory_db", new_inmemory);
|
2014-02-07 11:49:24 +01:00
|
|
|
|
2014-02-07 14:29:53 +01:00
|
|
|
if (QSqlDatabase::isDriverAvailable(APP_DB_DRIVER_MYSQL)) {
|
2014-02-07 11:49:24 +01:00
|
|
|
// Save MySQL.
|
2014-02-07 21:39:59 +01:00
|
|
|
Settings::instance()->setValue(APP_CFG_DB, "mysql_hostname", m_ui->m_txtMysqlHostname->lineEdit()->text());
|
|
|
|
Settings::instance()->setValue(APP_CFG_DB, "mysql_username", m_ui->m_txtMysqlUsername->lineEdit()->text());
|
|
|
|
Settings::instance()->setValue(APP_CFG_DB, "mysql_password", m_ui->m_txtMysqlPassword->lineEdit()->text());
|
|
|
|
Settings::instance()->setValue(APP_CFG_DB, "mysql_port", m_ui->m_spinMysqlPort->value());
|
2014-02-07 11:49:24 +01:00
|
|
|
}
|
|
|
|
|
2014-02-07 16:57:16 +01:00
|
|
|
Settings::instance()->setValue(APP_CFG_DB, "database_driver", selected_db_driver);
|
2014-02-07 11:49:24 +01:00
|
|
|
|
2014-02-08 22:13:58 +01:00
|
|
|
if (original_db_driver != selected_db_driver ||
|
|
|
|
m_initialSettings.m_mysqlDataStorageChanged) {
|
2014-02-07 11:49:24 +01:00
|
|
|
m_changedDataTexts.append(tr("data storage backend changed"));
|
|
|
|
}
|
2013-06-24 16:18:13 +02:00
|
|
|
}
|
|
|
|
|
2014-02-08 09:12:00 +01:00
|
|
|
void FormSettings::mysqlTestConnection() {
|
2014-02-11 17:23:40 +01:00
|
|
|
DatabaseFactory::MySQLError error_code = DatabaseFactory::instance()->mysqlTestConnection(m_ui->m_txtMysqlHostname->lineEdit()->text(),
|
|
|
|
m_ui->m_spinMysqlPort->value(),
|
|
|
|
m_ui->m_txtMysqlUsername->lineEdit()->text(),
|
|
|
|
m_ui->m_txtMysqlPassword->lineEdit()->text());
|
2014-02-20 17:08:12 +01:00
|
|
|
QString interpretation = DatabaseFactory::instance()->mysqlInterpretErrorCode(error_code);
|
2014-02-11 17:23:40 +01:00
|
|
|
|
|
|
|
switch (error_code) {
|
|
|
|
case DatabaseFactory::MySQLOk:
|
|
|
|
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Ok,
|
2014-02-20 17:08:12 +01:00
|
|
|
interpretation,
|
|
|
|
interpretation);
|
2014-02-11 17:23:40 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Error,
|
2014-02-20 17:08:12 +01:00
|
|
|
interpretation,
|
|
|
|
interpretation);
|
2014-02-11 17:23:40 +01:00
|
|
|
break;
|
2014-02-08 09:12:00 +01:00
|
|
|
|
2014-02-11 17:23:40 +01:00
|
|
|
|
|
|
|
}
|
2014-02-08 09:12:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::onMysqlHostnameChanged(const QString &new_hostname) {
|
|
|
|
if (new_hostname.isEmpty()) {
|
|
|
|
m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::Warning,
|
|
|
|
tr("Hostname is empty."));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_ui->m_txtMysqlHostname->setStatus(LineEditWithStatus::Ok,
|
|
|
|
tr("Hostname looks ok."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::onMysqlUsernameChanged(const QString &new_username) {
|
|
|
|
if (new_username.isEmpty()) {
|
|
|
|
m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::Warning,
|
|
|
|
tr("Username is empty."));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_ui->m_txtMysqlUsername->setStatus(LineEditWithStatus::Ok,
|
|
|
|
tr("Username looks ok."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::onMysqlPasswordChanged(const QString &new_password) {
|
|
|
|
if (new_password.isEmpty()) {
|
|
|
|
m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::Warning,
|
|
|
|
tr("Password is empty."));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_ui->m_txtMysqlPassword->setStatus(LineEditWithStatus::Ok,
|
|
|
|
tr("Password looks ok."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-08 22:13:58 +01:00
|
|
|
void FormSettings::onMysqlDataStorageEdited() {
|
|
|
|
m_initialSettings.m_mysqlDataStorageChanged = true;
|
|
|
|
}
|
|
|
|
|
2014-02-07 21:39:59 +01:00
|
|
|
void FormSettings::loadGeneral() {
|
2014-02-26 21:41:13 +01:00
|
|
|
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text().arg(APP_NAME));
|
|
|
|
|
2014-02-07 21:39:59 +01:00
|
|
|
// Load auto-start status.
|
|
|
|
SystemFactory::AutoStartStatus autostart_status = SystemFactory::instance()->getAutoStartStatus();
|
|
|
|
switch (autostart_status) {
|
|
|
|
case SystemFactory::Enabled:
|
|
|
|
m_ui->m_checkAutostart->setChecked(true);
|
|
|
|
break;
|
|
|
|
case SystemFactory::Disabled:
|
|
|
|
m_ui->m_checkAutostart->setChecked(false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_ui->m_checkAutostart->setEnabled(false);
|
|
|
|
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text() +
|
|
|
|
tr(" (not supported on this platform)"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveGeneral() {
|
|
|
|
// If auto-start feature is available and user wants
|
|
|
|
// to turn it on, then turn it on.
|
|
|
|
if (m_ui->m_checkAutostart->isChecked()) {
|
|
|
|
SystemFactory::instance()->setAutoStartStatus(SystemFactory::Enabled);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SystemFactory::instance()->setAutoStartStatus(SystemFactory::Disabled);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-15 19:48:56 +02:00
|
|
|
void FormSettings::loadInterface() {
|
2014-01-10 09:18:29 +01:00
|
|
|
Settings *settings = Settings::instance();
|
2013-08-30 17:40:17 +02:00
|
|
|
|
2013-06-17 20:17:13 +02:00
|
|
|
// Load settings of tray icon.
|
|
|
|
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
2013-08-30 17:40:17 +02:00
|
|
|
m_ui->m_radioTrayOff->setChecked(!settings->value(APP_CFG_GUI,
|
|
|
|
"use_tray_icon",
|
|
|
|
true).toBool());
|
2013-06-17 20:17:13 +02:00
|
|
|
}
|
2013-06-19 21:28:26 +02:00
|
|
|
// Tray icon is not supported on this machine.
|
2013-06-17 20:17:13 +02:00
|
|
|
else {
|
2013-07-30 18:54:36 +02:00
|
|
|
m_ui->m_radioTrayOff->setText(tr("Disable (Tray icon is not available.)"));
|
2013-06-17 20:17:13 +02:00
|
|
|
m_ui->m_radioTrayOff->setChecked(true);
|
|
|
|
m_ui->m_grpTray->setDisabled(true);
|
|
|
|
}
|
|
|
|
|
2014-02-13 19:25:57 +01:00
|
|
|
m_ui->m_checkHidden->setChecked(settings->value(APP_CFG_GUI,
|
|
|
|
"start_hidden",
|
|
|
|
false).toBool());
|
|
|
|
m_ui->m_checkHideWhenMinimized->setChecked(settings->value(APP_CFG_GUI,
|
|
|
|
"hide_when_minimized",
|
|
|
|
false).toBool());
|
|
|
|
|
2013-06-17 20:17:13 +02:00
|
|
|
// Load settings of icon theme.
|
2014-01-10 09:18:29 +01:00
|
|
|
QString current_theme = IconThemeFactory::instance()->currentIconTheme();
|
2013-06-15 19:48:56 +02:00
|
|
|
|
2014-01-10 09:18:29 +01:00
|
|
|
foreach (const QString &icon_theme_name, IconThemeFactory::instance()->installedIconThemes()) {
|
2013-12-10 08:03:30 +01:00
|
|
|
if (icon_theme_name == APP_NO_THEME) {
|
2013-12-08 14:02:28 +01:00
|
|
|
// Add just "no theme" on other systems.
|
2014-02-26 21:41:13 +01:00
|
|
|
//: Label for disabling icon theme.
|
2013-08-03 07:34:41 +02:00
|
|
|
m_ui->m_cmbIconTheme->addItem(tr("no icon theme"),
|
2013-12-10 08:03:30 +01:00
|
|
|
APP_NO_THEME);
|
2013-06-15 19:48:56 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_ui->m_cmbIconTheme->addItem(icon_theme_name,
|
|
|
|
icon_theme_name);
|
|
|
|
}
|
2013-08-03 07:34:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mark active theme.
|
2013-12-10 08:03:30 +01:00
|
|
|
if (current_theme == APP_NO_THEME) {
|
|
|
|
// Because "no icon theme" lies at the index 0.
|
2013-08-03 07:34:41 +02:00
|
|
|
m_ui->m_cmbIconTheme->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
else {
|
2013-08-30 17:40:17 +02:00
|
|
|
#if QT_VERSION >= 0x050000
|
2013-08-03 07:34:41 +02:00
|
|
|
m_ui->m_cmbIconTheme->setCurrentText(current_theme);
|
2013-08-30 17:40:17 +02:00
|
|
|
#else
|
|
|
|
int theme_index = m_ui->m_cmbIconTheme->findText(current_theme);
|
|
|
|
if (theme_index >= 0) {
|
|
|
|
m_ui->m_cmbIconTheme->setCurrentIndex(theme_index);
|
|
|
|
}
|
|
|
|
#endif
|
2013-09-22 07:38:42 +02:00
|
|
|
}
|
2013-09-20 18:18:49 +02:00
|
|
|
|
2013-09-22 07:38:42 +02:00
|
|
|
// Load skin.
|
2014-01-10 09:18:29 +01:00
|
|
|
QString selected_skin = SkinFactory::instance()->selectedSkinName();
|
2013-09-20 18:18:49 +02:00
|
|
|
|
2014-01-10 09:18:29 +01:00
|
|
|
foreach (const Skin &skin, SkinFactory::instance()->installedSkins()) {
|
2013-09-22 07:38:42 +02:00
|
|
|
QTreeWidgetItem *new_item = new QTreeWidgetItem(QStringList() <<
|
|
|
|
skin.m_visibleName <<
|
|
|
|
skin.m_version <<
|
|
|
|
skin.m_author <<
|
|
|
|
skin.m_email);
|
|
|
|
new_item->setData(0, Qt::UserRole, QVariant::fromValue(skin));
|
2013-09-20 18:18:49 +02:00
|
|
|
|
2013-09-22 07:38:42 +02:00
|
|
|
// Add this skin and mark it as active if its active now.
|
|
|
|
m_ui->m_treeSkins->addTopLevelItem(new_item);
|
2013-09-20 18:18:49 +02:00
|
|
|
|
2013-09-22 07:38:42 +02:00
|
|
|
if (skin.m_baseName == selected_skin) {
|
|
|
|
m_ui->m_treeSkins->setCurrentItem(new_item);
|
2013-11-15 11:03:12 +01:00
|
|
|
m_ui->m_lblActiveContents->setText(skin.m_visibleName);
|
2013-09-20 18:18:49 +02:00
|
|
|
}
|
2013-06-15 19:48:56 +02:00
|
|
|
}
|
2013-07-30 18:54:36 +02:00
|
|
|
|
2013-11-15 11:03:12 +01:00
|
|
|
if (m_ui->m_treeSkins->currentItem() == NULL &&
|
|
|
|
m_ui->m_treeSkins->topLevelItemCount() > 0) {
|
|
|
|
// Currently active skin is NOT available, select another one as selected
|
|
|
|
// if possible.
|
2013-09-22 07:38:42 +02:00
|
|
|
m_ui->m_treeSkins->setCurrentItem(m_ui->m_treeSkins->topLevelItem(0));
|
|
|
|
}
|
|
|
|
|
2013-07-30 18:54:36 +02:00
|
|
|
// Load tab settings.
|
2013-08-30 17:40:17 +02:00
|
|
|
m_ui->m_checkCloseTabsMiddleClick->setChecked(settings->value(APP_CFG_GUI,
|
|
|
|
"tab_close_mid_button",
|
|
|
|
true).toBool());
|
|
|
|
m_ui->m_checkCloseTabsDoubleClick->setChecked(settings->value(APP_CFG_GUI,
|
|
|
|
"tab_close_double_button",
|
|
|
|
true).toBool());
|
|
|
|
m_ui->m_checkNewTabDoubleClick->setChecked(settings->value(APP_CFG_GUI,
|
|
|
|
"tab_new_double_button",
|
|
|
|
true).toBool());
|
2013-11-09 08:48:13 +01:00
|
|
|
m_ui->m_hideTabBarIfOneTabVisible->setChecked(settings->value(APP_CFG_GUI,
|
|
|
|
"hide_tabbar_one_tab",
|
|
|
|
true).toBool());
|
2014-02-10 17:19:43 +01:00
|
|
|
|
|
|
|
// Load toolbar button style.
|
2014-02-16 08:24:27 +01:00
|
|
|
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Icon only"), Qt::ToolButtonIconOnly);
|
|
|
|
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Text only"), Qt::ToolButtonTextOnly);
|
|
|
|
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Text beside icon"), Qt::ToolButtonTextBesideIcon);
|
|
|
|
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Text under icon"), Qt::ToolButtonTextUnderIcon);
|
|
|
|
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Follow OS style"), Qt::ToolButtonFollowStyle);
|
2014-02-10 17:19:43 +01:00
|
|
|
|
|
|
|
m_ui->m_cmbToolbarButtonStyle->setCurrentIndex(m_ui->m_cmbToolbarButtonStyle->findData(Settings::instance()->value(APP_CFG_GUI,
|
|
|
|
"toolbar_style",
|
|
|
|
Qt::ToolButtonIconOnly).toInt()));
|
|
|
|
|
2013-06-15 19:48:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveInterface() {
|
2014-01-10 09:18:29 +01:00
|
|
|
Settings *settings = Settings::instance();
|
2013-08-30 17:40:17 +02:00
|
|
|
|
2014-02-10 17:19:43 +01:00
|
|
|
// Save toolbar.
|
|
|
|
Settings::instance()->setValue(APP_CFG_GUI,
|
|
|
|
"toolbar_style",
|
|
|
|
m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex()));
|
|
|
|
|
2013-06-17 20:17:13 +02:00
|
|
|
// Save tray icon.
|
|
|
|
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
2013-08-30 17:40:17 +02:00
|
|
|
settings->setValue(APP_CFG_GUI, "use_tray_icon",
|
|
|
|
m_ui->m_radioTrayOn->isChecked());
|
|
|
|
if (settings->value(APP_CFG_GUI, "use_tray_icon", true).toBool()) {
|
2014-01-10 09:18:29 +01:00
|
|
|
SystemTrayIcon::instance()->show();
|
2014-01-13 21:43:35 +01:00
|
|
|
FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->notifyWithCounts();
|
2013-06-19 15:48:33 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-01-10 09:18:29 +01:00
|
|
|
FormMain::instance()->display();
|
2013-06-19 15:48:33 +02:00
|
|
|
SystemTrayIcon::deleteInstance();
|
|
|
|
}
|
2013-06-17 20:17:13 +02:00
|
|
|
}
|
|
|
|
|
2014-02-13 19:25:57 +01:00
|
|
|
settings->setValue(APP_CFG_GUI, "start_hidden",
|
|
|
|
m_ui->m_checkHidden->isChecked());
|
|
|
|
settings->setValue(APP_CFG_GUI,
|
|
|
|
"hide_when_minimized",
|
|
|
|
m_ui->m_checkHideWhenMinimized->isChecked());
|
|
|
|
|
2013-06-15 19:48:56 +02:00
|
|
|
// Save selected icon theme.
|
2013-07-30 18:54:36 +02:00
|
|
|
QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString();
|
2014-01-10 09:18:29 +01:00
|
|
|
QString original_icon_theme = IconThemeFactory::instance()->currentIconTheme();
|
|
|
|
IconThemeFactory::instance()->setCurrentIconTheme(selected_icon_theme);
|
2013-07-30 18:54:36 +02:00
|
|
|
|
2013-12-07 20:33:41 +01:00
|
|
|
// Check if icon theme was changed.
|
2013-12-06 15:12:30 +01:00
|
|
|
if (selected_icon_theme != original_icon_theme) {
|
2013-12-20 16:30:39 +01:00
|
|
|
m_changedDataTexts.append(tr("icon theme changed"));
|
2013-12-06 15:12:30 +01:00
|
|
|
}
|
|
|
|
|
2013-09-20 18:18:49 +02:00
|
|
|
// Save and activate new skin.
|
2013-11-15 22:09:38 +01:00
|
|
|
if (m_ui->m_treeSkins->selectedItems().size() > 0) {
|
|
|
|
Skin active_skin = m_ui->m_treeSkins->currentItem()->data(0, Qt::UserRole).value<Skin>();
|
2013-12-03 18:38:43 +01:00
|
|
|
|
2014-01-10 09:18:29 +01:00
|
|
|
if (SkinFactory::instance()->selectedSkinName() != active_skin.m_baseName) {
|
|
|
|
SkinFactory::instance()->setCurrentSkinName(active_skin.m_baseName);
|
2013-12-20 16:30:39 +01:00
|
|
|
m_changedDataTexts.append(tr("skin changed"));
|
2013-12-03 18:38:43 +01:00
|
|
|
}
|
2013-11-15 22:09:38 +01:00
|
|
|
}
|
2013-09-20 18:18:49 +02:00
|
|
|
|
2013-07-30 18:54:36 +02:00
|
|
|
// Save tab settings.
|
2013-08-30 17:40:17 +02:00
|
|
|
settings->setValue(APP_CFG_GUI, "tab_close_mid_button",
|
|
|
|
m_ui->m_checkCloseTabsMiddleClick->isChecked());
|
|
|
|
settings->setValue(APP_CFG_GUI, "tab_close_double_button",
|
|
|
|
m_ui->m_checkCloseTabsDoubleClick->isChecked());
|
|
|
|
settings->setValue(APP_CFG_GUI, "tab_new_double_button",
|
|
|
|
m_ui->m_checkNewTabDoubleClick->isChecked());
|
2013-11-09 08:48:13 +01:00
|
|
|
settings->setValue(APP_CFG_GUI, "hide_tabbar_one_tab",
|
|
|
|
m_ui->m_hideTabBarIfOneTabVisible->isChecked());
|
2014-01-13 21:43:35 +01:00
|
|
|
|
|
|
|
FormMain::instance()->tabWidget()->checkTabBarVisibility();
|
2014-02-10 17:19:43 +01:00
|
|
|
FormMain::instance()->tabWidget()->feedMessageViewer()->refreshVisualProperties();
|
2013-06-15 19:48:56 +02:00
|
|
|
}
|