Clean up D-Bus support, rely on tray icon baloons, because on sole Qt 5 they are rock-solid and enough.

This commit is contained in:
Martin Rotter 2016-05-24 06:20:20 +02:00
parent 48ad293a3e
commit 5d7f8a9e20
11 changed files with 14 additions and 93 deletions

View File

@ -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"

View File

@ -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();

View File

@ -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.

View File

@ -88,7 +88,7 @@
<item row="0" column="1">
<widget class="QStackedWidget" name="m_stackedSettings">
<property name="currentIndex">
<number>4</number>
<number>0</number>
</property>
<widget class="QWidget" name="m_pageGeneral">
<layout class="QFormLayout" name="formLayout_5">
@ -642,16 +642,6 @@ Authors of this application are NOT responsible for lost data.</string>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="m_checkEnableDBusNotifications">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>Enable D-Bus notifications</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="m_tabTabs">

View File

@ -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);

View File

@ -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);
}

View File

@ -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.

View File

@ -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;

View File

@ -134,9 +134,6 @@ namespace GUI {
KEY EnableNotifications;
VALUE(bool) EnableNotificationsDef;
KEY UseFancyNotifications;
VALUE(bool) UseFancyNotificationsDef;
KEY TabCloseMiddleClick;
VALUE(bool) TabCloseMiddleClickDef;

View File

@ -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()));
}
}

View File

@ -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()));
}
}