opacity support for notifications
This commit is contained in:
parent
700b932cd8
commit
d2c94992e5
@ -15,9 +15,8 @@ using namespace std::chrono_literals;
|
|||||||
|
|
||||||
BaseToastNotification::BaseToastNotification(QWidget* parent) : QDialog(parent), m_timerId(-1) {
|
BaseToastNotification::BaseToastNotification(QWidget* parent) : QDialog(parent), m_timerId(-1) {
|
||||||
setAttribute(Qt::WidgetAttribute::WA_ShowWithoutActivating);
|
setAttribute(Qt::WidgetAttribute::WA_ShowWithoutActivating);
|
||||||
setFixedWidth(qApp->settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsWidth)).toInt());
|
// setFixedWidth(qApp->settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsWidth)).toInt());
|
||||||
setFocusPolicy(Qt::FocusPolicy::NoFocus);
|
setFocusPolicy(Qt::FocusPolicy::NoFocus);
|
||||||
|
|
||||||
setAttribute(Qt::WidgetAttribute::WA_DeleteOnClose, false);
|
setAttribute(Qt::WidgetAttribute::WA_DeleteOnClose, false);
|
||||||
|
|
||||||
setWindowFlags(
|
setWindowFlags(
|
||||||
|
@ -31,7 +31,7 @@ QString ToastNotificationsManager::textForPosition(ToastNotificationsManager::No
|
|||||||
|
|
||||||
ToastNotificationsManager::ToastNotificationsManager(QObject* parent)
|
ToastNotificationsManager::ToastNotificationsManager(QObject* parent)
|
||||||
: QObject(parent), m_position(ToastNotificationsManager::NotificationPosition::TopRight), m_screen(0), m_margins(0),
|
: QObject(parent), m_position(ToastNotificationsManager::NotificationPosition::TopRight), m_screen(0), m_margins(0),
|
||||||
m_articleListNotification(nullptr) {
|
m_width(0), m_opacity(0.0), m_articleListNotification(nullptr) {
|
||||||
resetNotifications(false);
|
resetNotifications(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,8 +65,8 @@ void ToastNotificationsManager::resetNotifications(bool reload_existing_notifica
|
|||||||
.value<ToastNotificationsManager::NotificationPosition>();
|
.value<ToastNotificationsManager::NotificationPosition>();
|
||||||
m_screen = qApp->settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsScreen)).toInt();
|
m_screen = qApp->settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsScreen)).toInt();
|
||||||
m_margins = qApp->settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsMargin)).toInt();
|
m_margins = qApp->settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsMargin)).toInt();
|
||||||
|
m_opacity = qApp->settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsOpacity)).toDouble();
|
||||||
auto notif_width = qApp->settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsWidth)).toInt();
|
m_width = qApp->settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsWidth)).toInt();
|
||||||
|
|
||||||
if (reload_existing_notifications) {
|
if (reload_existing_notifications) {
|
||||||
auto notif = m_activeNotifications;
|
auto notif = m_activeNotifications;
|
||||||
@ -76,8 +76,6 @@ void ToastNotificationsManager::resetNotifications(bool reload_existing_notifica
|
|||||||
while (!notif.isEmpty()) {
|
while (!notif.isEmpty()) {
|
||||||
BaseToastNotification* one_notif = notif.takeLast();
|
BaseToastNotification* one_notif = notif.takeLast();
|
||||||
|
|
||||||
one_notif->setFixedWidth(notif_width);
|
|
||||||
|
|
||||||
processNotification(one_notif);
|
processNotification(one_notif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,6 +90,9 @@ void ToastNotificationsManager::clear(bool delete_from_memory) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ToastNotificationsManager::processNotification(BaseToastNotification* notif) {
|
void ToastNotificationsManager::processNotification(BaseToastNotification* notif) {
|
||||||
|
notif->setWindowOpacity(m_opacity);
|
||||||
|
notif->setFixedWidth(m_width);
|
||||||
|
|
||||||
notif->show();
|
notif->show();
|
||||||
|
|
||||||
auto* screen = moveToProperScreen(notif);
|
auto* screen = moveToProperScreen(notif);
|
||||||
|
@ -69,6 +69,8 @@ class ToastNotificationsManager : public QObject {
|
|||||||
NotificationPosition m_position;
|
NotificationPosition m_position;
|
||||||
int m_screen;
|
int m_screen;
|
||||||
int m_margins;
|
int m_margins;
|
||||||
|
int m_width;
|
||||||
|
double m_opacity;
|
||||||
|
|
||||||
// List of all displayed notifications, newest notifications are in the beginning of the list
|
// List of all displayed notifications, newest notifications are in the beginning of the list
|
||||||
// and oldest at the end.
|
// and oldest at the end.
|
||||||
|
@ -30,6 +30,7 @@ SettingsNotifications::SettingsNotifications(Settings* settings, QWidget* parent
|
|||||||
connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings);
|
connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings);
|
||||||
connect(m_ui.m_sbMargin, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings);
|
connect(m_ui.m_sbMargin, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings);
|
||||||
connect(m_ui.m_sbWidth, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings);
|
connect(m_ui.m_sbWidth, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings);
|
||||||
|
connect(m_ui.m_sbOpacity, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::dirtifySettings);
|
||||||
|
|
||||||
connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::showScreenInfo);
|
connect(m_ui.m_sbScreen, QOverload<int>::of(&QSpinBox::valueChanged), this, &SettingsNotifications::showScreenInfo);
|
||||||
|
|
||||||
@ -64,6 +65,7 @@ void SettingsNotifications::loadSettings() {
|
|||||||
m_ui.m_sbScreen->setValue(settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsScreen)).toInt());
|
m_ui.m_sbScreen->setValue(settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsScreen)).toInt());
|
||||||
m_ui.m_sbWidth->setValue(settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsWidth)).toInt());
|
m_ui.m_sbWidth->setValue(settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsWidth)).toInt());
|
||||||
m_ui.m_sbMargin->setValue(settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsMargin)).toInt());
|
m_ui.m_sbMargin->setValue(settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsMargin)).toInt());
|
||||||
|
m_ui.m_sbOpacity->setValue(settings()->value(GROUP(GUI), SETTING(GUI::ToastNotificationsOpacity)).toDouble() * 100);
|
||||||
|
|
||||||
m_ui.m_cbCustomNotificationsPosition
|
m_ui.m_cbCustomNotificationsPosition
|
||||||
->setCurrentIndex(m_ui.m_cbCustomNotificationsPosition
|
->setCurrentIndex(m_ui.m_cbCustomNotificationsPosition
|
||||||
@ -85,6 +87,7 @@ void SettingsNotifications::saveSettings() {
|
|||||||
settings()->setValue(GROUP(GUI), GUI::ToastNotificationsScreen, m_ui.m_sbScreen->value());
|
settings()->setValue(GROUP(GUI), GUI::ToastNotificationsScreen, m_ui.m_sbScreen->value());
|
||||||
settings()->setValue(GROUP(GUI), GUI::ToastNotificationsWidth, m_ui.m_sbWidth->value());
|
settings()->setValue(GROUP(GUI), GUI::ToastNotificationsWidth, m_ui.m_sbWidth->value());
|
||||||
settings()->setValue(GROUP(GUI), GUI::ToastNotificationsMargin, m_ui.m_sbMargin->value());
|
settings()->setValue(GROUP(GUI), GUI::ToastNotificationsMargin, m_ui.m_sbMargin->value());
|
||||||
|
settings()->setValue(GROUP(GUI), GUI::ToastNotificationsOpacity, m_ui.m_sbOpacity->value() / 100.0);
|
||||||
|
|
||||||
settings()->setValue(GROUP(GUI),
|
settings()->setValue(GROUP(GUI),
|
||||||
GUI::ToastNotificationsPosition,
|
GUI::ToastNotificationsPosition,
|
||||||
|
@ -76,31 +76,20 @@
|
|||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QComboBox" name="m_cbCustomNotificationsPosition"/>
|
<widget class="QComboBox" name="m_cbCustomNotificationsPosition"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="1" column="0">
|
||||||
<widget class="QSpinBox" name="m_sbScreen">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="value">
|
|
||||||
<number>99</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Screen</string>
|
<string>Width</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="buddy">
|
||||||
</item>
|
<cstring>m_sbWidth</cstring>
|
||||||
<item row="4" column="1">
|
|
||||||
<widget class="QLabel" name="m_lblScreenInfo">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QSpinBox" name="m_sbWidth">
|
<widget class="QSpinBox" name="m_sbWidth">
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string> px</string>
|
<string notr="true"> px</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>50</number>
|
<number>50</number>
|
||||||
@ -110,27 +99,67 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Width</string>
|
<string>Margins</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_sbMargin</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QSpinBox" name="m_sbMargin">
|
<widget class="QSpinBox" name="m_sbMargin">
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string> px</string>
|
<string notr="true"> px</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<number>100</number>
|
<number>100</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Margins</string>
|
<string>Screen</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_sbScreen</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QSpinBox" name="m_sbScreen">
|
||||||
|
<property name="value">
|
||||||
|
<number>99</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QLabel" name="m_lblScreenInfo">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QSpinBox" name="m_sbOpacity">
|
||||||
|
<property name="suffix">
|
||||||
|
<string notr="true"> %</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Opacity</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>m_sbOpacity</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -158,6 +187,13 @@
|
|||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>m_checkEnableNotifications</tabstop>
|
<tabstop>m_checkEnableNotifications</tabstop>
|
||||||
|
<tabstop>m_rbNativeNotifications</tabstop>
|
||||||
|
<tabstop>m_rbCustomNotifications</tabstop>
|
||||||
|
<tabstop>m_cbCustomNotificationsPosition</tabstop>
|
||||||
|
<tabstop>m_sbWidth</tabstop>
|
||||||
|
<tabstop>m_sbMargin</tabstop>
|
||||||
|
<tabstop>m_sbScreen</tabstop>
|
||||||
|
<tabstop>m_sbOpacity</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
|
@ -298,6 +298,9 @@ DVALUE(int) GUI::ToastNotificationsScreenDef = -1;
|
|||||||
DKEY GUI::ToastNotificationsMargin = "toast_notifications_margin";
|
DKEY GUI::ToastNotificationsMargin = "toast_notifications_margin";
|
||||||
DVALUE(int) GUI::ToastNotificationsMarginDef = NOTIFICATIONS_MARGIN;
|
DVALUE(int) GUI::ToastNotificationsMarginDef = NOTIFICATIONS_MARGIN;
|
||||||
|
|
||||||
|
DKEY GUI::ToastNotificationsOpacity = "toast_notifications_opacity";
|
||||||
|
DVALUE(double) GUI::ToastNotificationsOpacityDef = 0.9;
|
||||||
|
|
||||||
DKEY GUI::ToastNotificationsWidth = "toast_notifications_width";
|
DKEY GUI::ToastNotificationsWidth = "toast_notifications_width";
|
||||||
DVALUE(int) GUI::ToastNotificationsWidthDef = NOTIFICATIONS_WIDTH;
|
DVALUE(int) GUI::ToastNotificationsWidthDef = NOTIFICATIONS_WIDTH;
|
||||||
|
|
||||||
|
@ -231,6 +231,9 @@ namespace GUI {
|
|||||||
KEY ToastNotificationsMargin;
|
KEY ToastNotificationsMargin;
|
||||||
VALUE(int) ToastNotificationsMarginDef;
|
VALUE(int) ToastNotificationsMarginDef;
|
||||||
|
|
||||||
|
KEY ToastNotificationsOpacity;
|
||||||
|
VALUE(double) ToastNotificationsOpacityDef;
|
||||||
|
|
||||||
KEY ToastNotificationsWidth;
|
KEY ToastNotificationsWidth;
|
||||||
VALUE(int) ToastNotificationsWidthDef;
|
VALUE(int) ToastNotificationsWidthDef;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user