Const stuff.

This commit is contained in:
Martin Rotter 2016-01-12 07:54:34 +01:00
parent d7470c7465
commit 756991d7e8
7 changed files with 186 additions and 204 deletions

View File

@ -86,7 +86,7 @@ FormMain::FormMain(QWidget *parent, Qt::WindowFlags f)
} }
FormMain::~FormMain() { FormMain::~FormMain() {
qDebug("Destroying FormDatabaseCleanup instance."); qDebug("Destroying FormMain instance.");
} }
QList<QAction*> FormMain::allActions() const { QList<QAction*> FormMain::allActions() const {

View File

@ -45,7 +45,7 @@ FormRestoreDatabaseSettings::FormRestoreDatabaseSettings(QWidget *parent)
} }
FormRestoreDatabaseSettings::~FormRestoreDatabaseSettings() { FormRestoreDatabaseSettings::~FormRestoreDatabaseSettings() {
delete m_ui; qDebug("Destroying FormRestoreDatabaseSettings instance.");
} }
void FormRestoreDatabaseSettings::performRestoration() { void FormRestoreDatabaseSettings::performRestoration() {
@ -64,7 +64,7 @@ void FormRestoreDatabaseSettings::performRestoration() {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Restoration was initiated. Restart to proceed."), m_ui->m_lblResult->setStatus(WidgetWithStatus::Ok, tr("Restoration was initiated. Restart to proceed."),
tr("You need to restart application for restoration process to finish.")); tr("You need to restart application for restoration process to finish."));
} }
catch (ApplicationException &ex) { catch (const ApplicationException &ex) {
m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, ex.message(), m_ui->m_lblResult->setStatus(WidgetWithStatus::Error, ex.message(),
tr("Database and/or settings were not copied to restoration directory successully.")); tr("Database and/or settings were not copied to restoration directory successully."));
} }
@ -92,12 +92,12 @@ void FormRestoreDatabaseSettings::selectFolder(QString folder) {
return; return;
} }
QDir selected_folder(folder); const QDir selected_folder(folder);
QFileInfoList available_databases = selected_folder.entryInfoList(QStringList() << QString("*") + BACKUP_SUFFIX_DATABASE , const QFileInfoList available_databases = selected_folder.entryInfoList(QStringList() << QString("*") + BACKUP_SUFFIX_DATABASE ,
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable | QDir::Files | QDir::NoDotAndDotDot | QDir::Readable |
QDir::CaseSensitive | QDir::NoSymLinks, QDir::CaseSensitive | QDir::NoSymLinks,
QDir::Name); QDir::Name);
QFileInfoList available_settings = selected_folder.entryInfoList(QStringList() << QString("*") + BACKUP_SUFFIX_SETTINGS , const QFileInfoList available_settings = selected_folder.entryInfoList(QStringList() << QString("*") + BACKUP_SUFFIX_SETTINGS ,
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable | QDir::Files | QDir::NoDotAndDotDot | QDir::Readable |
QDir::CaseSensitive | QDir::NoSymLinks, QDir::CaseSensitive | QDir::NoSymLinks,
QDir::Name); QDir::Name);

2
src/gui/dialogs/formrestoredatabasesettings.h Normal file → Executable file
View File

@ -41,7 +41,7 @@ class FormRestoreDatabaseSettings : public QDialog {
void selectFolder(QString folder = QString()); void selectFolder(QString folder = QString());
private: private:
Ui::FormRestoreDatabaseSettings *m_ui; QScopedPointer<Ui::FormRestoreDatabaseSettings> m_ui;
QPushButton *m_btnRestart; QPushButton *m_btnRestart;
}; };

View File

