diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bae2017c..6e88cd538 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,7 +152,6 @@ message(STATUS "[${APP_LOW_NAME}] Obtaining revision number.") if(EXISTS "${PROJECT_SOURCE_DIR}/.git") find_package(Git) if(GIT_FOUND) - # TODO: https://wiki.archlinux.org/index.php/VCS_PKGBUILD_Guidelines#Git execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} diff --git a/src/application.cpp b/src/application.cpp index e307a99b6..5af4313a5 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -19,7 +19,7 @@ Application::Application(const QString &id, int &argc, char **argv) - : QtSingleApplication(id, argc, argv) { + : QtSingleApplication(id, argc, argv), m_settings(NULL) { } Application::~Application() { diff --git a/src/application.h b/src/application.h index fb9b88182..c66705d30 100644 --- a/src/application.h +++ b/src/application.h @@ -20,9 +20,13 @@ #include "qtsingleapplication/qtsingleapplication.h" +#include "miscellaneous/settings.h" + #if defined(qApp) #undef qApp #endif + +// Define new qApp macro. Yeaaaaah. #define qApp (Application::instance()) @@ -35,10 +39,21 @@ class Application : public QtSingleApplication { explicit Application(const QString &id, int &argc, char **argv); virtual ~Application(); + inline Settings *settings() { + if (m_settings == NULL) { + m_settings = Settings::setupSettings(this); + } + + return m_settings; + } + // Returns pointer to "GOD" application singleton. inline static Application *instance() { return static_cast(QCoreApplication::instance()); } + + private: + Settings *m_settings; }; #endif // APPLICATION_H diff --git a/src/core/feedsmodelcategory.cpp b/src/core/feedsmodelcategory.cpp index 54100a6e4..3537b26a5 100755 --- a/src/core/feedsmodelcategory.cpp +++ b/src/core/feedsmodelcategory.cpp @@ -87,9 +87,9 @@ QVariant FeedsModelCategory::data(int column, int role) const { return m_title; } else if (column == FDS_MODEL_COUNTS_INDEX) { - return Settings::instance()->value(APP_CFG_FEEDS, - "count_format", - "(%unread)").toString() + return qApp->settings()->value(APP_CFG_FEEDS, + "count_format", + "(%unread)").toString() .replace("%unread", QString::number(countOfUnreadMessages())) .replace("%all", QString::number(countOfAllMessages())); } diff --git a/src/core/feedsmodelfeed.cpp b/src/core/feedsmodelfeed.cpp index 7100b705a..fd657cba4 100755 --- a/src/core/feedsmodelfeed.cpp +++ b/src/core/feedsmodelfeed.cpp @@ -146,7 +146,7 @@ QPair FeedsModelFeed::guessFeed(co QByteArray feed_contents; 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, !username.isEmpty(), username, @@ -255,9 +255,9 @@ QVariant FeedsModelFeed::data(int column, int role) const { return m_title; } else if (column == FDS_MODEL_COUNTS_INDEX) { - return Settings::instance()->value(APP_CFG_FEEDS, - "count_format", - "(%unread)").toString() + return qApp->settings()->value(APP_CFG_FEEDS, + "count_format", + "(%unread)").toString() .replace("%unread", QString::number(countOfUnreadMessages())) .replace("%all", QString::number(countOfAllMessages())); } @@ -348,7 +348,7 @@ QVariant FeedsModelFeed::data(int column, int role) const { void FeedsModelFeed::update() { 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(), download_timeout, feed_contents, diff --git a/src/dynamic-shortcuts/dynamicshortcuts.cpp b/src/dynamic-shortcuts/dynamicshortcuts.cpp index a09519a29..b2b51a557 100644 --- a/src/dynamic-shortcuts/dynamicshortcuts.cpp +++ b/src/dynamic-shortcuts/dynamicshortcuts.cpp @@ -19,6 +19,7 @@ #include "definitions/definitions.h" #include "miscellaneous/settings.h" +#include "application.h" #include @@ -26,8 +27,8 @@ DynamicShortcuts::DynamicShortcuts() { } -void DynamicShortcuts::save(const QList actions) { - Settings *settings = Settings::instance(); +void DynamicShortcuts::save(const QList actions) { + Settings *settings = qApp->settings(); foreach (QAction *action, actions) { settings->setValue(APP_CFG_CUTS, @@ -36,8 +37,8 @@ void DynamicShortcuts::save(const QList actions) { } } -void DynamicShortcuts::load(const QList actions) { - Settings *settings = Settings::instance(); +void DynamicShortcuts::load(const QList actions) { + Settings *settings = qApp->settings(); foreach (QAction *action, actions) { QString shortcut_for_action = settings->value(APP_CFG_CUTS, diff --git a/src/gui/feedmessageviewer.cpp b/src/gui/feedmessageviewer.cpp index 141039cba..f9dee095a 100644 --- a/src/gui/feedmessageviewer.cpp +++ b/src/gui/feedmessageviewer.cpp @@ -76,7 +76,7 @@ FeedMessageViewer::~FeedMessageViewer() { } void FeedMessageViewer::saveSize() { - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); m_feedsView->saveExpandedStates(); @@ -108,7 +108,7 @@ void FeedMessageViewer::saveSize() { } void FeedMessageViewer::loadSize() { - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); int default_msg_section_size = m_messagesView->header()->defaultSectionSize(); m_feedsView->loadExpandedStates(); @@ -436,9 +436,9 @@ void FeedMessageViewer::vacuumDatabase() { } void FeedMessageViewer::refreshVisualProperties() { - Qt::ToolButtonStyle button_style = static_cast(Settings::instance()->value(APP_CFG_GUI, - "toolbar_style", - Qt::ToolButtonIconOnly).toInt()); + Qt::ToolButtonStyle button_style = static_cast(qApp->settings()->value(APP_CFG_GUI, + "toolbar_style", + Qt::ToolButtonIconOnly).toInt()); m_toolBarFeeds->setToolButtonStyle(button_style); m_toolBarMessages->setToolButtonStyle(button_style); diff --git a/src/gui/feedstoolbar.cpp b/src/gui/feedstoolbar.cpp index 718c7b50f..2962f7098 100644 --- a/src/gui/feedstoolbar.cpp +++ b/src/gui/feedstoolbar.cpp @@ -40,15 +40,15 @@ QList FeedsToolBar::changeableActions() const { } 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); } void FeedsToolBar::loadChangeableActions() { - QStringList action_names = Settings::instance()->value(APP_CFG_GUI, - "feeds_toolbar", - "m_actionUpdateAllFeeds,m_actionMarkAllFeedsRead").toString().split(',', - QString::SkipEmptyParts); + QStringList action_names = qApp->settings()->value(APP_CFG_GUI, + "feeds_toolbar", + "m_actionUpdateAllFeeds,m_actionMarkAllFeedsRead").toString().split(',', + QString::SkipEmptyParts); loadChangeableActions(action_names); } diff --git a/src/gui/feedsview.cpp b/src/gui/feedsview.cpp index 21b79579b..aa1e9f3ce 100644 --- a/src/gui/feedsview.cpp +++ b/src/gui/feedsview.cpp @@ -74,9 +74,9 @@ void FeedsView::quit() { void FeedsView::updateAutoUpdateStatus() { // Restore global intervals. // 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_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. // NOTE: The timer must run even if global auto-update @@ -117,7 +117,7 @@ FeedsModelFeed *FeedsView::isCurrentIndexFeed() const { } void FeedsView::saveExpandedStates() { - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); // Iterate all categories and save their expand statuses. foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) { @@ -128,7 +128,7 @@ void FeedsView::saveExpandedStates() { } void FeedsView::loadExpandedStates() { - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); // Iterate all categories and save their expand statuses. foreach (FeedsModelCategory *category, sourceModel()->allCategories().values()) { @@ -159,7 +159,7 @@ void FeedsView::updateAllFeeds() { } 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."); QTimer::singleShot(STARTUP_UPDATE_DELAY, this, SLOT(updateAllFeeds())); } diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp index d798f3eb5..b146af5a7 100755 --- a/src/gui/formmain.cpp +++ b/src/gui/formmain.cpp @@ -247,7 +247,7 @@ void FormMain::onAboutToQuit() { qDebug("Cleaning up resources and saving application state."); 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(); } @@ -336,7 +336,7 @@ void FormMain::setupIcons() { void FormMain::loadSize() { QRect screen = qApp->desktop()->screenGeometry(); - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); // Reload main window size & position. resize(settings->value(APP_CFG_GUI, "window_size", size()).toSize()); @@ -360,7 +360,7 @@ void FormMain::loadSize() { } void FormMain::saveSize() { - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); bool is_fullscreen = isFullScreen(); if (is_fullscreen) { @@ -450,9 +450,9 @@ void FormMain::changeEvent(QEvent *event) { case QEvent::WindowStateChange: { if (this->windowState() & Qt::WindowMinimized && SystemTrayIcon::isSystemTrayActivated() && - Settings::instance()->value(APP_CFG_GUI, - "hide_when_minimized", - false).toBool()) { + qApp->settings()->value(APP_CFG_GUI, + "hide_when_minimized", + false).toBool()) { event->ignore(); QTimer::singleShot(CHANGE_EVENT_DELAY, this, SLOT(switchVisibility())); } diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index 111fc5152..3fa11d814 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -198,24 +198,28 @@ void FormSettings::selectBrowserExecutable() { } void FormSettings::loadFeedsMessages() { - m_ui->m_checkKeppMessagesInTheMiddle->setChecked(Settings::instance()->value(APP_CFG_MESSAGES, "keep_cursor_center", false).toBool()); - 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_spinAutoUpdateInterval->setValue(Settings::instance()->value(APP_CFG_FEEDS, "auto_update_interval", DEFAULT_AUTO_UPDATE_INTERVAL).toInt()); - m_ui->m_spinFeedUpdateTimeout->setValue(Settings::instance()->value(APP_CFG_FEEDS, "feed_update_timeout", DOWNLOAD_TIMEOUT).toInt()); - m_ui->m_checkUpdateAllFeedsOnStartup->setChecked(Settings::instance()->value(APP_CFG_FEEDS, "feeds_update_on_startup", false).toBool()); + 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, "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->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() { - Settings::instance()->setValue(APP_CFG_MESSAGES, "keep_cursor_center", m_ui->m_checkKeppMessagesInTheMiddle->isChecked()); - 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::instance()->setValue(APP_CFG_FEEDS, "auto_update_interval", m_ui->m_spinAutoUpdateInterval->value()); - Settings::instance()->setValue(APP_CFG_FEEDS, "feed_update_timeout", m_ui->m_spinFeedUpdateTimeout->value()); - Settings::instance()->setValue(APP_CFG_FEEDS, "feeds_update_on_startup", m_ui->m_checkUpdateAllFeedsOnStartup->isChecked()); - Settings::instance()->setValue(APP_CFG_FEEDS, "count_format", m_ui->m_cmbCountsFeedList->currentText()); + 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, "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()->sourceModel()->reloadWholeLayout(); @@ -326,7 +330,7 @@ void FormSettings::saveSettings() { saveLanguage(); saveFeedsMessages(); - Settings::instance()->checkSettings(); + qApp->settings()->checkSettings(); promptForRestart(); accept(); @@ -349,7 +353,7 @@ void FormSettings::onProxyTypeChanged(int index) { } void FormSettings::loadBrowser() { - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); // Load settings of web browser GUI. m_initialSettings.m_webBrowserProgress = QColor(settings->value(APP_CFG_BROWSER, @@ -382,7 +386,7 @@ void FormSettings::loadBrowser() { } void FormSettings::saveBrowser() { - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); // Save settings of GUI of web browser. settings->setValue(APP_CFG_BROWSER, @@ -420,10 +424,10 @@ void FormSettings::loadProxy() { m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy); // Load the settings. - QNetworkProxy::ProxyType selected_proxy_type = static_cast(Settings::instance()->value(APP_CFG_PROXY, - "proxy_type", - QNetworkProxy::NoProxy).toInt()); - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); + QNetworkProxy::ProxyType selected_proxy_type = static_cast(settings->value(APP_CFG_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, @@ -437,7 +441,7 @@ void FormSettings::loadProxy() { } void FormSettings::saveProxy() { - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); settings->setValue(APP_CFG_PROXY, "proxy_type", m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex())); @@ -479,7 +483,7 @@ void FormSettings::saveLanguage() { return; } - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); QString actual_lang = Localization::instance()->loadedLanguage(); QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1); @@ -516,27 +520,28 @@ void FormSettings::loadDataStorage() { tr("SQLite (embedded database)"), APP_DB_SQLITE_DRIVER); // 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)) { // Load MySQL. - m_ui->m_cmbDatabaseDriver->addItem( - tr("MySQL/MariaDB (dedicated database)"), APP_DB_MYSQL_DRIVER); + m_ui->m_cmbDatabaseDriver->addItem(tr("MySQL/MariaDB (dedicated database)"), APP_DB_MYSQL_DRIVER); // Setup placeholders. m_ui->m_txtMysqlHostname->lineEdit()->setPlaceholderText(tr("Hostname of your MySQL server")); m_ui->m_txtMysqlUsername->lineEdit()->setPlaceholderText(tr("Username to login with")); m_ui->m_txtMysqlPassword->lineEdit()->setPlaceholderText(tr("Password for your username")); - m_ui->m_txtMysqlHostname->lineEdit()->setText(Settings::instance()->value(APP_CFG_DB, "mysql_hostname").toString()); - m_ui->m_txtMysqlUsername->lineEdit()->setText(Settings::instance()->value(APP_CFG_DB, "mysql_username").toString()); - m_ui->m_txtMysqlPassword->lineEdit()->setText(Settings::instance()->value(APP_CFG_DB, "mysql_password").toString()); - m_ui->m_spinMysqlPort->setValue(Settings::instance()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt()); + 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()); } - int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(Settings::instance()->value(APP_CFG_DB, - "database_driver", - APP_DB_SQLITE_DRIVER).toString()); + int index_current_backend = m_ui->m_cmbDatabaseDriver->findData(settings->value(APP_CFG_DB, + "database_driver", + APP_DB_SQLITE_DRIVER).toString()); if (index_current_backend >= 0) { m_ui->m_cmbDatabaseDriver->setCurrentIndex(index_current_backend); @@ -545,7 +550,9 @@ void FormSettings::loadDataStorage() { void FormSettings::saveDataStorage() { // 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(); if (original_inmemory != new_inmemory) { @@ -553,21 +560,21 @@ void FormSettings::saveDataStorage() { } // 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(); // 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)) { // Save MySQL. - Settings::instance()->setValue(APP_CFG_DB, "mysql_hostname", m_ui->m_txtMysqlHostname->lineEdit()->text()); - Settings::instance()->setValue(APP_CFG_DB, "mysql_username", m_ui->m_txtMysqlUsername->lineEdit()->text()); - Settings::instance()->setValue(APP_CFG_DB, "mysql_password", m_ui->m_txtMysqlPassword->lineEdit()->text()); - Settings::instance()->setValue(APP_CFG_DB, "mysql_port", m_ui->m_spinMysqlPort->value()); + 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::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 || m_initialSettings.m_mysqlDataStorageChanged) { @@ -668,7 +675,7 @@ void FormSettings::saveGeneral() { } void FormSettings::loadInterface() { - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); // Load settings of tray icon. if (SystemTrayIcon::isSystemTrayAvailable()) { @@ -770,9 +777,9 @@ 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(Settings::instance()->value(APP_CFG_GUI, - "toolbar_style", - Qt::ToolButtonIconOnly).toInt())); + m_ui->m_cmbToolbarButtonStyle->setCurrentIndex(m_ui->m_cmbToolbarButtonStyle->findData(qApp->settings()->value(APP_CFG_GUI, + "toolbar_style", + Qt::ToolButtonIconOnly).toInt())); // Load toolbars. m_ui->m_editorFeedsToolbar->loadFromToolBar(FormMain::instance()->tabWidget()->feedMessageViewer()->feedsToolBar()); @@ -780,17 +787,18 @@ void FormSettings::loadInterface() { } void FormSettings::saveInterface() { - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); // Save toolbar. - Settings::instance()->setValue(APP_CFG_GUI, - "toolbar_style", - m_ui->m_cmbToolbarButtonStyle->itemData(m_ui->m_cmbToolbarButtonStyle->currentIndex())); + settings->setValue(APP_CFG_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", m_ui->m_radioTrayOn->isChecked()); + if (settings->value(APP_CFG_GUI, "use_tray_icon", true).toBool()) { SystemTrayIcon::instance()->show(); FormMain::instance()->tabWidget()->feedMessageViewer()->feedsView()->notifyWithCounts(); diff --git a/src/gui/messagestoolbar.cpp b/src/gui/messagestoolbar.cpp index d8f87ed86..3ff6c3059 100644 --- a/src/gui/messagestoolbar.cpp +++ b/src/gui/messagestoolbar.cpp @@ -50,7 +50,7 @@ QList MessagesToolBar::changeableActions() const { } 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); // If user hidden search messages box, then remove the filter. @@ -144,10 +144,10 @@ void MessagesToolBar::initializeHighlighter() { } void MessagesToolBar::loadChangeableActions() { - QStringList action_names = Settings::instance()->value(APP_CFG_GUI, - "messages_toolbar", - "m_actionMarkSelectedMessagesAsRead,m_actionMarkSelectedMessagesAsUnread,m_actionSwitchImportanceOfSelectedMessages,separator,highlighter,spacer,search").toString().split(',', - QString::SkipEmptyParts); + QStringList action_names = qApp->settings()->value(APP_CFG_GUI, + "messages_toolbar", + "m_actionMarkSelectedMessagesAsRead,m_actionMarkSelectedMessagesAsUnread,m_actionSwitchImportanceOfSelectedMessages,separator,highlighter,spacer,search").toString().split(',', + QString::SkipEmptyParts); loadChangeableActions(action_names); } diff --git a/src/gui/messagesview.cpp b/src/gui/messagesview.cpp index 9f2634b7c..eef86c505 100644 --- a/src/gui/messagesview.cpp +++ b/src/gui/messagesview.cpp @@ -214,9 +214,9 @@ void MessagesView::currentChanged(const QModelIndex ¤t, void MessagesView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) { - if (Settings::instance()->value(APP_CFG_MESSAGES, - "keep_cursor_center", - false).toBool()) { + if (qApp->settings()->value(APP_CFG_MESSAGES, + "keep_cursor_center", + false).toBool()) { scrollTo(currentIndex(), QAbstractItemView::PositionAtCenter); } diff --git a/src/gui/systemtrayicon.cpp b/src/gui/systemtrayicon.cpp index 9a626b223..09da78680 100644 --- a/src/gui/systemtrayicon.cpp +++ b/src/gui/systemtrayicon.cpp @@ -91,9 +91,9 @@ bool SystemTrayIcon::isSystemTrayAvailable() { } bool SystemTrayIcon::isSystemTrayActivated() { - return SystemTrayIcon::isSystemTrayAvailable() && Settings::instance()->value(APP_CFG_GUI, - "use_tray_icon", - true).toBool(); + return SystemTrayIcon::isSystemTrayAvailable() && qApp->settings()->value(APP_CFG_GUI, + "use_tray_icon", + true).toBool(); } SystemTrayIcon *SystemTrayIcon::instance() { diff --git a/src/gui/tabbar.cpp b/src/gui/tabbar.cpp index 3d0890cf7..c51caf5d9 100644 --- a/src/gui/tabbar.cpp +++ b/src/gui/tabbar.cpp @@ -112,9 +112,9 @@ 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 && Settings::instance()->value(APP_CFG_GUI, - "tab_close_mid_button", - true).toBool()) { + if (event->button() & Qt::MiddleButton && qApp->settings()->value(APP_CFG_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,9 +133,9 @@ 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 && Settings::instance()->value(APP_CFG_GUI, - "tab_close_double_button", - true).toBool()) { + if (event->button() & Qt::LeftButton && qApp->settings()->value(APP_CFG_GUI, + "tab_close_double_button", + true).toBool()) { if (tabType(tab_index) == TabBar::Closable) { // This tab is closable, so we can close it. emit tabCloseRequested(tab_index); @@ -145,9 +145,9 @@ 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 (Settings::instance()->value(APP_CFG_GUI, - "tab_new_double_button", - true).toBool()) { + else if (qApp->settings()->value(APP_CFG_GUI, + "tab_new_double_button", + true).toBool()) { emit emptySpaceDoubleClicked(); } } diff --git a/src/gui/tabwidget.cpp b/src/gui/tabwidget.cpp index 8185cc42e..8526fbfe2 100644 --- a/src/gui/tabwidget.cpp +++ b/src/gui/tabwidget.cpp @@ -86,9 +86,9 @@ void TabWidget::openMainMenu() { } void TabWidget::checkTabBarVisibility() { - bool should_be_visible = count() > 1 || !Settings::instance()->value(APP_CFG_GUI, - "hide_tabbar_one_tab", - true).toBool(); + bool should_be_visible = count() > 1 || !qApp->settings()->value(APP_CFG_GUI, + "hide_tabbar_one_tab", + true).toBool(); if (should_be_visible) { setCornerWidget(m_btnMainMenu, Qt::TopLeftCorner); @@ -109,7 +109,7 @@ void TabWidget::checkTabBarVisibility() { } void TabWidget::tabInserted(int index) { - QTabWidget::tabInserted(index); + QTabWidget::tabInserted(index); checkTabBarVisibility(); int count_of_tabs = count(); @@ -272,9 +272,9 @@ int TabWidget::addLinkedBrowser(const QString &initial_url) { } int TabWidget::addLinkedBrowser(const QUrl &initial_url) { - return addBrowser(Settings::instance()->value(APP_CFG_BROWSER, - "queue_tabs", - true).toBool(), + return addBrowser(qApp->settings()->value(APP_CFG_BROWSER, + "queue_tabs", + true).toBool(), false, initial_url); } diff --git a/src/main.cpp b/src/main.cpp index bc17476f3..68a2b99d7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -104,8 +104,8 @@ int main(int argc, char *argv[]) { DynamicShortcuts::load(main_window.allActions().values()); // Display main window. - if (Settings::instance()->value(APP_CFG_GUI, "start_hidden", - false).toBool() && + if (qApp->settings()->value(APP_CFG_GUI, "start_hidden", + false).toBool() && SystemTrayIcon::isSystemTrayActivated()) { qDebug("Hiding the main window when the application is starting."); main_window.switchVisibility(true); diff --git a/src/miscellaneous/databasefactory.cpp b/src/miscellaneous/databasefactory.cpp index fffc608f7..bcdbfec57 100644 --- a/src/miscellaneous/databasefactory.cpp +++ b/src/miscellaneous/databasefactory.cpp @@ -97,7 +97,7 @@ QString DatabaseFactory::mysqlInterpretErrorCode(MySQLError error_code) { } void DatabaseFactory::sqliteAssemblyDatabaseFilePath() { - if (Settings::instance()->type() == Settings::Portable) { + if (qApp->settings()->type() == Settings::Portable) { m_sqliteDatabaseFilePath = qApp->applicationDirPath() + QDir::separator() + QString(APP_DB_SQLITE_PATH); @@ -330,9 +330,9 @@ void DatabaseFactory::sqliteSaveMemoryDatabase() { } void DatabaseFactory::determineDriver() { - QString db_driver = Settings::instance()->value(APP_CFG_DB, - "database_driver", - APP_DB_SQLITE_DRIVER).toString(); + QString db_driver = qApp->settings()->value(APP_CFG_DB, + "database_driver", + APP_DB_SQLITE_DRIVER).toString(); if (db_driver == APP_DB_MYSQL_DRIVER && QSqlDatabase::isDriverAvailable(APP_DB_SQLITE_DRIVER)) { @@ -344,7 +344,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 (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. m_activeDatabaseDriver = SQLITE_MEMORY; @@ -382,10 +382,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(Settings::instance()->value(APP_CFG_DB, "mysql_hostname").toString()); - database.setPort(Settings::instance()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt()); - database.setUserName(Settings::instance()->value(APP_CFG_DB, "mysql_username").toString()); - database.setPassword(Settings::instance()->value(APP_CFG_DB, "mysql_password").toString()); + 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.setDatabaseName(APP_LOW_NAME); } @@ -408,10 +408,10 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString &connection_ QSqlDatabase database = QSqlDatabase::addDatabase(APP_DB_MYSQL_DRIVER, connection_name); - database.setHostName(Settings::instance()->value(APP_CFG_DB, "mysql_hostname").toString()); - database.setPort(Settings::instance()->value(APP_CFG_DB, "mysql_port", APP_DB_MYSQL_PORT).toInt()); - database.setUserName(Settings::instance()->value(APP_CFG_DB, "mysql_username").toString()); - database.setPassword(Settings::instance()->value(APP_CFG_DB, "mysql_password").toString()); + 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()); if (!database.open()) { qFatal("MySQL database was NOT opened. Delivered error message: '%s'", diff --git a/src/miscellaneous/iconfactory.cpp b/src/miscellaneous/iconfactory.cpp index 302017f3c..b24deb64d 100644 --- a/src/miscellaneous/iconfactory.cpp +++ b/src/miscellaneous/iconfactory.cpp @@ -72,19 +72,17 @@ void IconFactory::setupSearchPaths() { "\'").join(", "))); } - - void IconFactory::setCurrentIconTheme(const QString &theme_name) { - Settings::instance()->setValue(APP_CFG_GUI, - "icon_theme", - theme_name); + qApp->settings()->setValue(APP_CFG_GUI, + "icon_theme", + theme_name); } void IconFactory::loadCurrentIconTheme() { QStringList installed_themes = installedIconThemes(); - QString theme_name_from_settings = Settings::instance()->value(APP_CFG_GUI, - "icon_theme", - APP_THEME_DEFAULT).toString(); + QString theme_name_from_settings = qApp->settings()->value(APP_CFG_GUI, + "icon_theme", + APP_THEME_DEFAULT).toString(); if (m_currentIconTheme == theme_name_from_settings) { qDebug("Icon theme '%s' already loaded.", diff --git a/src/miscellaneous/localization.cpp b/src/miscellaneous/localization.cpp index 291610320..a21112c19 100644 --- a/src/miscellaneous/localization.cpp +++ b/src/miscellaneous/localization.cpp @@ -47,9 +47,9 @@ Localization *Localization::instance() { } QString Localization::desiredLanguage() { - return Settings::instance()->value(APP_CFG_GEN, - "language", - QLocale::system().name()).toString(); + return qApp->settings()->value(APP_CFG_GEN, + "language", + QLocale::system().name()).toString(); } void Localization::load() { diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index f30a87e43..99181a6d6 100644 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -26,8 +26,6 @@ #include -QPointer Settings::s_instance; - Settings::Settings(const QString &file_name, Format format, const Type &status, QObject *parent) : QSettings(file_name, format, parent), m_initializationStatus(status) { @@ -45,15 +43,9 @@ QSettings::Status Settings::checkSettings() { return status(); } -Settings *Settings::instance() { - if (s_instance.isNull()) { - setupSettings(); - } +Settings *Settings::setupSettings(QObject *parent) { + Settings *new_settings; - return s_instance; -} - -QSettings::Status Settings::setupSettings() { // If settings file exists in executable file working directory // (in subdirectory APP_CFG_PATH), then use it (portable settings). // Otherwise use settings file stored in homePath(); @@ -66,8 +58,8 @@ QSettings::Status Settings::setupSettings() { // Check if portable settings are available. if (QFile(app_path_file).exists()) { // Portable settings are available, use them. - s_instance = new Settings(app_path_file, QSettings::IniFormat, - Settings::Portable, qApp); + new_settings = new Settings(app_path_file, QSettings::IniFormat, + Settings::Portable, parent); // Construct icon cache in the same 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 home_path_file = home_path + relative_path; - s_instance = new Settings(home_path_file, QSettings::IniFormat, - Settings::NonPortable, qApp); + new_settings = new Settings(home_path_file, QSettings::IniFormat, + Settings::NonPortable, parent); // Construct icon cache in the same 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))); } - return (*s_instance).checkSettings(); + return new_settings; } diff --git a/src/miscellaneous/settings.h b/src/miscellaneous/settings.h index dc825d874..462016222 100644 --- a/src/miscellaneous/settings.h +++ b/src/miscellaneous/settings.h @@ -33,9 +33,6 @@ class Settings : public QSettings { NonPortable }; - // Singleton getter. - static Settings *instance(); - // Destructor. virtual ~Settings(); @@ -60,18 +57,15 @@ class Settings : public QSettings { // Synchronizes settings. QSettings::Status checkSettings(); + // Creates settings file in correct location. + static Settings* setupSettings(QObject *parent); + private: // Constructor. Settings(const QString & file_name, Format format, const Type &type, QObject * parent = 0); Type m_initializationStatus; - - // Creates settings file in correct location. - static QSettings::Status setupSettings(); - - // Private singleton value. - static QPointer s_instance; }; #endif // SETTINGS_H diff --git a/src/miscellaneous/skinfactory.cpp b/src/miscellaneous/skinfactory.cpp index 3958428d8..b1ef28bdc 100644 --- a/src/miscellaneous/skinfactory.cpp +++ b/src/miscellaneous/skinfactory.cpp @@ -109,13 +109,13 @@ bool SkinFactory::loadSkinFromData(const Skin &skin) { } 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() { - return Settings::instance()->value(APP_CFG_GUI, - "skin", - APP_SKIN_DEFAULT).toString(); + return qApp->settings()->value(APP_CFG_GUI, + "skin", + APP_SKIN_DEFAULT).toString(); } Skin SkinFactory::skinInfo(const QString &skin_name, bool *ok) { diff --git a/src/network-web/basenetworkaccessmanager.cpp b/src/network-web/basenetworkaccessmanager.cpp index 1b8d57c4a..a3cec19cc 100644 --- a/src/network-web/basenetworkaccessmanager.cpp +++ b/src/network-web/basenetworkaccessmanager.cpp @@ -19,6 +19,7 @@ #include "definitions/definitions.h" #include "miscellaneous/settings.h" +#include "application.h" #include #include @@ -38,7 +39,7 @@ BaseNetworkAccessManager::~BaseNetworkAccessManager() { void BaseNetworkAccessManager::loadSettings() { QNetworkProxy new_proxy; - QNetworkProxy::ProxyType selected_proxy_type = static_cast(Settings::instance()->value(APP_CFG_PROXY, + QNetworkProxy::ProxyType selected_proxy_type = static_cast(qApp->settings()->value(APP_CFG_PROXY, "proxy_type", QNetworkProxy::NoProxy).toInt()); @@ -52,7 +53,7 @@ void BaseNetworkAccessManager::loadSettings() { return; } - Settings *settings = Settings::instance(); + Settings *settings = qApp->settings(); // Custom proxy is selected, set it up. new_proxy.setType(selected_proxy_type); diff --git a/src/network-web/webfactory.cpp b/src/network-web/webfactory.cpp index b02d590e2..df3c9a9f9 100644 --- a/src/network-web/webfactory.cpp +++ b/src/network-web/webfactory.cpp @@ -24,7 +24,7 @@ WebFactory::~WebFactory() { } void WebFactory::loadState() { - Settings *settings = Settings::instance(); + 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); @@ -32,14 +32,14 @@ void WebFactory::loadState() { } bool WebFactory::openUrlInExternalBrowser(const QString &url) { - if (Settings::instance()->value(APP_CFG_BROWSER, - "custom_external_browser", - false).toBool()) { - QString browser = Settings::instance()->value(APP_CFG_BROWSER, - "external_browser_executable").toString(); - QString arguments = Settings::instance()->value(APP_CFG_BROWSER, - "external_browser_arguments", - "%1").toString(); + 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(); return QProcess::startDetached(browser, QStringList() << arguments.arg(url)); } @@ -50,9 +50,9 @@ bool WebFactory::openUrlInExternalBrowser(const QString &url) { void WebFactory::switchJavascript(bool enable, bool save_settings) { if (save_settings) { - Settings::instance()->setValue(APP_CFG_BROWSER, - "enable_javascript", - enable); + qApp->settings()->setValue(APP_CFG_BROWSER, + "enable_javascript", + enable); } m_globalSettings->setAttribute(QWebSettings::JavascriptEnabled, enable); @@ -61,9 +61,9 @@ void WebFactory::switchJavascript(bool enable, bool save_settings) { void WebFactory::switchPlugins(bool enable, bool save_settings) { if (save_settings) { - Settings::instance()->setValue(APP_CFG_BROWSER, - "enable_plugins", - enable); + qApp->settings()->setValue(APP_CFG_BROWSER, + "enable_plugins", + enable); } m_globalSettings->setAttribute(QWebSettings::PluginsEnabled, enable); @@ -72,9 +72,9 @@ void WebFactory::switchPlugins(bool enable, bool save_settings) { void WebFactory::switchImages(bool enable, bool save_settings) { if (save_settings) { - Settings::instance()->setValue(APP_CFG_BROWSER, - "enable_images", - enable); + qApp->settings()->setValue(APP_CFG_BROWSER, + "enable_images", + enable); } m_globalSettings->setAttribute(QWebSettings::AutoLoadImages, enable); diff --git a/src/network-web/webview.cpp b/src/network-web/webview.cpp index a0276ff4a..0141eca36 100644 --- a/src/network-web/webview.cpp +++ b/src/network-web/webview.cpp @@ -228,9 +228,9 @@ void WebView::mousePressEvent(QMouseEvent *event) { void WebView::mouseReleaseEvent(QMouseEvent *event) { if (event->button() & Qt::MiddleButton) { - bool are_gestures_enabled = Settings::instance()->value(APP_CFG_BROWSER, - "gestures_enabled", - true).toBool(); + bool are_gestures_enabled = qApp->settings()->value(APP_CFG_BROWSER, + "gestures_enabled", + true).toBool(); if (are_gestures_enabled) { QPoint release_point = event->pos(); int left_move = m_gestureOrigin.x() - release_point.x();