From 5d7f8a9e203477ba253d92a1a56d3ea19b81c6a8 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Tue, 24 May 2016 06:20:20 +0200 Subject: [PATCH] Clean up D-Bus support, rely on tray icon baloons, because on sole Qt 5 they are rock-solid and enough. --- CMakeLists.txt | 32 +++-------------------------- src/core/feedsmodel.cpp | 3 +-- src/gui/dialogs/formsettings.cpp | 14 ------------- src/gui/dialogs/formsettings.ui | 12 +---------- src/main.cpp | 2 +- src/miscellaneous/application.cpp | 32 +++++------------------------ src/miscellaneous/application.h | 2 +- src/miscellaneous/settings.cpp | 3 --- src/miscellaneous/settings.h | 3 --- src/miscellaneous/systemfactory.cpp | 2 +- src/network-web/downloadmanager.cpp | 2 +- 11 files changed, 14 insertions(+), 93 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e23ea5d7a..fed3b93a2 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,13 +217,7 @@ elseif(${MSVC_VERSION} VERSION_LESS 1600) endif(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") # Setup libraries. -if(UNIX) - # On Unices, enable D-Bus support. - find_package(Qt5 REQUIRED DBus Sql Widgets Xml Network LinguistTools PrintSupport) -else(UNIX) - find_package(Qt5 REQUIRED Sql Widgets Xml Network LinguistTools PrintSupport) -endif(UNIX) - +find_package(Qt5 REQUIRED Sql Widgets Xml Network LinguistTools PrintSupport) message(STATUS "[${APP_LOW_NAME}] Found Qt version: '${Qt5_VERSION}'.") if(Qt5_VERSION VERSION_LESS MINIMUM_QT_VERSION) @@ -405,28 +399,8 @@ if(WIN32) target_link_libraries(${EXE_NAME} Qt5::WinMain) endif(WIN32) -if(UNIX) - # Use modules from Qt. - qt5_use_modules(${EXE_NAME} - DBus - Core - Widgets - Sql - Network - Xml - PrintSupport - ) -else(UNIX) - # Use modules from Qt. - qt5_use_modules(${EXE_NAME} - Core - Widgets - Sql - Network - Xml - PrintSupport - ) -endif(UNIX) +# Use modules from Qt. +qt5_use_modules(${EXE_NAME} Core Widgets Sql Network Xml PrintSupport) set(FAENZA_FOLDERS "resources/graphics/Faenza/actions" diff --git a/src/core/feedsmodel.cpp b/src/core/feedsmodel.cpp index a76c2e47a..d7a371d68 100755 --- a/src/core/feedsmodel.cpp +++ b/src/core/feedsmodel.cpp @@ -174,8 +174,7 @@ void FeedsModel::onFeedUpdatesFinished(const FeedDownloadResults &results) { if (!results.updatedFeeds().isEmpty()) { // Now, inform about results via GUI message/notification. - qApp->showGuiMessage(tr("New messages downloaded"), results.overview(10), QSystemTrayIcon::NoIcon, - 0, false, qApp->icons()->fromTheme(QSL("view-refresh"))); + qApp->showGuiMessage(tr("New messages downloaded"), results.overview(10), QSystemTrayIcon::NoIcon, 0, false); } emit feedsUpdateFinished(); diff --git a/src/gui/dialogs/formsettings.cpp b/src/gui/dialogs/formsettings.cpp index 67223d057..a833460d3 100755 --- a/src/gui/dialogs/formsettings.cpp +++ b/src/gui/dialogs/formsettings.cpp @@ -120,12 +120,6 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form connect(m_ui->m_checkMysqlShowPassword, SIGNAL(toggled(bool)), this, SLOT(switchMysqlPasswordVisiblity(bool))); connect(m_ui->m_btnChangeMessagesFont, SIGNAL(clicked()), this, SLOT(changeMessagesFont())); - connect(m_ui->m_checkEnableNotifications, &QCheckBox::toggled, [=](bool checked) { - if (!checked) { - m_ui->m_checkEnableDBusNotifications->setChecked(false); - } - }); - // Load all settings. loadGeneral(); loadDataStorage(); @@ -704,13 +698,6 @@ void FormSettings::loadInterface() { // Load fancy notification settings. m_ui->m_checkEnableNotifications->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool()); -#if defined(Q_OS_LINUX) - m_ui->m_checkEnableDBusNotifications->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::UseFancyNotifications)).toBool()); -#else - m_ui->m_checkEnableDBusNotifications->setText(m_ui->m_checkEnableDBusNotifications->text() + tr(" (not available)")); - m_ui->m_checkEnableDBusNotifications->setEnabled(false); -#endif - // Load settings of icon theme. const QString current_theme = qApp->icons()->currentIconTheme(); @@ -803,7 +790,6 @@ void FormSettings::saveInterface() { m_settings->setValue(GROUP(GUI), GUI::HideMainWindowWhenMinimized, m_ui->m_checkHideWhenMinimized->isChecked()); // Save notifications. - m_settings->setValue(GROUP(GUI), GUI::UseFancyNotifications, m_ui->m_checkEnableDBusNotifications->isChecked()); m_settings->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui->m_checkEnableNotifications->isChecked()); // Save selected icon theme. diff --git a/src/gui/dialogs/formsettings.ui b/src/gui/dialogs/formsettings.ui index 4ee095da7..a5da21baa 100755 --- a/src/gui/dialogs/formsettings.ui +++ b/src/gui/dialogs/formsettings.ui @@ -88,7 +88,7 @@ - 4 + 0 @@ -642,16 +642,6 @@ Authors of this application are NOT responsible for lost data. - - - - - - - Enable D-Bus notifications - - - diff --git a/src/main.cpp b/src/main.cpp index b74bf92c0..da984c8dc 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) { if (qApp->isFirstRun() || qApp->isFirstRun(APP_VERSION)) { qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n" "version by clicking this popup notification.").arg(APP_LONG_NAME), - QSystemTrayIcon::NoIcon, 0, false, QIcon(), &main_window, SLOT(showAbout())); + QSystemTrayIcon::NoIcon, 0, false, &main_window, SLOT(showAbout())); } else { qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.").arg(APP_LONG_NAME), QSystemTrayIcon::NoIcon); diff --git a/src/miscellaneous/application.cpp b/src/miscellaneous/application.cpp index 1e0942e60..c0a54be4f 100755 --- a/src/miscellaneous/application.cpp +++ b/src/miscellaneous/application.cpp @@ -222,34 +222,12 @@ void Application::deleteTrayIcon() { void Application::showGuiMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon message_type, QWidget *parent, - bool show_at_least_msgbox, const QIcon &custom_icon, - QObject *invokation_target, const char *invokation_slot) { - if (Notification::areNotificationsEnabled()) { -#if defined(Q_OS_LINUX) - if (Notification::areDBusNotificationsEnabled()) { - // Show OSD instead if tray icon bubble, depending on settings. - if (custom_icon.isNull()) { - notification()->notify(message, title, message_type, invokation_target, invokation_slot); - } - else { - notification()->notify(message, title, custom_icon, invokation_target, invokation_slot); - } - - return; - } - else if (SystemTrayIcon::isSystemTrayActivated()) { - trayIcon()->showMessage(title, message, message_type, TRAY_ICON_BUBBLE_TIMEOUT, invokation_target, invokation_slot); - return; - } -#else - if (SystemTrayIcon::isSystemTrayActivated()) { - trayIcon()->showMessage(title, message, message_type, TRAY_ICON_BUBBLE_TIMEOUT, invokation_target, invokation_slot); - return; - } -#endif + bool show_at_least_msgbox, QObject *invokation_target, + const char *invokation_slot) { + if (Notification::areNotificationsEnabled() && SystemTrayIcon::isSystemTrayActivated()) { + trayIcon()->showMessage(title, message, message_type, TRAY_ICON_BUBBLE_TIMEOUT, invokation_target, invokation_slot); } - - if (show_at_least_msgbox) { + else if (show_at_least_msgbox) { // Tray icon or OSD is not available, display simple text box. MessageBox::show(parent, (QMessageBox::Icon) message_type, title, message); } diff --git a/src/miscellaneous/application.h b/src/miscellaneous/application.h index 7e28be5fe..3af8e78d3 100755 --- a/src/miscellaneous/application.h +++ b/src/miscellaneous/application.h @@ -158,7 +158,7 @@ class Application : public QtSingleApplication { // Displays given simple message in tray icon bubble or OSD // or in message box if tray icon is disabled. void showGuiMessage(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon message_type, - QWidget *parent = NULL, bool show_at_least_msgbox = false, const QIcon &custom_icon = QIcon(), + QWidget *parent = NULL, bool show_at_least_msgbox = false, QObject *invokation_target = NULL, const char *invokation_slot = NULL); // Returns pointer to "GOD" application singleton. diff --git a/src/miscellaneous/settings.cpp b/src/miscellaneous/settings.cpp index 2e71c2e0c..25b969444 100755 --- a/src/miscellaneous/settings.cpp +++ b/src/miscellaneous/settings.cpp @@ -115,9 +115,6 @@ DVALUE(bool) GUI::UseTrayIconDef = true; DKEY GUI::EnableNotifications = "enable_notifications"; DVALUE(bool) GUI::EnableNotificationsDef = true; -DKEY GUI::UseFancyNotifications = "use_fancy_notifications"; -DVALUE(bool) GUI::UseFancyNotificationsDef = true; - DKEY GUI::TabCloseMiddleClick = "tab_close_mid_button"; DVALUE(bool) GUI::TabCloseMiddleClickDef = true; diff --git a/src/miscellaneous/settings.h b/src/miscellaneous/settings.h index 68e7d3cdc..9ca113b57 100755 --- a/src/miscellaneous/settings.h +++ b/src/miscellaneous/settings.h @@ -134,9 +134,6 @@ namespace GUI { KEY EnableNotifications; VALUE(bool) EnableNotificationsDef; - KEY UseFancyNotifications; - VALUE(bool) UseFancyNotificationsDef; - KEY TabCloseMiddleClick; VALUE(bool) TabCloseMiddleClickDef; diff --git a/src/miscellaneous/systemfactory.cpp b/src/miscellaneous/systemfactory.cpp index ab6206aa0..793d7b475 100755 --- a/src/miscellaneous/systemfactory.cpp +++ b/src/miscellaneous/systemfactory.cpp @@ -279,6 +279,6 @@ void SystemFactory::checkForUpdatesOnStartup() { qApp->showGuiMessage(tr("New version available"), tr("Click the bubble for more information."), QSystemTrayIcon::Information, - NULL, true, QIcon(), qApp->mainForm(), SLOT(showUpdates())); + NULL, true, qApp->mainForm(), SLOT(showUpdates())); } } diff --git a/src/network-web/downloadmanager.cpp b/src/network-web/downloadmanager.cpp index 8ec689cde..253a8fbae 100755 --- a/src/network-web/downloadmanager.cpp +++ b/src/network-web/downloadmanager.cpp @@ -436,7 +436,7 @@ void DownloadItem::finished() { if (downloadedSuccessfully()) { qApp->showGuiMessage(tr("Download finished"), tr("File '%1' is downloaded.\nClick here to open parent directory.").arg(QDir::toNativeSeparators(m_output.fileName())), - QSystemTrayIcon::Information, 0, false, QIcon(), this, SLOT(openFolder())); + QSystemTrayIcon::Information, 0, false, this, SLOT(openFolder())); } }