Settings cleanups.

This commit is contained in:
Martin Rotter 2014-11-08 17:44:00 +01:00
parent 94c17ae5db
commit 4a75f13e68
26 changed files with 194 additions and 186 deletions

View File

@ -86,7 +86,7 @@ QVariant FeedsModelCategory::data(int column, int role) const {
return m_title;
}
else if (column == FDS_MODEL_COUNTS_INDEX) {
return qApp->settings()->value(APP_CFG_FEEDS, SETTING(Feeds::CountFormat)).toString()
return qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString()
.replace(PLACEHOLDER_UNREAD_COUNTS, QString::number(countOfUnreadMessages()))
.replace(PLACEHOLDER_ALL_COUNTS, QString::number(countOfAllMessages()));
}

View File

@ -174,7 +174,7 @@ QPair<FeedsModelFeed*, QNetworkReply::NetworkError> FeedsModelFeed::guessFeed(co
QByteArray feed_contents;
NetworkResult network_result = NetworkFactory::downloadFeedFile(url,
qApp->settings()->value(APP_CFG_FEEDS,
qApp->settings()->value(GROUP(Feeds),
SETTING(Feeds::UpdateTimeout)).toInt(),
feed_contents,
!username.isEmpty(),
@ -287,7 +287,7 @@ QVariant FeedsModelFeed::data(int column, int role) const {
return m_title;
}
else if (column == FDS_MODEL_COUNTS_INDEX) {
return qApp->settings()->value(APP_CFG_FEEDS, SETTING(Feeds::CountFormat)).toString()
return qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString()
.replace(PLACEHOLDER_UNREAD_COUNTS, QString::number(countOfUnreadMessages()))
.replace(PLACEHOLDER_ALL_COUNTS, QString::number(countOfAllMessages()));
}
@ -389,7 +389,7 @@ QVariant FeedsModelFeed::data(int column, int role) const {
void FeedsModelFeed::update() {
QByteArray feed_contents;
int download_timeout = qApp->settings()->value(APP_CFG_FEEDS, SETTING(Feeds::UpdateTimeout)).toInt();
int download_timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
m_networkError = NetworkFactory::downloadFeedFile(url(), download_timeout, feed_contents, passwordProtected(), username(), password()).first;
if (m_networkError != QNetworkReply::NoError) {

View File

@ -62,7 +62,7 @@ QVariant FeedsModelRecycleBin::data(int column, int role) const {
return m_title;
}
else if (column == FDS_MODEL_COUNTS_INDEX) {
return qApp->settings()->value(APP_CFG_FEEDS, SETTING(Feeds::CountFormat)).toString()
return qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString()
.replace(PLACEHOLDER_UNREAD_COUNTS, QString::number(countOfUnreadMessages()))
.replace(PLACEHOLDER_ALL_COUNTS, QString::number(countOfAllMessages()));
}

View File

@ -108,8 +108,8 @@ int MessagesModel::messageId(int row_index) const {
}
void MessagesModel::updateDateFormat() {
if (qApp->settings()->value(APP_CFG_MESSAGES, SETTING(Messages::UseCustomDate)).toBool()) {
m_customDateFormat = qApp->settings()->value(APP_CFG_MESSAGES, SETTING(Messages::CustomDateFormat)).toString();
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool()) {
m_customDateFormat = qApp->settings()->value(GROUP(Messages), SETTING(Messages::CustomDateFormat)).toString();
}
else {
m_customDateFormat = QString();

View File

@ -103,15 +103,6 @@
#define APP_CFG_PATH "data/config"
#define APP_CFG_FILE "config.ini"
#define APP_CFG_GUI "gui"
#define APP_CFG_GEN "main"
#define APP_CFG_PROXY "proxy"
#define APP_CFG_DB "database"
#define APP_CFG_CUTS "keyboard"
#define APP_CFG_BROWSER "browser"
#define APP_CFG_MESSAGES "messages"
#define APP_CFG_FEEDS "feeds"
#define APP_CFG_CAT_EXP "categories_expand_states"
#if defined(Q_OS_OSX)
#define APP_PREFIX "@CMAKE_INSTALL_PREFIX@/@APP_LOW_NAME@.app/Contents/Resources"

View File

@ -31,9 +31,7 @@ void DynamicShortcuts::save(const QList<QAction*> actions) {
Settings *settings = qApp->settings();
foreach (QAction *action, actions) {
settings->setValue(APP_CFG_CUTS,
action->objectName(),
action->shortcut().toString(QKeySequence::PortableText));
settings->setValue(GROUP(Keyboard), action->objectName(), action->shortcut().toString(QKeySequence::PortableText));
}
}
@ -41,7 +39,7 @@ void DynamicShortcuts::load(const QList<QAction*> actions) {
Settings *settings = qApp->settings();
foreach (QAction *action, actions) {
QString shortcut_for_action = settings->value(APP_CFG_CUTS,
QString shortcut_for_action = settings->value(GROUP(Keyboard),
action->objectName(),
action->shortcut().toString(QKeySequence::PortableText)).toString();
action->setShortcut(QKeySequence::fromString(shortcut_for_action, QKeySequence::PortableText));

View File

@ -80,8 +80,8 @@ void FeedMessageViewer::saveSize() {
m_feedsView->saveExpandedStates();
// Store offsets of splitters.
settings->setValue(APP_CFG_GUI, "splitter_feeds", QString(m_feedSplitter->saveState().toBase64()));
settings->setValue(APP_CFG_GUI, "splitter_messages", QString(m_messageSplitter->saveState().toBase64()));
settings->setValue(GROUP(GUI), "splitter_feeds", QString(m_feedSplitter->saveState().toBase64()));
settings->setValue(GROUP(GUI), "splitter_messages", QString(m_messageSplitter->saveState().toBase64()));
// States of splitters are stored, let's store
// widths of columns.
@ -89,13 +89,13 @@ void FeedMessageViewer::saveSize() {
int width_column_date = m_messagesView->columnWidth(MSG_DB_DCREATED_INDEX);
if (width_column_author != 0 && width_column_date != 0) {
settings->setValue(APP_CFG_GUI, KEY_MESSAGES_VIEW + QString::number(MSG_DB_AUTHOR_INDEX), width_column_author);
settings->setValue(APP_CFG_GUI, KEY_MESSAGES_VIEW + QString::number(MSG_DB_DCREATED_INDEX), width_column_date);
settings->setValue(GROUP(GUI), KEY_MESSAGES_VIEW + QString::number(MSG_DB_AUTHOR_INDEX), width_column_author);
settings->setValue(GROUP(GUI), KEY_MESSAGES_VIEW + QString::number(MSG_DB_DCREATED_INDEX), width_column_date);
}
// Store "visibility" of toolbars and list headers.
settings->setValue(APP_CFG_GUI, "enable_toolbars", m_toolBarsEnabled);
settings->setValue(APP_CFG_GUI, "enable_list_headers", m_listHeadersEnabled);
settings->setValue(GROUP(GUI), "enable_toolbars", m_toolBarsEnabled);
settings->setValue(GROUP(GUI), "enable_list_headers", m_listHeadersEnabled);
}
void FeedMessageViewer::loadSize() {
@ -105,14 +105,14 @@ void FeedMessageViewer::loadSize() {
m_feedsView->loadExpandedStates();
// Restore offsets of splitters.
m_feedSplitter->restoreState(QByteArray::fromBase64(settings->value(APP_CFG_GUI, SETTING(GUI::SplitterFeeds)).toString().toLocal8Bit()));
m_messageSplitter->restoreState(QByteArray::fromBase64(settings->value(APP_CFG_GUI, SETTING(GUI::SplitterMessages)).toString().toLocal8Bit()));
m_feedSplitter->restoreState(QByteArray::fromBase64(settings->value(GROUP(GUI), SETTING(GUI::SplitterFeeds)).toString().toLocal8Bit()));
m_messageSplitter->restoreState(QByteArray::fromBase64(settings->value(GROUP(GUI), SETTING(GUI::SplitterMessages)).toString().toLocal8Bit()));
// Splitters are restored, now, restore widths of columns.
m_messagesView->setColumnWidth(MSG_DB_AUTHOR_INDEX, settings->value(APP_CFG_GUI,
m_messagesView->setColumnWidth(MSG_DB_AUTHOR_INDEX, settings->value(GROUP(GUI),
KEY_MESSAGES_VIEW + QString::number(MSG_DB_AUTHOR_INDEX),
default_msg_section_size).toInt());
m_messagesView->setColumnWidth(MSG_DB_DCREATED_INDEX, settings->value(APP_CFG_GUI,
m_messagesView->setColumnWidth(MSG_DB_DCREATED_INDEX, settings->value(GROUP(GUI),
KEY_MESSAGES_VIEW + QString::number(MSG_DB_DCREATED_INDEX),
default_msg_section_size).toInt());
}
@ -128,7 +128,7 @@ void FeedMessageViewer::quit() {
qDebug("Feed downloader thread aborted. Deleting it from memory.");
m_feedDownloader->deleteLater();
if (qApp->settings()->value(APP_CFG_MESSAGES, SETTING(Messages::ClearReadOnExit)).toBool()) {
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::ClearReadOnExit)).toBool()) {
m_feedsView->clearAllReadMessages();
}
}
@ -396,7 +396,7 @@ void FeedMessageViewer::vacuumDatabase() {
}
void FeedMessageViewer::refreshVisualProperties() {
Qt::ToolButtonStyle button_style = static_cast<Qt::ToolButtonStyle>(qApp->settings()->value(APP_CFG_GUI,
Qt::ToolButtonStyle button_style = static_cast<Qt::ToolButtonStyle>(qApp->settings()->value(GROUP(GUI),
SETTING(GUI::ToolbarStyle)).toInt());
m_toolBarFeeds->setToolButtonStyle(button_style);

View File

@ -48,12 +48,12 @@ QList<QAction*> FeedsToolBar::changeableActions() const {
}
void FeedsToolBar::saveChangeableActions(const QStringList &actions) {
qApp->settings()->setValue(APP_CFG_GUI, "feeds_toolbar", actions.join(","));
qApp->settings()->setValue(GROUP(GUI), "feeds_toolbar", actions.join(","));
loadChangeableActions(actions);
}
void FeedsToolBar::loadChangeableActions() {
QStringList action_names = qApp->settings()->value(APP_CFG_GUI,
QStringList action_names = qApp->settings()->value(GROUP(GUI),
"feeds_toolbar",
"m_actionUpdateAllFeeds,m_actionMarkAllFeedsRead").toString().split(',',
QString::SkipEmptyParts);

View File

@ -77,9 +77,9 @@ void FeedsView::quit() {
void FeedsView::updateAutoUpdateStatus() {
// Restore global intervals.
// NOTE: Specific per-feed interval are left intact.
m_globalAutoUpdateInitialInterval = qApp->settings()->value(APP_CFG_FEEDS, "auto_update_interval", DEFAULT_AUTO_UPDATE_INTERVAL).toInt();
m_globalAutoUpdateInitialInterval = qApp->settings()->value(GROUP(Feeds), "auto_update_interval", DEFAULT_AUTO_UPDATE_INTERVAL).toInt();
m_globalAutoUpdateRemainingInterval = m_globalAutoUpdateInitialInterval;
m_globalAutoUpdateEnabled = qApp->settings()->value(APP_CFG_FEEDS, "auto_update_enabled", false).toBool();
m_globalAutoUpdateEnabled = qApp->settings()->value(GROUP(Feeds), "auto_update_enabled", false).toBool();
// Start global auto-update timer if it is not running yet.
// NOTE: The timer must run even if global auto-update
@ -142,7 +142,7 @@ void FeedsView::saveExpandedStates() {
// Iterate all categories and save their expand statuses.
foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) {
settings->setValue(APP_CFG_CAT_EXP,
settings->setValue(GROUP(Categories),
QString::number(category->id()),
isExpanded(model()->mapFromSource(sourceModel()->indexForItem(category))));
}
@ -154,7 +154,7 @@ void FeedsView::loadExpandedStates() {
// Iterate all categories and save their expand statuses.
foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) {
setExpanded(model()->mapFromSource(sourceModel()->indexForItem(category)),
settings->value(APP_CFG_CAT_EXP, QString::number(category->id()), true).toBool());
settings->value(GROUP(Categories), QString::number(category->id()), true).toBool());
}
}
@ -170,7 +170,7 @@ void FeedsView::updateAllFeeds() {
}
void FeedsView::updateAllFeedsOnStartup() {
if (qApp->settings()->value(APP_CFG_FEEDS, "feeds_update_on_startup", false).toBool()) {
if (qApp->settings()->value(GROUP(Feeds), "feeds_update_on_startup", false).toBool()) {
qDebug("Requesting update for all feeds on application startup.");
QTimer::singleShot(STARTUP_UPDATE_DELAY, this, SLOT(updateAllFeeds()));
}

View File

@ -284,26 +284,26 @@ void FormMain::loadSize() {
Settings *settings = qApp->settings();
// Reload main window size & position.
resize(settings->value(APP_CFG_GUI, "window_size", size()).toSize());
move(settings->value(APP_CFG_GUI, "window_position", screen.center() - rect().center()).toPoint());
resize(settings->value(GROUP(GUI), "window_size", size()).toSize());
move(settings->value(GROUP(GUI), "window_position", screen.center() - rect().center()).toPoint());
// If user exited the application while in fullsreen mode,
// then re-enable it now.
if (settings->value(APP_CFG_GUI, "start_in_fullscreen", false).toBool()) {
if (settings->value(GROUP(GUI), "start_in_fullscreen", false).toBool()) {
m_ui->m_actionFullscreen->setChecked(true);
}
if (settings->value(APP_CFG_GUI, "window_is_maximized", false).toBool()) {
if (settings->value(GROUP(GUI), "window_is_maximized", false).toBool()) {
setWindowState(windowState() | Qt::WindowMaximized);
}
// Hide the main menu if user wants it.
m_ui->m_actionSwitchMainMenu->setChecked(settings->value(APP_CFG_GUI, "main_menu_visible", true).toBool());
m_ui->m_actionSwitchMainMenu->setChecked(settings->value(GROUP(GUI), "main_menu_visible", true).toBool());
// Adjust dimensions of "feeds & messages" widget.
m_ui->m_tabWidget->feedMessageViewer()->loadSize();
m_ui->m_actionSwitchToolBars->setChecked(settings->value(APP_CFG_GUI, "enable_toolbars", true).toBool());
m_ui->m_actionSwitchListHeaders->setChecked(settings->value(APP_CFG_GUI, "enable_list_headers", true).toBool());
m_ui->m_actionSwitchToolBars->setChecked(settings->value(GROUP(GUI), "enable_toolbars", true).toBool());
m_ui->m_actionSwitchListHeaders->setChecked(settings->value(GROUP(GUI), "enable_list_headers", true).toBool());
}
void FormMain::saveSize() {
@ -319,11 +319,11 @@ void FormMain::saveSize() {
setWindowState(windowState() & ~Qt::WindowMaximized);
}
settings->setValue(APP_CFG_GUI, "main_menu_visible", m_ui->m_actionSwitchMainMenu->isChecked());
settings->setValue(APP_CFG_GUI, "window_position", pos());
settings->setValue(APP_CFG_GUI, "window_size", size());
settings->setValue(APP_CFG_GUI, "window_is_maximized", is_maximized);
settings->setValue(APP_CFG_GUI, "start_in_fullscreen", is_fullscreen);
settings->setValue(GROUP(GUI), "main_menu_visible", m_ui->m_actionSwitchMainMenu->isChecked());
settings->setValue(GROUP(GUI), "window_position", pos());
settings->setValue(GROUP(GUI), "window_size", size());
settings->setValue(GROUP(GUI), "window_is_maximized", is_maximized);
settings->setValue(GROUP(GUI), "start_in_fullscreen", is_fullscreen);
m_ui->m_tabWidget->feedMessageViewer()->saveSize();
}
@ -416,7 +416,7 @@ void FormMain::changeEvent(QEvent *event) {
case QEvent::WindowStateChange: {
if (this->windowState() & Qt::WindowMinimized &&
SystemTrayIcon::isSystemTrayActivated() &&
qApp->settings()->value(APP_CFG_GUI, "hide_when_minimized", false).toBool()) {
qApp->settings()->value(GROUP(GUI), "hide_when_minimized", false).toBool()) {
event->ignore();
QTimer::singleShot(CHANGE_EVENT_DELAY, this, SLOT(switchVisibility()));
}

View File

@ -178,19 +178,19 @@ void FormSettings::selectBrowserExecutable() {
void FormSettings::loadFeedsMessages() {
Settings *settings = qApp->settings();
m_ui->m_checkKeppMessagesInTheMiddle->setChecked(settings->value(APP_CFG_MESSAGES, "keep_cursor_center", false).toBool());
m_ui->m_checkRemoveReadMessagesOnExit->setChecked(settings->value(APP_CFG_MESSAGES, "clear_read_on_exit", false).toBool());
m_ui->m_checkAutoUpdate->setChecked(settings->value(APP_CFG_FEEDS, "auto_update_enabled", false).toBool());
m_ui->m_spinAutoUpdateInterval->setValue(settings->value(APP_CFG_FEEDS, "auto_update_interval", DEFAULT_AUTO_UPDATE_INTERVAL).toInt());
m_ui->m_spinFeedUpdateTimeout->setValue(settings->value(APP_CFG_FEEDS, SETTING(Feeds::UpdateTimeout)).toInt());
m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(settings->value(APP_CFG_FEEDS, "feeds_update_on_startup", false).toBool());
m_ui->m_checkKeppMessagesInTheMiddle->setChecked(settings->value(GROUP(Messages), "keep_cursor_center", false).toBool());
m_ui->m_checkRemoveReadMessagesOnExit->setChecked(settings->value(GROUP(Messages), "clear_read_on_exit", false).toBool());
m_ui->m_checkAutoUpdate->setChecked(settings->value(GROUP(Feeds), "auto_update_enabled", false).toBool());
m_ui->m_spinAutoUpdateInterval->setValue(settings->value(GROUP(Feeds), "auto_update_interval", DEFAULT_AUTO_UPDATE_INTERVAL).toInt());
m_ui->m_spinFeedUpdateTimeout->setValue(settings->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt());
m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(settings->value(GROUP(Feeds), "feeds_update_on_startup", false).toBool());
m_ui->m_cmbCountsFeedList->addItems(QStringList() << "(%unread)" << "[%unread]" << "%unread/%all" << "%unread-%all" << "[%unread|%all]");
m_ui->m_cmbCountsFeedList->setEditText(settings->value(APP_CFG_FEEDS, "count_format", "(%unread)").toString());
m_ui->m_cmbCountsFeedList->setEditText(settings->value(GROUP(Feeds), "count_format", "(%unread)").toString());
initializeMessageDateFormats();
m_ui->m_checkMessagesDateTimeFormat->setChecked(settings->value(APP_CFG_MESSAGES, "use_custom_date").toBool());
int index_format = m_ui->m_cmbMessagesDateTimeFormat->findData(settings->value(APP_CFG_MESSAGES, "custom_date_format").toString());
m_ui->m_checkMessagesDateTimeFormat->setChecked(settings->value(GROUP(Messages), "use_custom_date").toBool());
int index_format = m_ui->m_cmbMessagesDateTimeFormat->findData(settings->value(GROUP(Messages), "custom_date_format").toString());
if (index_format >= 0) {
m_ui->m_cmbMessagesDateTimeFormat->setCurrentIndex(index_format);
@ -212,15 +212,15 @@ void FormSettings::initializeMessageDateFormats() {
void FormSettings::saveFeedsMessages() {
Settings *settings = qApp->settings();
settings->setValue(APP_CFG_MESSAGES, "keep_cursor_center", m_ui->m_checkKeppMessagesInTheMiddle->isChecked());
settings->setValue(APP_CFG_MESSAGES, "clear_read_on_exit", m_ui->m_checkRemoveReadMessagesOnExit->isChecked());
settings->setValue(APP_CFG_FEEDS, "auto_update_enabled", m_ui->m_checkAutoUpdate->isChecked());
settings->setValue(APP_CFG_FEEDS, "auto_update_interval", m_ui->m_spinAutoUpdateInterval->value());
settings->setValue(APP_CFG_FEEDS, Feeds::UpdateTimeout, m_ui->m_spinFeedUpdateTimeout->value());
settings->setValue(APP_CFG_FEEDS, "feeds_update_on_startup", m_ui->m_checkUpdateAllFeedsOnStartup->isChecked());
settings->setValue(APP_CFG_FEEDS, "count_format", m_ui->m_cmbCountsFeedList->currentText());
settings->setValue(APP_CFG_MESSAGES, "use_custom_date", m_ui->m_checkMessagesDateTimeFormat->isChecked());
settings->setValue(APP_CFG_MESSAGES, "custom_date_format",
settings->setValue(GROUP(Messages), "keep_cursor_center", m_ui->m_checkKeppMessagesInTheMiddle->isChecked());
settings->setValue(GROUP(Messages), "clear_read_on_exit", m_ui->m_checkRemoveReadMessagesOnExit->isChecked());
settings->setValue(GROUP(Feeds), "auto_update_enabled", m_ui->m_checkAutoUpdate->isChecked());
settings->setValue(GROUP(Feeds), "auto_update_interval", m_ui->m_spinAutoUpdateInterval->value());
settings->setValue(GROUP(Feeds), Feeds::UpdateTimeout, m_ui->m_spinFeedUpdateTimeout->value());
settings->setValue(GROUP(Feeds), "feeds_update_on_startup", m_ui->m_checkUpdateAllFeedsOnStartup->isChecked());
settings->setValue(GROUP(Feeds), "count_format", m_ui->m_cmbCountsFeedList->currentText());
settings->setValue(GROUP(Messages), "use_custom_date", m_ui->m_checkMessagesDateTimeFormat->isChecked());
settings->setValue(GROUP(Messages), "custom_date_format",
m_ui->m_cmbMessagesDateTimeFormat->itemData(m_ui->m_cmbMessagesDateTimeFormat->currentIndex()).toString());
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->updateAutoUpdateStatus();
@ -333,19 +333,19 @@ void FormSettings::loadBrowser() {
Settings *settings = qApp->settings();
// Load settings of web browser GUI.
m_ui->m_checkMouseGestures->setChecked(settings->value(APP_CFG_BROWSER,
m_ui->m_checkMouseGestures->setChecked(settings->value(GROUP(Browser),
"gestures_enabled",
true).toBool());
m_ui->m_checkQueueTabs->setChecked(settings->value(APP_CFG_BROWSER,
m_ui->m_checkQueueTabs->setChecked(settings->value(GROUP(Browser),
"queue_tabs",
true).toBool());
m_ui->m_cmbExternalBrowserPreset->addItem(tr("Opera 12 or older"), "-nosession %1");
m_ui->m_txtExternalBrowserExecutable->setText(settings->value(APP_CFG_BROWSER,
m_ui->m_txtExternalBrowserExecutable->setText(settings->value(GROUP(Browser),
"external_browser_executable").toString());
m_ui->m_txtExternalBrowserArguments->setText(settings->value(APP_CFG_BROWSER,
m_ui->m_txtExternalBrowserArguments->setText(settings->value(GROUP(Browser),
"external_browser_arguments",
"%1").toString());
m_ui->m_grpCustomExternalBrowser->setChecked(settings->value(APP_CFG_BROWSER,
m_ui->m_grpCustomExternalBrowser->setChecked(settings->value(GROUP(Browser),
"custom_external_browser",
false).toBool());
m_ui->m_checkAutoLoadImages->setChecked(WebFactory::instance()->autoloadImages());
@ -357,13 +357,13 @@ void FormSettings::saveBrowser() {
Settings *settings = qApp->settings();
// Save settings of GUI of web browser.
settings->setValue(APP_CFG_BROWSER,
settings->setValue(GROUP(Browser),
"custom_external_browser",
m_ui->m_grpCustomExternalBrowser->isChecked());
settings->setValue(APP_CFG_BROWSER,
settings->setValue(GROUP(Browser),
"gestures_enabled",
m_ui->m_checkMouseGestures->isChecked());
settings->setValue(APP_CFG_BROWSER,
settings->setValue(GROUP(Browser),
"queue_tabs",
m_ui->m_checkQueueTabs->isChecked());
@ -371,10 +371,10 @@ void FormSettings::saveBrowser() {
WebFactory::instance()->switchJavascript(m_ui->m_checkEnableJavascript->isChecked());
WebFactory::instance()->switchPlugins(m_ui->m_checkEnablePlugins->isChecked());
settings->setValue(APP_CFG_BROWSER,
settings->setValue(GROUP(Browser),
"external_browser_executable",
m_ui->m_txtExternalBrowserExecutable->text());
settings->setValue(APP_CFG_BROWSER,
settings->setValue(GROUP(Browser),
"external_browser_arguments",
m_ui->m_txtExternalBrowserArguments->text());
}
@ -387,33 +387,33 @@ void FormSettings::loadProxy() {
// Load the settings.
Settings *settings = qApp->settings();
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(settings->value(APP_CFG_PROXY,
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(settings->value(GROUP(Proxy),
"proxy_type",
QNetworkProxy::NoProxy).toInt());
m_ui->m_cmbProxyType->setCurrentIndex(m_ui->m_cmbProxyType->findData(selected_proxy_type));
m_ui->m_txtProxyHost->setText(settings->value(APP_CFG_PROXY,
m_ui->m_txtProxyHost->setText(settings->value(GROUP(Proxy),
"host").toString());
m_ui->m_txtProxyUsername->setText(settings->value(APP_CFG_PROXY,
m_ui->m_txtProxyUsername->setText(settings->value(GROUP(Proxy),
"username").toString());
m_ui->m_txtProxyPassword->setText(settings->value(APP_CFG_PROXY,
m_ui->m_txtProxyPassword->setText(settings->value(GROUP(Proxy),
"password").toString());
m_ui->m_spinProxyPort->setValue(settings->value(APP_CFG_PROXY,
m_ui->m_spinProxyPort->setValue(settings->value(GROUP(Proxy),
"port", 80).toInt());
}
void FormSettings::saveProxy() {
Settings *settings = qApp->settings();
settings->setValue(APP_CFG_PROXY, "proxy_type",
settings->setValue(GROUP(Proxy), "proxy_type",
m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex()));
settings->setValue(APP_CFG_PROXY, "host",
settings->setValue(GROUP(Proxy), "host",
m_ui->m_txtProxyHost->text());
settings->setValue(APP_CFG_PROXY, "username",
settings->setValue(GROUP(Proxy), "username",
m_ui->m_txtProxyUsername->text());
settings->setValue(APP_CFG_PROXY, "password",
settings->setValue(GROUP(Proxy), "password",
m_ui->m_txtProxyPassword->text());
settings->setValue(APP_CFG_PROXY, "port",
settings->setValue(GROUP(Proxy), "port",
m_ui->m_spinProxyPort->value());
// Reload settings for all network access managers.
@ -453,7 +453,7 @@ void FormSettings::saveLanguage() {
// Save prompt for restart if language has changed.
if (new_lang != actual_lang) {
m_changedDataTexts.append(tr("language changed"));
settings->setValue(APP_CFG_GEN, "language", new_lang);
settings->setValue(GROUP(General), "language", new_lang);
}
}
@ -480,7 +480,7 @@ void FormSettings::loadDataStorage() {
// Load in-memory database status.
Settings *settings = qApp->settings();
m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(settings->value(APP_CFG_DB, "use_in_memory_db", false).toBool());
m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(settings->value(GROUP(Database), "use_in_memory_db", false).toBool());
if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) {
onMysqlHostnameChanged(QString());
@ -495,13 +495,13 @@ void FormSettings::loadDataStorage() {
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_txtMysqlHostname->lineEdit()->setText(settings->value(APP_CFG_DB, "mysql_hostname").toString());
m_ui->m_txtMysqlUsername->lineEdit()->setText(settings->value(APP_CFG_DB, "mysql_username").toString());
m_ui->m_txtMysqlPassword->lineEdit()->setText(settings->value(APP_CFG_DB, "mysql_password").toString());
m_ui->m_spinMysqlPort->setValue(settings->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt());
m_ui->m_txtMysqlHostname->lineEdit()->setText(settings->value(GROUP(Database), "mysql_hostname").toString());
m_ui->m_txtMysqlUsername->lineEdit()->setText(settings->value(GROUP(Database), "mysql_username").toString());
m_ui->m_txtMysqlPassword->lineEdit()->setText(settings->value(GROUP(Database), "mysql_password").toString());
m_ui->m_spinMysqlPort->setValue(settings->value(GROUP(Database), "mysql_port", APP_DB_MYSQL_PORT).toInt());
}
int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(settings->value(APP_CFG_DB, "database_driver",
int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(settings->value(GROUP(Database), "database_driver",
APP_DB_SQLITE_DRIVER).toString());
if (index_current_backend >= 0) {
@ -513,7 +513,7 @@ void FormSettings::saveDataStorage() {
// Setup in-memory database status.
Settings *settings = qApp->settings();
bool original_inmemory = settings->value(APP_CFG_DB, "use_in_memory_db", false).toBool();
bool original_inmemory = settings->value(GROUP(Database), "use_in_memory_db", false).toBool();
bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked();
if (original_inmemory != new_inmemory) {
@ -521,21 +521,21 @@ void FormSettings::saveDataStorage() {
}
// Save data storage settings.
QString original_db_driver = settings->value(APP_CFG_DB, "database_driver", APP_DB_SQLITE_DRIVER).toString();
QString original_db_driver = settings->value(GROUP(Database), "database_driver", APP_DB_SQLITE_DRIVER).toString();
QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(m_ui->m_cmbDatabaseDriver->currentIndex()).toString();
// Save SQLite.
settings->setValue(APP_CFG_DB, "use_in_memory_db", new_inmemory);
settings->setValue(GROUP(Database), "use_in_memory_db", new_inmemory);
if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) {
// Save MySQL.
settings->setValue(APP_CFG_DB, "mysql_hostname", m_ui->m_txtMysqlHostname->lineEdit()->text());
settings->setValue(APP_CFG_DB, "mysql_username", m_ui->m_txtMysqlUsername->lineEdit()->text());
settings->setValue(APP_CFG_DB, "mysql_password", m_ui->m_txtMysqlPassword->lineEdit()->text());
settings->setValue(APP_CFG_DB, "mysql_port", m_ui->m_spinMysqlPort->value());
settings->setValue(GROUP(Database), "mysql_hostname", m_ui->m_txtMysqlHostname->lineEdit()->text());
settings->setValue(GROUP(Database), "mysql_username", m_ui->m_txtMysqlUsername->lineEdit()->text());
settings->setValue(GROUP(Database), "mysql_password", m_ui->m_txtMysqlPassword->lineEdit()->text());
settings->setValue(GROUP(Database), "mysql_port", m_ui->m_spinMysqlPort->value());
}
settings->setValue(APP_CFG_DB, "database_driver", selected_db_driver);
settings->setValue(GROUP(Database), "database_driver", selected_db_driver);
if (original_db_driver != selected_db_driver ||
m_initialSettings.m_dataStorageDataChanged) {
@ -618,7 +618,7 @@ void FormSettings::selectSqlBackend(int index) {
void FormSettings::loadGeneral() {
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text().arg(APP_NAME));
m_ui->m_checkForUpdatesOnStart->setChecked(qApp->settings()->value(APP_CFG_GEN, "update_on_start", true).toBool());
m_ui->m_checkForUpdatesOnStart->setChecked(qApp->settings()->value(GROUP(General), "update_on_start", true).toBool());
// Load auto-start status.
SystemFactory::AutoStartStatus autostart_status = qApp->system()->getAutoStartStatus();
@ -638,7 +638,7 @@ void FormSettings::loadGeneral() {
#if defined(Q_OS_WIN)
m_ui->m_checkRemoveTrolltechJunk->setEnabled(true);
m_ui->m_checkRemoveTrolltechJunk->setChecked(qApp->settings()->value(APP_CFG_GEN, "remove_trolltech_junk", false).toBool());
m_ui->m_checkRemoveTrolltechJunk->setChecked(qApp->settings()->value(GROUP(General), "remove_trolltech_junk", false).toBool());
#endif
}
@ -651,8 +651,8 @@ void FormSettings::saveGeneral() {
qApp->system()->setAutoStartStatus(SystemFactory::Disabled);
}
qApp->settings()->setValue(APP_CFG_GEN, "update_on_start", m_ui->m_checkForUpdatesOnStart->isChecked());
qApp->settings()->setValue(APP_CFG_GEN, "remove_trolltech_junk", m_ui->m_checkRemoveTrolltechJunk->isChecked());
qApp->settings()->setValue(GROUP(General), "update_on_start", m_ui->m_checkForUpdatesOnStart->isChecked());
qApp->settings()->setValue(GROUP(General), "remove_trolltech_junk", m_ui->m_checkRemoveTrolltechJunk->isChecked());
}
void FormSettings::loadInterface() {
@ -660,7 +660,7 @@ void FormSettings::loadInterface() {
// Load settings of tray icon.
if (SystemTrayIcon::isSystemTrayAvailable()) {
m_ui->m_radioTrayOff->setChecked(!settings->value(APP_CFG_GUI,
m_ui->m_radioTrayOff->setChecked(!settings->value(GROUP(GUI),
"use_tray_icon",
true).toBool());
}
@ -671,10 +671,10 @@ void FormSettings::loadInterface() {
m_ui->m_grpTray->setDisabled(true);
}
m_ui->m_checkHidden->setChecked(settings->value(APP_CFG_GUI,
m_ui->m_checkHidden->setChecked(settings->value(GROUP(GUI),
"start_hidden",
false).toBool());
m_ui->m_checkHideWhenMinimized->setChecked(settings->value(APP_CFG_GUI,
m_ui->m_checkHideWhenMinimized->setChecked(settings->value(GROUP(GUI),
"hide_when_minimized",
false).toBool());
@ -738,16 +738,16 @@ void FormSettings::loadInterface() {
}
// Load tab settings.
m_ui->m_checkCloseTabsMiddleClick->setChecked(settings->value(APP_CFG_GUI,
m_ui->m_checkCloseTabsMiddleClick->setChecked(settings->value(GROUP(GUI),
"tab_close_mid_button",
true).toBool());
m_ui->m_checkCloseTabsDoubleClick->setChecked(settings->value(APP_CFG_GUI,
m_ui->m_checkCloseTabsDoubleClick->setChecked(settings->value(GROUP(GUI),
"tab_close_double_button",
true).toBool());
m_ui->m_checkNewTabDoubleClick->setChecked(settings->value(APP_CFG_GUI,
m_ui->m_checkNewTabDoubleClick->setChecked(settings->value(GROUP(GUI),
"tab_new_double_button",
true).toBool());
m_ui->m_hideTabBarIfOneTabVisible->setChecked(settings->value(APP_CFG_GUI,
m_ui->m_hideTabBarIfOneTabVisible->setChecked(settings->value(GROUP(GUI),
"hide_tabbar_one_tab",
true).toBool());
@ -758,7 +758,7 @@ void FormSettings::loadInterface() {
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(qApp->settings()->value(APP_CFG_GUI,
m_ui->m_cmbToolbarButtonStyle->setCurrentIndex(m_ui->m_cmbToolbarButtonStyle->findData(qApp->settings()->value(GROUP(GUI),
"toolbar_style",
Qt::ToolButtonIconOnly).toInt()));
@ -771,16 +771,16 @@ void FormSettings::saveInterface() {
Settings *settings = qApp->settings();
// Save toolbar.
settings->setValue(APP_CFG_GUI,
settings->setValue(GROUP(GUI),
"toolbar_style",
m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex()));
// Save tray icon.
if (SystemTrayIcon::isSystemTrayAvailable()) {
settings->setValue(APP_CFG_GUI, "use_tray_icon",
settings->setValue(GROUP(GUI), "use_tray_icon",
m_ui->m_radioTrayOn->isChecked());
if (settings->value(APP_CFG_GUI, "use_tray_icon", true).toBool()) {
if (settings->value(GROUP(GUI), "use_tray_icon", true).toBool()) {
qApp->showTrayIcon();
}
else {
@ -788,9 +788,9 @@ void FormSettings::saveInterface() {
}
}
settings->setValue(APP_CFG_GUI, "start_hidden",
settings->setValue(GROUP(GUI), "start_hidden",
m_ui->m_checkHidden->isChecked());
settings->setValue(APP_CFG_GUI,
settings->setValue(GROUP(GUI),
"hide_when_minimized",
m_ui->m_checkHideWhenMinimized->isChecked());
@ -815,13 +815,13 @@ void FormSettings::saveInterface() {
}
// Save tab settings.
settings->setValue(APP_CFG_GUI, "tab_close_mid_button",
settings->setValue(GROUP(GUI), "tab_close_mid_button",
m_ui->m_checkCloseTabsMiddleClick->isChecked());
settings->setValue(APP_CFG_GUI, "tab_close_double_button",
settings->setValue(GROUP(GUI), "tab_close_double_button",
m_ui->m_checkCloseTabsDoubleClick->isChecked());
settings->setValue(APP_CFG_GUI, "tab_new_double_button",
settings->setValue(GROUP(GUI), "tab_new_double_button",
m_ui->m_checkNewTabDoubleClick->isChecked());
settings->setValue(APP_CFG_GUI, "hide_tabbar_one_tab",
settings->setValue(GROUP(GUI), "hide_tabbar_one_tab",
m_ui->m_hideTabBarIfOneTabVisible->isChecked());
m_ui->m_editorFeedsToolbar->saveToolBar();

View File

@ -57,7 +57,7 @@ QList<QAction*> MessagesToolBar::changeableActions() const {
}
void MessagesToolBar::saveChangeableActions(const QStringList& actions) {
qApp->settings()->setValue(APP_CFG_GUI, "messages_toolbar", actions.join(","));
qApp->settings()->setValue(GROUP(GUI), "messages_toolbar", actions.join(","));
loadChangeableActions(actions);
// If user hidden search messages box, then remove the filter.
@ -151,7 +151,7 @@ void MessagesToolBar::initializeHighlighter() {
}
void MessagesToolBar::loadChangeableActions() {
QStringList action_names = qApp->settings()->value(APP_CFG_GUI,
QStringList action_names = qApp->settings()->value(GROUP(GUI),
"messages_toolbar",
"m_actionMarkSelectedMessagesAsRead,m_actionMarkSelectedMessagesAsUnread,m_actionSwitchImportanceOfSelectedMessages,separator,highlighter,spacer,search").toString().split(',',
QString::SkipEmptyParts);

View File

@ -226,7 +226,7 @@ void MessagesView::currentChanged(const QModelIndex &current,
void MessagesView::selectionChanged(const QItemSelection &selected,
const QItemSelection &deselected) {
if (qApp->settings()->value(APP_CFG_MESSAGES, "keep_cursor_center", false).toBool()) {
if (qApp->settings()->value(GROUP(Messages), "keep_cursor_center", false).toBool()) {
scrollTo(currentIndex(), QAbstractItemView::PositionAtCenter);
}
@ -236,8 +236,8 @@ void MessagesView::selectionChanged(const QItemSelection &selected,
void MessagesView::loadFeeds(const QList<int> &feed_ids) {
m_sourceModel->loadMessages(feed_ids);
int col = qApp->settings()->value(APP_CFG_GUI, "default_sort_column_messages", MSG_DB_DCREATED_INDEX).toInt();
Qt::SortOrder ord = static_cast<Qt::SortOrder>(qApp->settings()->value(APP_CFG_GUI,
int col = qApp->settings()->value(GROUP(GUI), "default_sort_column_messages", MSG_DB_DCREATED_INDEX).toInt();
Qt::SortOrder ord = static_cast<Qt::SortOrder>(qApp->settings()->value(GROUP(GUI),
"default_sort_order_messages", Qt::DescendingOrder).toInt());
sortByColumn(col, ord);
@ -514,6 +514,6 @@ void MessagesView::adjustColumns() {
}
void MessagesView::saveSortState(int column, Qt::SortOrder order) {
qApp->settings()->setValue(APP_CFG_GUI, "default_sort_column_messages", column);
qApp->settings()->setValue(APP_CFG_GUI, "default_sort_order_messages", order);
qApp->settings()->setValue(GROUP(GUI), "default_sort_column_messages", column);
qApp->settings()->setValue(GROUP(GUI), "default_sort_order_messages", order);
}

View File

@ -89,7 +89,7 @@ bool SystemTrayIcon::isSystemTrayAvailable() {
}
bool SystemTrayIcon::isSystemTrayActivated() {
return SystemTrayIcon::isSystemTrayAvailable() && qApp->settings()->value(APP_CFG_GUI, "use_tray_icon", true).toBool();
return SystemTrayIcon::isSystemTrayAvailable() && qApp->settings()->value(GROUP(GUI), "use_tray_icon", true).toBool();
}
void SystemTrayIcon::showPrivate() {

View File

@ -112,9 +112,7 @@ void TabBar::mousePressEvent(QMouseEvent *event) {
// Check if user clicked tab with middle button.
// NOTE: This needs to be done here because
// destination does not know the original event.
if (event->button() & Qt::MiddleButton && qApp->settings()->value(APP_CFG_GUI,
"tab_close_mid_button",
true).toBool()) {
if (event->button() & Qt::MiddleButton && qApp->settings()->value(GROUP(GUI), "tab_close_mid_button", true).toBool()) {
if (tabType(tab_index) == TabBar::Closable) {
// This tab is closable, so we can close it.
emit tabCloseRequested(tab_index);
@ -133,7 +131,7 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent *event) {
// Check if user clicked tab with middle button.
// NOTE: This needs to be done here because
// destination does not know the original event.
if (event->button() & Qt::LeftButton && qApp->settings()->value(APP_CFG_GUI,
if (event->button() & Qt::LeftButton && qApp->settings()->value(GROUP(GUI),
"tab_close_double_button",
true).toBool()) {
if (tabType(tab_index) == TabBar::Closable) {
@ -145,7 +143,7 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent *event) {
// Check if new tab should be opened with initial web browser.
// NOTE: This check could be unnecesary here and should be done in
// destination object but we keep it here for consistency.
else if (qApp->settings()->value(APP_CFG_GUI,
else if (qApp->settings()->value(GROUP(GUI),
"tab_new_double_button",
true).toBool()) {
emit emptySpaceDoubleClicked();

View File

@ -87,7 +87,7 @@ void TabWidget::openMainMenu() {
}
void TabWidget::checkTabBarVisibility() {
bool should_be_visible = count() > 1 || !qApp->settings()->value(APP_CFG_GUI,
bool should_be_visible = count() > 1 || !qApp->settings()->value(GROUP(GUI),
"hide_tabbar_one_tab",
true).toBool();
@ -273,7 +273,7 @@ int TabWidget::addLinkedBrowser(const QString &initial_url) {
}
int TabWidget::addLinkedBrowser(const QUrl &initial_url) {
return addBrowser(qApp->settings()->value(APP_CFG_BROWSER,
return addBrowser(qApp->settings()->value(GROUP(Browser),
"queue_tabs",
true).toBool(),
false,

View File

@ -100,7 +100,7 @@ int main(int argc, char *argv[]) {
DynamicShortcuts::load(qApp->userActions());
// Display main window.
if (qApp->settings()->value(APP_CFG_GUI, "start_hidden", false).toBool() && SystemTrayIcon::isSystemTrayActivated()) {
if (qApp->settings()->value(GROUP(GUI), "start_hidden", false).toBool() && SystemTrayIcon::isSystemTrayActivated()) {
qDebug("Hiding the main window when the application is starting.");
main_window.switchVisibility(true);
}
@ -113,7 +113,7 @@ int main(int argc, char *argv[]) {
if (SystemTrayIcon::isSystemTrayActivated()) {
qApp->showTrayIcon();
if (qApp->settings()->value(APP_CFG_GEN, "update_on_start", true).toBool()) {
if (qApp->settings()->value(GROUP(General), "update_on_start", true).toBool()) {
QTimer::singleShot(STARTUP_UPDATE_DELAY, application.system(), SLOT(checkForUpdatesAsynchronously()));
}
}

View File

@ -447,7 +447,7 @@ void DatabaseFactory::sqliteSaveMemoryDatabase() {
}
void DatabaseFactory::determineDriver() {
QString db_driver = qApp->settings()->value(APP_CFG_DB, "database_driver", APP_DB_SQLITE_DRIVER).toString();
QString db_driver = qApp->settings()->value(GROUP(Database), "database_driver", APP_DB_SQLITE_DRIVER).toString();
if (db_driver == APP_DB_MYSQL_DRIVER && QSqlDatabase::isDriverAvailable(APP_DB_SQLITE_DRIVER)) {
// User wants to use MySQL and MySQL is actually available. Use it.
@ -458,7 +458,7 @@ void DatabaseFactory::determineDriver() {
else {
// User wants to use SQLite, which is always available. Check if file-based
// or in-memory database will be used.
if (qApp->settings()->value(APP_CFG_DB, "use_in_memory_db", false).toBool()) {
if (qApp->settings()->value(GROUP(Database), "use_in_memory_db", false).toBool()) {
// Use in-memory SQLite database.
m_activeDatabaseDriver = SQLITE_MEMORY;
@ -499,10 +499,10 @@ QSqlDatabase DatabaseFactory::mysqlConnection(const QString &connection_name) {
// yet, add it and set it up.
database = QSqlDatabase::addDatabase(APP_DB_MYSQL_DRIVER, connection_name);
database.setHostName(qApp->settings()->value(APP_CFG_DB, "mysql_hostname").toString());
database.setPort(qApp->settings()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt());
database.setUserName(qApp->settings()->value(APP_CFG_DB, "mysql_username").toString());
database.setPassword(qApp->settings()->value(APP_CFG_DB, "mysql_password").toString());
database.setHostName(qApp->settings()->value(GROUP(Database), "mysql_hostname").toString());
database.setPort(qApp->settings()->value(GROUP(Database), "mysql_port", APP_DB_MYSQL_PORT).toInt());
database.setUserName(qApp->settings()->value(GROUP(Database), "mysql_username").toString());
database.setPassword(qApp->settings()->value(GROUP(Database), "mysql_password").toString());
database.setDatabaseName(APP_LOW_NAME);
}
@ -524,10 +524,10 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString &connection_
// Folders are created. Create new QSQLDatabase object.
QSqlDatabase database = QSqlDatabase::addDatabase(APP_DB_MYSQL_DRIVER, connection_name);
database.setHostName(qApp->settings()->value(APP_CFG_DB, "mysql_hostname").toString());
database.setPort(qApp->settings()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt());
database.setUserName(qApp->settings()->value(APP_CFG_DB, "mysql_username").toString());
database.setPassword(qApp->settings()->value(APP_CFG_DB, "mysql_password").toString());
database.setHostName(qApp->settings()->value(GROUP(Database), "mysql_hostname").toString());
database.setPort(qApp->settings()->value(GROUP(Database), "mysql_port", APP_DB_MYSQL_PORT).toInt());
database.setUserName(qApp->settings()->value(GROUP(Database), "mysql_username").toString());
database.setPassword(qApp->settings()->value(GROUP(Database), "mysql_password").toString());
if (!database.open()) {
qFatal("MySQL database was NOT opened. Delivered error message: '%s'",

View File

@ -64,12 +64,12 @@ void IconFactory::setupSearchPaths() {
}
void IconFactory::setCurrentIconTheme(const QString &theme_name) {
qApp->settings()->setValue(APP_CFG_GUI, "icon_theme", theme_name);
qApp->settings()->setValue(GROUP(GUI), "icon_theme", theme_name);
}
void IconFactory::loadCurrentIconTheme() {
QStringList installed_themes = installedIconThemes();
QString theme_name_from_settings = qApp->settings()->value(APP_CFG_GUI,
QString theme_name_from_settings = qApp->settings()->value(GROUP(GUI),
"icon_theme",
APP_THEME_DEFAULT).toString();

View File

@ -34,9 +34,7 @@ Localization::~Localization() {
}
QString Localization::desiredLanguage() {
return qApp->settings()->value(APP_CFG_GEN,
"language",
QLocale::system().name()).toString();
return qApp->settings()->value(GROUP(General), "language", QLocale::system().name()).toString();
}
void Localization::loadActiveLanguage() {
@ -44,9 +42,7 @@ void Localization::loadActiveLanguage() {
QTranslator *app_translator = new QTranslator(qApp);
QString desired_localization = desiredLanguage();
if (app_translator->load(QString("rssguard-%1.qm").arg(desired_localization),
APP_LANG_PATH,
"-")) {
if (app_translator->load(QString("rssguard-%1.qm").arg(desired_localization), APP_LANG_PATH, "-")) {
Application::installTranslator(app_translator);
qDebug("Application localization '%s' loaded successfully.", qPrintable(desired_localization));
}

View File

@ -27,9 +27,12 @@
#define KEY static const char*
#define VALUE(x) static const x
#define SETTING(x) x, x##Def
#define GROUP(x) x::ID
// Feeds.
namespace Feeds {
KEY ID = "feeds";
KEY UpdateTimeout = "feed_update_timeout";
VALUE(int) UpdateTimeoutDef = DOWNLOAD_TIMEOUT;
@ -39,6 +42,8 @@ namespace Feeds {
// Messages.
namespace Messages {
KEY ID = "messages";
KEY UseCustomDate = "use_custom_date";
VALUE(bool) UseCustomDateDef = false;
@ -51,6 +56,8 @@ namespace Messages {
// GUI.
namespace GUI {
KEY ID = "gui";
KEY SplitterFeeds = "splitter_feeds";
VALUE(char*) SplitterFeedsDef = "";
@ -63,7 +70,32 @@ namespace GUI {
// General.
namespace General {
KEY ID = "main";
}
// Proxy.
namespace Proxy {
KEY ID = "proxy";
}
// Database.
namespace Database {
KEY ID = "database";
}
// Keyboard.
namespace Keyboard {
KEY ID = "keyboard";
}
// Web browser.
namespace Browser {
KEY ID = "browser";
}
// Categories.
namespace Categories {
KEY ID = "categories_expand_states";
}

View File

@ -97,11 +97,11 @@ bool SkinFactory::loadSkinFromData(const Skin &skin) {
}
void SkinFactory::setCurrentSkinName(const QString &skin_name) {
qApp->settings()->setValue(APP_CFG_GUI, "skin", skin_name);
qApp->settings()->setValue(GROUP(GUI), "skin", skin_name);
}
QString SkinFactory::selectedSkinName() {
return qApp->settings()->value(APP_CFG_GUI,
return qApp->settings()->value(GROUP(GUI),
"skin",
APP_SKIN_DEFAULT).toString();
}

View File

@ -156,7 +156,7 @@ bool SystemFactory::setAutoStartStatus(const AutoStartStatus &new_status) {
#if defined(Q_OS_WIN)
bool SystemFactory::removeTrolltechJunkRegistryKeys() {
if (qApp->settings()->value(APP_CFG_GEN, "remove_trolltech_junk", false).toBool()) {
if (qApp->settings()->value(GROUP(General), "remove_trolltech_junk", false).toBool()) {
QSettings registry_key("HKEY_CURRENT_USER\\Software\\TrollTech", QSettings::NativeFormat);
registry_key.remove("");

View File

@ -36,7 +36,7 @@ BaseNetworkAccessManager::~BaseNetworkAccessManager() {
void BaseNetworkAccessManager::loadSettings() {
QNetworkProxy new_proxy;
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(qApp->settings()->value(APP_CFG_PROXY,
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(qApp->settings()->value(GROUP(Proxy),
"proxy_type",
QNetworkProxy::NoProxy).toInt());
@ -54,10 +54,10 @@ void BaseNetworkAccessManager::loadSettings() {
// Custom proxy is selected, set it up.
new_proxy.setType(selected_proxy_type);
new_proxy.setHostName(settings->value(APP_CFG_PROXY, "host").toString());
new_proxy.setPort(settings->value(APP_CFG_PROXY, "port", 80).toInt());
new_proxy.setUser(settings->value(APP_CFG_PROXY, "username").toString());
new_proxy.setPassword(settings->value(APP_CFG_PROXY, "password").toString());
new_proxy.setHostName(settings->value(GROUP(Proxy), "host").toString());
new_proxy.setPort(settings->value(GROUP(Proxy), "port", 80).toInt());
new_proxy.setUser(settings->value(GROUP(Proxy), "username").toString());
new_proxy.setPassword(settings->value(GROUP(Proxy), "password").toString());
setProxy(new_proxy);
qDebug("Settings of BaseNetworkAccessManager loaded.");

View File

@ -24,20 +24,15 @@ WebFactory::~WebFactory() {
void WebFactory::loadState() {
Settings *settings = qApp->settings();
switchJavascript(settings->value(APP_CFG_BROWSER, "enable_javascript", true).toBool(), false);
switchImages(settings->value(APP_CFG_BROWSER, "enable_images", true).toBool(), false);
switchPlugins(settings->value(APP_CFG_BROWSER, "enable_plugins", false).toBool(), false);
switchJavascript(settings->value(GROUP(Browser), "enable_javascript", true).toBool(), false);
switchImages(settings->value(GROUP(Browser), "enable_images", true).toBool(), false);
switchPlugins(settings->value(GROUP(Browser), "enable_plugins", false).toBool(), false);
}
bool WebFactory::openUrlInExternalBrowser(const QString &url) {
if (qApp->settings()->value(APP_CFG_BROWSER,
"custom_external_browser",
false).toBool()) {
QString browser = qApp->settings()->value(APP_CFG_BROWSER,
"external_browser_executable").toString();
QString arguments = qApp->settings()->value(APP_CFG_BROWSER,
"external_browser_arguments",
"%1").toString();
if (qApp->settings()->value(GROUP(Browser), "custom_external_browser", false).toBool()) {
QString browser = qApp->settings()->value(GROUP(Browser), "external_browser_executable").toString();
QString arguments = qApp->settings()->value(GROUP(Browser), "external_browser_arguments", "%1").toString();
return QProcess::startDetached(browser, QStringList() << arguments.arg(url));
}
@ -48,9 +43,7 @@ bool WebFactory::openUrlInExternalBrowser(const QString &url) {
void WebFactory::switchJavascript(bool enable, bool save_settings) {
if (save_settings) {
qApp->settings()->setValue(APP_CFG_BROWSER,
"enable_javascript",
enable);
qApp->settings()->setValue(GROUP(Browser), "enable_javascript", enable);
}
m_globalSettings->setAttribute(QWebSettings::JavascriptEnabled, enable);
@ -59,7 +52,7 @@ void WebFactory::switchJavascript(bool enable, bool save_settings) {
void WebFactory::switchPlugins(bool enable, bool save_settings) {
if (save_settings) {
qApp->settings()->setValue(APP_CFG_BROWSER,
qApp->settings()->setValue(GROUP(Browser),
"enable_plugins",
enable);
}
@ -70,7 +63,7 @@ void WebFactory::switchPlugins(bool enable, bool save_settings) {
void WebFactory::switchImages(bool enable, bool save_settings) {
if (save_settings) {
qApp->settings()->setValue(APP_CFG_BROWSER,
qApp->settings()->setValue(GROUP(Browser),
"enable_images",
enable);
}

View File

@ -238,7 +238,7 @@ void WebView::mousePressEvent(QMouseEvent *event) {
void WebView::mouseReleaseEvent(QMouseEvent *event) {
if (event->button() & Qt::MiddleButton) {
bool are_gestures_enabled = qApp->settings()->value(APP_CFG_BROWSER,
bool are_gestures_enabled = qApp->settings()->value(GROUP(Browser),
"gestures_enabled",
true).toBool();
if (are_gestures_enabled) {