From 444c65221a588985120270bd6d7d1f6daa8049b7 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 2 Aug 2016 07:58:08 +0200 Subject: [PATCH] Work on new settings. --- src/gui/dialogs/formabout.h | 8 +- src/gui/dialogs/formaddaccount.h | 4 - src/gui/dialogs/formbackupdatabasesettings.h | 4 - src/gui/dialogs/formdatabasecleanup.h | 4 - src/gui/dialogs/formmain.h | 4 +- src/gui/dialogs/formrestoredatabasesettings.h | 4 - src/gui/dialogs/formsettings.cpp | 742 +------- src/gui/dialogs/formsettings.h | 69 +- src/gui/dialogs/formsettings.ui | 1582 +---------------- src/gui/dialogs/formupdate.h | 7 +- src/gui/settings/settingsbrowsermail.cpp | 170 +- src/gui/settings/settingsbrowsermail.h | 48 +- src/gui/settings/settingsdatabase.cpp | 17 + src/gui/settings/settingsdatabase.h | 21 + src/gui/settings/settingsdownloads.cpp | 68 +- src/gui/settings/settingsdownloads.h | 43 +- src/gui/settings/settingsfeedsmessages.cpp | 117 +- src/gui/settings/settingsfeedsmessages.h | 45 +- src/gui/settings/settingsgeneral.h | 5 +- src/gui/settings/settingsgui.cpp | 34 + src/gui/settings/settingsgui.h | 25 + src/gui/settings/settingslocalization.cpp | 17 + src/gui/settings/settingslocalization.h | 21 + src/gui/settings/settingspanel.h | 2 + src/gui/settings/settingsshortcuts.cpp | 17 + src/gui/settings/settingsshortcuts.h | 21 + 26 files changed, 624 insertions(+), 2475 deletions(-) diff --git a/src/gui/dialogs/formabout.h b/src/gui/dialogs/formabout.h index b573838b4..0d4025b02 100755 --- a/src/gui/dialogs/formabout.h +++ b/src/gui/dialogs/formabout.h @@ -18,16 +18,12 @@ #ifndef FORMABOUT_H #define FORMABOUT_H +#include + #include "ui_formabout.h" #include "definitions/definitions.h" -#include - - -namespace Ui { - class FormAbout; -} class FormAbout : public QDialog { Q_OBJECT diff --git a/src/gui/dialogs/formaddaccount.h b/src/gui/dialogs/formaddaccount.h index 6ff15f1e9..ce215a6ad 100755 --- a/src/gui/dialogs/formaddaccount.h +++ b/src/gui/dialogs/formaddaccount.h @@ -23,10 +23,6 @@ #include "ui_formaddaccount.h" -namespace Ui { - class FormAddAccount; -} - class ServiceEntryPoint; class FeedsModel; diff --git a/src/gui/dialogs/formbackupdatabasesettings.h b/src/gui/dialogs/formbackupdatabasesettings.h index 2b6a3f8a2..5110155c5 100755 --- a/src/gui/dialogs/formbackupdatabasesettings.h +++ b/src/gui/dialogs/formbackupdatabasesettings.h @@ -23,10 +23,6 @@ #include "ui_formbackupdatabasesettings.h" -namespace Ui { - class FormBackupDatabaseSettings; -} - class FormBackupDatabaseSettings : public QDialog { Q_OBJECT diff --git a/src/gui/dialogs/formdatabasecleanup.h b/src/gui/dialogs/formdatabasecleanup.h index daad5c82c..839195437 100755 --- a/src/gui/dialogs/formdatabasecleanup.h +++ b/src/gui/dialogs/formdatabasecleanup.h @@ -25,10 +25,6 @@ #include "miscellaneous/databasecleaner.h" -namespace Ui { - class FormDatabaseCleanup; -} - class FormDatabaseCleanup : public QDialog { Q_OBJECT diff --git a/src/gui/dialogs/formmain.h b/src/gui/dialogs/formmain.h index f6ec7d739..b0678d128 100755 --- a/src/gui/dialogs/formmain.h +++ b/src/gui/dialogs/formmain.h @@ -18,10 +18,10 @@ #ifndef FORMMAIN_H #define FORMMAIN_H -#include "ui_formmain.h" - #include +#include "ui_formmain.h" + class StatusBar; diff --git a/src/gui/dialogs/formrestoredatabasesettings.h b/src/gui/dialogs/formrestoredatabasesettings.h index fb1c2ba93..da4fbf43d 100755 --- a/src/gui/dialogs/formrestoredatabasesettings.h +++ b/src/gui/dialogs/formrestoredatabasesettings.h @@ -23,10 +23,6 @@ #include "ui_formrestoredatabasesettings.h" -namespace Ui { - class FormRestoreDatabaseSettings; -} - class FormRestoreDatabaseSettings : public QDialog { Q_OBJECT diff --git a/src/gui/dialogs/formsettings.cpp b/src/gui/dialogs/formsettings.cpp index d51b27927..0498ab0d7 100755 --- a/src/gui/dialogs/formsettings.cpp +++ b/src/gui/dialogs/formsettings.cpp @@ -52,277 +52,23 @@ #include -FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormSettings), m_settings(nullptr) { +FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormSettings), m_settings(qApp->settings()) { m_ui->setupUi(this); - m_settings = qApp->settings(); - // Set flags and attributes. setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); setWindowIcon(qApp->icons()->fromTheme(QSL("emblem-system"))); - m_ui->m_editorMessagesToolbar->activeItemsWidget()->viewport()->installEventFilter(this); - m_ui->m_editorFeedsToolbar->activeItemsWidget()->viewport()->installEventFilter(this); - m_ui->m_editorMessagesToolbar->availableItemsWidget()->viewport()->installEventFilter(this); - m_ui->m_editorFeedsToolbar->availableItemsWidget()->viewport()->installEventFilter(this); - - // Setup behavior. - m_ui->m_listSettings->setCurrentRow(0); - m_ui->m_treeLanguages->setColumnCount(3); - m_ui->m_treeLanguages->setHeaderHidden(false); - m_ui->m_treeLanguages->setHeaderLabels(QStringList() - << /*: Language column of language list. */ tr("Language") - << /*: Lang. code column of language list. */ tr("Code") - << tr("Author")); - - m_ui->m_treeSkins->setColumnCount(4); - m_ui->m_treeSkins->setHeaderHidden(false); - m_ui->m_treeSkins->setHeaderLabels(QStringList() - << /*: Skin list name column. */ tr("Name") - << /*: Version column of skin list. */ tr("Version") - << tr("Author") - << tr("E-mail")); - - // Setup languages. - 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); - - // 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); - // Establish needed connections. connect(m_ui->m_buttonBox, SIGNAL(accepted()), this, SLOT(saveSettings())); - - connect(m_ui->m_cmbProxyType, SIGNAL(currentIndexChanged(int)), this, SLOT(onProxyTypeChanged(int))); - connect(m_ui->m_checkShowPassword, SIGNAL(stateChanged(int)), this, SLOT(displayProxyPassword(int))); - connect(m_ui->m_cmbExternalBrowserPreset, SIGNAL(currentIndexChanged(int)), this, SLOT(changeDefaultBrowserArguments(int))); - connect(m_ui->m_btnExternalBrowserExecutable, SIGNAL(clicked()), this, SLOT(selectBrowserExecutable())); - connect(m_ui->m_cmbExternalEmailPreset, SIGNAL(currentIndexChanged(int)), this, SLOT(changeDefaultEmailArguments(int))); - connect(m_ui->m_btnExternalEmailExecutable, SIGNAL(clicked()), this, SLOT(selectEmailExecutable())); - - connect(m_ui->m_btnDownloadsTargetDirectory, SIGNAL(clicked()), this, SLOT(selectDownloadsDirectory())); - - connect(m_ui->m_btnChangeMessagesFont, SIGNAL(clicked()), this, SLOT(changeMessagesFont())); - - - // Load all settings. - loadGeneral(); - loadDataStorage(); - loadShortcuts(); - loadInterface(); - loadProxy(); - loadBrowser(); - loadLanguage(); - loadFeedsMessages(); - loadDownloads(); } FormSettings::~FormSettings() { qDebug("Destroying FormSettings distance."); } -void FormSettings::changeDefaultBrowserArguments(int index) { - if (index != 0) { - m_ui->m_txtExternalBrowserArguments->setText(m_ui->m_cmbExternalBrowserPreset->itemData(index).toString()); - } -} - -void FormSettings::onSkinSelected(QTreeWidgetItem *current, QTreeWidgetItem *previous) { - Q_UNUSED(previous) - - if (current != nullptr) { - const Skin skin = current->data(0, Qt::UserRole).value(); - m_ui->m_lblSelectedContents->setText(skin.m_visibleName); - } -} - -void FormSettings::loadDownloads() { - m_ui->m_checkOpenManagerWhenDownloadStarts->setChecked(m_settings->value(GROUP(Downloads), - SETTING(Downloads::ShowDownloadsWhenNewDownloadStarts)).toBool()); - m_ui->m_txtDownloadsTargetDirectory->setText(QDir::toNativeSeparators(m_settings->value(GROUP(Downloads), - SETTING(Downloads::TargetDirectory)).toString())); - m_ui->m_rbDownloadsAskEachFile->setChecked(m_settings->value(GROUP(Downloads), - SETTING(Downloads::AlwaysPromptForFilename)).toBool()); -} - -void FormSettings::saveDownloads() { - m_settings->setValue(GROUP(Downloads), Downloads::ShowDownloadsWhenNewDownloadStarts, m_ui->m_checkOpenManagerWhenDownloadStarts->isChecked()); - m_settings->setValue(GROUP(Downloads), Downloads::TargetDirectory, m_ui->m_txtDownloadsTargetDirectory->text()); - m_settings->setValue(GROUP(Downloads), Downloads::AlwaysPromptForFilename, m_ui->m_rbDownloadsAskEachFile->isChecked()); - qApp->downloadManager()->setDownloadDirectory(m_ui->m_txtDownloadsTargetDirectory->text()); -} - -void FormSettings::selectDownloadsDirectory() { - const QString target_directory = QFileDialog::getExistingDirectory(this, - tr("Select downloads target directory"), - m_ui->m_txtDownloadsTargetDirectory->text() - ); - - if (!target_directory.isEmpty()) { - m_ui->m_txtDownloadsTargetDirectory->setText(QDir::toNativeSeparators(target_directory)); - } -} - -void FormSettings::selectBrowserExecutable() { - const QString executable_file = QFileDialog::getOpenFileName(this, - tr("Select web browser executable"), - qApp->homeFolderPath(), - //: File filter for external browser selection dialog. - #if defined(Q_OS_LINUX) - tr("Executables (*)") - #else - tr("Executables (*.*)") - #endif - ); - - if (!executable_file.isEmpty()) { - m_ui->m_txtExternalBrowserExecutable->setText(QDir::toNativeSeparators(executable_file)); - } -} - -void FormSettings::changeDefaultEmailArguments(int index) { - if (index != 0) { - m_ui->m_txtExternalEmailArguments->setText(m_ui->m_cmbExternalEmailPreset->itemData(index).toString()); - } -} - -void FormSettings::selectEmailExecutable() { - QString executable_file = QFileDialog::getOpenFileName(this, - tr("Select e-mail executable"), - qApp->homeFolderPath(), - //: File filter for external e-mail selection dialog. - #if defined(Q_OS_LINUX) - tr("Executables (*)") - #else - tr("Executables (*.*)") - #endif - ); - - if (!executable_file.isEmpty()) { - m_ui->m_txtExternalEmailExecutable->setText(QDir::toNativeSeparators(executable_file)); - } -} - -void FormSettings::loadFeedsMessages() { - m_ui->m_checkKeppMessagesInTheMiddle->setChecked(m_settings->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()); - m_ui->m_checkRemoveReadMessagesOnExit->setChecked(m_settings->value(GROUP(Messages), SETTING(Messages::ClearReadOnExit)).toBool()); - m_ui->m_checkAutoUpdate->setChecked(m_settings->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateEnabled)).toBool()); - m_ui->m_spinAutoUpdateInterval->setValue(m_settings->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt()); - m_ui->m_spinFeedUpdateTimeout->setValue(m_settings->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt()); - m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(m_settings->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool()); - m_ui->m_cmbCountsFeedList->addItems(QStringList() << "(%unread)" << "[%unread]" << "%unread/%all" << "%unread-%all" << "[%unread|%all]"); - m_ui->m_cmbCountsFeedList->setEditText(m_settings->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString()); - - initializeMessageDateFormats(); - - m_ui->m_checkMessagesDateTimeFormat->setChecked(m_settings->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool()); - const int index_format = m_ui->m_cmbMessagesDateTimeFormat->findData(m_settings->value(GROUP(Messages), SETTING(Messages::CustomDateFormat)).toString()); - - if (index_format >= 0) { - m_ui->m_cmbMessagesDateTimeFormat->setCurrentIndex(index_format); - } - - m_ui->m_lblMessagesFont->setText(tr("Font preview")); - QFont fon; - fon.fromString(m_settings->value(GROUP(Messages), - SETTING(Messages::PreviewerFontStandard)).toString()); - m_ui->m_lblMessagesFont->setFont(fon); - -} - -void FormSettings::initializeMessageDateFormats() { - QStringList best_formats; best_formats << QSL("d/M/yyyy hh:mm:ss") << QSL("ddd, d. M. yy hh:mm:ss") << - QSL("yyyy-MM-dd HH:mm:ss.z") << QSL("yyyy-MM-ddThh:mm:ss") << - QSL("MMM d yyyy hh:mm:ss");; - const QLocale current_locale = qApp->localization()->loadedLocale(); - const QDateTime current_dt = QDateTime::currentDateTime(); - - foreach (const QString &format, best_formats) { - m_ui->m_cmbMessagesDateTimeFormat->addItem(current_locale.toString(current_dt, format), format); - } -} - -void FormSettings::changeMessagesFont() { - bool ok; - QFont new_font = QFontDialog::getFont(&ok, m_ui->m_lblMessagesFont->font(), - this, tr("Select new font for message viewer"), - QFontDialog::DontUseNativeDialog); - - if (ok) { - m_ui->m_lblMessagesFont->setFont(new_font); - } -} - -void FormSettings::saveFeedsMessages() { - m_settings->setValue(GROUP(Messages), Messages::KeepCursorInCenter, m_ui->m_checkKeppMessagesInTheMiddle->isChecked()); - m_settings->setValue(GROUP(Messages), Messages::ClearReadOnExit, m_ui->m_checkRemoveReadMessagesOnExit->isChecked()); - m_settings->setValue(GROUP(Feeds), Feeds::AutoUpdateEnabled, m_ui->m_checkAutoUpdate->isChecked()); - m_settings->setValue(GROUP(Feeds), Feeds::AutoUpdateInterval, m_ui->m_spinAutoUpdateInterval->value()); - m_settings->setValue(GROUP(Feeds), Feeds::UpdateTimeout, m_ui->m_spinFeedUpdateTimeout->value()); - m_settings->setValue(GROUP(Feeds), Feeds::FeedsUpdateOnStartup, m_ui->m_checkUpdateAllFeedsOnStartup->isChecked()); - m_settings->setValue(GROUP(Feeds), Feeds::CountFormat, m_ui->m_cmbCountsFeedList->currentText()); - m_settings->setValue(GROUP(Messages), Messages::UseCustomDate, m_ui->m_checkMessagesDateTimeFormat->isChecked()); - m_settings->setValue(GROUP(Messages), Messages::CustomDateFormat, - m_ui->m_cmbMessagesDateTimeFormat->itemData(m_ui->m_cmbMessagesDateTimeFormat->currentIndex()).toString()); - - // Save fonts. - m_settings->setValue(GROUP(Messages), Messages::PreviewerFontStandard, m_ui->m_lblMessagesFont->font().toString()); - - qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts(); - qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->updateAutoUpdateStatus(); - qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->reloadWholeLayout(); - qApp->mainForm()->tabWidget()->feedMessageViewer()->messagesView()->sourceModel()->updateDateFormat(); - qApp->mainForm()->tabWidget()->feedMessageViewer()->messagesView()->sourceModel()->reloadWholeLayout(); -} - -void FormSettings::displayProxyPassword(int state) { - if (state == Qt::Checked) { - m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::Normal); - } - else { - m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit); - } -} - -bool FormSettings::doSaveCheck() { - bool everything_ok = true; - QStringList resulting_information; - - // Setup indication of settings consistence. - if (!m_ui->m_shortcuts->areShortcutsUnique()) { - everything_ok = false; - resulting_information.append(tr("some keyboard shortcuts are not unique")); - } - - // 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(QL1S("%1")))) { - everything_ok = false; - resulting_information.append(tr("custom external browser is not set correctly")); - } - - if (!everything_ok) { - resulting_information.replaceInStrings(QRegExp(QSL("^")), QString::fromUtf8(" • ")); - - 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(QSL(",\n")))); - } - - return everything_ok; -} - void FormSettings::promptForRestart() { - if (!m_changedDataTexts.isEmpty()) { + /*if (!m_changedDataTexts.isEmpty()) { const QStringList changed_settings_description = m_changedDataTexts.replaceInStrings(QRegExp(QSL("^")), QString::fromUtf8(" • ")); MessageBox::show(this, QMessageBox::Question, @@ -332,494 +78,12 @@ void FormSettings::promptForRestart() { QString(), tr("List of changes:\n%1.").arg(changed_settings_description .join(QSL(",\n"))), QMessageBox::Ok, QMessageBox::Ok); - } + }*/ } void FormSettings::saveSettings() { - // Make sure everything is saveable. - if (!doSaveCheck()) { - return; - } - // Save all settings. - saveGeneral(); - saveDataStorage(); - saveShortcuts(); - saveInterface(); - saveProxy(); - saveBrowser(); - saveLanguage(); - saveFeedsMessages(); - saveDownloads(); - m_settings->checkSettings(); promptForRestart(); - accept(); } - -void FormSettings::onProxyTypeChanged(int index) { - const QNetworkProxy::ProxyType selected_type = static_cast(m_ui->m_cmbProxyType->itemData(index).toInt()); - const bool is_proxy_selected = selected_type != QNetworkProxy::NoProxy && selected_type != QNetworkProxy::DefaultProxy; - - 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); - 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); -} - -void FormSettings::loadBrowser() { - // Load settings of web browser GUI. - m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), QSL("-nosession %1")); - m_ui->m_txtExternalBrowserExecutable->setText(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserExecutable)).toString()); - m_ui->m_txtExternalBrowserArguments->setText(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserArguments)).toString()); - m_ui->m_grpCustomExternalBrowser->setChecked(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool()); - - // Load settings of e-mail. - m_ui->m_cmbExternalEmailPreset->addItem(tr("Mozilla Thunderbird"), QSL("-compose \"subject='%1',body='%2'\"")); - m_ui->m_txtExternalEmailExecutable->setText(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailExecutable)).toString()); - m_ui->m_txtExternalEmailArguments->setText(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailArguments)).toString()); - m_ui->m_grpCustomExternalEmail->setChecked(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailEnabled)).toBool()); -} - -void FormSettings::saveBrowser() { - // Save settings of GUI of web browser. - m_settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserEnabled, m_ui->m_grpCustomExternalBrowser->isChecked()); - m_settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserExecutable, m_ui->m_txtExternalBrowserExecutable->text()); - m_settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserArguments, m_ui->m_txtExternalBrowserArguments->text()); - - // Save settings of e-mail. - m_settings->setValue(GROUP(Browser), Browser::CustomExternalEmailExecutable, m_ui->m_txtExternalEmailExecutable->text()); - m_settings->setValue(GROUP(Browser), Browser::CustomExternalEmailArguments, m_ui->m_txtExternalEmailArguments->text()); - m_settings->setValue(GROUP(Browser), Browser::CustomExternalEmailEnabled, m_ui->m_grpCustomExternalEmail->isChecked()); -} - -void FormSettings::loadProxy() { - m_ui->m_cmbProxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy); - m_ui->m_cmbProxyType->addItem(tr("System proxy"), QNetworkProxy::DefaultProxy); - m_ui->m_cmbProxyType->addItem(tr("Socks5"), QNetworkProxy::Socks5Proxy); - m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy); - - // Load the settings. - QNetworkProxy::ProxyType selected_proxy_type = static_cast(m_settings->value(GROUP(Proxy), SETTING(Proxy::Type)).toInt()); - - m_ui->m_cmbProxyType->setCurrentIndex(m_ui->m_cmbProxyType->findData(selected_proxy_type)); - m_ui->m_txtProxyHost->setText(m_settings->value(GROUP(Proxy), SETTING(Proxy::Host)).toString()); - m_ui->m_txtProxyUsername->setText(m_settings->value(GROUP(Proxy), SETTING(Proxy::Username)).toString()); - m_ui->m_txtProxyPassword->setText(TextFactory::decrypt(m_settings->value(GROUP(Proxy), SETTING(Proxy::Password)).toString())); - m_ui->m_spinProxyPort->setValue(m_settings->value(GROUP(Proxy), SETTING(Proxy::Port)).toInt()); -} - -void FormSettings::saveProxy() { - m_settings->setValue(GROUP(Proxy), Proxy::Type, m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex())); - m_settings->setValue(GROUP(Proxy), Proxy::Host, m_ui->m_txtProxyHost->text()); - m_settings->setValue(GROUP(Proxy), Proxy::Username, m_ui->m_txtProxyUsername->text()); - m_settings->setValue(GROUP(Proxy), Proxy::Password, TextFactory::encrypt(m_ui->m_txtProxyPassword->text())); - m_settings->setValue(GROUP(Proxy), Proxy::Port, m_ui->m_spinProxyPort->value()); - - // Reload settings for all network access managers. - SilentNetworkAccessManager::instance()->loadSettings(); -} - -void FormSettings::loadLanguage() { - foreach (const Language &language, qApp->localization()->installedLanguages()) { - QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->m_treeLanguages); - item->setText(0, language.m_name); - item->setText(1, language.m_code); - item->setText(2, language.m_author); - item->setIcon(0, qApp->icons()->miscIcon(QString(FLAG_ICON_SUBFOLDER) + QDir::separator() + language.m_code)); - } - - QList matching_items = m_ui->m_treeLanguages->findItems(qApp->localization()->loadedLanguage(), Qt::MatchContains, 1); - - if (!matching_items.isEmpty()) { - m_ui->m_treeLanguages->setCurrentItem(matching_items[0]); - } -} - -void FormSettings::saveLanguage() { - if (m_ui->m_treeLanguages->currentItem() == nullptr) { - qDebug("No localizations loaded in settings dialog, so no saving for them."); - return; - } - - const QString actual_lang = qApp->localization()->loadedLanguage(); - const QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1); - - // Save prompt for restart if language has changed. - if (new_lang != actual_lang) { - m_changedDataTexts.append(tr("language changed")); - m_settings->setValue(GROUP(General), General::Language, new_lang); - } -} - -void FormSettings::loadShortcuts() { - m_ui->m_shortcuts->populate(qApp->mainForm()->allActions()); -} - -void FormSettings::saveShortcuts() { - // Update the actual shortcuts of some actions. - m_ui->m_shortcuts->updateShortcuts(); - - // Save new shortcuts to the settings. - DynamicShortcuts::save(qApp->mainForm()->allActions()); -} - -void FormSettings::loadDataStorage() { - m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Information, tr("No connection test triggered so far."), tr("You did not executed any connection test yet.")); - - // Load SQLite. - m_ui->m_cmbDatabaseDriver->addItem(qApp->database()->humanDriverName(DatabaseFactory::SQLITE), APP_DB_SQLITE_DRIVER); - - // Load in-memory database status. - m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(m_settings->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool()); - - if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) { - onMysqlHostnameChanged(QString()); - onMysqlUsernameChanged(QString()); - onMysqlPasswordChanged(QString()); - onMysqlDatabaseChanged(QString()); - - // Load MySQL. - m_ui->m_cmbDatabaseDriver->addItem(qApp->database()->humanDriverName(DatabaseFactory::MYSQL), APP_DB_MYSQL_DRIVER); - - // 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")); - m_ui->m_txtMysqlDatabase->lineEdit()->setPlaceholderText(tr("Working database which you have full access to.")); - - m_ui->m_txtMysqlHostname->lineEdit()->setText(m_settings->value(GROUP(Database), SETTING(Database::MySQLHostname)).toString()); - m_ui->m_txtMysqlUsername->lineEdit()->setText(m_settings->value(GROUP(Database), SETTING(Database::MySQLUsername)).toString()); - m_ui->m_txtMysqlPassword->lineEdit()->setText(TextFactory::decrypt(m_settings->value(GROUP(Database), SETTING(Database::MySQLPassword)).toString())); - m_ui->m_txtMysqlDatabase->lineEdit()->setText(m_settings->value(GROUP(Database), SETTING(Database::MySQLDatabase)).toString()); - m_ui->m_spinMysqlPort->setValue(m_settings->value(GROUP(Database), SETTING(Database::MySQLPort)).toInt()); - - m_ui->m_checkMysqlShowPassword->setChecked(false); - } - - int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(m_settings->value(GROUP(Database), SETTING(Database::ActiveDriver)).toString()); - - if (index_current_backend >= 0) { - m_ui->m_cmbDatabaseDriver->setCurrentIndex(index_current_backend); - } -} - -void FormSettings::saveDataStorage() { - // Setup in-memory database status. - const bool original_inmemory = m_settings->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool(); - const bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked(); - - if (original_inmemory != new_inmemory) { - m_changedDataTexts.append(tr("in-memory database switched")); - } - - // Save data storage settings. - QString original_db_driver = m_settings->value(GROUP(Database), SETTING(Database::ActiveDriver)).toString(); - QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(m_ui->m_cmbDatabaseDriver->currentIndex()).toString(); - - // Save SQLite. - m_settings->setValue(GROUP(Database), Database::UseInMemory, new_inmemory); - - if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) { - // Save MySQL. - m_settings->setValue(GROUP(Database), Database::MySQLHostname, m_ui->m_txtMysqlHostname->lineEdit()->text()); - m_settings->setValue(GROUP(Database), Database::MySQLUsername, m_ui->m_txtMysqlUsername->lineEdit()->text()); - m_settings->setValue(GROUP(Database), Database::MySQLPassword, TextFactory::encrypt(m_ui->m_txtMysqlPassword->lineEdit()->text())); - m_settings->setValue(GROUP(Database), Database::MySQLDatabase, m_ui->m_txtMysqlDatabase->lineEdit()->text()); - m_settings->setValue(GROUP(Database), Database::MySQLPort, m_ui->m_spinMysqlPort->value()); - } - - m_settings->setValue(GROUP(Database), Database::ActiveDriver, selected_db_driver); - - if (original_db_driver != selected_db_driver || m_initialSettings.m_dataStorageDataChanged) { - m_changedDataTexts.append(tr("data storage backend changed")); - } -} - -void FormSettings::mysqlTestConnection() { - const DatabaseFactory::MySQLError error_code = qApp->database()->mysqlTestConnection(m_ui->m_txtMysqlHostname->lineEdit()->text(), - m_ui->m_spinMysqlPort->value(), - m_ui->m_txtMysqlDatabase->lineEdit()->text(), - m_ui->m_txtMysqlUsername->lineEdit()->text(), - m_ui->m_txtMysqlPassword->lineEdit()->text()); - const QString interpretation = qApp->database()->mysqlInterpretErrorCode(error_code); - - - switch (error_code) { - case DatabaseFactory::MySQLOk: - case DatabaseFactory::MySQLUnknownDatabase: - m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Ok, interpretation, interpretation); - break; - - default: - m_ui->m_lblMysqlTestResult->setStatus(WidgetWithStatus::Error, interpretation, interpretation); - break; - } -} - -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.")); - } -} - -void FormSettings::onMysqlDatabaseChanged(const QString &new_database) { - if (new_database.isEmpty()) { - m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::Warning, tr("Working database is empty.")); - } - else { - m_ui->m_txtMysqlDatabase->setStatus(LineEditWithStatus::Ok, tr("Working database is ok.")); - } -} - -void FormSettings::onMysqlDataStorageEdited() { - m_initialSettings.m_dataStorageDataChanged = true; -} - -void FormSettings::selectSqlBackend(int index) { - const QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(index).toString(); - - if (selected_db_driver == APP_DB_SQLITE_DRIVER) { - m_ui->m_stackedDatabaseDriver->setCurrentIndex(0); - } - else if (selected_db_driver == APP_DB_MYSQL_DRIVER) { - m_ui->m_stackedDatabaseDriver->setCurrentIndex(1); - } - else { - qWarning("GUI for given database driver '%s' is not available.", qPrintable(selected_db_driver)); - } -} - -void FormSettings::switchMysqlPasswordVisiblity(bool visible) { - m_ui->m_txtMysqlPassword->lineEdit()->setEchoMode(visible ? QLineEdit::Normal : QLineEdit::Password); -} - -void FormSettings::loadGeneral() { - m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text().arg(APP_NAME)); - m_ui->m_checkForUpdatesOnStart->setChecked(m_settings->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool()); - - // Load auto-start status. - const SystemFactory::AutoStartStatus autostart_status = qApp->system()->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; - } - -#if defined(Q_OS_WIN) - m_ui->m_checkRemoveTrolltechJunk->setVisible(true); - m_ui->m_checkRemoveTrolltechJunk->setChecked(m_settings->value(GROUP(General), SETTING(General::RemoveTrolltechJunk)).toBool()); -#else - m_ui->m_checkRemoveTrolltechJunk->setVisible(false); -#endif -} - -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()) { - qApp->system()->setAutoStartStatus(SystemFactory::Enabled); - } - else { - qApp->system()->setAutoStartStatus(SystemFactory::Disabled); - } - - m_settings->setValue(GROUP(General), General::UpdateOnStartup, m_ui->m_checkForUpdatesOnStart->isChecked()); - m_settings->setValue(GROUP(General), General::RemoveTrolltechJunk, m_ui->m_checkRemoveTrolltechJunk->isChecked()); -} - -void FormSettings::loadInterface() { - // Load settings of tray icon. - if (SystemTrayIcon::isSystemTrayAvailable()) { - m_ui->m_grpTray->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool()); - } - // Tray icon is not supported on this machine. - else { - m_ui->m_grpTray->setTitle(m_ui->m_grpTray->title() + QL1C(' ') + tr("(Tray icon is not available.)")); - m_ui->m_grpTray->setChecked(false); - } - - m_ui->m_checkHidden->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool()); - m_ui->m_checkHideWhenMinimized->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::HideMainWindowWhenMinimized)).toBool()); - - // Load fancy notification settings. - m_ui->m_checkEnableNotifications->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool()); - - // Load settings of icon theme. - const QString current_theme = qApp->icons()->currentIconTheme(); - - foreach (const QString &icon_theme_name, qApp->icons()->installedIconThemes()) { - if (icon_theme_name == APP_NO_THEME) { - // Add just "no theme" on other systems. - //: Label for disabling icon theme. - m_ui->m_cmbIconTheme->addItem(tr("no icon theme/system icon theme"), APP_NO_THEME); - } - else { - m_ui->m_cmbIconTheme->addItem(icon_theme_name, icon_theme_name); - } - } - - // Mark active theme. - if (current_theme == QSL(APP_NO_THEME)) { - // Because "no icon theme" lies at the index 0. - m_ui->m_cmbIconTheme->setCurrentIndex(0); - } - else { - m_ui->m_cmbIconTheme->setCurrentText(current_theme); - } - - // Load skin. - const QString selected_skin = qApp->skins()->selectedSkinName(); - - foreach (const Skin &skin, qApp->skins()->installedSkins()) { - 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)); - - // Add this skin and mark it as active if its active now. - m_ui->m_treeSkins->addTopLevelItem(new_item); - - if (skin.m_baseName == selected_skin) { - m_ui->m_treeSkins->setCurrentItem(new_item); - m_ui->m_lblActiveContents->setText(skin.m_visibleName); - } - } - - if (m_ui->m_treeSkins->currentItem() == nullptr && - m_ui->m_treeSkins->topLevelItemCount() > 0) { - // Currently active skin is NOT available, select another one as selected - // if possible. - m_ui->m_treeSkins->setCurrentItem(m_ui->m_treeSkins->topLevelItem(0)); - } - - // Load tab settings. - m_ui->m_checkCloseTabsMiddleClick->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::TabCloseMiddleClick)).toBool()); - m_ui->m_checkCloseTabsDoubleClick->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::TabCloseDoubleClick)).toBool()); - m_ui->m_checkNewTabDoubleClick->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::TabNewDoubleClick)).toBool()); - m_ui->m_hideTabBarIfOneTabVisible->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::HideTabBarIfOnlyOneTab)).toBool()); - - // Load toolbar button style. - 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); - - m_ui->m_cmbToolbarButtonStyle->setCurrentIndex(m_ui->m_cmbToolbarButtonStyle->findData(m_settings->value(GROUP(GUI), - SETTING(GUI::ToolbarStyle)).toInt())); - - // Load toolbars. - m_ui->m_editorFeedsToolbar->loadFromToolBar(qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsToolBar()); - m_ui->m_editorMessagesToolbar->loadFromToolBar(qApp->mainForm()->tabWidget()->feedMessageViewer()->messagesToolBar()); - m_ui->m_editorStatusbar->loadFromToolBar(qApp->mainForm()->statusBar()); -} - -void FormSettings::saveInterface() { - // Save toolbar. - m_settings->setValue(GROUP(GUI), GUI::ToolbarStyle, m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex())); - - // Save tray icon. - if (SystemTrayIcon::isSystemTrayAvailable()) { - m_settings->setValue(GROUP(GUI), GUI::UseTrayIcon, m_ui->m_grpTray->isChecked()); - - if (m_ui->m_grpTray->isChecked()) { - qApp->showTrayIcon(); - } - else { - qApp->deleteTrayIcon(); - } - } - - m_settings->setValue(GROUP(GUI), GUI::MainWindowStartsHidden, m_ui->m_checkHidden->isChecked()); - m_settings->setValue(GROUP(GUI), GUI::HideMainWindowWhenMinimized, m_ui->m_checkHideWhenMinimized->isChecked()); - - // Save notifications. - m_settings->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui->m_checkEnableNotifications->isChecked()); - - // Save selected icon theme. - QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString(); - QString original_icon_theme = qApp->icons()->currentIconTheme(); - qApp->icons()->setCurrentIconTheme(selected_icon_theme); - - // Check if icon theme was changed. - if (selected_icon_theme != original_icon_theme) { - m_changedDataTexts.append(tr("icon theme changed")); - } - - // Save and activate new skin. - if (m_ui->m_treeSkins->selectedItems().size() > 0) { - const Skin active_skin = m_ui->m_treeSkins->currentItem()->data(0, Qt::UserRole).value(); - - if (qApp->skins()->selectedSkinName() != active_skin.m_baseName) { - qApp->skins()->setCurrentSkinName(active_skin.m_baseName); - m_changedDataTexts.append(tr("skin changed")); - } - } - - // Save tab settings. - m_settings->setValue(GROUP(GUI), GUI::TabCloseMiddleClick, m_ui->m_checkCloseTabsMiddleClick->isChecked()); - m_settings->setValue(GROUP(GUI), GUI::TabCloseDoubleClick, m_ui->m_checkCloseTabsDoubleClick->isChecked()); - m_settings->setValue(GROUP(GUI), GUI::TabNewDoubleClick, m_ui->m_checkNewTabDoubleClick->isChecked()); - m_settings->setValue(GROUP(GUI), GUI::HideTabBarIfOnlyOneTab, m_ui->m_hideTabBarIfOneTabVisible->isChecked()); - - m_ui->m_editorFeedsToolbar->saveToolBar(); - m_ui->m_editorMessagesToolbar->saveToolBar(); - m_ui->m_editorStatusbar->saveToolBar(); - - qApp->mainForm()->tabWidget()->checkTabBarVisibility(); - qApp->mainForm()->tabWidget()->feedMessageViewer()->refreshVisualProperties(); -} - -bool FormSettings::eventFilter(QObject *obj, QEvent *e) { - Q_UNUSED(obj) - - if (e->type() == QEvent::Drop) { - QDropEvent *drop_event = static_cast(e); - - if (drop_event->keyboardModifiers() != Qt::NoModifier) { - drop_event->setDropAction(Qt::MoveAction); - } - } - - return false; -} diff --git a/src/gui/dialogs/formsettings.h b/src/gui/dialogs/formsettings.h index c3933b270..07c324472 100755 --- a/src/gui/dialogs/formsettings.h +++ b/src/gui/dialogs/formsettings.h @@ -18,27 +18,13 @@ #ifndef FORMSETTINGS_H #define FORMSETTINGS_H -#include "ui_formsettings.h" - #include +#include "ui_formsettings.h" -namespace Ui { - class FormSettings; -} class Settings; -// Structure holding some initial values. -struct TemporarySettings { - - public: - TemporarySettings() : m_dataStorageDataChanged(false) { - } - - bool m_dataStorageDataChanged; -}; - class FormSettings : public QDialog { Q_OBJECT @@ -47,69 +33,16 @@ class FormSettings : public QDialog { explicit FormSettings(QWidget *parent = 0); virtual ~FormSettings(); - protected: - // Does check of controls before dialog can be submitted. - bool doSaveCheck(); - bool eventFilter(QObject *obj, QEvent *e); - private slots: // Displays "restart" dialog if some critical settings changed. void promptForRestart(); // Saves settings into global configuration. void saveSettings(); - - void loadInterface(); - void saveInterface(); - void onSkinSelected(QTreeWidgetItem *current, QTreeWidgetItem *previous); - - void loadDownloads(); - void saveDownloads(); - void selectDownloadsDirectory(); - - void loadGeneral(); - void saveGeneral(); - - void loadDataStorage(); - void saveDataStorage(); - void mysqlTestConnection(); - void onMysqlHostnameChanged(const QString &new_hostname); - void onMysqlUsernameChanged(const QString &new_username); - void onMysqlPasswordChanged(const QString &new_password); - void onMysqlDatabaseChanged(const QString &new_database); - void onMysqlDataStorageEdited(); - void selectSqlBackend(int index); - void switchMysqlPasswordVisiblity(bool visible); - - void loadLanguage(); - void saveLanguage(); - - void loadShortcuts(); - void saveShortcuts(); - - void loadBrowser(); - void saveBrowser(); - void changeDefaultBrowserArguments(int index); - void selectBrowserExecutable(); - - void changeDefaultEmailArguments(int index); - void selectEmailExecutable(); - - void loadProxy(); - void saveProxy(); - void displayProxyPassword(int state); - void onProxyTypeChanged(int index); - - void loadFeedsMessages(); - void initializeMessageDateFormats(); - void changeMessagesFont(); - void saveFeedsMessages(); private: QScopedPointer m_ui; Settings *m_settings; - TemporarySettings m_initialSettings; - QStringList m_changedDataTexts; }; #endif // FORMSETTINGS_H diff --git a/src/gui/dialogs/formsettings.ui b/src/gui/dialogs/formsettings.ui index e30a1d633..7e1097e3b 100755 --- a/src/gui/dialogs/formsettings.ui +++ b/src/gui/dialogs/formsettings.ui @@ -43,1450 +43,13 @@ -1 - - - General - - - - - Data storage - - - - - Keyboard shortcuts - - - - - User interface - - - - - Language - - - - - Web browser & e-mail & proxy - - - - - Feeds & messages - - - - - Downloads - - - 4 + -1 - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Launch %1 on operating system startup - - - - - - - Check for updates on application startup - - - - - - - Remove junk Trolltech registry key (HKCU\Software\Trolltech) when application quits (Use at your own risk!) - - - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - 0 - - - 0 - - - 0 - - - 0 - - - - - WARNING: Note that switching to another data storage type will NOT copy existing your data from currently active data storage to newly selected one. - - - Qt::AlignCenter - - - true - - - - - - - Database driver - - - m_cmbDatabaseDriver - - - - - - - - - - 1 - - - - - QFormLayout::AllNonFixedFieldsGrow - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Use in-memory database as the working database - - - - - - - Usage of in-memory working database has several advantages and pitfalls. Make sure that you are familiar with these before you turn this feature on. Advantages: -<ul> -<li>higher speed for feed/message manipulations (especially with thousands of messages displayed),</li> -<li>whole database stored in RAM, thus your hard drive can rest more.</li> -</ul> -Disadvantages: -<ul> -<li>if application crashes, your changes from last session are lost,</li> -<li>application startup and shutdown can take little longer (max. 2 seconds).</li> -</ul> -Authors of this application are NOT responsible for lost data. - - - Qt::RichText - - - true - - - 20 - - - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Hostname - - - m_txtMysqlHostname - - - - - - - - - - - - Port - - - m_spinMysqlPort - - - - - - - - 100 - 0 - - - - 1 - - - 65536 - - - 3306 - - - - - - - - - Username - - - m_txtMysqlUsername - - - - - - - - - - Password - - - m_txtMysqlPassword - - - - - - - - - - - - Test setup - - - false - - - - - - - - 0 - 0 - - - - Qt::RightToLeft - - - - - - - - - - true - - - - Note that speed of used MySQL server and latency of used connection medium HEAVILY influences the final performance of this application. Using slow database connections leads to bad performance when browsing feeds or messages. - - - Qt::AlignCenter - - - true - - - 10 - - - - - - - &Show password - - - true - - - - - - - - - - Working database - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - true - - - - - 0 - 0 - 742 - 451 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QTabWidget::North - - - 0 - - - - Icons && skins - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::NoFrame - - - true - - - - - 0 - 0 - 736 - 425 - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Icons - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Icon theme - - - m_cmbIconTheme - - - - - - - - - - - - - Skins - - - - - - - 0 - 0 - - - - 0 - - - false - - - false - - - false - - - 80 - - - - 1 - - - - - - - - Active skin: - - - - - - - - - - - - - - Selected skin: - - - - - - - - - - - - - - - - - - - - - - Tray area && notifications - - - - - - Tray icon - - - true - - - - QFormLayout::ExpandingFieldsGrow - - - - - Hide main window when it is minimized - - - - - - - Start application hidden - - - - - - - Enable popup balloon tooltips - - - - - - - - - - - Tabs - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Open new tabs with left mouse button double-click on tab bar - - - - - - - Hide tab bar if just one tab is visible - - - - - - - Close tabs with - - - - - - Right mouse button double-click - - - - - - - Middle mouse button single-click - - - - - - - - - - - Toolbars - - - - - - - - - 0 - - - - Toolbar for feeds list - - - - - Toolbar for messages list - - - - - Statusbar - - - - - - - - - 0 - 1 - - - - 0 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - Toolbar button style - - - - - - - Select toolbar to edit - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QAbstractItemView::NoEditTriggers - - - 0 - - - false - - - true - - - false - - - 0 - - - 80 - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - - External web browser - - - - - - <html><head/><body><p>If unchecked, then default system-wide web browser is used.</p></body></html> - - - Use custom external web browser - - - false - - - true - - - - - - Web browser executable - - - - - - - - - true - - - Executable file of web browser - - - - - - - &Browse - - - - - - - - - Executable parameters - - - - - - - Parameters to executable - - - - - - - Use sample arguments for - - - - - - - QComboBox::AdjustToContents - - - - Select browser - - - - - - - - Note that "%1" (without quotation marks) is placeholder for URL of selected message. - - - Qt::AlignCenter - - - - - - - - - - - External e-mail client - - - - - - <html><head/><body><p>If unchecked, then default system-wide web browser is used.</p></body></html> - - - Use custom external e-mail client - - - false - - - true - - - - - - E-mail client executable - - - - - - - - - true - - - Executable file of e-mail client - - - - - - - &Browse - - - - - - - - - Executable parameters - - - - - - - Parameters to executable - - - - - - - Use sample arguments for - - - - - - - QComboBox::AdjustToContents - - - - Select client - - - - - - - - Placeholders: - • %1 - title of selected message, - • %2 - body of selected message. - - - 20 - - - - - - - - - - - Proxy - - - - - - Type - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m_cmbProxyType - - - - - - - - - - Host - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m_txtProxyHost - - - - - - - - - true - - - Hostname or IP of your proxy server - - - - - - - Port - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m_spinProxyPort - - - - - - - true - - - 65535 - - - 80 - - - - - - - - - Username - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m_txtProxyUsername - - - - - - - true - - - Your username for proxy server authentication - - - - - - - Password - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m_txtProxyPassword - - - - - - - true - - - QLineEdit::PasswordEchoOnEdit - - - Your password for proxy server authentication - - - - - - - true - - - Display password - - - - - - - Note that these settings are applied only on newly established connections. - - - Qt::AlignCenter - - - true - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - - Feeds && categories - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Update all feed on application startup - - - - - - - Auto-update all feeds every - - - - - - - Feed connection timeout - - - - - - - Connection timeout is time interval which is reserved for downloading new messages for the feed. If this time interval elapses, then download process is aborted. - - - ms - - - 100 - - - 45000 - - - 100 - - - - - - - Message count format in feed list - - - - - - - - - - true - - - - - - - - true - - - - Enter format for count of messages displayed next to each feed/category in feed list. Use "%all" and "%unread" strings which are placeholders for the actual count of all (or unread) messages. - - - Qt::AlignCenter - - - true - - - - - - - false - - - false - - - true - - - - - - - - Messages - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Remove all read messages from all feeds on application exit - - - - - - - Keep message selection in the middle of the message list viewport - - - - - - - Use custom date/time format (overrides format loaded from active localization) - - - true - - - true - - - - - - - - - - Internal message browser fonts - - - - - - - - - - - - - &Change font - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Open download manager when new download is started - - - - - - - Target directory for downloaded files - - - - - - Ask for each individual downloaded file - - - - - - - - - Save all downloaded files to - - - true - - - - - - - true - - - Target directory where all downloaded files are saved - - - - - - - &Browse - - - - - - - - - - @@ -1501,87 +64,8 @@ Authors of this application are NOT responsible for lost data. - - - LabelWithStatus - QWidget -
labelwithstatus.h
- 1 -
- - LineEditWithStatus - QWidget -
lineeditwithstatus.h
- 1 -
- - TimeSpinBox - QDoubleSpinBox -
timespinbox.h
-
- - DynamicShortcutsWidget - QWidget -
dynamicshortcutswidget.h
- 1 -
- - ToolBarEditor - QWidget -
toolbareditor.h
- 1 -
-
- m_cmbDatabaseDriver - m_spinMysqlPort - m_checkMysqlShowPassword - m_btnMysqlTestSetup m_listSettings - m_checkSqliteUseInMemoryDatabase - m_checkAutostart - m_checkRemoveTrolltechJunk - m_checkForUpdatesOnStart - m_scrollShortcuts - m_tabUi - m_scrollIconSkins - m_cmbIconTheme - m_treeSkins - m_checkHideWhenMinimized - m_checkHidden - m_checkNewTabDoubleClick - m_hideTabBarIfOneTabVisible - m_checkCloseTabsDoubleClick - m_checkCloseTabsMiddleClick - m_cmbToolbarButtonStyle - m_cmbSelectToolBar - m_treeLanguages - m_tabBrowserProxy - m_grpCustomExternalBrowser - m_txtExternalBrowserExecutable - m_btnExternalBrowserExecutable - m_txtExternalBrowserArguments - m_cmbExternalBrowserPreset - m_cmbProxyType - m_txtProxyHost - m_spinProxyPort - m_txtProxyUsername - m_txtProxyPassword - m_checkShowPassword - m_tabFeedsMessages - m_checkUpdateAllFeedsOnStartup - m_checkAutoUpdate - m_spinAutoUpdateInterval - m_spinFeedUpdateTimeout - m_cmbCountsFeedList - m_checkRemoveReadMessagesOnExit - m_checkKeppMessagesInTheMiddle - m_checkMessagesDateTimeFormat - m_cmbMessagesDateTimeFormat - m_rbDownloadsAskEachFile - m_rbDownloadsSaveAllIntoDirectory - m_txtDownloadsTargetDirectory - m_btnDownloadsTargetDirectory @@ -1617,69 +101,5 @@ Authors of this application are NOT responsible for lost data. - - m_checkMessagesDateTimeFormat - toggled(bool) - m_cmbMessagesDateTimeFormat - setEnabled(bool) - - - 445 - 94 - - - 778 - 95 - - - - - m_rbDownloadsAskEachFile - toggled(bool) - m_txtDownloadsTargetDirectory - setDisabled(bool) - - - 821 - 50 - - - 522 - 49 - - - - - m_rbDownloadsAskEachFile - toggled(bool) - m_btnDownloadsTargetDirectory - setDisabled(bool) - - - 348 - 77 - - - 968 - 50 - - - - - m_checkAutoUpdate - toggled(bool) - m_spinAutoUpdateInterval - setEnabled(bool) - - - 324 - 71 - - - 707 - 72 - - - diff --git a/src/gui/dialogs/formupdate.h b/src/gui/dialogs/formupdate.h index fd35e3ffd..e10bd92b3 100755 --- a/src/gui/dialogs/formupdate.h +++ b/src/gui/dialogs/formupdate.h @@ -18,19 +18,16 @@ #ifndef FORMUPDATE_H #define FORMUPDATE_H +#include + #include "ui_formupdate.h" #include "miscellaneous/systemfactory.h" -#include #include #include -namespace Ui { - class FormUpdate; -} - class Downloader; class FormUpdate : public QDialog { diff --git a/src/gui/settings/settingsbrowsermail.cpp b/src/gui/settings/settingsbrowsermail.cpp index f75f7f774..87d907b13 100755 --- a/src/gui/settings/settingsbrowsermail.cpp +++ b/src/gui/settings/settingsbrowsermail.cpp @@ -1,14 +1,164 @@ -#include "settingsbrowsermail.h" -#include "ui_settingsbrowsermail.h" +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . -SettingsBrowserMail::SettingsBrowserMail(QWidget *parent) : - QWidget(parent), - ui(new Ui::SettingsBrowserMail) -{ - ui->setupUi(this); +#include "gui/settings/settingsbrowsermail.h" + +#include "network-web/silentnetworkaccessmanager.h" +#include "miscellaneous/application.h" +#include "miscellaneous/textfactory.h" + +#include +#include + + +SettingsBrowserMail::SettingsBrowserMail(Settings *settings, QWidget *parent) + : SettingsPanel(settings, parent), m_ui(new Ui::SettingsBrowserMail) { + m_ui->setupUi(this); + + connect(m_ui->m_cmbProxyType, static_cast(&QComboBox::currentIndexChanged), this, &SettingsBrowserMail::onProxyTypeChanged); + connect(m_ui->m_checkShowPassword, &QCheckBox::stateChanged, this, &SettingsBrowserMail::displayProxyPassword); + connect(m_ui->m_cmbExternalBrowserPreset, static_cast(&QComboBox::currentIndexChanged), this, &SettingsBrowserMail::changeDefaultBrowserArguments); + connect(m_ui->m_btnExternalBrowserExecutable, &QPushButton::clicked, this, &SettingsBrowserMail::selectBrowserExecutable); + connect(m_ui->m_cmbExternalEmailPreset, static_cast(&QComboBox::currentIndexChanged), this, &SettingsBrowserMail::changeDefaultEmailArguments); + connect(m_ui->m_btnExternalEmailExecutable, &QPushButton::clicked, this, &SettingsBrowserMail::selectEmailExecutable); } -SettingsBrowserMail::~SettingsBrowserMail() -{ - delete ui; +SettingsBrowserMail::~SettingsBrowserMail() { + delete m_ui; +} + +void SettingsBrowserMail::changeDefaultBrowserArguments(int index) { + if (index != 0) { + m_ui->m_txtExternalBrowserArguments->setText(m_ui->m_cmbExternalBrowserPreset->itemData(index).toString()); + } +} + +void SettingsBrowserMail::selectBrowserExecutable() { + const QString executable_file = QFileDialog::getOpenFileName(this, + tr("Select web browser executable"), + qApp->homeFolderPath(), + //: File filter for external browser selection dialog. + #if defined(Q_OS_LINUX) + tr("Executables (*)") + #else + tr("Executables (*.*)") + #endif + ); + + if (!executable_file.isEmpty()) { + m_ui->m_txtExternalBrowserExecutable->setText(QDir::toNativeSeparators(executable_file)); + } +} + +void SettingsBrowserMail::displayProxyPassword(int state) { + if (state == Qt::Checked) { + m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::Normal); + } + else { + m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit); + } +} + +void SettingsBrowserMail::onProxyTypeChanged(int index) { + const QNetworkProxy::ProxyType selected_type = static_cast(m_ui->m_cmbProxyType->itemData(index).toInt()); + const bool is_proxy_selected = selected_type != QNetworkProxy::NoProxy && selected_type != QNetworkProxy::DefaultProxy; + + 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); + 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); +} + +void SettingsBrowserMail::changeDefaultEmailArguments(int index) { + if (index != 0) { + m_ui->m_txtExternalEmailArguments->setText(m_ui->m_cmbExternalEmailPreset->itemData(index).toString()); + } +} + +void SettingsBrowserMail::selectEmailExecutable() { + QString executable_file = QFileDialog::getOpenFileName(this, + tr("Select e-mail executable"), + qApp->homeFolderPath(), + //: File filter for external e-mail selection dialog. + #if defined(Q_OS_LINUX) + tr("Executables (*)") + #else + tr("Executables (*.*)") + #endif + ); + + if (!executable_file.isEmpty()) { + m_ui->m_txtExternalEmailExecutable->setText(QDir::toNativeSeparators(executable_file)); + } +} + +void SettingsBrowserMail::loadSettings() { + // Load settings of web browser GUI. + m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), QSL("-nosession %1")); + m_ui->m_txtExternalBrowserExecutable->setText(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserExecutable)).toString()); + m_ui->m_txtExternalBrowserArguments->setText(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserArguments)).toString()); + m_ui->m_grpCustomExternalBrowser->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool()); + + // Load settings of e-mail. + m_ui->m_cmbExternalEmailPreset->addItem(tr("Mozilla Thunderbird"), QSL("-compose \"subject='%1',body='%2'\"")); + m_ui->m_txtExternalEmailExecutable->setText(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailExecutable)).toString()); + m_ui->m_txtExternalEmailArguments->setText(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailArguments)).toString()); + m_ui->m_grpCustomExternalEmail->setChecked(settings()->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailEnabled)).toBool()); + + m_ui->m_cmbProxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy); + m_ui->m_cmbProxyType->addItem(tr("System proxy"), QNetworkProxy::DefaultProxy); + m_ui->m_cmbProxyType->addItem(tr("Socks5"), QNetworkProxy::Socks5Proxy); + m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy); + + // Load the settings. + QNetworkProxy::ProxyType selected_proxy_type = static_cast(settings()->value(GROUP(Proxy), SETTING(Proxy::Type)).toInt()); + + m_ui->m_cmbProxyType->setCurrentIndex(m_ui->m_cmbProxyType->findData(selected_proxy_type)); + m_ui->m_txtProxyHost->setText(settings()->value(GROUP(Proxy), SETTING(Proxy::Host)).toString()); + m_ui->m_txtProxyUsername->setText(settings()->value(GROUP(Proxy), SETTING(Proxy::Username)).toString()); + m_ui->m_txtProxyPassword->setText(TextFactory::decrypt(settings()->value(GROUP(Proxy), SETTING(Proxy::Password)).toString())); + m_ui->m_spinProxyPort->setValue(settings()->value(GROUP(Proxy), SETTING(Proxy::Port)).toInt()); + + +} + +void SettingsBrowserMail::saveSettings() { + // Save settings of GUI of web browser. + settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserEnabled, m_ui->m_grpCustomExternalBrowser->isChecked()); + settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserExecutable, m_ui->m_txtExternalBrowserExecutable->text()); + settings()->setValue(GROUP(Browser), Browser::CustomExternalBrowserArguments, m_ui->m_txtExternalBrowserArguments->text()); + + // Save settings of e-mail. + settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailExecutable, m_ui->m_txtExternalEmailExecutable->text()); + settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailArguments, m_ui->m_txtExternalEmailArguments->text()); + settings()->setValue(GROUP(Browser), Browser::CustomExternalEmailEnabled, m_ui->m_grpCustomExternalEmail->isChecked()); + + settings()->setValue(GROUP(Proxy), Proxy::Type, m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex())); + settings()->setValue(GROUP(Proxy), Proxy::Host, m_ui->m_txtProxyHost->text()); + settings()->setValue(GROUP(Proxy), Proxy::Username, m_ui->m_txtProxyUsername->text()); + settings()->setValue(GROUP(Proxy), Proxy::Password, TextFactory::encrypt(m_ui->m_txtProxyPassword->text())); + settings()->setValue(GROUP(Proxy), Proxy::Port, m_ui->m_spinProxyPort->value()); + + // Reload settings for all network access managers. + SilentNetworkAccessManager::instance()->loadSettings(); } diff --git a/src/gui/settings/settingsbrowsermail.h b/src/gui/settings/settingsbrowsermail.h index 4518304e2..c7373e877 100755 --- a/src/gui/settings/settingsbrowsermail.h +++ b/src/gui/settings/settingsbrowsermail.h @@ -1,22 +1,52 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #ifndef SETTINGSBROWSERMAIL_H #define SETTINGSBROWSERMAIL_H -#include +#include "gui/settings/settingspanel.h" -namespace Ui { - class SettingsBrowserMail; -} +#include "ui_settingsbrowsermail.h" -class SettingsBrowserMail : public QWidget -{ + +class SettingsBrowserMail : public SettingsPanel { Q_OBJECT public: - explicit SettingsBrowserMail(QWidget *parent = 0); - ~SettingsBrowserMail(); + explicit SettingsBrowserMail(Settings *settings, QWidget *parent = 0); + virtual ~SettingsBrowserMail(); + + inline QString title() const { + return tr("Web browser & e-mail & proxy"); + } + + void loadSettings(); + void saveSettings(); + + private slots: + void changeDefaultBrowserArguments(int index); + void selectBrowserExecutable(); + void changeDefaultEmailArguments(int index); + void selectEmailExecutable(); + void displayProxyPassword(int state); + void onProxyTypeChanged(int index); private: - Ui::SettingsBrowserMail *ui; + Ui::SettingsBrowserMail *m_ui; }; #endif // SETTINGSBROWSERMAIL_H diff --git a/src/gui/settings/settingsdatabase.cpp b/src/gui/settings/settingsdatabase.cpp index c9b495e1a..39271bb63 100755 --- a/src/gui/settings/settingsdatabase.cpp +++ b/src/gui/settings/settingsdatabase.cpp @@ -1,3 +1,20 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #include "gui/settings/settingsdatabase.h" #include "miscellaneous/databasefactory.h" diff --git a/src/gui/settings/settingsdatabase.h b/src/gui/settings/settingsdatabase.h index 9bd420799..99c328710 100755 --- a/src/gui/settings/settingsdatabase.h +++ b/src/gui/settings/settingsdatabase.h @@ -1,3 +1,20 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #ifndef SETTINGSDATABASE_H #define SETTINGSDATABASE_H @@ -13,6 +30,10 @@ class SettingsDatabase : public SettingsPanel { explicit SettingsDatabase(Settings *settings, QWidget *parent = 0); virtual ~SettingsDatabase(); + inline QString title() const { + return tr("Data storage"); + } + void loadSettings(); void saveSettings(); diff --git a/src/gui/settings/settingsdownloads.cpp b/src/gui/settings/settingsdownloads.cpp index ed0ce52cf..dc45eaea0 100755 --- a/src/gui/settings/settingsdownloads.cpp +++ b/src/gui/settings/settingsdownloads.cpp @@ -1,14 +1,62 @@ -#include "settingsdownloads.h" -#include "ui_settingsdownloads.h" +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . -SettingsDownloads::SettingsDownloads(QWidget *parent) : - QWidget(parent), - ui(new Ui::SettingsDownloads) -{ - ui->setupUi(this); +#include "gui/settings/settingsdownloads.h" + +#include "miscellaneous/settings.h" +#include "network-web/downloadmanager.h" +#include "miscellaneous/application.h" + +#include + + +SettingsDownloads::SettingsDownloads(Settings *settings, QWidget *parent) + : SettingsPanel(settings, parent), m_ui(new Ui::SettingsDownloads) { + m_ui->setupUi(this); + connect(m_ui->m_btnDownloadsTargetDirectory, &QPushButton::clicked, this, &SettingsDownloads::selectDownloadsDirectory); } -SettingsDownloads::~SettingsDownloads() -{ - delete ui; +SettingsDownloads::~SettingsDownloads() { + delete m_ui; +} + +void SettingsDownloads::selectDownloadsDirectory() { + const QString target_directory = QFileDialog::getExistingDirectory(this, + tr("Select downloads target directory"), + m_ui->m_txtDownloadsTargetDirectory->text() + ); + + if (!target_directory.isEmpty()) { + m_ui->m_txtDownloadsTargetDirectory->setText(QDir::toNativeSeparators(target_directory)); + } +} + +void SettingsDownloads::loadSettings() { + m_ui->m_checkOpenManagerWhenDownloadStarts->setChecked(settings()->value(GROUP(Downloads), + SETTING(Downloads::ShowDownloadsWhenNewDownloadStarts)).toBool()); + m_ui->m_txtDownloadsTargetDirectory->setText(QDir::toNativeSeparators(settings()->value(GROUP(Downloads), + SETTING(Downloads::TargetDirectory)).toString())); + m_ui->m_rbDownloadsAskEachFile->setChecked(settings()->value(GROUP(Downloads), + SETTING(Downloads::AlwaysPromptForFilename)).toBool()); +} + +void SettingsDownloads::saveSettings() { + settings()->setValue(GROUP(Downloads), Downloads::ShowDownloadsWhenNewDownloadStarts, m_ui->m_checkOpenManagerWhenDownloadStarts->isChecked()); + settings()->setValue(GROUP(Downloads), Downloads::TargetDirectory, m_ui->m_txtDownloadsTargetDirectory->text()); + settings()->setValue(GROUP(Downloads), Downloads::AlwaysPromptForFilename, m_ui->m_rbDownloadsAskEachFile->isChecked()); + qApp->downloadManager()->setDownloadDirectory(m_ui->m_txtDownloadsTargetDirectory->text()); } diff --git a/src/gui/settings/settingsdownloads.h b/src/gui/settings/settingsdownloads.h index 3bfa7c2fa..72a596484 100755 --- a/src/gui/settings/settingsdownloads.h +++ b/src/gui/settings/settingsdownloads.h @@ -1,22 +1,47 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #ifndef SETTINGSDOWNLOADS_H #define SETTINGSDOWNLOADS_H -#include +#include "gui/settings/settingspanel.h" -namespace Ui { - class SettingsDownloads; -} +#include "ui_settingsdownloads.h" -class SettingsDownloads : public QWidget -{ + +class SettingsDownloads : public SettingsPanel { Q_OBJECT public: - explicit SettingsDownloads(QWidget *parent = 0); - ~SettingsDownloads(); + explicit SettingsDownloads(Settings *settings, QWidget *parent = 0); + virtual ~SettingsDownloads(); + + inline QString title() const { + return tr("Downloads"); + } + + void loadSettings(); + void saveSettings(); + + private slots: + void selectDownloadsDirectory(); private: - Ui::SettingsDownloads *ui; + Ui::SettingsDownloads *m_ui; }; #endif // SETTINGSDOWNLOADS_H diff --git a/src/gui/settings/settingsfeedsmessages.cpp b/src/gui/settings/settingsfeedsmessages.cpp index f07e75544..b8e721115 100755 --- a/src/gui/settings/settingsfeedsmessages.cpp +++ b/src/gui/settings/settingsfeedsmessages.cpp @@ -1,14 +1,111 @@ -#include "settingsfeedsmessages.h" -#include "ui_settingsfeedsmessages.h" +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . -SettingsFeedsMessages::SettingsFeedsMessages(QWidget *parent) : - QWidget(parent), - ui(new Ui::SettingsFeedsMessages) -{ - ui->setupUi(this); +#include "gui/settings/settingsfeedsmessages.h" + +#include "definitions/definitions.h" +#include "miscellaneous/application.h" +#include "gui/dialogs/formmain.h" +#include "gui/feedmessageviewer.h" +#include "gui/feedsview.h" +#include "gui/messagesview.h" + +#include + + +SettingsFeedsMessages::SettingsFeedsMessages(Settings *settings, QWidget *parent) + : SettingsPanel(settings, parent), m_ui(new Ui::SettingsFeedsMessages){ + m_ui->setupUi(this); + initializeMessageDateFormats(); + connect(m_ui->m_btnChangeMessagesFont, &QPushButton::clicked, this, &SettingsFeedsMessages::changeMessagesFont); } -SettingsFeedsMessages::~SettingsFeedsMessages() -{ - delete ui; +SettingsFeedsMessages::~SettingsFeedsMessages() { + delete m_ui; +} + + +void SettingsFeedsMessages::initializeMessageDateFormats() { + QStringList best_formats; best_formats << QSL("d/M/yyyy hh:mm:ss") << QSL("ddd, d. M. yy hh:mm:ss") << + QSL("yyyy-MM-dd HH:mm:ss.z") << QSL("yyyy-MM-ddThh:mm:ss") << + QSL("MMM d yyyy hh:mm:ss");; + const QLocale current_locale = qApp->localization()->loadedLocale(); + const QDateTime current_dt = QDateTime::currentDateTime(); + + foreach (const QString &format, best_formats) { + m_ui->m_cmbMessagesDateTimeFormat->addItem(current_locale.toString(current_dt, format), format); + } +} + +void SettingsFeedsMessages::changeMessagesFont() { + bool ok; + QFont new_font = QFontDialog::getFont(&ok, m_ui->m_lblMessagesFont->font(), + this, tr("Select new font for message viewer"), + QFontDialog::DontUseNativeDialog); + + if (ok) { + m_ui->m_lblMessagesFont->setFont(new_font); + } +} + +void SettingsFeedsMessages::loadSettings() { + m_ui->m_checkKeppMessagesInTheMiddle->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()); + m_ui->m_checkRemoveReadMessagesOnExit->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::ClearReadOnExit)).toBool()); + m_ui->m_checkAutoUpdate->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateEnabled)).toBool()); + m_ui->m_spinAutoUpdateInterval->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt()); + m_ui->m_spinFeedUpdateTimeout->setValue(settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt()); + m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(settings()->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool()); + m_ui->m_cmbCountsFeedList->addItems(QStringList() << "(%unread)" << "[%unread]" << "%unread/%all" << "%unread-%all" << "[%unread|%all]"); + m_ui->m_cmbCountsFeedList->setEditText(settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString()); + + initializeMessageDateFormats(); + + m_ui->m_checkMessagesDateTimeFormat->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool()); + const int index_format = m_ui->m_cmbMessagesDateTimeFormat->findData(settings()->value(GROUP(Messages), SETTING(Messages::CustomDateFormat)).toString()); + + if (index_format >= 0) { + m_ui->m_cmbMessagesDateTimeFormat->setCurrentIndex(index_format); + } + + m_ui->m_lblMessagesFont->setText(tr("Font preview")); + QFont fon; + fon.fromString(settings()->value(GROUP(Messages), + SETTING(Messages::PreviewerFontStandard)).toString()); + m_ui->m_lblMessagesFont->setFont(fon); +} + +void SettingsFeedsMessages::saveSettings() { + settings()->setValue(GROUP(Messages), Messages::KeepCursorInCenter, m_ui->m_checkKeppMessagesInTheMiddle->isChecked()); + settings()->setValue(GROUP(Messages), Messages::ClearReadOnExit, m_ui->m_checkRemoveReadMessagesOnExit->isChecked()); + settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateEnabled, m_ui->m_checkAutoUpdate->isChecked()); + settings()->setValue(GROUP(Feeds), Feeds::AutoUpdateInterval, m_ui->m_spinAutoUpdateInterval->value()); + settings()->setValue(GROUP(Feeds), Feeds::UpdateTimeout, m_ui->m_spinFeedUpdateTimeout->value()); + settings()->setValue(GROUP(Feeds), Feeds::FeedsUpdateOnStartup, m_ui->m_checkUpdateAllFeedsOnStartup->isChecked()); + settings()->setValue(GROUP(Feeds), Feeds::CountFormat, m_ui->m_cmbCountsFeedList->currentText()); + settings()->setValue(GROUP(Messages), Messages::UseCustomDate, m_ui->m_checkMessagesDateTimeFormat->isChecked()); + settings()->setValue(GROUP(Messages), Messages::CustomDateFormat, + m_ui->m_cmbMessagesDateTimeFormat->itemData(m_ui->m_cmbMessagesDateTimeFormat->currentIndex()).toString()); + + // Save fonts. + settings()->setValue(GROUP(Messages), Messages::PreviewerFontStandard, m_ui->m_lblMessagesFont->font().toString()); + + qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts(); + qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->updateAutoUpdateStatus(); + qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->reloadWholeLayout(); + qApp->mainForm()->tabWidget()->feedMessageViewer()->messagesView()->sourceModel()->updateDateFormat(); + qApp->mainForm()->tabWidget()->feedMessageViewer()->messagesView()->sourceModel()->reloadWholeLayout(); } diff --git a/src/gui/settings/settingsfeedsmessages.h b/src/gui/settings/settingsfeedsmessages.h index e00cf2632..f32fa010d 100755 --- a/src/gui/settings/settingsfeedsmessages.h +++ b/src/gui/settings/settingsfeedsmessages.h @@ -1,22 +1,49 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #ifndef SETTINGSFEEDSMESSAGES_H #define SETTINGSFEEDSMESSAGES_H -#include +#include "gui/settings/settingspanel.h" -namespace Ui { - class SettingsFeedsMessages; -} +#include "ui_settingsfeedsmessages.h" -class SettingsFeedsMessages : public QWidget -{ + +class SettingsFeedsMessages : public SettingsPanel { Q_OBJECT public: - explicit SettingsFeedsMessages(QWidget *parent = 0); - ~SettingsFeedsMessages(); + explicit SettingsFeedsMessages(Settings *settings, QWidget *parent = 0); + virtual ~SettingsFeedsMessages(); + + inline QString title() const { + return tr("Feeds & messages"); + } + + void loadSettings(); + void saveSettings(); + + private slots: + void changeMessagesFont(); private: - Ui::SettingsFeedsMessages *ui; + void initializeMessageDateFormats(); + + Ui::SettingsFeedsMessages *m_ui; }; #endif // SETTINGSFEEDSMESSAGES_H diff --git a/src/gui/settings/settingsgeneral.h b/src/gui/settings/settingsgeneral.h index bf0c1b1a8..ee77b71c4 100755 --- a/src/gui/settings/settingsgeneral.h +++ b/src/gui/settings/settingsgeneral.h @@ -30,7 +30,10 @@ class SettingsGeneral : public SettingsPanel { explicit SettingsGeneral(Settings *settings, QWidget *parent = 0); virtual ~SettingsGeneral(); - protected: + inline QString title() const { + return tr("General"); + } + void loadSettings(); void saveSettings(); diff --git a/src/gui/settings/settingsgui.cpp b/src/gui/settings/settingsgui.cpp index dfccc9146..e742f8bd6 100755 --- a/src/gui/settings/settingsgui.cpp +++ b/src/gui/settings/settingsgui.cpp @@ -1,3 +1,20 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #include "gui/settings/settingsgui.h" #include "gui/systemtrayicon.h" @@ -11,6 +28,8 @@ #include "gui/messagestoolbar.h" #include "gui/statusbar.h" +#include + SettingsGui::SettingsGui(Settings *settings, QWidget *parent) : SettingsPanel(settings, parent), m_ui(new Ui::SettingsGui) { m_ui->setupUi(this); @@ -42,6 +61,21 @@ SettingsGui::~SettingsGui() { delete m_ui; } +bool SettingsGui::eventFilter(QObject *obj, QEvent *e) { + Q_UNUSED(obj) + + if (e->type() == QEvent::Drop) { + QDropEvent *drop_event = static_cast(e); + + if (drop_event->keyboardModifiers() != Qt::NoModifier) { + drop_event->setDropAction(Qt::MoveAction); + } + } + + return false; +} + + void SettingsGui::loadSettings() { onBeginLoadSettings(); diff --git a/src/gui/settings/settingsgui.h b/src/gui/settings/settingsgui.h index 2ca305266..f9466d75c 100755 --- a/src/gui/settings/settingsgui.h +++ b/src/gui/settings/settingsgui.h @@ -1,3 +1,20 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #ifndef SETTINGSGUI_H #define SETTINGSGUI_H @@ -13,9 +30,17 @@ class SettingsGui : public SettingsPanel { explicit SettingsGui(Settings *settings, QWidget *parent = 0); virtual ~SettingsGui(); + inline QString title() const { + return tr("User interface"); + } + void loadSettings(); void saveSettings(); + protected: + // Does check of controls before dialog can be submitted. + bool eventFilter(QObject *obj, QEvent *e); + private slots: void onSkinSelected(QTreeWidgetItem *current, QTreeWidgetItem *previous); diff --git a/src/gui/settings/settingslocalization.cpp b/src/gui/settings/settingslocalization.cpp index a01c16cd7..c1a04b4bb 100755 --- a/src/gui/settings/settingslocalization.cpp +++ b/src/gui/settings/settingslocalization.cpp @@ -1,3 +1,20 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #include "gui/settings/settingslocalization.h" #include "miscellaneous/localization.h" diff --git a/src/gui/settings/settingslocalization.h b/src/gui/settings/settingslocalization.h index 67e7577bc..f2c0b7e83 100755 --- a/src/gui/settings/settingslocalization.h +++ b/src/gui/settings/settingslocalization.h @@ -1,3 +1,20 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #ifndef SETTINGSLOCALIZATION_H #define SETTINGSLOCALIZATION_H @@ -13,6 +30,10 @@ class SettingsLocalization : public SettingsPanel { explicit SettingsLocalization(Settings *settings, QWidget *parent = 0); virtual ~SettingsLocalization(); + inline QString title() const { + return tr("Language"); + } + void loadSettings(); void saveSettings(); diff --git a/src/gui/settings/settingspanel.h b/src/gui/settings/settingspanel.h index 50fa005d4..a6245b0fd 100755 --- a/src/gui/settings/settingspanel.h +++ b/src/gui/settings/settingspanel.h @@ -29,6 +29,8 @@ class SettingsPanel : public QWidget { public: explicit SettingsPanel(Settings *settings, QWidget *parent = 0); + virtual QString title() const = 0; + virtual void loadSettings() = 0; virtual void saveSettings() = 0; diff --git a/src/gui/settings/settingsshortcuts.cpp b/src/gui/settings/settingsshortcuts.cpp index 7a0ff774d..dc453fc3f 100755 --- a/src/gui/settings/settingsshortcuts.cpp +++ b/src/gui/settings/settingsshortcuts.cpp @@ -1,3 +1,20 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #include "gui/settings/settingsshortcuts.h" #include "gui/dialogs/formmain.h" diff --git a/src/gui/settings/settingsshortcuts.h b/src/gui/settings/settingsshortcuts.h index 79f599111..e6b823d2f 100755 --- a/src/gui/settings/settingsshortcuts.h +++ b/src/gui/settings/settingsshortcuts.h @@ -1,3 +1,20 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2016 by Martin Rotter +// +// 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 . + #ifndef SETTINGSSHORTCUTS_H #define SETTINGSSHORTCUTS_H @@ -13,6 +30,10 @@ class SettingsShortcuts : public SettingsPanel { explicit SettingsShortcuts(Settings *settings, QWidget *parent = 0); virtual ~SettingsShortcuts(); + inline QString title() const { + return tr("Keyboard shortcuts"); + } + void loadSettings(); void saveSettings();