Refactored settings.
This commit is contained in:
parent
07c78623b1
commit
3b7c11853d
@ -152,7 +152,6 @@ message(STATUS "[${APP_LOW_NAME}] Obtaining revision number.")
|
|||||||
if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
if(EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
||||||
find_package(Git)
|
find_package(Git)
|
||||||
if(GIT_FOUND)
|
if(GIT_FOUND)
|
||||||
# TODO: https://wiki.archlinux.org/index.php/VCS_PKGBUILD_Guidelines#Git
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
Application::Application(const QString &id, int &argc, char **argv)
|
Application::Application(const QString &id, int &argc, char **argv)
|
||||||
: QtSingleApplication(id, argc, argv) {
|
: QtSingleApplication(id, argc, argv), m_settings(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application() {
|
Application::~Application() {
|
||||||
|
@ -20,9 +20,13 @@
|
|||||||
|
|
||||||
#include "qtsingleapplication/qtsingleapplication.h"
|
#include "qtsingleapplication/qtsingleapplication.h"
|
||||||
|
|
||||||
|
#include "miscellaneous/settings.h"
|
||||||
|
|
||||||
#if defined(qApp)
|
#if defined(qApp)
|
||||||
#undef qApp
|
#undef qApp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Define new qApp macro. Yeaaaaah.
|
||||||
#define qApp (Application::instance())
|
#define qApp (Application::instance())
|
||||||
|
|
||||||
|
|
||||||
@ -35,10 +39,21 @@ class Application : public QtSingleApplication {
|
|||||||
explicit Application(const QString &id, int &argc, char **argv);
|
explicit Application(const QString &id, int &argc, char **argv);
|
||||||
virtual ~Application();
|
virtual ~Application();
|
||||||
|
|
||||||
|
inline Settings *settings() {
|
||||||
|
if (m_settings == NULL) {
|
||||||
|
m_settings = Settings::setupSettings(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_settings;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns pointer to "GOD" application singleton.
|
// Returns pointer to "GOD" application singleton.
|
||||||
inline static Application *instance() {
|
inline static Application *instance() {
|
||||||
return static_cast<Application*>(QCoreApplication::instance());
|
return static_cast<Application*>(QCoreApplication::instance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Settings *m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPLICATION_H
|
#endif // APPLICATION_H
|
||||||
|
@ -87,7 +87,7 @@ QVariant FeedsModelCategory::data(int column, int role) const {
|
|||||||
return m_title;
|
return m_title;
|
||||||
}
|
}
|
||||||
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
return Settings::instance()->value(APP_CFG_FEEDS,
|
return qApp->settings()->value(APP_CFG_FEEDS,
|
||||||
"count_format",
|
"count_format",
|
||||||
"(%unread)").toString()
|
"(%unread)").toString()
|
||||||
.replace("%unread", QString::number(countOfUnreadMessages()))
|
.replace("%unread", QString::number(countOfUnreadMessages()))
|
||||||
|
@ -146,7 +146,7 @@ QPair<FeedsModelFeed*, QNetworkReply::NetworkError> FeedsModelFeed::guessFeed(co
|
|||||||
|
|
||||||
QByteArray feed_contents;
|
QByteArray feed_contents;
|
||||||
if ((result.second = NetworkFactory::downloadFeedFile(url,
|
if ((result.second = NetworkFactory::downloadFeedFile(url,
|
||||||
Settings::instance()->value(APP_CFG_FEEDS, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt(),
|
qApp->settings()->value(APP_CFG_FEEDS, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt(),
|
||||||
feed_contents,
|
feed_contents,
|
||||||
!username.isEmpty(),
|
!username.isEmpty(),
|
||||||
username,
|
username,
|
||||||
@ -255,7 +255,7 @@ QVariant FeedsModelFeed::data(int column, int role) const {
|
|||||||
return m_title;
|
return m_title;
|
||||||
}
|
}
|
||||||
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||||
return Settings::instance()->value(APP_CFG_FEEDS,
|
return qApp->settings()->value(APP_CFG_FEEDS,
|
||||||
"count_format",
|
"count_format",
|
||||||
"(%unread)").toString()
|
"(%unread)").toString()
|
||||||
.replace("%unread", QString::number(countOfUnreadMessages()))
|
.replace("%unread", QString::number(countOfUnreadMessages()))
|
||||||
@ -348,7 +348,7 @@ QVariant FeedsModelFeed::data(int column, int role) const {
|
|||||||
|
|
||||||
void FeedsModelFeed::update() {
|
void FeedsModelFeed::update() {
|
||||||
QByteArray feed_contents;
|
QByteArray feed_contents;
|
||||||
int download_timeout = Settings::instance()->value(APP_CFG_FEEDS, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt();
|
int download_timeout = qApp->settings()->value(APP_CFG_FEEDS, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt();
|
||||||
QNetworkReply::NetworkError download_result = NetworkFactory::downloadFeedFile(url(),
|
QNetworkReply::NetworkError download_result = NetworkFactory::downloadFeedFile(url(),
|
||||||
download_timeout,
|
download_timeout,
|
||||||
feed_contents,
|
feed_contents,
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "definitions/definitions.h"
|
#include "definitions/definitions.h"
|
||||||
#include "miscellaneous/settings.h"
|
#include "miscellaneous/settings.h"
|
||||||
|
#include "application.h"
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ DynamicShortcuts::DynamicShortcuts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DynamicShortcuts::save(const QList<QAction*> actions) {
|
void DynamicShortcuts::save(const QList<QAction*> actions) {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
foreach (QAction *action, actions) {
|
foreach (QAction *action, actions) {
|
||||||
settings->setValue(APP_CFG_CUTS,
|
settings->setValue(APP_CFG_CUTS,
|
||||||
@ -37,7 +38,7 @@ void DynamicShortcuts::save(const QList<QAction *> actions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DynamicShortcuts::load(const QList<QAction*> actions) {
|
void DynamicShortcuts::load(const QList<QAction*> actions) {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
foreach (QAction *action, actions) {
|
foreach (QAction *action, actions) {
|
||||||
QString shortcut_for_action = settings->value(APP_CFG_CUTS,
|
QString shortcut_for_action = settings->value(APP_CFG_CUTS,
|
||||||
|
@ -76,7 +76,7 @@ FeedMessageViewer::~FeedMessageViewer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedMessageViewer::saveSize() {
|
void FeedMessageViewer::saveSize() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
m_feedsView->saveExpandedStates();
|
m_feedsView->saveExpandedStates();
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ void FeedMessageViewer::saveSize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedMessageViewer::loadSize() {
|
void FeedMessageViewer::loadSize() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
int default_msg_section_size = m_messagesView->header()->defaultSectionSize();
|
int default_msg_section_size = m_messagesView->header()->defaultSectionSize();
|
||||||
|
|
||||||
m_feedsView->loadExpandedStates();
|
m_feedsView->loadExpandedStates();
|
||||||
@ -436,7 +436,7 @@ void FeedMessageViewer::vacuumDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedMessageViewer::refreshVisualProperties() {
|
void FeedMessageViewer::refreshVisualProperties() {
|
||||||
Qt::ToolButtonStyle button_style = static_cast<Qt::ToolButtonStyle>(Settings::instance()->value(APP_CFG_GUI,
|
Qt::ToolButtonStyle button_style = static_cast<Qt::ToolButtonStyle>(qApp->settings()->value(APP_CFG_GUI,
|
||||||
"toolbar_style",
|
"toolbar_style",
|
||||||
Qt::ToolButtonIconOnly).toInt());
|
Qt::ToolButtonIconOnly).toInt());
|
||||||
|
|
||||||
|
@ -40,12 +40,12 @@ QList<QAction *> FeedsToolBar::changeableActions() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedsToolBar::saveChangeableActions(const QStringList &actions) {
|
void FeedsToolBar::saveChangeableActions(const QStringList &actions) {
|
||||||
Settings::instance()->setValue(APP_CFG_GUI, "feeds_toolbar", actions.join(","));
|
qApp->settings()->setValue(APP_CFG_GUI, "feeds_toolbar", actions.join(","));
|
||||||
loadChangeableActions(actions);
|
loadChangeableActions(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedsToolBar::loadChangeableActions() {
|
void FeedsToolBar::loadChangeableActions() {
|
||||||
QStringList action_names = Settings::instance()->value(APP_CFG_GUI,
|
QStringList action_names = qApp->settings()->value(APP_CFG_GUI,
|
||||||
"feeds_toolbar",
|
"feeds_toolbar",
|
||||||
"m_actionUpdateAllFeeds,m_actionMarkAllFeedsRead").toString().split(',',
|
"m_actionUpdateAllFeeds,m_actionMarkAllFeedsRead").toString().split(',',
|
||||||
QString::SkipEmptyParts);
|
QString::SkipEmptyParts);
|
||||||
|
@ -74,9 +74,9 @@ void FeedsView::quit() {
|
|||||||
void FeedsView::updateAutoUpdateStatus() {
|
void FeedsView::updateAutoUpdateStatus() {
|
||||||
// Restore global intervals.
|
// Restore global intervals.
|
||||||
// NOTE: Specific per-feed interval are left intact.
|
// NOTE: Specific per-feed interval are left intact.
|
||||||
m_globalAutoUpdateInitialInterval = Settings::instance()->value(APP_CFG_FEEDS, "auto_update_interval", DEFAULT_AUTO_UPDATE_INTERVAL).toInt();
|
m_globalAutoUpdateInitialInterval = qApp->settings()->value(APP_CFG_FEEDS, "auto_update_interval", DEFAULT_AUTO_UPDATE_INTERVAL).toInt();
|
||||||
m_globalAutoUpdateRemainingInterval = m_globalAutoUpdateInitialInterval;
|
m_globalAutoUpdateRemainingInterval = m_globalAutoUpdateInitialInterval;
|
||||||
m_globalAutoUpdateEnabled = Settings::instance()->value(APP_CFG_FEEDS, "auto_update_enabled", false).toBool();
|
m_globalAutoUpdateEnabled = qApp->settings()->value(APP_CFG_FEEDS, "auto_update_enabled", false).toBool();
|
||||||
|
|
||||||
// Start global auto-update timer if it is not running yet.
|
// Start global auto-update timer if it is not running yet.
|
||||||
// NOTE: The timer must run even if global auto-update
|
// NOTE: The timer must run even if global auto-update
|
||||||
@ -117,7 +117,7 @@ FeedsModelFeed *FeedsView::isCurrentIndexFeed() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::saveExpandedStates() {
|
void FeedsView::saveExpandedStates() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
// Iterate all categories and save their expand statuses.
|
// Iterate all categories and save their expand statuses.
|
||||||
foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) {
|
foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) {
|
||||||
@ -128,7 +128,7 @@ void FeedsView::saveExpandedStates() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::loadExpandedStates() {
|
void FeedsView::loadExpandedStates() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
// Iterate all categories and save their expand statuses.
|
// Iterate all categories and save their expand statuses.
|
||||||
foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) {
|
foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) {
|
||||||
@ -159,7 +159,7 @@ void FeedsView::updateAllFeeds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FeedsView::updateAllFeedsOnStartup() {
|
void FeedsView::updateAllFeedsOnStartup() {
|
||||||
if (Settings::instance()->value(APP_CFG_FEEDS, "feeds_update_on_startup", false).toBool()) {
|
if (qApp->settings()->value(APP_CFG_FEEDS, "feeds_update_on_startup", false).toBool()) {
|
||||||
qDebug("Requesting update for all feeds on application startup.");
|
qDebug("Requesting update for all feeds on application startup.");
|
||||||
QTimer::singleShot(STARTUP_UPDATE_DELAY, this, SLOT(updateAllFeeds()));
|
QTimer::singleShot(STARTUP_UPDATE_DELAY, this, SLOT(updateAllFeeds()));
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ void FormMain::onAboutToQuit() {
|
|||||||
qDebug("Cleaning up resources and saving application state.");
|
qDebug("Cleaning up resources and saving application state.");
|
||||||
m_ui->m_tabWidget->feedMessageViewer()->quit();
|
m_ui->m_tabWidget->feedMessageViewer()->quit();
|
||||||
|
|
||||||
if (Settings::instance()->value(APP_CFG_MESSAGES, "clear_read_on_exit", false).toBool()) {
|
if (qApp->settings()->value(APP_CFG_MESSAGES, "clear_read_on_exit", false).toBool()) {
|
||||||
m_ui->m_tabWidget->feedMessageViewer()->feedsView()->clearAllReadMessages();
|
m_ui->m_tabWidget->feedMessageViewer()->feedsView()->clearAllReadMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ void FormMain::setupIcons() {
|
|||||||
|
|
||||||
void FormMain::loadSize() {
|
void FormMain::loadSize() {
|
||||||
QRect screen = qApp->desktop()->screenGeometry();
|
QRect screen = qApp->desktop()->screenGeometry();
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
// Reload main window size & position.
|
// Reload main window size & position.
|
||||||
resize(settings->value(APP_CFG_GUI, "window_size", size()).toSize());
|
resize(settings->value(APP_CFG_GUI, "window_size", size()).toSize());
|
||||||
@ -360,7 +360,7 @@ void FormMain::loadSize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormMain::saveSize() {
|
void FormMain::saveSize() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
bool is_fullscreen = isFullScreen();
|
bool is_fullscreen = isFullScreen();
|
||||||
|
|
||||||
if (is_fullscreen) {
|
if (is_fullscreen) {
|
||||||
@ -450,7 +450,7 @@ void FormMain::changeEvent(QEvent *event) {
|
|||||||
case QEvent::WindowStateChange: {
|
case QEvent::WindowStateChange: {
|
||||||
if (this->windowState() & Qt::WindowMinimized &&
|
if (this->windowState() & Qt::WindowMinimized &&
|
||||||
SystemTrayIcon::isSystemTrayActivated() &&
|
SystemTrayIcon::isSystemTrayActivated() &&
|
||||||
Settings::instance()->value(APP_CFG_GUI,
|
qApp->settings()->value(APP_CFG_GUI,
|
||||||
"hide_when_minimized",
|
"hide_when_minimized",
|
||||||
false).toBool()) {
|
false).toBool()) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
|
@ -198,24 +198,28 @@ void FormSettings::selectBrowserExecutable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::loadFeedsMessages() {
|
void FormSettings::loadFeedsMessages() {
|
||||||
m_ui->m_checkKeppMessagesInTheMiddle->setChecked(Settings::instance()->value(APP_CFG_MESSAGES, "keep_cursor_center", false).toBool());
|
Settings *settings = qApp->settings();
|
||||||
m_ui->m_checkRemoveReadMessagesOnExit->setChecked(Settings::instance()->value(APP_CFG_MESSAGES, "clear_read_on_exit", false).toBool());
|
|
||||||
m_ui->m_checkAutoUpdate->setChecked(Settings::instance()->value(APP_CFG_FEEDS, "auto_update_enabled", false).toBool());
|
m_ui->m_checkKeppMessagesInTheMiddle->setChecked(settings->value(APP_CFG_MESSAGES, "keep_cursor_center", false).toBool());
|
||||||
m_ui->m_spinAutoUpdateInterval->setValue(Settings::instance()->value(APP_CFG_FEEDS, "auto_update_interval", DEFAULT_AUTO_UPDATE_INTERVAL).toInt());
|
m_ui->m_checkRemoveReadMessagesOnExit->setChecked(settings->value(APP_CFG_MESSAGES, "clear_read_on_exit", false).toBool());
|
||||||
m_ui->m_spinFeedUpdateTimeout->setValue(Settings::instance()->value(APP_CFG_FEEDS, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt());
|
m_ui->m_checkAutoUpdate->setChecked(settings->value(APP_CFG_FEEDS, "auto_update_enabled", false).toBool());
|
||||||
m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(Settings::instance()->value(APP_CFG_FEEDS, "feeds_update_on_startup", 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, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt());
|
||||||
|
m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(settings->value(APP_CFG_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->addItems(QStringList() << "(%unread)" << "[%unread]" << "%unread/%all" << "%unread-%all" << "[%unread|%all]");
|
||||||
m_ui->m_cmbCountsFeedList->setEditText(Settings::instance()->value(APP_CFG_FEEDS, "count_format", "(%unread)").toString());
|
m_ui->m_cmbCountsFeedList->setEditText(settings->value(APP_CFG_FEEDS, "count_format", "(%unread)").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::saveFeedsMessages() {
|
void FormSettings::saveFeedsMessages() {
|
||||||
Settings::instance()->setValue(APP_CFG_MESSAGES, "keep_cursor_center", m_ui->m_checkKeppMessagesInTheMiddle->isChecked());
|
Settings *settings = qApp->settings();
|
||||||
Settings::instance()->setValue(APP_CFG_MESSAGES, "clear_read_on_exit", m_ui->m_checkRemoveReadMessagesOnExit->isChecked());
|
|
||||||
Settings::instance()->setValue(APP_CFG_FEEDS, "auto_update_enabled", m_ui->m_checkAutoUpdate->isChecked());
|
settings->setValue(APP_CFG_MESSAGES, "keep_cursor_center", m_ui->m_checkKeppMessagesInTheMiddle->isChecked());
|
||||||
Settings::instance()->setValue(APP_CFG_FEEDS, "auto_update_interval", m_ui->m_spinAutoUpdateInterval->value());
|
settings->setValue(APP_CFG_MESSAGES, "clear_read_on_exit", m_ui->m_checkRemoveReadMessagesOnExit->isChecked());
|
||||||
Settings::instance()->setValue(APP_CFG_FEEDS, "feed_update_timeout", m_ui->m_spinFeedUpdateTimeout->value());
|
settings->setValue(APP_CFG_FEEDS, "auto_update_enabled", m_ui->m_checkAutoUpdate->isChecked());
|
||||||
Settings::instance()->setValue(APP_CFG_FEEDS, "feeds_update_on_startup", m_ui->m_checkUpdateAllFeedsOnStartup->isChecked());
|
settings->setValue(APP_CFG_FEEDS, "auto_update_interval", m_ui->m_spinAutoUpdateInterval->value());
|
||||||
Settings::instance()->setValue(APP_CFG_FEEDS, "count_format", m_ui->m_cmbCountsFeedList->currentText());
|
settings->setValue(APP_CFG_FEEDS, "feed_update_timeout", 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());
|
||||||
|
|
||||||
FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->updateAutoUpdateStatus();
|
FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->updateAutoUpdateStatus();
|
||||||
FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->reloadWholeLayout();
|
FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->sourceModel()->reloadWholeLayout();
|
||||||
@ -326,7 +330,7 @@ void FormSettings::saveSettings() {
|
|||||||
saveLanguage();
|
saveLanguage();
|
||||||
saveFeedsMessages();
|
saveFeedsMessages();
|
||||||
|
|
||||||
Settings::instance()->checkSettings();
|
qApp->settings()->checkSettings();
|
||||||
promptForRestart();
|
promptForRestart();
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
@ -349,7 +353,7 @@ void FormSettings::onProxyTypeChanged(int index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::loadBrowser() {
|
void FormSettings::loadBrowser() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
// Load settings of web browser GUI.
|
// Load settings of web browser GUI.
|
||||||
m_initialSettings.m_webBrowserProgress = QColor(settings->value(APP_CFG_BROWSER,
|
m_initialSettings.m_webBrowserProgress = QColor(settings->value(APP_CFG_BROWSER,
|
||||||
@ -382,7 +386,7 @@ void FormSettings::loadBrowser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::saveBrowser() {
|
void FormSettings::saveBrowser() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
// Save settings of GUI of web browser.
|
// Save settings of GUI of web browser.
|
||||||
settings->setValue(APP_CFG_BROWSER,
|
settings->setValue(APP_CFG_BROWSER,
|
||||||
@ -420,10 +424,10 @@ 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.
|
||||||
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(Settings::instance()->value(APP_CFG_PROXY,
|
Settings *settings = qApp->settings();
|
||||||
|
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(settings->value(APP_CFG_PROXY,
|
||||||
"proxy_type",
|
"proxy_type",
|
||||||
QNetworkProxy::NoProxy).toInt());
|
QNetworkProxy::NoProxy).toInt());
|
||||||
Settings *settings = Settings::instance();
|
|
||||||
|
|
||||||
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(APP_CFG_PROXY,
|
m_ui->m_txtProxyHost->setText(settings->value(APP_CFG_PROXY,
|
||||||
@ -437,7 +441,7 @@ void FormSettings::loadProxy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::saveProxy() {
|
void FormSettings::saveProxy() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
settings->setValue(APP_CFG_PROXY, "proxy_type",
|
settings->setValue(APP_CFG_PROXY, "proxy_type",
|
||||||
m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex()));
|
m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex()));
|
||||||
@ -479,7 +483,7 @@ void FormSettings::saveLanguage() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
QString actual_lang = Localization::instance()->loadedLanguage();
|
QString actual_lang = Localization::instance()->loadedLanguage();
|
||||||
QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1);
|
QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1);
|
||||||
|
|
||||||
@ -516,25 +520,26 @@ void FormSettings::loadDataStorage() {
|
|||||||
tr("SQLite (embedded database)"), APP_DB_SQLITE_DRIVER);
|
tr("SQLite (embedded database)"), APP_DB_SQLITE_DRIVER);
|
||||||
|
|
||||||
// Load in-memory database status.
|
// Load in-memory database status.
|
||||||
m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(Settings::instance()->value(APP_CFG_DB, "use_in_memory_db", false).toBool());
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
|
m_ui->m_checkSqliteUseInMemoryDatabase->setChecked(settings->value(APP_CFG_DB, "use_in_memory_db", false).toBool());
|
||||||
|
|
||||||
if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) {
|
if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) {
|
||||||
// Load MySQL.
|
// Load MySQL.
|
||||||
m_ui->m_cmbDatabaseDriver->addItem(
|
m_ui->m_cmbDatabaseDriver->addItem(tr("MySQL/MariaDB (dedicated database)"), APP_DB_MYSQL_DRIVER);
|
||||||
tr("MySQL/MariaDB (dedicated database)"), APP_DB_MYSQL_DRIVER);
|
|
||||||
|
|
||||||
// Setup placeholders.
|
// Setup placeholders.
|
||||||
m_ui->m_txtMysqlHostname->lineEdit()->setPlaceholderText(tr("Hostname of your MySQL server"));
|
m_ui->m_txtMysqlHostname->lineEdit()->setPlaceholderText(tr("Hostname of your MySQL server"));
|
||||||
m_ui->m_txtMysqlUsername->lineEdit()->setPlaceholderText(tr("Username to login with"));
|
m_ui->m_txtMysqlUsername->lineEdit()->setPlaceholderText(tr("Username to login with"));
|
||||||
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_txtMysqlHostname->lineEdit()->setText(Settings::instance()->value(APP_CFG_DB, "mysql_hostname").toString());
|
m_ui->m_txtMysqlHostname->lineEdit()->setText(settings->value(APP_CFG_DB, "mysql_hostname").toString());
|
||||||
m_ui->m_txtMysqlUsername->lineEdit()->setText(Settings::instance()->value(APP_CFG_DB, "mysql_username").toString());
|
m_ui->m_txtMysqlUsername->lineEdit()->setText(settings->value(APP_CFG_DB, "mysql_username").toString());
|
||||||
m_ui->m_txtMysqlPassword->lineEdit()->setText(Settings::instance()->value(APP_CFG_DB, "mysql_password").toString());
|
m_ui->m_txtMysqlPassword->lineEdit()->setText(settings->value(APP_CFG_DB, "mysql_password").toString());
|
||||||
m_ui->m_spinMysqlPort->setValue(Settings::instance()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt());
|
m_ui->m_spinMysqlPort->setValue(settings->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(Settings::instance()->value(APP_CFG_DB,
|
int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(settings->value(APP_CFG_DB,
|
||||||
"database_driver",
|
"database_driver",
|
||||||
APP_DB_SQLITE_DRIVER).toString());
|
APP_DB_SQLITE_DRIVER).toString());
|
||||||
|
|
||||||
@ -545,7 +550,9 @@ void FormSettings::loadDataStorage() {
|
|||||||
|
|
||||||
void FormSettings::saveDataStorage() {
|
void FormSettings::saveDataStorage() {
|
||||||
// Setup in-memory database status.
|
// Setup in-memory database status.
|
||||||
bool original_inmemory = Settings::instance()->value(APP_CFG_DB, "use_in_memory_db", false).toBool();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
|
bool original_inmemory = settings->value(APP_CFG_DB, "use_in_memory_db", false).toBool();
|
||||||
bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked();
|
bool new_inmemory = m_ui->m_checkSqliteUseInMemoryDatabase->isChecked();
|
||||||
|
|
||||||
if (original_inmemory != new_inmemory) {
|
if (original_inmemory != new_inmemory) {
|
||||||
@ -553,21 +560,21 @@ void FormSettings::saveDataStorage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save data storage settings.
|
// Save data storage settings.
|
||||||
QString original_db_driver = Settings::instance()->value(APP_CFG_DB, "database_driver", APP_DB_SQLITE_DRIVER).toString();
|
QString original_db_driver = settings->value(APP_CFG_DB, "database_driver", APP_DB_SQLITE_DRIVER).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::instance()->setValue(APP_CFG_DB, "use_in_memory_db", new_inmemory);
|
settings->setValue(APP_CFG_DB, "use_in_memory_db", new_inmemory);
|
||||||
|
|
||||||
if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) {
|
if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) {
|
||||||
// Save MySQL.
|
// Save MySQL.
|
||||||
Settings::instance()->setValue(APP_CFG_DB, "mysql_hostname", m_ui->m_txtMysqlHostname->lineEdit()->text());
|
settings->setValue(APP_CFG_DB, "mysql_hostname", m_ui->m_txtMysqlHostname->lineEdit()->text());
|
||||||
Settings::instance()->setValue(APP_CFG_DB, "mysql_username", m_ui->m_txtMysqlUsername->lineEdit()->text());
|
settings->setValue(APP_CFG_DB, "mysql_username", m_ui->m_txtMysqlUsername->lineEdit()->text());
|
||||||
Settings::instance()->setValue(APP_CFG_DB, "mysql_password", m_ui->m_txtMysqlPassword->lineEdit()->text());
|
settings->setValue(APP_CFG_DB, "mysql_password", m_ui->m_txtMysqlPassword->lineEdit()->text());
|
||||||
Settings::instance()->setValue(APP_CFG_DB, "mysql_port", m_ui->m_spinMysqlPort->value());
|
settings->setValue(APP_CFG_DB, "mysql_port", m_ui->m_spinMysqlPort->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::instance()->setValue(APP_CFG_DB, "database_driver", selected_db_driver);
|
settings->setValue(APP_CFG_DB, "database_driver", selected_db_driver);
|
||||||
|
|
||||||
if (original_db_driver != selected_db_driver ||
|
if (original_db_driver != selected_db_driver ||
|
||||||
m_initialSettings.m_mysqlDataStorageChanged) {
|
m_initialSettings.m_mysqlDataStorageChanged) {
|
||||||
@ -668,7 +675,7 @@ void FormSettings::saveGeneral() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::loadInterface() {
|
void FormSettings::loadInterface() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
// Load settings of tray icon.
|
// Load settings of tray icon.
|
||||||
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
@ -770,7 +777,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(Settings::instance()->value(APP_CFG_GUI,
|
m_ui->m_cmbToolbarButtonStyle->setCurrentIndex(m_ui->m_cmbToolbarButtonStyle->findData(qApp->settings()->value(APP_CFG_GUI,
|
||||||
"toolbar_style",
|
"toolbar_style",
|
||||||
Qt::ToolButtonIconOnly).toInt()));
|
Qt::ToolButtonIconOnly).toInt()));
|
||||||
|
|
||||||
@ -780,10 +787,10 @@ void FormSettings::loadInterface() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormSettings::saveInterface() {
|
void FormSettings::saveInterface() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
// Save toolbar.
|
// Save toolbar.
|
||||||
Settings::instance()->setValue(APP_CFG_GUI,
|
settings->setValue(APP_CFG_GUI,
|
||||||
"toolbar_style",
|
"toolbar_style",
|
||||||
m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex()));
|
m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex()));
|
||||||
|
|
||||||
@ -791,6 +798,7 @@ void FormSettings::saveInterface() {
|
|||||||
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
settings->setValue(APP_CFG_GUI, "use_tray_icon",
|
settings->setValue(APP_CFG_GUI, "use_tray_icon",
|
||||||
m_ui->m_radioTrayOn->isChecked());
|
m_ui->m_radioTrayOn->isChecked());
|
||||||
|
|
||||||
if (settings->value(APP_CFG_GUI, "use_tray_icon", true).toBool()) {
|
if (settings->value(APP_CFG_GUI, "use_tray_icon", true).toBool()) {
|
||||||
SystemTrayIcon::instance()->show();
|
SystemTrayIcon::instance()->show();
|
||||||
FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->notifyWithCounts();
|
FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->notifyWithCounts();
|
||||||
|
@ -50,7 +50,7 @@ QList<QAction*> MessagesToolBar::changeableActions() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagesToolBar::saveChangeableActions(const QStringList& actions) {
|
void MessagesToolBar::saveChangeableActions(const QStringList& actions) {
|
||||||
Settings::instance()->setValue(APP_CFG_GUI, "messages_toolbar", actions.join(","));
|
qApp->settings()->setValue(APP_CFG_GUI, "messages_toolbar", actions.join(","));
|
||||||
loadChangeableActions(actions);
|
loadChangeableActions(actions);
|
||||||
|
|
||||||
// If user hidden search messages box, then remove the filter.
|
// If user hidden search messages box, then remove the filter.
|
||||||
@ -144,7 +144,7 @@ void MessagesToolBar::initializeHighlighter() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MessagesToolBar::loadChangeableActions() {
|
void MessagesToolBar::loadChangeableActions() {
|
||||||
QStringList action_names = Settings::instance()->value(APP_CFG_GUI,
|
QStringList action_names = qApp->settings()->value(APP_CFG_GUI,
|
||||||
"messages_toolbar",
|
"messages_toolbar",
|
||||||
"m_actionMarkSelectedMessagesAsRead,m_actionMarkSelectedMessagesAsUnread,m_actionSwitchImportanceOfSelectedMessages,separator,highlighter,spacer,search").toString().split(',',
|
"m_actionMarkSelectedMessagesAsRead,m_actionMarkSelectedMessagesAsUnread,m_actionSwitchImportanceOfSelectedMessages,separator,highlighter,spacer,search").toString().split(',',
|
||||||
QString::SkipEmptyParts);
|
QString::SkipEmptyParts);
|
||||||
|
@ -214,7 +214,7 @@ void MessagesView::currentChanged(const QModelIndex ¤t,
|
|||||||
|
|
||||||
void MessagesView::selectionChanged(const QItemSelection &selected,
|
void MessagesView::selectionChanged(const QItemSelection &selected,
|
||||||
const QItemSelection &deselected) {
|
const QItemSelection &deselected) {
|
||||||
if (Settings::instance()->value(APP_CFG_MESSAGES,
|
if (qApp->settings()->value(APP_CFG_MESSAGES,
|
||||||
"keep_cursor_center",
|
"keep_cursor_center",
|
||||||
false).toBool()) {
|
false).toBool()) {
|
||||||
scrollTo(currentIndex(), QAbstractItemView::PositionAtCenter);
|
scrollTo(currentIndex(), QAbstractItemView::PositionAtCenter);
|
||||||
|
@ -91,7 +91,7 @@ bool SystemTrayIcon::isSystemTrayAvailable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SystemTrayIcon::isSystemTrayActivated() {
|
bool SystemTrayIcon::isSystemTrayActivated() {
|
||||||
return SystemTrayIcon::isSystemTrayAvailable() && Settings::instance()->value(APP_CFG_GUI,
|
return SystemTrayIcon::isSystemTrayAvailable() && qApp->settings()->value(APP_CFG_GUI,
|
||||||
"use_tray_icon",
|
"use_tray_icon",
|
||||||
true).toBool();
|
true).toBool();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ void TabBar::mousePressEvent(QMouseEvent *event) {
|
|||||||
// Check if user clicked tab with middle button.
|
// Check if user clicked tab with middle button.
|
||||||
// NOTE: This needs to be done here because
|
// NOTE: This needs to be done here because
|
||||||
// destination does not know the original event.
|
// destination does not know the original event.
|
||||||
if (event->button() & Qt::MiddleButton && Settings::instance()->value(APP_CFG_GUI,
|
if (event->button() & Qt::MiddleButton && qApp->settings()->value(APP_CFG_GUI,
|
||||||
"tab_close_mid_button",
|
"tab_close_mid_button",
|
||||||
true).toBool()) {
|
true).toBool()) {
|
||||||
if (tabType(tab_index) == TabBar::Closable) {
|
if (tabType(tab_index) == TabBar::Closable) {
|
||||||
@ -133,7 +133,7 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent *event) {
|
|||||||
// Check if user clicked tab with middle button.
|
// Check if user clicked tab with middle button.
|
||||||
// NOTE: This needs to be done here because
|
// NOTE: This needs to be done here because
|
||||||
// destination does not know the original event.
|
// destination does not know the original event.
|
||||||
if (event->button() & Qt::LeftButton && Settings::instance()->value(APP_CFG_GUI,
|
if (event->button() & Qt::LeftButton && qApp->settings()->value(APP_CFG_GUI,
|
||||||
"tab_close_double_button",
|
"tab_close_double_button",
|
||||||
true).toBool()) {
|
true).toBool()) {
|
||||||
if (tabType(tab_index) == TabBar::Closable) {
|
if (tabType(tab_index) == TabBar::Closable) {
|
||||||
@ -145,7 +145,7 @@ void TabBar::mouseDoubleClickEvent(QMouseEvent *event) {
|
|||||||
// Check if new tab should be opened with initial web browser.
|
// Check if new tab should be opened with initial web browser.
|
||||||
// NOTE: This check could be unnecesary here and should be done in
|
// NOTE: This check could be unnecesary here and should be done in
|
||||||
// destination object but we keep it here for consistency.
|
// destination object but we keep it here for consistency.
|
||||||
else if (Settings::instance()->value(APP_CFG_GUI,
|
else if (qApp->settings()->value(APP_CFG_GUI,
|
||||||
"tab_new_double_button",
|
"tab_new_double_button",
|
||||||
true).toBool()) {
|
true).toBool()) {
|
||||||
emit emptySpaceDoubleClicked();
|
emit emptySpaceDoubleClicked();
|
||||||
|
@ -86,7 +86,7 @@ void TabWidget::openMainMenu() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TabWidget::checkTabBarVisibility() {
|
void TabWidget::checkTabBarVisibility() {
|
||||||
bool should_be_visible = count() > 1 || !Settings::instance()->value(APP_CFG_GUI,
|
bool should_be_visible = count() > 1 || !qApp->settings()->value(APP_CFG_GUI,
|
||||||
"hide_tabbar_one_tab",
|
"hide_tabbar_one_tab",
|
||||||
true).toBool();
|
true).toBool();
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ int TabWidget::addLinkedBrowser(const QString &initial_url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TabWidget::addLinkedBrowser(const QUrl &initial_url) {
|
int TabWidget::addLinkedBrowser(const QUrl &initial_url) {
|
||||||
return addBrowser(Settings::instance()->value(APP_CFG_BROWSER,
|
return addBrowser(qApp->settings()->value(APP_CFG_BROWSER,
|
||||||
"queue_tabs",
|
"queue_tabs",
|
||||||
true).toBool(),
|
true).toBool(),
|
||||||
false,
|
false,
|
||||||
|
@ -104,7 +104,7 @@ int main(int argc, char *argv[]) {
|
|||||||
DynamicShortcuts::load(main_window.allActions().values());
|
DynamicShortcuts::load(main_window.allActions().values());
|
||||||
|
|
||||||
// Display main window.
|
// Display main window.
|
||||||
if (Settings::instance()->value(APP_CFG_GUI, "start_hidden",
|
if (qApp->settings()->value(APP_CFG_GUI, "start_hidden",
|
||||||
false).toBool() &&
|
false).toBool() &&
|
||||||
SystemTrayIcon::isSystemTrayActivated()) {
|
SystemTrayIcon::isSystemTrayActivated()) {
|
||||||
qDebug("Hiding the main window when the application is starting.");
|
qDebug("Hiding the main window when the application is starting.");
|
||||||
|
@ -97,7 +97,7 @@ QString DatabaseFactory::mysqlInterpretErrorCode(MySQLError error_code) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseFactory::sqliteAssemblyDatabaseFilePath() {
|
void DatabaseFactory::sqliteAssemblyDatabaseFilePath() {
|
||||||
if (Settings::instance()->type() == Settings::Portable) {
|
if (qApp->settings()->type() == Settings::Portable) {
|
||||||
m_sqliteDatabaseFilePath = qApp->applicationDirPath() +
|
m_sqliteDatabaseFilePath = qApp->applicationDirPath() +
|
||||||
QDir::separator() +
|
QDir::separator() +
|
||||||
QString(APP_DB_SQLITE_PATH);
|
QString(APP_DB_SQLITE_PATH);
|
||||||
@ -330,7 +330,7 @@ void DatabaseFactory::sqliteSaveMemoryDatabase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseFactory::determineDriver() {
|
void DatabaseFactory::determineDriver() {
|
||||||
QString db_driver = Settings::instance()->value(APP_CFG_DB,
|
QString db_driver = qApp->settings()->value(APP_CFG_DB,
|
||||||
"database_driver",
|
"database_driver",
|
||||||
APP_DB_SQLITE_DRIVER).toString();
|
APP_DB_SQLITE_DRIVER).toString();
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ void DatabaseFactory::determineDriver() {
|
|||||||
else {
|
else {
|
||||||
// User wants to use SQLite, which is always available. Check if file-based
|
// User wants to use SQLite, which is always available. Check if file-based
|
||||||
// or in-memory database will be used.
|
// or in-memory database will be used.
|
||||||
if (Settings::instance()->value(APP_CFG_DB, "use_in_memory_db", false).toBool()) {
|
if (qApp->settings()->value(APP_CFG_DB, "use_in_memory_db", false).toBool()) {
|
||||||
// Use in-memory SQLite database.
|
// Use in-memory SQLite database.
|
||||||
m_activeDatabaseDriver = SQLITE_MEMORY;
|
m_activeDatabaseDriver = SQLITE_MEMORY;
|
||||||
|
|
||||||
@ -382,10 +382,10 @@ QSqlDatabase DatabaseFactory::mysqlConnection(const QString &connection_name) {
|
|||||||
// yet, add it and set it up.
|
// yet, add it and set it up.
|
||||||
database = QSqlDatabase::addDatabase(APP_DB_MYSQL_DRIVER, connection_name);
|
database = QSqlDatabase::addDatabase(APP_DB_MYSQL_DRIVER, connection_name);
|
||||||
|
|
||||||
database.setHostName(Settings::instance()->value(APP_CFG_DB, "mysql_hostname").toString());
|
database.setHostName(qApp->settings()->value(APP_CFG_DB, "mysql_hostname").toString());
|
||||||
database.setPort(Settings::instance()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt());
|
database.setPort(qApp->settings()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt());
|
||||||
database.setUserName(Settings::instance()->value(APP_CFG_DB, "mysql_username").toString());
|
database.setUserName(qApp->settings()->value(APP_CFG_DB, "mysql_username").toString());
|
||||||
database.setPassword(Settings::instance()->value(APP_CFG_DB, "mysql_password").toString());
|
database.setPassword(qApp->settings()->value(APP_CFG_DB, "mysql_password").toString());
|
||||||
database.setDatabaseName(APP_LOW_NAME);
|
database.setDatabaseName(APP_LOW_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,10 +408,10 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString &connection_
|
|||||||
QSqlDatabase database = QSqlDatabase::addDatabase(APP_DB_MYSQL_DRIVER,
|
QSqlDatabase database = QSqlDatabase::addDatabase(APP_DB_MYSQL_DRIVER,
|
||||||
connection_name);
|
connection_name);
|
||||||
|
|
||||||
database.setHostName(Settings::instance()->value(APP_CFG_DB, "mysql_hostname").toString());
|
database.setHostName(qApp->settings()->value(APP_CFG_DB, "mysql_hostname").toString());
|
||||||
database.setPort(Settings::instance()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt());
|
database.setPort(qApp->settings()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt());
|
||||||
database.setUserName(Settings::instance()->value(APP_CFG_DB, "mysql_username").toString());
|
database.setUserName(qApp->settings()->value(APP_CFG_DB, "mysql_username").toString());
|
||||||
database.setPassword(Settings::instance()->value(APP_CFG_DB, "mysql_password").toString());
|
database.setPassword(qApp->settings()->value(APP_CFG_DB, "mysql_password").toString());
|
||||||
|
|
||||||
if (!database.open()) {
|
if (!database.open()) {
|
||||||
qFatal("MySQL database was NOT opened. Delivered error message: '%s'",
|
qFatal("MySQL database was NOT opened. Delivered error message: '%s'",
|
||||||
|
@ -72,17 +72,15 @@ void IconFactory::setupSearchPaths() {
|
|||||||
"\'").join(", ")));
|
"\'").join(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void IconFactory::setCurrentIconTheme(const QString &theme_name) {
|
void IconFactory::setCurrentIconTheme(const QString &theme_name) {
|
||||||
Settings::instance()->setValue(APP_CFG_GUI,
|
qApp->settings()->setValue(APP_CFG_GUI,
|
||||||
"icon_theme",
|
"icon_theme",
|
||||||
theme_name);
|
theme_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconFactory::loadCurrentIconTheme() {
|
void IconFactory::loadCurrentIconTheme() {
|
||||||
QStringList installed_themes = installedIconThemes();
|
QStringList installed_themes = installedIconThemes();
|
||||||
QString theme_name_from_settings = Settings::instance()->value(APP_CFG_GUI,
|
QString theme_name_from_settings = qApp->settings()->value(APP_CFG_GUI,
|
||||||
"icon_theme",
|
"icon_theme",
|
||||||
APP_THEME_DEFAULT).toString();
|
APP_THEME_DEFAULT).toString();
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ Localization *Localization::instance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString Localization::desiredLanguage() {
|
QString Localization::desiredLanguage() {
|
||||||
return Settings::instance()->value(APP_CFG_GEN,
|
return qApp->settings()->value(APP_CFG_GEN,
|
||||||
"language",
|
"language",
|
||||||
QLocale::system().name()).toString();
|
QLocale::system().name()).toString();
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
#include <QWebSettings>
|
#include <QWebSettings>
|
||||||
|
|
||||||
|
|
||||||
QPointer<Settings> Settings::s_instance;
|
|
||||||
|
|
||||||
Settings::Settings(const QString &file_name, Format format,
|
Settings::Settings(const QString &file_name, Format format,
|
||||||
const Type &status, QObject *parent)
|
const Type &status, QObject *parent)
|
||||||
: QSettings(file_name, format, parent), m_initializationStatus(status) {
|
: QSettings(file_name, format, parent), m_initializationStatus(status) {
|
||||||
@ -45,15 +43,9 @@ QSettings::Status Settings::checkSettings() {
|
|||||||
return status();
|
return status();
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings *Settings::instance() {
|
Settings *Settings::setupSettings(QObject *parent) {
|
||||||
if (s_instance.isNull()) {
|
Settings *new_settings;
|
||||||
setupSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
return s_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSettings::Status Settings::setupSettings() {
|
|
||||||
// If settings file exists in executable file working directory
|
// If settings file exists in executable file working directory
|
||||||
// (in subdirectory APP_CFG_PATH), then use it (portable settings).
|
// (in subdirectory APP_CFG_PATH), then use it (portable settings).
|
||||||
// Otherwise use settings file stored in homePath();
|
// Otherwise use settings file stored in homePath();
|
||||||
@ -66,8 +58,8 @@ QSettings::Status Settings::setupSettings() {
|
|||||||
// Check if portable settings are available.
|
// Check if portable settings are available.
|
||||||
if (QFile(app_path_file).exists()) {
|
if (QFile(app_path_file).exists()) {
|
||||||
// Portable settings are available, use them.
|
// Portable settings are available, use them.
|
||||||
s_instance = new Settings(app_path_file, QSettings::IniFormat,
|
new_settings = new Settings(app_path_file, QSettings::IniFormat,
|
||||||
Settings::Portable, qApp);
|
Settings::Portable, parent);
|
||||||
|
|
||||||
// Construct icon cache in the same path.
|
// Construct icon cache in the same path.
|
||||||
QString web_path = app_path + QDir::separator() + QString(APP_DB_WEB_PATH);
|
QString web_path = app_path + QDir::separator() + QString(APP_DB_WEB_PATH);
|
||||||
@ -84,8 +76,8 @@ QSettings::Status Settings::setupSettings() {
|
|||||||
QString(APP_LOW_H_NAME);
|
QString(APP_LOW_H_NAME);
|
||||||
QString home_path_file = home_path + relative_path;
|
QString home_path_file = home_path + relative_path;
|
||||||
|
|
||||||
s_instance = new Settings(home_path_file, QSettings::IniFormat,
|
new_settings = new Settings(home_path_file, QSettings::IniFormat,
|
||||||
Settings::NonPortable, qApp);
|
Settings::NonPortable, parent);
|
||||||
|
|
||||||
// Construct icon cache in the same path.
|
// Construct icon cache in the same path.
|
||||||
QString web_path = home_path + QDir::separator() + QString(APP_DB_WEB_PATH);
|
QString web_path = home_path + QDir::separator() + QString(APP_DB_WEB_PATH);
|
||||||
@ -96,5 +88,5 @@ QSettings::Status Settings::setupSettings() {
|
|||||||
qPrintable(QDir::toNativeSeparators(home_path_file)));
|
qPrintable(QDir::toNativeSeparators(home_path_file)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*s_instance).checkSettings();
|
return new_settings;
|
||||||
}
|
}
|
||||||
|
@ -33,9 +33,6 @@ class Settings : public QSettings {
|
|||||||
NonPortable
|
NonPortable
|
||||||
};
|
};
|
||||||
|
|
||||||
// Singleton getter.
|
|
||||||
static Settings *instance();
|
|
||||||
|
|
||||||
// Destructor.
|
// Destructor.
|
||||||
virtual ~Settings();
|
virtual ~Settings();
|
||||||
|
|
||||||
@ -60,18 +57,15 @@ class Settings : public QSettings {
|
|||||||
// Synchronizes settings.
|
// Synchronizes settings.
|
||||||
QSettings::Status checkSettings();
|
QSettings::Status checkSettings();
|
||||||
|
|
||||||
|
// Creates settings file in correct location.
|
||||||
|
static Settings* setupSettings(QObject *parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Constructor.
|
// Constructor.
|
||||||
Settings(const QString & file_name, Format format,
|
Settings(const QString & file_name, Format format,
|
||||||
const Type &type, QObject * parent = 0);
|
const Type &type, QObject * parent = 0);
|
||||||
|
|
||||||
Type m_initializationStatus;
|
Type m_initializationStatus;
|
||||||
|
|
||||||
// Creates settings file in correct location.
|
|
||||||
static QSettings::Status setupSettings();
|
|
||||||
|
|
||||||
// Private singleton value.
|
|
||||||
static QPointer<Settings> s_instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGS_H
|
#endif // SETTINGS_H
|
||||||
|
@ -109,11 +109,11 @@ bool SkinFactory::loadSkinFromData(const Skin &skin) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkinFactory::setCurrentSkinName(const QString &skin_name) {
|
void SkinFactory::setCurrentSkinName(const QString &skin_name) {
|
||||||
Settings::instance()->setValue(APP_CFG_GUI, "skin", skin_name);
|
qApp->settings()->setValue(APP_CFG_GUI, "skin", skin_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SkinFactory::selectedSkinName() {
|
QString SkinFactory::selectedSkinName() {
|
||||||
return Settings::instance()->value(APP_CFG_GUI,
|
return qApp->settings()->value(APP_CFG_GUI,
|
||||||
"skin",
|
"skin",
|
||||||
APP_SKIN_DEFAULT).toString();
|
APP_SKIN_DEFAULT).toString();
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "definitions/definitions.h"
|
#include "definitions/definitions.h"
|
||||||
#include "miscellaneous/settings.h"
|
#include "miscellaneous/settings.h"
|
||||||
|
#include "application.h"
|
||||||
|
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
@ -38,7 +39,7 @@ BaseNetworkAccessManager::~BaseNetworkAccessManager() {
|
|||||||
|
|
||||||
void BaseNetworkAccessManager::loadSettings() {
|
void BaseNetworkAccessManager::loadSettings() {
|
||||||
QNetworkProxy new_proxy;
|
QNetworkProxy new_proxy;
|
||||||
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(Settings::instance()->value(APP_CFG_PROXY,
|
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(qApp->settings()->value(APP_CFG_PROXY,
|
||||||
"proxy_type",
|
"proxy_type",
|
||||||
QNetworkProxy::NoProxy).toInt());
|
QNetworkProxy::NoProxy).toInt());
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ void BaseNetworkAccessManager::loadSettings() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
// Custom proxy is selected, set it up.
|
// Custom proxy is selected, set it up.
|
||||||
new_proxy.setType(selected_proxy_type);
|
new_proxy.setType(selected_proxy_type);
|
||||||
|
@ -24,7 +24,7 @@ WebFactory::~WebFactory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WebFactory::loadState() {
|
void WebFactory::loadState() {
|
||||||
Settings *settings = Settings::instance();
|
Settings *settings = qApp->settings();
|
||||||
|
|
||||||
switchJavascript(settings->value(APP_CFG_BROWSER, "enable_javascript", true).toBool(), false);
|
switchJavascript(settings->value(APP_CFG_BROWSER, "enable_javascript", true).toBool(), false);
|
||||||
switchImages(settings->value(APP_CFG_BROWSER, "enable_images", true).toBool(), false);
|
switchImages(settings->value(APP_CFG_BROWSER, "enable_images", true).toBool(), false);
|
||||||
@ -32,12 +32,12 @@ void WebFactory::loadState() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool WebFactory::openUrlInExternalBrowser(const QString &url) {
|
bool WebFactory::openUrlInExternalBrowser(const QString &url) {
|
||||||
if (Settings::instance()->value(APP_CFG_BROWSER,
|
if (qApp->settings()->value(APP_CFG_BROWSER,
|
||||||
"custom_external_browser",
|
"custom_external_browser",
|
||||||
false).toBool()) {
|
false).toBool()) {
|
||||||
QString browser = Settings::instance()->value(APP_CFG_BROWSER,
|
QString browser = qApp->settings()->value(APP_CFG_BROWSER,
|
||||||
"external_browser_executable").toString();
|
"external_browser_executable").toString();
|
||||||
QString arguments = Settings::instance()->value(APP_CFG_BROWSER,
|
QString arguments = qApp->settings()->value(APP_CFG_BROWSER,
|
||||||
"external_browser_arguments",
|
"external_browser_arguments",
|
||||||
"%1").toString();
|
"%1").toString();
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ bool WebFactory::openUrlInExternalBrowser(const QString &url) {
|
|||||||
|
|
||||||
void WebFactory::switchJavascript(bool enable, bool save_settings) {
|
void WebFactory::switchJavascript(bool enable, bool save_settings) {
|
||||||
if (save_settings) {
|
if (save_settings) {
|
||||||
Settings::instance()->setValue(APP_CFG_BROWSER,
|
qApp->settings()->setValue(APP_CFG_BROWSER,
|
||||||
"enable_javascript",
|
"enable_javascript",
|
||||||
enable);
|
enable);
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ void WebFactory::switchJavascript(bool enable, bool save_settings) {
|
|||||||
|
|
||||||
void WebFactory::switchPlugins(bool enable, bool save_settings) {
|
void WebFactory::switchPlugins(bool enable, bool save_settings) {
|
||||||
if (save_settings) {
|
if (save_settings) {
|
||||||
Settings::instance()->setValue(APP_CFG_BROWSER,
|
qApp->settings()->setValue(APP_CFG_BROWSER,
|
||||||
"enable_plugins",
|
"enable_plugins",
|
||||||
enable);
|
enable);
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ void WebFactory::switchPlugins(bool enable, bool save_settings) {
|
|||||||
|
|
||||||
void WebFactory::switchImages(bool enable, bool save_settings) {
|
void WebFactory::switchImages(bool enable, bool save_settings) {
|
||||||
if (save_settings) {
|
if (save_settings) {
|
||||||
Settings::instance()->setValue(APP_CFG_BROWSER,
|
qApp->settings()->setValue(APP_CFG_BROWSER,
|
||||||
"enable_images",
|
"enable_images",
|
||||||
enable);
|
enable);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ void WebView::mousePressEvent(QMouseEvent *event) {
|
|||||||
|
|
||||||
void WebView::mouseReleaseEvent(QMouseEvent *event) {
|
void WebView::mouseReleaseEvent(QMouseEvent *event) {
|
||||||
if (event->button() & Qt::MiddleButton) {
|
if (event->button() & Qt::MiddleButton) {
|
||||||
bool are_gestures_enabled = Settings::instance()->value(APP_CFG_BROWSER,
|
bool are_gestures_enabled = qApp->settings()->value(APP_CFG_BROWSER,
|
||||||
"gestures_enabled",
|
"gestures_enabled",
|
||||||
true).toBool();
|
true).toBool();
|
||||||
if (are_gestures_enabled) {
|
if (are_gestures_enabled) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user