From 92b982cf5382c6cf24632b816c4357e43a6ff130 Mon Sep 17 00:00:00 2001 From: reionwong Date: Fri, 24 Sep 2021 16:13:45 +0800 Subject: [PATCH] Improvement notification --- notificationd/qml/NotificationPopup.qml | 27 ++++++++++++++++--------- settings-daemon/language/language.cpp | 26 ++++++++++++++++++++++-- settings-daemon/theme/thememanager.cpp | 17 ++++++++++++++++ 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/notificationd/qml/NotificationPopup.qml b/notificationd/qml/NotificationPopup.qml index 2d37116..086caea 100644 --- a/notificationd/qml/NotificationPopup.qml +++ b/notificationd/qml/NotificationPopup.qml @@ -97,30 +97,39 @@ Window { visible: text elide: Text.ElideRight Layout.fillWidth: true + rightPadding: FishUI.Units.smallSpacing } Label { text: model.body visible: text + rightPadding: FishUI.Units.smallSpacing + maximumLineCount: 2 elide: Text.ElideRight + wrapMode: Text.Wrap Layout.fillWidth: true + // Layout.fillHeight: true + Layout.alignment: Qt.AlignVCenter } Item { Layout.fillHeight: true } } - - Image { - width: 24 - height: 24 - source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark" : "light") + "/close.svg" - sourceSize: Qt.size(width, height) - visible: _mouseArea.containsMouse - Layout.alignment: Qt.AlignTop - } } +// Image { +// anchors.top: parent.top +// anchors.right: parent.right +// anchors.topMargin: FishUI.Units.smallSpacing / 2 +// anchors.rightMargin: FishUI.Units.smallSpacing +// width: 24 +// height: 24 +// source: "qrc:/images/" + (FishUI.Theme.darkMode ? "dark" : "light") + "/close.svg" +// sourceSize: Qt.size(width, height) +// visible: _mouseArea.containsMouse +// } + Timer { id: timer interval: 5000 diff --git a/settings-daemon/language/language.cpp b/settings-daemon/language/language.cpp index 7fb9052..a6fdbaf 100644 --- a/settings-daemon/language/language.cpp +++ b/settings-daemon/language/language.cpp @@ -20,6 +20,8 @@ #include "language.h" #include "languageadaptor.h" +#include + Language::Language(QObject *parent) : QObject(parent) , m_settings(new QSettings(QStringLiteral("cutefishos"), QStringLiteral("language"))) @@ -40,7 +42,27 @@ QString Language::languageCode() const void Language::setLanguage(const QString &code) { - m_settings->setValue("language", code); + if (m_settings->value("language").toString() == code) { + return; + } + m_settings->setValue("language", code); emit languageChanged(); -} \ No newline at end of file + + QDBusInterface iface("org.freedesktop.Notifications", + "/org/freedesktop/Notifications", + "org.freedesktop.Notifications", + QDBusConnection::sessionBus()); + if (iface.isValid()) { + QList args; + args << "cutefish-settings"; + args << ((unsigned int) 0); + args << "preferences-system"; + args << ""; + args << tr("The system language has been changed, please log out and log in"); + args << QStringList(); + args << QVariantMap(); + args << (int) 10; + iface.asyncCallWithArgumentList("Notify", args); + } +} diff --git a/settings-daemon/theme/thememanager.cpp b/settings-daemon/theme/thememanager.cpp index a4be565..786a667 100644 --- a/settings-daemon/theme/thememanager.cpp +++ b/settings-daemon/theme/thememanager.cpp @@ -197,6 +197,23 @@ void ThemeManager::setDevicePixelRatio(qreal ratio) m_settings->setValue("forceFontDPI", fontDpi); m_settings->sync(); applyXResources(); + + QDBusInterface iface("org.freedesktop.Notifications", + "/org/freedesktop/Notifications", + "org.freedesktop.Notifications", + QDBusConnection::sessionBus()); + if (iface.isValid()) { + QList args; + args << "cutefish-settings"; + args << ((unsigned int) 0); + args << "preferences-system"; + args << ""; + args << tr("Screen scaling needs to be re-login to take effect"); + args << QStringList(); + args << QVariantMap(); + args << (int) 10; + iface.asyncCallWithArgumentList("Notify", args); + } } QString ThemeManager::wallpaper()