Removed fancy notifications.
This commit is contained in:
parent
3682c20611
commit
cd6ec970fa
@ -1,11 +1,10 @@
|
||||
3.1.1
|
||||
—————
|
||||
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
PLEASE, FILL THIS SURVEY.
|
||||
Main:
|
||||
|
||||
http://goo.gl/forms/GcvPYgS2a8
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
▪ Internal web browser and message preview window now use component based on Chromium/Blink (QtWebEngine).
|
||||
▪ RSS Guard now uses only Qt 5.6 or higher.
|
||||
|
||||
Added:
|
||||
|
||||
@ -16,6 +15,7 @@ Added:
|
||||
|
||||
Fixed:
|
||||
|
||||
▪ Download manager now correctly displays download progress/info.
|
||||
▪ When user selects "Save as..." for some file from internal web browser, file selection dialog is always shown. (bug #174)
|
||||
▪ Better detection of MySQL server status. (bug #169)
|
||||
▪ Ordering of messages is now done on SQL server (stands for both MySQL and SQLite). (bug #172)
|
||||
@ -27,6 +27,7 @@ Fixed:
|
||||
Changed:
|
||||
|
||||
▪ Better performance when recalculating counts of all/unread messages in categories with many feeds.
|
||||
▪ Custom notification popup window is now removed, it was buggy on Windows 10. Windows 10 offers good built-in alternative. On Linux, we rely on D-Bus notifications.
|
||||
|
||||
3.1.0
|
||||
—————
|
||||
|
@ -119,7 +119,12 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form
|
||||
connect(m_ui->m_cmbDatabaseDriver, SIGNAL(currentIndexChanged(int)), this, SLOT(selectSqlBackend(int)));
|
||||
connect(m_ui->m_btnDownloadsTargetDirectory, SIGNAL(clicked()), this, SLOT(selectDownloadsDirectory()));
|
||||
connect(m_ui->m_checkMysqlShowPassword, SIGNAL(toggled(bool)), this, SLOT(switchMysqlPasswordVisiblity(bool)));
|
||||
connect(m_ui->m_btnChangeNotificationColor, SIGNAL(clicked()), this, SLOT(selectNewNotificationColor()));
|
||||
|
||||
connect(m_ui->m_checkEnableNotifications, &QCheckBox::toggled, [=](bool checked) {
|
||||
if (!checked) {
|
||||
m_ui->m_checkEnableDBusNotifications->setChecked(false);
|
||||
}
|
||||
});
|
||||
|
||||
// Load all settings.
|
||||
loadGeneral();
|
||||
@ -152,14 +157,6 @@ void FormSettings::onSkinSelected(QTreeWidgetItem *current, QTreeWidgetItem *pre
|
||||
}
|
||||
}
|
||||
|
||||
void FormSettings::selectNewNotificationColor() {
|
||||
QColorDialog dialog(m_ui->m_lblNotificationColor->color(), this);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
m_ui->m_lblNotificationColor->setColor(dialog.selectedColor());
|
||||
}
|
||||
}
|
||||
|
||||
void FormSettings::loadDownloads() {
|
||||
m_ui->m_checkOpenManagerWhenDownloadStarts->setChecked(m_settings->value(GROUP(Downloads),
|
||||
SETTING(Downloads::ShowDownloadsWhenNewDownloadStarts)).toBool());
|
||||
@ -703,14 +700,14 @@ void FormSettings::loadInterface() {
|
||||
m_ui->m_checkHideWhenMinimized->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::HideMainWindowWhenMinimized)).toBool());
|
||||
|
||||
// Load fancy notification settings.
|
||||
m_ui->m_grpNotifications->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::UseFancyNotifications)).toBool());
|
||||
m_ui->m_cmbNotificationPosition->addItem(tr("Bottom-left corner"), Qt::BottomLeftCorner);
|
||||
m_ui->m_cmbNotificationPosition->addItem(tr("Top-left corner"), Qt::TopLeftCorner);
|
||||
m_ui->m_cmbNotificationPosition->addItem(tr("Bottom-right corner"), Qt::BottomRightCorner);
|
||||
m_ui->m_cmbNotificationPosition->addItem(tr("Top-right corner"), Qt::TopRightCorner);
|
||||
m_ui->m_cmbNotificationPosition->setCurrentIndex(m_ui->m_cmbNotificationPosition->findData(static_cast<Qt::Corner>(m_settings->value(GROUP(GUI), SETTING(GUI::FancyNotificationsPosition)).toInt())));
|
||||
m_ui->m_grpBaseNotifications->setChecked(m_settings->value(GROUP(GUI), SETTING(GUI::EnableNotifications)).toBool());
|
||||
m_ui->m_lblNotificationColor->setColor(m_settings->value(GROUP(GUI), SETTING(GUI::NotificationBackgroundColor)).value<QColor>());
|
||||
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();
|
||||
@ -804,10 +801,8 @@ 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_grpNotifications->isChecked());
|
||||
m_settings->setValue(GROUP(GUI), GUI::EnableNotifications, m_ui->m_grpBaseNotifications->isChecked());
|
||||
m_settings->setValue(GROUP(GUI), GUI::FancyNotificationsPosition, static_cast<Qt::Corner>(m_ui->m_cmbNotificationPosition->itemData(m_ui->m_cmbNotificationPosition->currentIndex()).toInt()));
|
||||
m_settings->setValue(GROUP(GUI), GUI::NotificationBackgroundColor, m_ui->m_lblNotificationColor->color());
|
||||
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.
|
||||
QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString();
|
||||
@ -841,7 +836,6 @@ void FormSettings::saveInterface() {
|
||||
|
||||
qApp->mainForm()->tabWidget()->checkTabBarVisibility();
|
||||
qApp->mainForm()->tabWidget()->feedMessageViewer()->refreshVisualProperties();
|
||||
qApp->notification()->loadSettings();
|
||||
}
|
||||
|
||||
bool FormSettings::eventFilter(QObject *obj, QEvent *e) {
|
||||
|
@ -62,7 +62,6 @@ class FormSettings : public QDialog {
|
||||
void loadInterface();
|
||||
void saveInterface();
|
||||
void onSkinSelected(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void selectNewNotificationColor();
|
||||
|
||||
void loadDownloads();
|
||||
void saveDownloads();
|
||||
|
@ -88,7 +88,7 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QStackedWidget" name="m_stackedSettings">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_pageGeneral">
|
||||
<layout class="QFormLayout" name="formLayout_5">
|
||||
@ -470,7 +470,7 @@ Authors of this application are NOT responsible for lost data.</string>
|
||||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_tabIconSkin">
|
||||
<attribute name="title">
|
||||
@ -613,7 +613,14 @@ Authors of this application are NOT responsible for lost data.</string>
|
||||
<string>Tray area && notifications</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="m_checkEnableNotifications">
|
||||
<property name="text">
|
||||
<string>Enable notifications</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="m_grpTray">
|
||||
<property name="title">
|
||||
<string>Tray icon</string>
|
||||
@ -642,79 +649,14 @@ Authors of this application are NOT responsible for lost data.</string>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QGroupBox" name="m_grpBaseNotifications">
|
||||
<property name="title">
|
||||
<string>Enable notifications</string>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="m_checkEnableDBusNotifications">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
<property name="text">
|
||||
<string>Enable D-Bus notifications</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_16">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_grpNotifications">
|
||||
<property name="title">
|
||||
<string>Fancy && modern popup notifications (This uses OS native notifications via D-Bus if available.)</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_23">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="m_lblNotificationPosition">
|
||||
<property name="text">
|
||||
<string>Notification position</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="m_cmbNotificationPosition"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Background color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_17">
|
||||
<item>
|
||||
<widget class="ColorLabel" name="m_lblNotificationColor">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="m_btnChangeNotificationColor">
|
||||
<property name="text">
|
||||
<string>Change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -1667,11 +1609,6 @@ Authors of this application are NOT responsible for lost data.</string>
|
||||
<header>toolbareditor.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ColorLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>colorlabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>m_cmbDatabaseDriver</tabstop>
|
||||
@ -1811,38 +1748,6 @@ Authors of this application are NOT responsible for lost data.</string>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_grpNotifications</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>m_lblNotificationPosition</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>625</x>
|
||||
<y>77</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>326</x>
|
||||
<y>84</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_grpNotifications</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>m_cmbNotificationPosition</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>625</x>
|
||||
<y>77</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>696</x>
|
||||
<y>84</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_rbDownloadsAskEachFile</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
@ -1859,21 +1764,5 @@ Authors of this application are NOT responsible for lost data.</string>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>m_grpBaseNotifications</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>m_grpNotifications</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>624</x>
|
||||
<y>82</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>624</x>
|
||||
<y>89</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
@ -24,23 +24,15 @@
|
||||
#include "miscellaneous/textfactory.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
#include <Carbon/Carbon.h>
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <QtDBus>
|
||||
#endif
|
||||
|
||||
|
||||
Notification::Notification() : QWidget(0), m_title(QString()), m_text(QString()), m_icon(QPixmap()), m_screen(-1),
|
||||
m_width(-1), m_height(-1), m_padding(5), m_widgetMargin(2 * m_padding), m_timerId(0), m_clickTarget(NULL),
|
||||
m_clickSlot(NULL) {
|
||||
Notification::Notification(QObject *parent) : QObject(parent), m_title(QString()), m_text(QString()), m_icon(QPixmap()),
|
||||
m_timerId(0), m_clickTarget(NULL), m_clickSlot(NULL) {
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
m_dBusActiveNotification = 0;
|
||||
@ -62,16 +54,13 @@ Notification::Notification() : QWidget(0), m_title(QString()), m_text(QString())
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
setupWidget();
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
Notification::~Notification() {
|
||||
qDebug("Destroying Notification instance.");
|
||||
}
|
||||
|
||||
bool Notification::areFancyNotificationsEnabled() {
|
||||
bool Notification::areDBusNotificationsEnabled() {
|
||||
return qApp->settings()->value(GROUP(GUI), SETTING(GUI::UseFancyNotifications)).toBool();
|
||||
}
|
||||
|
||||
@ -118,17 +107,7 @@ void Notification::notify(const QString &text, const QString &title, const QIcon
|
||||
}
|
||||
#endif
|
||||
|
||||
if (m_clickTarget != NULL && m_clickSlot != NULL) {
|
||||
// Connect invokation target.
|
||||
connect(this, SIGNAL(clicked()), m_clickTarget, m_clickSlot, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
// Show it.
|
||||
updateGeometries();
|
||||
|
||||
QTimer::singleShot(20, this, SLOT(show()));
|
||||
QTimer::singleShot(0, this, SLOT(repaint()));
|
||||
|
||||
m_timerId = startTimer(TRAY_ICON_BUBBLE_TIMEOUT);
|
||||
}
|
||||
|
||||
@ -138,13 +117,6 @@ void Notification::notify(const QString &text, const QString &title, QSystemTray
|
||||
}
|
||||
|
||||
void Notification::cancel() {
|
||||
hide();
|
||||
|
||||
if (m_clickTarget != NULL && m_clickSlot != NULL) {
|
||||
// Disconnect previous bubble click signalling.
|
||||
disconnect(this, SIGNAL(clicked()), m_clickTarget, m_clickSlot);
|
||||
}
|
||||
|
||||
m_clickSlot = NULL;
|
||||
m_clickTarget = NULL;
|
||||
|
||||
@ -153,6 +125,11 @@ void Notification::cancel() {
|
||||
}
|
||||
}
|
||||
|
||||
void Notification::timerEvent(QTimerEvent *event) {
|
||||
QObject::timerEvent(event);
|
||||
cancel();
|
||||
}
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
void Notification::notificationClosed(uint id, uint reason) {
|
||||
if (m_clickTarget != NULL && m_clickSlot != NULL && m_dBusActiveNotification == id && reason == 2) {
|
||||
@ -160,156 +137,3 @@ void Notification::notificationClosed(uint id, uint reason) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void Notification::updateGeometries() {
|
||||
// Calculate width and height of notification with given icon and text.
|
||||
QFont bold_font = font();
|
||||
bold_font.setBold(true);
|
||||
QFontMetrics bold_metrics(bold_font);
|
||||
|
||||
m_width = m_padding +
|
||||
m_icon.width() + m_padding + /* contents */ qMax(TextFactory::stringWidth(m_title, bold_metrics),
|
||||
TextFactory::stringWidth(m_text, fontMetrics())) +
|
||||
m_padding;
|
||||
m_height = m_padding +
|
||||
/* contents */
|
||||
qMax(m_icon.height(),
|
||||
TextFactory::stringHeight(m_title, bold_metrics) + m_padding + TextFactory::stringHeight(m_text, fontMetrics())) +
|
||||
m_padding;
|
||||
|
||||
// Calculate real position.
|
||||
int x, y;
|
||||
QRect screen_geometry = QApplication::desktop()->availableGeometry(m_screen);
|
||||
|
||||
switch (m_position) {
|
||||
case Qt::BottomLeftCorner:
|
||||
x = m_widgetMargin;
|
||||
y = screen_geometry.height() - m_widgetMargin - m_height;
|
||||
break;
|
||||
|
||||
case Qt::TopLeftCorner:
|
||||
x = m_widgetMargin;
|
||||
y = m_widgetMargin;
|
||||
break;
|
||||
|
||||
case Qt::TopRightCorner:
|
||||
x = screen_geometry.width() - m_widgetMargin - m_width;
|
||||
y = m_widgetMargin;
|
||||
break;
|
||||
|
||||
case Qt::BottomRightCorner:
|
||||
default:
|
||||
x = screen_geometry.width() - m_widgetMargin - m_width;
|
||||
y = screen_geometry.height() - m_widgetMargin - m_height;
|
||||
break;
|
||||
}
|
||||
|
||||
setGeometry(x, y, m_width, m_height);
|
||||
}
|
||||
|
||||
void Notification::paintEvent(QPaintEvent *event) {
|
||||
Q_UNUSED(event)
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setFont(font());
|
||||
|
||||
if (!underMouse()) {
|
||||
painter.setOpacity(0.88);
|
||||
}
|
||||
else {
|
||||
painter.setOpacity(0.97);
|
||||
}
|
||||
|
||||
// Draw background.
|
||||
painter.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::Qt4CompatiblePainting);
|
||||
painter.setBrush(m_backgroundColor);
|
||||
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.drawRoundedRect(0, 0, width(), height(), 5.0, 5.0);
|
||||
|
||||
// Draw icon.
|
||||
painter.drawPixmap(m_padding, m_padding, m_icon);
|
||||
|
||||
// Draw text.
|
||||
painter.setPen(Qt::black);
|
||||
|
||||
// Needed heighs/widths.
|
||||
int title_height = TextFactory::stringHeight(m_title, fontMetrics());
|
||||
int remaining_width = width() - m_padding - m_icon.width() - m_padding /* - here comes contents */ - m_padding;
|
||||
int remaining_height = height() - m_padding - title_height - m_padding /* - here comes contents */ - m_padding;
|
||||
|
||||
painter.drawText(m_padding + m_icon.width() + m_padding, m_padding + title_height + m_padding,
|
||||
remaining_width, remaining_height,
|
||||
Qt::AlignLeft, m_text);
|
||||
|
||||
// Draw heading.
|
||||
QFont font = painter.font();
|
||||
font.setBold(true);
|
||||
painter.setFont(font);
|
||||
|
||||
painter.drawText(m_padding + m_icon.width() + m_padding, m_padding,
|
||||
remaining_width, remaining_height,
|
||||
Qt::AlignHCenter | Qt::AlignTop, m_title);
|
||||
}
|
||||
|
||||
void Notification::mousePressEvent(QMouseEvent *event) {
|
||||
QWidget::mousePressEvent(event);
|
||||
emit clicked();
|
||||
cancel();
|
||||
}
|
||||
|
||||
void Notification::enterEvent(QEvent *event) {
|
||||
QWidget::enterEvent(event);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Notification::leaveEvent(QEvent *event) {
|
||||
QWidget::leaveEvent(event);
|
||||
repaint();
|
||||
}
|
||||
|
||||
void Notification::timerEvent(QTimerEvent *event) {
|
||||
QWidget::timerEvent(event);
|
||||
cancel();
|
||||
}
|
||||
|
||||
void Notification::loadSettings() {
|
||||
m_position = static_cast<Qt::Corner>(qApp->settings()->value(GROUP(GUI), SETTING(GUI::FancyNotificationsPosition)).toInt());
|
||||
m_backgroundColor = qApp->settings()->value(GROUP(GUI), SETTING(GUI::NotificationBackgroundColor)).value<QColor>();
|
||||
}
|
||||
|
||||
void Notification::setupWidget() {
|
||||
// Set window flags.
|
||||
Qt::WindowFlags window_flags = Qt::FramelessWindowHint | Qt::WindowSystemMenuHint |
|
||||
Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint;
|
||||
|
||||
window_flags |= Qt::WindowDoesNotAcceptFocus;
|
||||
|
||||
#if defined (Q_OS_MAC)
|
||||
window_flags |= Qt::SubWindow;
|
||||
#else
|
||||
window_flags |= Qt::Tool;
|
||||
#endif
|
||||
|
||||
setWindowFlags(window_flags);
|
||||
|
||||
// Set widget attributes.
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setAttribute(Qt::WA_X11DoNotAcceptFocus);
|
||||
setAttribute(Qt::WA_ShowWithoutActivating);
|
||||
|
||||
#if defined (Q_OS_MAC)
|
||||
winId();
|
||||
|
||||
int setAttr[] = {kHIWindowBitDoesNotHide, kHIWindowBitDoesNotCycle, kHIWindowBitNoShadow, 0};
|
||||
int clearAttr[] = {0};
|
||||
HIWindowChangeAttributes(qt_mac_window_for(this), setAttr, clearAttr);
|
||||
#endif
|
||||
|
||||
// Window will be meant to be on top, but should not steal focus.
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
QFont fon(font());
|
||||
fon.setPointSize(fon.pointSize() + 5);
|
||||
setFont(fon);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
#ifndef NOTIFICATION_H
|
||||
#define NOTIFICATION_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
@ -27,15 +27,16 @@
|
||||
class QDBusInterface;
|
||||
#endif
|
||||
|
||||
class Notification : public QWidget {
|
||||
// Wraps D-Bus notifications.
|
||||
class Notification : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructors.
|
||||
explicit Notification();
|
||||
explicit Notification(QObject *parent = 0);
|
||||
virtual ~Notification();
|
||||
|
||||
static bool areFancyNotificationsEnabled();
|
||||
static bool areDBusNotificationsEnabled();
|
||||
static bool areNotificationsEnabled();
|
||||
|
||||
public slots:
|
||||
@ -48,42 +49,18 @@ class Notification : public QWidget {
|
||||
// Cancels display of the notification.
|
||||
void cancel();
|
||||
|
||||
// Loads settings.
|
||||
void loadSettings();
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
public slots:
|
||||
void notificationClosed(uint id, uint reason);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void enterEvent(QEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
void timerEvent(QTimerEvent *event);
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
||||
private:
|
||||
void setupWidget();
|
||||
void updateGeometries();
|
||||
|
||||
QColor m_backgroundColor;
|
||||
QString m_title;
|
||||
QString m_text;
|
||||
QPixmap m_icon;
|
||||
|
||||
// Defaults to -1, which means "default" (primary) screen.
|
||||
int m_screen;
|
||||
Qt::Corner m_position;
|
||||
|
||||
// Is calculated according to contents.
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_padding;
|
||||
int m_widgetMargin;
|
||||
int m_timerId;
|
||||
|
||||
QObject *m_clickTarget;
|
||||
|
@ -134,6 +134,7 @@ int main(int argc, char *argv[]) {
|
||||
QTimer::singleShot(STARTUP_UPDATE_DELAY, application.system(), SLOT(checkForUpdatesOnStartup()));
|
||||
}
|
||||
|
||||
// Make sure that all download requests from web views are handled.
|
||||
QObject::connect(QWebEngineProfile::defaultProfile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
|
||||
qApp->downloadManager(), SLOT(download(QWebEngineDownloadItem*)));
|
||||
|
||||
|
@ -219,7 +219,7 @@ void Application::showGuiMessage(const QString &title, const QString &message,
|
||||
bool show_at_least_msgbox, const QIcon &custom_icon,
|
||||
QObject *invokation_target, const char *invokation_slot) {
|
||||
if (Notification::areNotificationsEnabled()) {
|
||||
if (Notification::areFancyNotificationsEnabled()) {
|
||||
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);
|
||||
|
@ -75,9 +75,6 @@ DVALUE(char*) GUI::SplitterFeedsDef = "";
|
||||
DKEY GUI::SplitterMessages = "splitter_messages";
|
||||
DVALUE(char*) GUI::SplitterMessagesDef = "";
|
||||
|
||||
DKEY GUI::NotificationBackgroundColor = "notification_background_color";
|
||||
DVALUE(QColor) GUI::NotificationBackgroundColorDef = QColor(220, 220, 220);
|
||||
|
||||
DKEY GUI::ToolbarStyle = "toolbar_style";
|
||||
DVALUE(Qt::ToolButtonStyle) GUI::ToolbarStyleDef = Qt::ToolButtonIconOnly;
|
||||
|
||||
@ -123,9 +120,6 @@ DVALUE(bool) GUI::EnableNotificationsDef = true;
|
||||
DKEY GUI::UseFancyNotifications = "use_fancy_notifications";
|
||||
DVALUE(bool) GUI::UseFancyNotificationsDef = true;
|
||||
|
||||
DKEY GUI::FancyNotificationsPosition = "fancy_notifications_position";
|
||||
DVALUE(Qt::Corner) GUI::FancyNotificationsPositionDef = Qt::BottomRightCorner;
|
||||
|
||||
DKEY GUI::TabCloseMiddleClick = "tab_close_mid_button";
|
||||
DVALUE(bool) GUI::TabCloseMiddleClickDef = true;
|
||||
|
||||
|
@ -92,9 +92,6 @@ namespace GUI {
|
||||
KEY SplitterMessages;
|
||||
VALUE(char*) SplitterMessagesDef;
|
||||
|
||||
KEY NotificationBackgroundColor;
|
||||
VALUE(QColor) NotificationBackgroundColorDef;
|
||||
|
||||
KEY ToolbarStyle;
|
||||
VALUE(Qt::ToolButtonStyle) ToolbarStyleDef;
|
||||
|
||||
@ -140,9 +137,6 @@ namespace GUI {
|
||||
KEY UseFancyNotifications;
|
||||
VALUE(bool) UseFancyNotificationsDef;
|
||||
|
||||
KEY FancyNotificationsPosition;
|
||||
VALUE(Qt::Corner) FancyNotificationsPositionDef;
|
||||
|
||||
KEY TabCloseMiddleClick;
|
||||
VALUE(bool) TabCloseMiddleClickDef;
|
||||
|
||||
|
@ -320,7 +320,7 @@ void DownloadItem::metaDataChanged() {
|
||||
void DownloadItem::downloadProgress(qint64 bytes_received, qint64 bytes_total) {
|
||||
QTime now = QTime::currentTime();
|
||||
|
||||
if (m_lastProgressTime.msecsTo(now) < 25) {
|
||||
if (m_lastProgressTime.isValid() && m_lastProgressTime.msecsTo(now) < 25) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user