@ -52,9 +52,11 @@
#include <QDir> #include <QDir>
FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormSettings) { FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormSettings), m_settings(NULL) {
m_ui->setupUi(this); m_ui->setupUi(this);
m_settings = qApp->settings();
// Set flags and attributes. // Set flags and attributes.
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint);
setWindowIcon(qApp->icons()->fromTheme(QSL("application-settings"))); setWindowIcon(qApp->icons()->fromTheme(QSL("application-settings")));
@ -148,7 +150,6 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form
FormSettings::~FormSettings() { FormSettings::~FormSettings() {
qDebug("Destroying FormSettings distance."); qDebug("Destroying FormSettings distance.");
delete m_ui;
} }
void FormSettings::changeDefaultBrowserArguments(int index) { void FormSettings::changeDefaultBrowserArguments(int index) {
@ -157,12 +158,11 @@ void FormSettings::changeDefaultBrowserArguments(int index) {
} }
} }
void FormSettings::onSkinSelected(QTreeWidgetItem *current, void FormSettings::onSkinSelected(QTreeWidgetItem *current, QTreeWidgetItem *previous) {
QTreeWidgetItem *previous) {
Q_UNUSED(previous) Q_UNUSED(previous)
if (current != NULL) { if (current != NULL) {
Skin skin = current->data(0, Qt::UserRole).value<Skin>(); const Skin skin = current->data(0, Qt::UserRole).value<Skin>();
m_ui->m_lblSelectedContents->setText(skin.m_visibleName); m_ui->m_lblSelectedContents->setText(skin.m_visibleName);
} }
} }
@ -176,20 +176,20 @@ void FormSettings::selectNewNotificationColor() {
} }
void FormSettings::loadDownloads() { void FormSettings::loadDownloads() {
m_ui->m_txtDownloadsTargetDirectory->setText(QDir::toNativeSeparators(qApp->settings()->value(GROUP(Downloads), m_ui->m_txtDownloadsTargetDirectory->setText(QDir::toNativeSeparators(m_settings->value(GROUP(Downloads),
SETTING(Downloads::TargetDirectory)).toString())); SETTING(Downloads::TargetDirectory)).toString()));
m_ui->m_rbDownloadsAskEachFile->setChecked(qApp->settings()->value(GROUP(Downloads), m_ui->m_rbDownloadsAskEachFile->setChecked(m_settings->value(GROUP(Downloads),
SETTING(Downloads::AlwaysPromptForFilename)).toBool()); SETTING(Downloads::AlwaysPromptForFilename)).toBool());
} }
void FormSettings::saveDownloads() { void FormSettings::saveDownloads() {
qApp->settings()->setValue(GROUP(Downloads), Downloads::TargetDirectory, m_ui->m_txtDownloadsTargetDirectory->text()); m_settings->setValue(GROUP(Downloads), Downloads::TargetDirectory, m_ui->m_txtDownloadsTargetDirectory->text());
qApp->settings()->setValue(GROUP(Downloads), Downloads::AlwaysPromptForFilename, m_ui->m_rbDownloadsAskEachFile->isChecked()); m_settings->setValue(GROUP(Downloads), Downloads::AlwaysPromptForFilename, m_ui->m_rbDownloadsAskEachFile->isChecked());
qApp->downloadManager()->setDownloadDirectory(m_ui->m_txtDownloadsTargetDirectory->text()); qApp->downloadManager()->setDownloadDirectory(m_ui->m_txtDownloadsTargetDirectory->text());
} }
void FormSettings::selectDownloadsDirectory() { void FormSettings::selectDownloadsDirectory() {
QString target_directory = QFileDialog::getExistingDirectory(this, const QString target_directory = QFileDialog::getExistingDirectory(this,
tr("Select downloads target directory"), tr("Select downloads target directory"),
m_ui->m_txtDownloadsTargetDirectory->text() m_ui->m_txtDownloadsTargetDirectory->text()
); );
@ -200,7 +200,7 @@ void FormSettings::selectDownloadsDirectory() {
} }
void FormSettings::selectBrowserExecutable() { void FormSettings::selectBrowserExecutable() {
QString executable_file = QFileDialog::getOpenFileName(this, const QString executable_file = QFileDialog::getOpenFileName(this,
tr("Select web browser executable"), tr("Select web browser executable"),
qApp->homeFolderPath(), qApp->homeFolderPath(),
//: File filter for external browser selection dialog. //: File filter for external browser selection dialog.
@ -240,28 +240,26 @@ void FormSettings::selectEmailExecutable() {
} }
void FormSettings::loadFeedsMessages() { void FormSettings::loadFeedsMessages() {
Settings *settings = qApp->settings(); 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_checkKeppMessagesInTheMiddle->setChecked(settings->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()); m_ui->m_checkAutoUpdate->setChecked(m_settings->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateEnabled)).toBool());
m_ui->m_checkRemoveReadMessagesOnExit->setChecked(settings->value(GROUP(Messages), SETTING(Messages::ClearReadOnExit)).toBool()); m_ui->m_spinAutoUpdateInterval->setValue(m_settings->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt());
m_ui->m_checkAutoUpdate->setChecked(settings->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateEnabled)).toBool()); m_ui->m_spinFeedUpdateTimeout->setValue(m_settings->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt());
m_ui->m_spinAutoUpdateInterval->setValue(settings->value(GROUP(Feeds), SETTING(Feeds::AutoUpdateInterval)).toInt()); m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(m_settings->value(GROUP(Feeds), SETTING(Feeds::FeedsUpdateOnStartup)).toBool());
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->addItems(QStringList() << "(%unread)" << "[%unread]" << "%unread/%all" << "%unread-%all" << "[%unread|%all]");
m_ui->m_cmbCountsFeedList->setEditText(settings->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString()); m_ui->m_cmbCountsFeedList->setEditText(m_settings->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString());
m_ui->m_checkRemoveDuplicateMessages->setChecked(settings->value(GROUP(Messages), SETTING(Messages::RemoveDuplicates)).toBool()); m_ui->m_checkRemoveDuplicateMessages->setChecked(m_settings->value(GROUP(Messages), SETTING(Messages::RemoveDuplicates)).toBool());
initializeMessageDateFormats(); initializeMessageDateFormats();
m_ui->m_checkMessagesDateTimeFormat->setChecked(settings->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool()); m_ui->m_checkMessagesDateTimeFormat->setChecked(m_settings->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool());
int index_format = m_ui->m_cmbMessagesDateTimeFormat->findData(settings->value(GROUP(Messages), SETTING(Messages::CustomDateFormat)).toString()); const int index_format = m_ui->m_cmbMessagesDateTimeFormat->findData(m_settings->value(GROUP(Messages), SETTING(Messages::CustomDateFormat)).toString());
if (index_format >= 0) { if (index_format >= 0) {
m_ui->m_cmbMessagesDateTimeFormat->setCurrentIndex(index_format); m_ui->m_cmbMessagesDateTimeFormat->setCurrentIndex(index_format);
} }
m_ui->m_cmbMessageFontStandard->setCurrentIndex(m_ui->m_cmbMessageFontStandard->findText(settings->value(GROUP(Messages), m_ui->m_cmbMessageFontStandard->setCurrentIndex(m_ui->m_cmbMessageFontStandard->findText(m_settings->value(GROUP(Messages),
SETTING(Messages::PreviewerFontStandard)).toString())); SETTING(Messages::PreviewerFontStandard)).toString()));
} }
@ -269,8 +267,8 @@ void FormSettings::initializeMessageDateFormats() {
QStringList best_formats; best_formats << QSL("d/M/yyyy hh:mm:ss") << QSL("ddd, d. M. yy hh:mm:ss") << 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("yyyy-MM-dd HH:mm:ss.z") << QSL("yyyy-MM-ddThh:mm:ss") <<
QSL("MMM d yyyy hh:mm:ss");; QSL("MMM d yyyy hh:mm:ss");;
QLocale current_locale = qApp->localization()->loadedLocale(); const QLocale current_locale = qApp->localization()->loadedLocale();
QDateTime current_dt = QDateTime::currentDateTime(); const QDateTime current_dt = QDateTime::currentDateTime();
foreach (const QString &format, best_formats) { foreach (const QString &format, best_formats) {
m_ui->m_cmbMessagesDateTimeFormat->addItem(current_locale.toString(current_dt, format), format); m_ui->m_cmbMessagesDateTimeFormat->addItem(current_locale.toString(current_dt, format), format);
@ -278,22 +276,20 @@ void FormSettings::initializeMessageDateFormats() {
} }
void FormSettings::saveFeedsMessages() { void FormSettings::saveFeedsMessages() {
Settings *settings = qApp->settings(); m_settings->setValue(GROUP(Messages), Messages::KeepCursorInCenter, m_ui->m_checkKeppMessagesInTheMiddle->isChecked());
m_settings->setValue(GROUP(Messages), Messages::ClearReadOnExit, m_ui->m_checkRemoveReadMessagesOnExit->isChecked());
settings->setValue(GROUP(Messages), Messages::KeepCursorInCenter, m_ui->m_checkKeppMessagesInTheMiddle->isChecked()); m_settings->setValue(GROUP(Feeds), Feeds::AutoUpdateEnabled, m_ui->m_checkAutoUpdate->isChecked());
settings->setValue(GROUP(Messages), Messages::ClearReadOnExit, m_ui->m_checkRemoveReadMessagesOnExit->isChecked()); m_settings->setValue(GROUP(Feeds), Feeds::AutoUpdateInterval, m_ui->m_spinAutoUpdateInterval->value());
settings->setValue(GROUP(Feeds), Feeds::AutoUpdateEnabled, m_ui->m_checkAutoUpdate->isChecked()); m_settings->setValue(GROUP(Feeds), Feeds::UpdateTimeout, m_ui->m_spinFeedUpdateTimeout->value());
settings->setValue(GROUP(Feeds), Feeds::AutoUpdateInterval, m_ui->m_spinAutoUpdateInterval->value()); m_settings->setValue(GROUP(Feeds), Feeds::FeedsUpdateOnStartup, m_ui->m_checkUpdateAllFeedsOnStartup->isChecked());
settings->setValue(GROUP(Feeds), Feeds::UpdateTimeout, m_ui->m_spinFeedUpdateTimeout->value()); m_settings->setValue(GROUP(Feeds), Feeds::CountFormat, m_ui->m_cmbCountsFeedList->currentText());
settings->setValue(GROUP(Feeds), Feeds::FeedsUpdateOnStartup, m_ui->m_checkUpdateAllFeedsOnStartup->isChecked()); m_settings->setValue(GROUP(Messages), Messages::UseCustomDate, m_ui->m_checkMessagesDateTimeFormat->isChecked());
settings->setValue(GROUP(Feeds), Feeds::CountFormat, m_ui->m_cmbCountsFeedList->currentText()); m_settings->setValue(GROUP(Messages), Messages::CustomDateFormat,
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()); m_ui->m_cmbMessagesDateTimeFormat->itemData(m_ui->m_cmbMessagesDateTimeFormat->currentIndex()).toString());
settings->setValue(GROUP(Messages), Messages::RemoveDuplicates, m_ui->m_checkRemoveDuplicateMessages->isChecked()); m_settings->setValue(GROUP(Messages), Messages::RemoveDuplicates, m_ui->m_checkRemoveDuplicateMessages->isChecked());
// Save fonts. // Save fonts.
settings->setValue(GROUP(Messages), Messages::PreviewerFontStandard, m_ui->m_cmbMessageFontStandard->currentFont().family()); m_settings->setValue(GROUP(Messages), Messages::PreviewerFontStandard, m_ui->m_cmbMessageFontStandard->currentFont().family());
qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts(); qApp->mainForm()->tabWidget()->feedMessageViewer()->loadMessageViewerFonts();
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->updateAutoUpdateStatus(); qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->updateAutoUpdateStatus();
@ -346,9 +342,8 @@ bool FormSettings::doSaveCheck() {
void FormSettings::promptForRestart() { void FormSettings::promptForRestart() {
if (!m_changedDataTexts.isEmpty()) { if (!m_changedDataTexts.isEmpty()) {
QStringList changed_settings_description = m_changedDataTexts.replaceInStrings(QRegExp(QSL("^")), QString::fromUtf8("")); const QStringList changed_settings_description = m_changedDataTexts.replaceInStrings(QRegExp(QSL("^")), QString::fromUtf8(""));
const QMessageBox::StandardButton clicked_button = MessageBox::show(this,
QMessageBox::StandardButton clicked_button = MessageBox::show(this,
QMessageBox::Question, QMessageBox::Question,
tr("Critical settings were changed"), tr("Critical settings were changed"),
tr("Some critical settings were changed and will be applied after the application gets restarted. " tr("Some critical settings were changed and will be applied after the application gets restarted. "
@ -380,15 +375,15 @@ void FormSettings::saveSettings() {
saveFeedsMessages(); saveFeedsMessages();
saveDownloads(); saveDownloads();
qApp->settings()->checkSettings(); m_settings->checkSettings();
promptForRestart(); promptForRestart();
accept(); accept();
} }
void FormSettings::onProxyTypeChanged(int index) { void FormSettings::onProxyTypeChanged(int index) {
QNetworkProxy::ProxyType selected_type = static_cast<QNetworkProxy::ProxyType>(m_ui->m_cmbProxyType->itemData(index).toInt()); const QNetworkProxy::ProxyType selected_type = static_cast<QNetworkProxy::ProxyType>(m_ui->m_cmbProxyType->itemData(index).toInt());
bool is_proxy_selected = selected_type != QNetworkProxy::NoProxy && selected_type != QNetworkProxy::DefaultProxy; const bool is_proxy_selected = selected_type != QNetworkProxy::NoProxy && selected_type != QNetworkProxy::DefaultProxy;
m_ui->m_txtProxyHost->setEnabled(is_proxy_selected); m_ui->m_txtProxyHost->setEnabled(is_proxy_selected);
m_ui->m_txtProxyPassword->setEnabled(is_proxy_selected); m_ui->m_txtProxyPassword->setEnabled(is_proxy_selected);
@ -403,40 +398,36 @@ void FormSettings::onProxyTypeChanged(int index) {
} }
void FormSettings::loadBrowser() { void FormSettings::loadBrowser() {
Settings *settings = qApp->settings();
// Load settings of web browser GUI. // Load settings of web browser GUI.
m_ui->m_checkMouseGestures->setChecked(settings->value(GROUP(Browser), SETTING(Browser::GesturesEnabled)).toBool()); m_ui->m_checkMouseGestures->setChecked(m_settings->value(GROUP(Browser), SETTING(Browser::GesturesEnabled)).toBool());
m_ui->m_checkQueueTabs->setChecked(settings->value(GROUP(Browser), SETTING(Browser::QueueTabs)).toBool()); m_ui->m_checkQueueTabs->setChecked(m_settings->value(GROUP(Browser), SETTING(Browser::QueueTabs)).toBool());
m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), QSL("-nosession %1")); 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_txtExternalBrowserExecutable->setText(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserExecutable)).toString());
m_ui->m_txtExternalBrowserArguments->setText(settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserArguments)).toString()); m_ui->m_txtExternalBrowserArguments->setText(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserArguments)).toString());
m_ui->m_grpCustomExternalBrowser->setChecked(settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool()); m_ui->m_grpCustomExternalBrowser->setChecked(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalBrowserEnabled)).toBool());
m_ui->m_checkAutoLoadImages->setChecked(WebFactory::instance()->autoloadImages()); m_ui->m_checkAutoLoadImages->setChecked(WebFactory::instance()->autoloadImages());
m_ui->m_checkEnableJavascript->setChecked(WebFactory::instance()->javascriptEnabled()); m_ui->m_checkEnableJavascript->setChecked(WebFactory::instance()->javascriptEnabled());
m_ui->m_checkEnablePlugins->setChecked(WebFactory::instance()->pluginsEnabled()); m_ui->m_checkEnablePlugins->setChecked(WebFactory::instance()->pluginsEnabled());
// Load settings of e-mail. // Load settings of e-mail.
m_ui->m_cmbExternalEmailPreset->addItem(tr("Mozilla Thunderbird"), QSL("-compose \"subject='%1',body='%2'\"")); 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_txtExternalEmailExecutable->setText(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailExecutable)).toString());
m_ui->m_txtExternalEmailArguments->setText(settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailArguments)).toString()); m_ui->m_txtExternalEmailArguments->setText(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailArguments)).toString());
m_ui->m_grpCustomExternalEmail->setChecked(settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailEnabled)).toBool()); m_ui->m_grpCustomExternalEmail->setChecked(m_settings->value(GROUP(Browser), SETTING(Browser::CustomExternalEmailEnabled)).toBool());
} }
void FormSettings::saveBrowser() { void FormSettings::saveBrowser() {
Settings *settings = qApp->settings();
// Save settings of GUI of web browser. // Save settings of GUI of web browser.
settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserEnabled, m_ui->m_grpCustomExternalBrowser->isChecked()); m_settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserEnabled, m_ui->m_grpCustomExternalBrowser->isChecked());
settings->setValue(GROUP(Browser), Browser::GesturesEnabled, m_ui->m_checkMouseGestures->isChecked()); m_settings->setValue(GROUP(Browser), Browser::GesturesEnabled, m_ui->m_checkMouseGestures->isChecked());
settings->setValue(GROUP(Browser), Browser::QueueTabs, m_ui->m_checkQueueTabs->isChecked()); m_settings->setValue(GROUP(Browser), Browser::QueueTabs, m_ui->m_checkQueueTabs->isChecked());
settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserExecutable, m_ui->m_txtExternalBrowserExecutable->text()); m_settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserExecutable, m_ui->m_txtExternalBrowserExecutable->text());
settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserArguments, m_ui->m_txtExternalBrowserArguments->text()); m_settings->setValue(GROUP(Browser), Browser::CustomExternalBrowserArguments, m_ui->m_txtExternalBrowserArguments->text());
// Save settings of e-mail. // Save settings of e-mail.
settings->setValue(GROUP(Browser), Browser::CustomExternalEmailExecutable, m_ui->m_txtExternalEmailExecutable->text()); m_settings->setValue(GROUP(Browser), Browser::CustomExternalEmailExecutable, m_ui->m_txtExternalEmailExecutable->text());
settings->setValue(GROUP(Browser), Browser::CustomExternalEmailArguments, m_ui->m_txtExternalEmailArguments->text()); m_settings->setValue(GROUP(Browser), Browser::CustomExternalEmailArguments, m_ui->m_txtExternalEmailArguments->text());
settings->setValue(GROUP(Browser), Browser::CustomExternalEmailEnabled, m_ui->m_grpCustomExternalEmail->isChecked()); m_settings->setValue(GROUP(Browser), Browser::CustomExternalEmailEnabled, m_ui->m_grpCustomExternalEmail->isChecked());
WebFactory::instance()->switchImages(m_ui->m_checkAutoLoadImages->isChecked()); WebFactory::instance()->switchImages(m_ui->m_checkAutoLoadImages->isChecked());
WebFactory::instance()->switchJavascript(m_ui->m_checkEnableJavascript->isChecked()); WebFactory::instance()->switchJavascript(m_ui->m_checkEnableJavascript->isChecked());
@ -450,24 +441,21 @@ void FormSettings::loadProxy() {
m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy); m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy);
// Load the settings. // Load the settings.
Settings *settings = qApp->settings(); QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(m_settings->value(GROUP(Proxy), SETTING(Proxy::Type)).toInt());
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(settings->value(GROUP(Proxy), SETTING(Proxy::Type)).toInt());
m_ui->m_cmbProxyType->setCurrentIndex(m_ui->m_cmbProxyType->findData(selected_proxy_type)); 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_txtProxyHost->setText(m_settings->value(GROUP(Proxy), SETTING(Proxy::Host)).toString());
m_ui->m_txtProxyUsername->setText(settings->value(GROUP(Proxy), SETTING(Proxy::Username)).toString()); m_ui->m_txtProxyUsername->setText(m_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_txtProxyPassword->setText(TextFactory::decrypt(m_settings->value(GROUP(Proxy), SETTING(Proxy::Password)).toString()));
m_ui->m_spinProxyPort->setValue(settings->value(GROUP(Proxy), SETTING(Proxy::Port)).toInt()); m_ui->m_spinProxyPort->setValue(m_settings->value(GROUP(Proxy), SETTING(Proxy::Port)).toInt());
} }
void FormSettings::saveProxy() { void FormSettings::saveProxy() {
Settings *settings = qApp->settings(); 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());
settings->setValue(GROUP(Proxy), Proxy::Type, m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex())); m_settings->setValue(GROUP(Proxy), Proxy::Username, m_ui->m_txtProxyUsername->text());
settings->setValue(GROUP(Proxy), Proxy::Host, m_ui->m_txtProxyHost->text()); m_settings->setValue(GROUP(Proxy), Proxy::Password, TextFactory::encrypt(m_ui->m_txtProxyPassword->text()));
settings->setValue(GROUP(Proxy), Proxy::Username, m_ui->m_txtProxyUsername->text()); m_settings->setValue(GROUP(Proxy), Proxy::Port, m_ui->m_spinProxyPort->value());
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. // Reload settings for all network access managers.
SilentNetworkAccessManager::instance()->loadSettings(); SilentNetworkAccessManager::instance()->loadSettings();
@ -485,6 +473,7 @@ void FormSettings::loadLanguage() {
} }
QList<QTreeWidgetItem*> matching_items = m_ui->m_treeLanguages->findItems(qApp->localization()->loadedLanguage(), Qt::MatchContains, 1); QList<QTreeWidgetItem*> matching_items = m_ui->m_treeLanguages->findItems(qApp->localization()->loadedLanguage(), Qt::MatchContains, 1);
if (!matching_items.isEmpty()) { if (!matching_items.isEmpty()) {
m_ui->m_treeLanguages->setCurrentItem(matching_items[0]); m_ui->m_treeLanguages->setCurrentItem(matching_items[0]);
} }
@ -496,14 +485,13 @@ void FormSettings::saveLanguage() {
return; return;
} }
Settings *settings = qApp->settings(); const QString actual_lang = qApp->localization()->loadedLanguage();
QString actual_lang = qApp->localization()->loadedLanguage(); const QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1);
QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1);
// Save prompt for restart if language has changed. // Save prompt for restart if language has changed.
if (new_lang != actual_lang) { if (new_lang != actual_lang) {
m_changedDataTexts.append(tr("language changed")); m_changedDataTexts.append(tr("language changed"));
settings->setValue(GROUP(General), General::Language, new_lang); m_settings->setValue(GROUP(General), General::Language, new_lang);
} }
} }
@ -526,9 +514,7 @@ void FormSettings::loadDataStorage() {
m_ui->m_cmbDatabaseDriver->addItem(qApp->database()->humanDriverName(DatabaseFactory::SQLITE), APP_DB_SQLITE_DRIVER); m_ui->m_cmbDatabaseDriver->addItem(qApp->database()->humanDriverName(DatabaseFactory::SQLITE), APP_DB_SQLITE_DRIVER);
// Load in-memory database status. // Load in-memory database status.
Settings *settings = qApp->settings(); m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(m_settings->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool());
m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(settings->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool());
if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) { if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) {
onMysqlHostnameChanged(QString()); onMysqlHostnameChanged(QString());
@ -545,16 +531,16 @@ void FormSettings::loadDataStorage() {
m_ui->m_txtMysqlPassword->lineEdit()->setPlaceholderText(tr("Password for your username")); 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_txtMysqlDatabase->lineEdit()->setPlaceholderText(tr("Working database which you have full access to."));
m_ui->m_txtMysqlHostname->lineEdit()->setText(settings->value(GROUP(Database), SETTING(Database::MySQLHostname)).toString()); m_ui->m_txtMysqlHostname->lineEdit()->setText(m_settings->value(GROUP(Database), SETTING(Database::MySQLHostname)).toString());
m_ui->m_txtMysqlUsername->lineEdit()->setText(settings->value(GROUP(Database), SETTING(Database::MySQLUsername)).toString()); m_ui->m_txtMysqlUsername->lineEdit()->setText(m_settings->value(GROUP(Database), SETTING(Database::MySQLUsername)).toString());
m_ui->m_txtMysqlPassword->lineEdit()->setText(TextFactory::decrypt(settings->value(GROUP(Database), SETTING(Database::MySQLPassword)).toString())); m_ui->m_txtMysqlPassword->lineEdit()->setText(TextFactory::decrypt(m_settings->value(GROUP(Database), SETTING(Database::MySQLPassword)).toString()));
m_ui->m_txtMysqlDatabase->lineEdit()->setText(settings->value(GROUP(Database), SETTING(Database::MySQLDatabase)).toString()); m_ui->m_txtMysqlDatabase->lineEdit()->setText(m_settings->value(GROUP(Database), SETTING(Database::MySQLDatabase)).toString());
m_ui->m_spinMysqlPort->setValue(settings->value(GROUP(Database), SETTING(Database::MySQLPort)).toInt()); m_ui->m_spinMysqlPort->setValue(m_settings->value(GROUP(Database), SETTING(Database::MySQLPort)).toInt());
m_ui->m_checkMysqlShowPassword->setChecked(false); m_ui->m_checkMysqlShowPassword->setChecked(false);
} }
int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(settings->value(GROUP(Database), SETTING(Database::ActiveDriver)).toString()); int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(m_settings->value(GROUP(Database), SETTING(Database::ActiveDriver)).toString());
if (index_current_backend >= 0) { if (index_current_backend >= 0) {
m_ui->m_cmbDatabaseDriver->setCurrentIndex(index_current_backend); m_ui->m_cmbDatabaseDriver->setCurrentIndex(index_current_backend);
@ -563,46 +549,43 @@ void FormSettings::loadDataStorage() {
void FormSettings::saveDataStorage() { void FormSettings::saveDataStorage() {
// Setup in-memory database status. // Setup in-memory database status.
Settings *settings = qApp->settings(); const bool original_inmemory = m_settings->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool();
const bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked();
bool original_inmemory = settings->value(GROUP(Database), SETTING(Database::UseInMemory)).toBool();
bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked();
if (original_inmemory != new_inmemory) { if (original_inmemory != new_inmemory) {
m_changedDataTexts.append(tr("in-memory database switched")); m_changedDataTexts.append(tr("in-memory database switched"));
} }
// Save data storage settings. // Save data storage settings.
QString original_db_driver = settings->value(GROUP(Database), SETTING(Database::ActiveDriver)).toString(); 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(); QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(m_ui->m_cmbDatabaseDriver->currentIndex()).toString();
// Save SQLite. // Save SQLite.
settings->setValue(GROUP(Database), Database::UseInMemory, new_inmemory); m_settings->setValue(GROUP(Database), Database::UseInMemory, new_inmemory);
if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) { if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) {
// Save MySQL. // Save MySQL.
settings->setValue(GROUP(Database), Database::MySQLHostname, m_ui->m_txtMysqlHostname->lineEdit()->text()); m_settings->setValue(GROUP(Database), Database::MySQLHostname, m_ui->m_txtMysqlHostname->lineEdit()->text());
settings->setValue(GROUP(Database), Database::MySQLUsername, m_ui->m_txtMysqlUsername->lineEdit()->text()); m_settings->setValue(GROUP(Database), Database::MySQLUsername, m_ui->m_txtMysqlUsername->lineEdit()->text());
settings->setValue(GROUP(Database), Database::MySQLPassword, TextFactory::encrypt(m_ui->m_txtMysqlPassword->lineEdit()->text())); m_settings->setValue(GROUP(Database), Database::MySQLPassword, TextFactory::encrypt(m_ui->m_txtMysqlPassword->lineEdit()->text()));
settings->setValue(GROUP(Database), Database::MySQLDatabase, m_ui->m_txtMysqlDatabase->lineEdit()->text()); m_settings->setValue(GROUP(Database), Database::MySQLDatabase, m_ui->m_txtMysqlDatabase->lineEdit()->text());
settings->setValue(GROUP(Database), Database::MySQLPort, m_ui->m_spinMysqlPort->value()); m_settings->setValue(GROUP(Database), Database::MySQLPort, m_ui->m_spinMysqlPort->value());
} }
settings->setValue(GROUP(Database), Database::ActiveDriver, selected_db_driver); m_settings->setValue(GROUP(Database), Database::ActiveDriver, selected_db_driver);
if (original_db_driver != selected_db_driver || if (original_db_driver != selected_db_driver || m_initialSettings.m_dataStorageDataChanged) {
m_initialSettings.m_dataStorageDataChanged) {
m_changedDataTexts.append(tr("data storage backend changed")); m_changedDataTexts.append(tr("data storage backend changed"));
} }
} }
void FormSettings::mysqlTestConnection() { void FormSettings::mysqlTestConnection() {
DatabaseFactory::MySQLError error_code = qApp->database()->mysqlTestConnection(m_ui->m_txtMysqlHostname->lineEdit()->text(), const DatabaseFactory::MySQLError error_code = qApp->database()->mysqlTestConnection(m_ui->m_txtMysqlHostname->lineEdit()->text(),
m_ui->m_spinMysqlPort->value(), m_ui->m_spinMysqlPort->value(),
m_ui->m_txtMysqlDatabase->lineEdit()->text(), m_ui->m_txtMysqlDatabase->lineEdit()->text(),
m_ui->m_txtMysqlUsername->lineEdit()->text(), m_ui->m_txtMysqlUsername->lineEdit()->text(),
m_ui->m_txtMysqlPassword->lineEdit()->text()); m_ui->m_txtMysqlPassword->lineEdit()->text());
QString interpretation = qApp->database()->mysqlInterpretErrorCode(error_code); const QString interpretation = qApp->database()->mysqlInterpretErrorCode(error_code);
switch (error_code) { switch (error_code) {
@ -657,7 +640,7 @@ void FormSettings::onMysqlDataStorageEdited() {
} }
void FormSettings::selectSqlBackend(int index) { void FormSettings::selectSqlBackend(int index) {
QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(index).toString(); const QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(index).toString();
if (selected_db_driver == APP_DB_SQLITE_DRIVER) { if (selected_db_driver == APP_DB_SQLITE_DRIVER) {
m_ui->m_stackedDatabaseDriver->setCurrentIndex(0); m_ui->m_stackedDatabaseDriver->setCurrentIndex(0);
@ -676,17 +659,20 @@ void FormSettings::switchMysqlPasswordVisiblity(bool visible) {
void FormSettings::loadGeneral() { void FormSettings::loadGeneral() {
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text().arg(APP_NAME)); m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text().arg(APP_NAME));
m_ui->m_checkForUpdatesOnStart->setChecked(qApp->settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool()); m_ui->m_checkForUpdatesOnStart->setChecked(m_settings->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool());
// Load auto-start status. // Load auto-start status.
SystemFactory::AutoStartStatus autostart_status = qApp->system()->getAutoStartStatus(); const SystemFactory::AutoStartStatus autostart_status = qApp->system()->getAutoStartStatus();
switch (autostart_status) { switch (autostart_status) {
case SystemFactory::Enabled: case SystemFactory::Enabled:
m_ui->m_checkAutostart->setChecked(true); m_ui->m_checkAutostart->setChecked(true);
break; break;
case SystemFactory::Disabled: case SystemFactory::Disabled:
m_ui->m_checkAutostart->setChecked(false); m_ui->m_checkAutostart->setChecked(false);
break; break;
default: default:
m_ui->m_checkAutostart->setEnabled(false); m_ui->m_checkAutostart->setEnabled(false);
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text() + tr(" (not supported on this platform)")); m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text() + tr(" (not supported on this platform)"));
@ -695,7 +681,7 @@ void FormSettings::loadGeneral() {
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
m_ui->m_checkRemoveTrolltechJunk->setVisible(true); m_ui->m_checkRemoveTrolltechJunk->setVisible(true);
m_ui->m_checkRemoveTrolltechJunk->setChecked(qApp->settings()->value(GROUP(General), SETTING(General::RemoveTrolltechJunk)).toBool()); m_ui->m_checkRemoveTrolltechJunk->setChecked(m_settings->value(GROUP(General), SETTING(General::RemoveTrolltechJunk)).toBool());
#else #else
m_ui->m_checkRemoveTrolltechJunk->setVisible(false); m_ui->m_checkRemoveTrolltechJunk->setVisible(false);
#endif #endif
@ -710,16 +696,14 @@ void FormSettings::saveGeneral() {
qApp->system()->setAutoStartStatus(SystemFactory::Disabled); qApp->system()->setAutoStartStatus(SystemFactory::Disabled);
} }
qApp->settings()->setValue(GROUP(General), General::UpdateOnStartup, m_ui->m_checkForUpdatesOnStart->isChecked()); m_settings->setValue(GROUP(General), General::UpdateOnStartup, m_ui->m_checkForUpdatesOnStart->isChecked());
qApp->settings()->setValue(GROUP(General), General::RemoveTrolltechJunk, m_ui->m_checkRemoveTrolltechJunk->isChecked()); m_settings->setValue(GROUP(General), General::RemoveTrolltechJunk, m_ui->m_checkRemoveTrolltechJunk->isChecked());
} }
void FormSettings::loadInterface() { void FormSettings::loadInterface() {
Settings *settings = qApp->settings();
// Load settings of tray icon. // Load settings of tray icon.
if (SystemTrayIcon::isSystemTrayAvailable()) { if (SystemTrayIcon::isSystemTrayAvailable()) {
m_ui->m_grpTray->setChecked(settings->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool()); m_ui->m_grpTray->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::UseTrayIcon)).toBool());
} }
// Tray icon is not supported on this machine. // Tray icon is not supported on this machine.
else { else {
@ -727,21 +711,21 @@ void FormSettings::loadInterface() {
m_ui->m_grpTray->setChecked(false); m_ui->m_grpTray->setChecked(false);
} }
m_ui->m_checkHidden->setChecked(settings->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool()); m_ui->m_checkHidden->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::MainWindowStartsHidden)).toBool());
m_ui->m_checkHideWhenMinimized->setChecked(settings->value(GROUP(GUI), SETTING(GUI::HideMainWindowWhenMinimized)).toBool()); m_ui->m_checkHideWhenMinimized->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::HideMainWindowWhenMinimized)).toBool());
// Load fancy notification settings. // Load fancy notification settings.
m_ui->m_grpNotifications->setChecked(settings->value(GROUP(GUI), SETTING(GUI::UseFancyNotifications)).toBool()); m_ui->m_grpNotifications->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::UseFancyNotifications)).toBool());
m_ui->m_cmbNotificationPosition->addItem(tr("Bottom-left corner"), Qt::BottomLeftCorner); m_ui->m_cmbNotificationPosition->addItem(tr("Bottom-left corner"), Qt::BottomLeftCorner);
m_ui->m_cmbNotificationPosition->addItem(tr("Top-left corner"), Qt::TopLeftCorner); m_ui->m_cmbNotificationPosition->addItem(tr("Top-left corner"), Qt::TopLeftCorner);
m_ui->m_cmbNotificationPosition->addItem(tr("Bottom-right corner"), Qt::BottomRightCorner); m_ui->m_cmbNotificationPosition->addItem(tr("Bottom-right corner"), Qt::BottomRightCorner);
m_ui->m_cmbNotificationPosition->addItem(tr("Top-right corner"), Qt::TopRightCorner); m_ui->m_cmbNotificationPosition->addItem(tr("Top-right corner"), Qt::TopRightCorner);
m_ui->m_cmbNotificationPosition->setCurrentIndex(m_ui->m_cmbNotificationPosition->findData(static_cast<Qt::Corner>(settings->value(GROUP(GUI), SETTING(GUI::FancyNotificationsPosition)).toInt()))); m_ui->m_cmbNotificationPosition->setCurrentIndex(m_ui->m_cmbNotificationPosition->findData(static_cast<Qt::Corner>(m_settings->value(GROUP(GUI), SETTING(GUI::FancyNotificationsPosition)).toInt())));
m_ui->m_grpBaseNotifications->setChecked(settings->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool()); m_ui->m_grpBaseNotifications->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool());
m_ui->m_lblNotificationColor->setColor(settings->value(GROUP(GUI), SETTING(GUI::NotificationBackgroundColor)).value<QColor>()); m_ui->m_lblNotificationColor->setColor(m_settings->value(GROUP(GUI), SETTING(GUI::NotificationBackgroundColor)).value<QColor>());
// Load settings of icon theme. // Load settings of icon theme.
QString current_theme = qApp->icons()->currentIconTheme(); const QString current_theme = qApp->icons()->currentIconTheme();
foreach (const QString &icon_theme_name, qApp->icons()->installedIconThemes()) { foreach (const QString &icon_theme_name, qApp->icons()->installedIconThemes()) {
if (icon_theme_name == APP_NO_THEME) { if (icon_theme_name == APP_NO_THEME) {
@ -764,6 +748,7 @@ void FormSettings::loadInterface() {
m_ui->m_cmbIconTheme->setCurrentText(current_theme); m_ui->m_cmbIconTheme->setCurrentText(current_theme);
#else #else
int theme_index = m_ui->m_cmbIconTheme->findText(current_theme); int theme_index = m_ui->m_cmbIconTheme->findText(current_theme);
if (theme_index >= 0) { if (theme_index >= 0) {
m_ui->m_cmbIconTheme->setCurrentIndex(theme_index); m_ui->m_cmbIconTheme->setCurrentIndex(theme_index);
} }
@ -771,7 +756,7 @@ void FormSettings::loadInterface() {
} }
// Load skin. // Load skin.
QString selected_skin = qApp->skins()->selectedSkinName(); const QString selected_skin = qApp->skins()->selectedSkinName();
foreach (const Skin &skin, qApp->skins()->installedSkins()) { foreach (const Skin &skin, qApp->skins()->installedSkins()) {
QTreeWidgetItem *new_item = new QTreeWidgetItem(QStringList() << QTreeWidgetItem *new_item = new QTreeWidgetItem(QStringList() <<
@ -798,10 +783,10 @@ void FormSettings::loadInterface() {
} }
// Load tab settings. // Load tab settings.
m_ui->m_checkCloseTabsMiddleClick->setChecked(settings->value(GROUP(GUI), SETTING(GUI::TabCloseMiddleClick)).toBool()); m_ui->m_checkCloseTabsMiddleClick->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::TabCloseMiddleClick)).toBool());
m_ui->m_checkCloseTabsDoubleClick->setChecked(settings->value(GROUP(GUI), SETTING(GUI::TabCloseDoubleClick)).toBool()); m_ui->m_checkCloseTabsDoubleClick->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::TabCloseDoubleClick)).toBool());
m_ui->m_checkNewTabDoubleClick->setChecked(settings->value(GROUP(GUI), SETTING(GUI::TabNewDoubleClick)).toBool()); m_ui->m_checkNewTabDoubleClick->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::TabNewDoubleClick)).toBool());
m_ui->m_hideTabBarIfOneTabVisible->setChecked(settings->value(GROUP(GUI), SETTING(GUI::HideTabBarIfOnlyOneTab)).toBool()); m_ui->m_hideTabBarIfOneTabVisible->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::HideTabBarIfOnlyOneTab)).toBool());
// Load toolbar button style. // Load toolbar button style.
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Icon only"), Qt::ToolButtonIconOnly); m_ui->m_cmbToolbarButtonStyle->addItem(tr("Icon only"), Qt::ToolButtonIconOnly);
@ -810,7 +795,7 @@ void FormSettings::loadInterface() {
m_ui->m_cmbToolbarButtonStyle->addItem(tr("Text under icon"), Qt::ToolButtonTextUnderIcon); 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->addItem(tr("Follow OS style"), Qt::ToolButtonFollowStyle);
m_ui->m_cmbToolbarButtonStyle->setCurrentIndex(m_ui->m_cmbToolbarButtonStyle->findData(qApp->settings()->value(GROUP(GUI), m_ui->m_cmbToolbarButtonStyle->setCurrentIndex(m_ui->m_cmbToolbarButtonStyle->findData(m_settings->value(GROUP(GUI),
SETTING(GUI::ToolbarStyle)).toInt())); SETTING(GUI::ToolbarStyle)).toInt()));
// Load toolbars. // Load toolbars.
@ -819,14 +804,12 @@ void FormSettings::loadInterface() {
} }
void FormSettings::saveInterface() { void FormSettings::saveInterface() {
Settings *settings = qApp->settings();
// Save toolbar. // Save toolbar.
settings->setValue(GROUP(GUI), GUI::ToolbarStyle, m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex())); m_settings->setValue(GROUP(GUI), GUI::ToolbarStyle, m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex()));
// Save tray icon. // Save tray icon.
if (SystemTrayIcon::isSystemTrayAvailable()) { if (SystemTrayIcon::isSystemTrayAvailable()) {
settings->setValue(GROUP(GUI), GUI::UseTrayIcon, m_ui->m_grpTray->isChecked()); m_settings->setValue(GROUP(GUI), GUI::UseTrayIcon, m_ui->m_grpTray->isChecked());
if (m_ui->m_grpTray->isChecked()) { if (m_ui->m_grpTray->isChecked()) {
qApp->showTrayIcon(); qApp->showTrayIcon();
@ -836,14 +819,14 @@ void FormSettings::saveInterface() {
} }
} }
settings->setValue(GROUP(GUI), GUI::MainWindowStartsHidden, m_ui->m_checkHidden->isChecked()); m_settings->setValue(GROUP(GUI), GUI::MainWindowStartsHidden, m_ui->m_checkHidden->isChecked());
settings->setValue(GROUP(GUI), GUI::HideMainWindowWhenMinimized, m_ui->m_checkHideWhenMinimized->isChecked()); m_settings->setValue(GROUP(GUI), GUI::HideMainWindowWhenMinimized, m_ui->m_checkHideWhenMinimized->isChecked());
// Save notifications. // Save notifications.
settings->setValue(GROUP(GUI), GUI::UseFancyNotifications, m_ui->m_grpNotifications->isChecked()); m_settings->setValue(GROUP(GUI), GUI::UseFancyNotifications, m_ui->m_grpNotifications->isChecked());
settings->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui->m_grpBaseNotifications->isChecked()); m_settings->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui->m_grpBaseNotifications->isChecked());
settings->setValue(GROUP(GUI), GUI::FancyNotificationsPosition, static_cast<Qt::Corner>(m_ui->m_cmbNotificationPosition->itemData(m_ui->m_cmbNotificationPosition->currentIndex()).toInt())); m_settings->setValue(GROUP(GUI), GUI::FancyNotificationsPosition, static_cast<Qt::Corner>(m_ui->m_cmbNotificationPosition->itemData(m_ui->m_cmbNotificationPosition->currentIndex()).toInt()));
settings->setValue(GROUP(GUI), GUI::NotificationBackgroundColor, m_ui->m_lblNotificationColor->color()); m_settings->setValue(GROUP(GUI), GUI::NotificationBackgroundColor, m_ui->m_lblNotificationColor->color());
// Save selected icon theme. // Save selected icon theme.
QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString(); QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString();
@ -857,7 +840,7 @@ void FormSettings::saveInterface() {
// Save and activate new skin. // Save and activate new skin.
if (m_ui->m_treeSkins->selectedItems().size() > 0) { if (m_ui->m_treeSkins->selectedItems().size() > 0) {
Skin active_skin = m_ui->m_treeSkins->currentItem()->data(0, Qt::UserRole).value<Skin>(); const Skin active_skin = m_ui->m_treeSkins->currentItem()->data(0, Qt::UserRole).value<Skin>();
if (qApp->skins()->selectedSkinName() != active_skin.m_baseName) { if (qApp->skins()->selectedSkinName() != active_skin.m_baseName) {
qApp->skins()->setCurrentSkinName(active_skin.m_baseName); qApp->skins()->setCurrentSkinName(active_skin.m_baseName);
@ -866,10 +849,10 @@ void FormSettings::saveInterface() {
} }
// Save tab settings. // Save tab settings.
settings->setValue(GROUP(GUI), GUI::TabCloseMiddleClick, m_ui->m_checkCloseTabsMiddleClick->isChecked()); m_settings->setValue(GROUP(GUI), GUI::TabCloseMiddleClick, m_ui->m_checkCloseTabsMiddleClick->isChecked());
settings->setValue(GROUP(GUI), GUI::TabCloseDoubleClick, m_ui->m_checkCloseTabsDoubleClick->isChecked()); m_settings->setValue(GROUP(GUI), GUI::TabCloseDoubleClick, m_ui->m_checkCloseTabsDoubleClick->isChecked());
settings->setValue(GROUP(GUI), GUI::TabNewDoubleClick, m_ui->m_checkNewTabDoubleClick->isChecked()); m_settings->setValue(GROUP(GUI), GUI::TabNewDoubleClick, m_ui->m_checkNewTabDoubleClick->isChecked());
settings->setValue(GROUP(GUI), GUI::HideTabBarIfOnlyOneTab, m_ui->m_hideTabBarIfOneTabVisible->isChecked()); m_settings->setValue(GROUP(GUI), GUI::HideTabBarIfOnlyOneTab, m_ui->m_hideTabBarIfOneTabVisible->isChecked());
m_ui->m_editorFeedsToolbar->saveToolBar(); m_ui->m_editorFeedsToolbar->saveToolBar();
m_ui->m_editorMessagesToolbar->saveToolBar(); m_ui->m_editorMessagesToolbar->saveToolBar();

View File

@ -27,6 +27,8 @@ namespace Ui {
class FormSettings; class FormSettings;
} }
class Settings;
// Structure holding some initial values. // Structure holding some initial values.
struct TemporarySettings { struct TemporarySettings {
@ -104,11 +106,10 @@ class FormSettings : public QDialog {
void saveFeedsMessages(); void saveFeedsMessages();
private: private:
Ui::FormSettings *m_ui; QScopedPointer<Ui::FormSettings> m_ui;
Settings *m_settings;
TemporarySettings m_initialSettings; TemporarySettings m_initialSettings;
QStringList m_changedDataTexts; QStringList m_changedDataTexts;
}; };
#endif // FORMSETTINGS_H #endif // FORMSETTINGS_H

View File

@ -51,7 +51,6 @@ FormUpdate::FormUpdate(QWidget *parent)
} }
FormUpdate::~FormUpdate() { FormUpdate::~FormUpdate() {
delete m_ui;
} }
bool FormUpdate::isUpdateForThisSystem() const { bool FormUpdate::isUpdateForThisSystem() const {
@ -67,7 +66,7 @@ bool FormUpdate::isSelfUpdateSupported() const {
} }
void FormUpdate::checkForUpdates() { void FormUpdate::checkForUpdates() {
QPair<UpdateInfo, QNetworkReply::NetworkError> update = qApp->system()->checkForUpdates(); const QPair<UpdateInfo, QNetworkReply::NetworkError> update = qApp->system()->checkForUpdates();
m_updateInfo = update.first; m_updateInfo = update.first;
@ -85,7 +84,7 @@ void FormUpdate::checkForUpdates() {
m_ui->m_lblAvailableRelease->setText(update.first.m_availableVersion); m_ui->m_lblAvailableRelease->setText(update.first.m_availableVersion);
m_ui->m_txtChanges->setText(update.first.m_changes); m_ui->m_txtChanges->setText(update.first.m_changes);
bool is_self_update_for_this_system = isUpdateForThisSystem() && isSelfUpdateSupported(); const bool is_self_update_for_this_system = isUpdateForThisSystem() && isSelfUpdateSupported();
if (SystemFactory::isUpdateNewer(update.first.m_availableVersion)) { if (SystemFactory::isUpdateNewer(update.first.m_availableVersion)) {
m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok, m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok,
@ -122,11 +121,11 @@ void FormUpdate::updateProgress(qint64 bytes_received, qint64 bytes_total) {
} }
void FormUpdate::saveUpdateFile(const QByteArray &file_contents) { void FormUpdate::saveUpdateFile(const QByteArray &file_contents) {
QString url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl;; const QString url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl;;
QString temp_directory = qApp->tempFolderPath(); const QString temp_directory = qApp->tempFolderPath();
if (!temp_directory.isEmpty()) { if (!temp_directory.isEmpty()) {
QString output_file_name = url_file.mid(url_file.lastIndexOf('/') + 1); const QString output_file_name = url_file.mid(url_file.lastIndexOf('/') + 1);
QFile output_file(temp_directory + QDir::separator() + output_file_name); QFile output_file(temp_directory + QDir::separator() + output_file_name);
if (output_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { if (output_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
@ -158,7 +157,6 @@ void FormUpdate::updateCompleted(QNetworkReply::NetworkError status, QByteArray
switch (status) { switch (status) {
case QNetworkReply::NoError: case QNetworkReply::NoError:
saveUpdateFile(contents); saveUpdateFile(contents);
m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok, tr("Downloaded successfully"), tr("Package was downloaded successfully.")); m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok, tr("Downloaded successfully"), tr("Package was downloaded successfully."));
m_btnUpdate->setText(tr("Install update")); m_btnUpdate->setText(tr("Install update"));
m_btnUpdate->setEnabled(true); m_btnUpdate->setEnabled(true);
@ -173,7 +171,7 @@ void FormUpdate::updateCompleted(QNetworkReply::NetworkError status, QByteArray
void FormUpdate::startUpdate() { void FormUpdate::startUpdate() {
QString url_file; QString url_file;
bool update_for_this_system = isUpdateForThisSystem() && isSelfUpdateSupported(); const bool update_for_this_system = isUpdateForThisSystem() && isSelfUpdateSupported();
if (update_for_this_system) { if (update_for_this_system) {
url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl; url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl;
@ -190,7 +188,7 @@ void FormUpdate::startUpdate() {
qDebug("Preparing to launch external installer '%s'.", qPrintable(QDir::toNativeSeparators(m_updateFilePath))); qDebug("Preparing to launch external installer '%s'.", qPrintable(QDir::toNativeSeparators(m_updateFilePath)));
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
long exec_result = (long) ShellExecute(NULL, const long exec_result = (long) ShellExecute(NULL,
NULL, NULL,
reinterpret_cast<const WCHAR*>(QDir::toNativeSeparators(m_updateFilePath).utf16()), reinterpret_cast<const WCHAR*>(QDir::toNativeSeparators(m_updateFilePath).utf16()),
NULL, NULL,

2
src/gui/dialogs/formupdate.h Normal file → Executable file
View File

@ -62,7 +62,7 @@ class FormUpdate : public QDialog {
Downloader *m_downloader; Downloader *m_downloader;
bool m_readyToInstall; bool m_readyToInstall;
QString m_updateFilePath; QString m_updateFilePath;
Ui::FormUpdate *m_ui; QScopedPointer<Ui::FormUpdate> m_ui;
UpdateInfo m_updateInfo; UpdateInfo m_updateInfo;
QPushButton *m_btnUpdate; QPushButton *m_btnUpdate;
}; };