From 97aeb45a76195fe97d6ba2b9b8fdc8558bee1e73 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Sat, 21 Jan 2017 18:38:19 +0100 Subject: [PATCH] Preferences: Add preview button for notifications --- src/lib/preferences/preferences.cpp | 43 ++++---- src/lib/preferences/preferences.h | 6 +- src/lib/preferences/preferences.ui | 151 +++++++++++++++++----------- 3 files changed, 114 insertions(+), 86 deletions(-) diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index acc853d96..d7f5366d7 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -399,8 +399,7 @@ Preferences::Preferences(BrowserWindow* window) ui->useOSDNotifications->setChecked(true); } - connect(ui->useNativeSystemNotifications, SIGNAL(toggled(bool)), this, SLOT(setNotificationPreviewVisible(bool))); - connect(ui->useOSDNotifications, SIGNAL(toggled(bool)), this, SLOT(setNotificationPreviewVisible(bool))); + connect(ui->notificationPreview, &QPushButton::clicked, this, &Preferences::showNotificationPreview); ui->doNotUseNotifications->setChecked(!settings.value("Enabled", true).toBool()); m_notifPosition = settings.value("Position", QPoint(10, 10)).toPoint(); @@ -559,7 +558,10 @@ void Preferences::showStackedPage(QListWidgetItem* item) ui->caption->setText("" + item->text() + ""); ui->stackedWidget->setCurrentIndex(index); - setNotificationPreviewVisible(index == 9); + if (m_notification) { + m_notifPosition = m_notification.data()->pos(); + delete m_notification.data(); + } if (index == 10) { m_pluginsList->load(); @@ -572,29 +574,22 @@ void Preferences::showStackedPage(QListWidgetItem* item) } } -void Preferences::setNotificationPreviewVisible(bool state) +void Preferences::showNotificationPreview() { - if (!state && m_notification) { - m_notifPosition = m_notification.data()->pos(); - delete m_notification.data(); - } - - if (state) { - if (ui->useOSDNotifications->isChecked()) { - if (m_notification) { - m_notifPosition = m_notification.data()->pos(); - delete m_notification.data(); - } - - m_notification = new DesktopNotification(true); - m_notification.data()->setHeading(tr("OSD Notification")); - m_notification.data()->setText(tr("Drag it on the screen to place it where you want.")); - m_notification.data()->move(m_notifPosition); - m_notification.data()->show(); - } - else if (ui->useNativeSystemNotifications->isChecked()) { - mApp->desktopNotifications()->nativeNotificationPreview(); + if (ui->useOSDNotifications->isChecked()) { + if (m_notification) { + m_notifPosition = m_notification.data()->pos(); + delete m_notification.data(); } + + m_notification = new DesktopNotification(true); + m_notification.data()->setHeading(tr("OSD Notification")); + m_notification.data()->setText(tr("Drag it on the screen to place it where you want.")); + m_notification.data()->move(m_notifPosition); + m_notification.data()->show(); + } + else if (ui->useNativeSystemNotifications->isChecked()) { + mApp->desktopNotifications()->nativeNotificationPreview(); } } diff --git a/src/lib/preferences/preferences.h b/src/lib/preferences/preferences.h index e26816de2..862f39939 100644 --- a/src/lib/preferences/preferences.h +++ b/src/lib/preferences/preferences.h @@ -1,6 +1,6 @@ /* ============================================================ -* QupZilla - WebKit based browser -* Copyright (C) 2010-2014 David Rosca +* QupZilla - Qt web browser +* Copyright (C) 2010-2017 David Rosca * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -86,7 +86,7 @@ private slots: void setProgressBarColorIcon(QColor col = QColor()); void selectCustomProgressBarColor(); - void setNotificationPreviewVisible(bool state); + void showNotificationPreview(); void makeQupZillaDefault(); diff --git a/src/lib/preferences/preferences.ui b/src/lib/preferences/preferences.ui index 7ae08c4b2..925afa800 100644 --- a/src/lib/preferences/preferences.ui +++ b/src/lib/preferences/preferences.ui @@ -2134,6 +2134,56 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Expiration timeout: + + + + + + + + 0 + 0 + + + + seconds + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -2141,12 +2191,18 @@ - - - - Use OSD Notifications + + + + Qt::Vertical - + + + 20 + 40 + + + @@ -2165,19 +2221,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -2194,44 +2237,7 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Expiration timeout: - - - - - - - - 0 - 0 - - - - seconds - - - - - - + <b>Note: </b>You can change position of OSD Notification by dragging it on the screen. @@ -2241,7 +2247,7 @@ - + Qt::Vertical @@ -2257,6 +2263,33 @@ + + + + Use OSD Notifications + + + + + + + Preview + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -2381,8 +2414,8 @@ 0 0 - 96 - 28 + 560 + 70