From 2c7a8e12783f64487b924dde8aef199e6fa20b10 Mon Sep 17 00:00:00 2001 From: iaom Date: Wed, 12 Apr 2023 11:07:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=A4=A7=E9=87=8F?= =?UTF-8?q?=E7=9A=84=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF=E5=92=8C=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbus/org.ukui.NotificationServer.xml | 2 +- .../settings-manager.cpp | 2 +- libukui-notification/popup-notification.h | 1 - notification-ukcc-plugin/CMakeLists.txt | 4 +- .../{noticemenu.cpp => notice-menu.cpp} | 26 +-- .../{noticemenu.h => notice-menu.h} | 8 +- .../notification-ukcc-plugin.cpp | 180 +++++++++--------- .../notification-ukcc-plugin.h | 14 +- 8 files changed, 115 insertions(+), 122 deletions(-) rename notification-ukcc-plugin/{noticemenu.cpp => notice-menu.cpp} (89%) rename notification-ukcc-plugin/{noticemenu.h => notice-menu.h} (84%) diff --git a/dbus/org.ukui.NotificationServer.xml b/dbus/org.ukui.NotificationServer.xml index 546ca35..ff3dbeb 100644 --- a/dbus/org.ukui.NotificationServer.xml +++ b/dbus/org.ukui.NotificationServer.xml @@ -15,7 +15,7 @@ - + diff --git a/libukui-notification/notification-settings/settings-manager.cpp b/libukui-notification/notification-settings/settings-manager.cpp index 9ae8386..9d9bb68 100644 --- a/libukui-notification/notification-settings/settings-manager.cpp +++ b/libukui-notification/notification-settings/settings-manager.cpp @@ -77,7 +77,7 @@ void SettingsManagerPrivate::checkAndLoad() // 读取配置文件 QJsonObject settingsData = jsonDocument.object(); - QString version = settingsData.find("VERSION").value().toString(); + QString version = settingsData.value("VERSION").toString(); if (version != QString(NOTIFICATION_SETTINGS_VERSION)) { qDebug() << "Notification settings version is different, need update! configFile:" << version << " new:" << NOTIFICATION_SETTINGS_VERSION; updateSettingsFile(); diff --git a/libukui-notification/popup-notification.h b/libukui-notification/popup-notification.h index 98a4069..ba5e525 100644 --- a/libukui-notification/popup-notification.h +++ b/libukui-notification/popup-notification.h @@ -16,7 +16,6 @@ #include namespace UkuiNotification { class PopupNotificationPrivate; -//TODO 可以增加通知基类,实现多种类型通知 typedef QList> ActionList; class UKUINOTIFICATION_EXPORT PopupNotification { diff --git a/notification-ukcc-plugin/CMakeLists.txt b/notification-ukcc-plugin/CMakeLists.txt index f146d96..34d8367 100644 --- a/notification-ukcc-plugin/CMakeLists.txt +++ b/notification-ukcc-plugin/CMakeLists.txt @@ -2,8 +2,8 @@ set(notification-ukcc-plugin_LIB_SRCS notification-ukcc-plugin.cpp notification-ukcc-plugin.h - noticemenu.cpp - noticemenu.h) + notice-menu.cpp + notice-menu.h) find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Widgets LinguistTools REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets LinguistTools REQUIRED) diff --git a/notification-ukcc-plugin/noticemenu.cpp b/notification-ukcc-plugin/notice-menu.cpp similarity index 89% rename from notification-ukcc-plugin/noticemenu.cpp rename to notification-ukcc-plugin/notice-menu.cpp index 117c4d8..a1c2338 100644 --- a/notification-ukcc-plugin/noticemenu.cpp +++ b/notification-ukcc-plugin/notice-menu.cpp @@ -1,4 +1,4 @@ -#include "noticemenu.h" +#include "notice-menu.h" #include #include #include @@ -11,12 +11,12 @@ NoticeMenu::NoticeMenu(QWidget *parent) : setConnect(); } -void NoticeMenu::initStaus(UkuiNotification::SingleApplicationSettings *settings) +void NoticeMenu::initStatus(UkuiNotification::SingleApplicationSettings *settings) { m_voiceBtn->blockSignals(true); m_showBtn->blockSignals(true); m_detailBtn->blockSignals(true); - m_styleGrounp->blockSignals(true); + m_styleGroup->blockSignals(true); m_voiceBtn->setChecked(settings->allowSound()); m_detailBtn->setChecked(settings->showContentOnLockScreen()); @@ -31,12 +31,12 @@ void NoticeMenu::initStaus(UkuiNotification::SingleApplicationSettings *settings } else if (style == UkuiNotification::SettingsProperty::NoPopup) { styleId = 2; } - m_styleGrounp->button(styleId)->setChecked(true); + m_styleGroup->button(styleId)->setChecked(true); m_voiceBtn->blockSignals(false); m_showBtn->blockSignals(false); m_detailBtn->blockSignals(false); - m_styleGrounp->blockSignals(false); + m_styleGroup->blockSignals(false); } void NoticeMenu::setVoiceEnable(bool state) @@ -70,9 +70,9 @@ void NoticeMenu::setPopupStyle(UkuiNotification::SettingsProperty::Property styl } else if (style == UkuiNotification::SettingsProperty::NoPopup) { styleId = 2; } - m_styleGrounp->blockSignals(true); - m_styleGrounp->button(styleId)->setChecked(true); - m_styleGrounp->blockSignals(false); + m_styleGroup->blockSignals(true); + m_styleGroup->button(styleId)->setChecked(true); + m_styleGroup->blockSignals(false); } void NoticeMenu::initUi() @@ -102,21 +102,21 @@ void NoticeMenu::initUi() QLabel *styletitleLabel = new QLabel(tr("Notification Style"), this); styletitleLabel->setContentsMargins(24, 0, 0, 0); - m_styleGrounp = new QButtonGroup(this); + m_styleGroup = new QButtonGroup(this); QFrame *mutativeFrame = new QFrame(this); m_mutativeBtn = new QRadioButton; - m_styleGrounp->addButton(m_mutativeBtn, 0); + m_styleGroup->addButton(m_mutativeBtn, 0); setFrame(mutativeFrame, tr("Banner: Appears in the upper right corner of the screen, and disappears automatically"), m_mutativeBtn); QFrame *alwaysFrame = new QFrame(this); m_alwaysBtn = new QRadioButton; - m_styleGrounp->addButton(m_alwaysBtn, 1); + m_styleGroup->addButton(m_alwaysBtn, 1); setFrame(alwaysFrame, tr("Tip:It will be kept on the screen until it is closed"), m_alwaysBtn); QFrame *noneFrame = new QFrame(this); m_noneBtn = new QRadioButton; - m_styleGrounp->addButton(m_noneBtn, 2); + m_styleGroup->addButton(m_noneBtn, 2); setFrame(noneFrame, tr("None:Notifications will not be displayed on the screen, but will go to the notification center"), m_noneBtn); menuLyt->addWidget(voiceFrame); @@ -189,7 +189,7 @@ void NoticeMenu::setConnect() connect(m_voiceBtn, &KSwitchButton::stateChanged, this, &NoticeMenu::voiceSignals); connect(m_detailBtn, &KSwitchButton::stateChanged, this, &NoticeMenu::detailSignals); connect(m_showBtn, &KSwitchButton::stateChanged, this, &NoticeMenu::showSignals); - connect(m_styleGrounp, QOverload::of(&QButtonGroup::buttonClicked), this, &NoticeMenu::styleBtnSignals); + connect(m_styleGroup, QOverload::of(&QButtonGroup::buttonClicked), this, &NoticeMenu::styleBtnSignals); } void NoticeMenu::showEvent(QShowEvent *event) diff --git a/notification-ukcc-plugin/noticemenu.h b/notification-ukcc-plugin/notice-menu.h similarity index 84% rename from notification-ukcc-plugin/noticemenu.h rename to notification-ukcc-plugin/notice-menu.h index ad72804..0f4d598 100644 --- a/notification-ukcc-plugin/noticemenu.h +++ b/notification-ukcc-plugin/notice-menu.h @@ -16,9 +16,9 @@ class NoticeMenu : public QMenu { Q_OBJECT public: - NoticeMenu(QWidget *parent = nullptr); + explicit NoticeMenu(QWidget *parent = nullptr); - void initStaus(UkuiNotification::SingleApplicationSettings *settings); + void initStatus(UkuiNotification::SingleApplicationSettings *settings); void setVoiceEnable(bool state); void setDetailShowOnLockScreenEnable(bool state); void setShowOnLockScreenEnable(bool state); @@ -36,13 +36,13 @@ private: KSwitchButton *m_voiceBtn = nullptr; KSwitchButton *m_detailBtn = nullptr; KSwitchButton *m_showBtn = nullptr; - QButtonGroup *m_styleGrounp = nullptr; + QButtonGroup *m_styleGroup = nullptr; QRadioButton *m_noneBtn = nullptr; QRadioButton *m_mutativeBtn = nullptr; QRadioButton *m_alwaysBtn = nullptr; protected: - void showEvent(QShowEvent *event); + void showEvent(QShowEvent *event) override; Q_SIGNALS: void voiceSignals(bool checked); diff --git a/notification-ukcc-plugin/notification-ukcc-plugin.cpp b/notification-ukcc-plugin/notification-ukcc-plugin.cpp index 8aaae95..425028f 100644 --- a/notification-ukcc-plugin/notification-ukcc-plugin.cpp +++ b/notification-ukcc-plugin/notification-ukcc-plugin.cpp @@ -1,22 +1,20 @@ #include "notification-ukcc-plugin.h" -#include "noticemenu.h" +#include "notice-menu.h" #include -#include #include #include #include -#include #include #include #include #define THEME_QT_SCHEMA "org.ukui.style" -class ukToolButton : public QToolButton +class ToolButton : public QToolButton { public: - ukToolButton(QWidget *parent = nullptr): + explicit ToolButton(QWidget *parent = nullptr): QToolButton(parent) { } @@ -164,9 +162,9 @@ void Notice::initUi(QWidget *widget) m_noticeAppFrame->setMaximumSize(QSize(16777215, 16777215)); m_noticeAppFrame->setFrameShape(QFrame::Box); - m_applistverticalLayout = new QVBoxLayout(m_noticeAppFrame); - m_applistverticalLayout->setContentsMargins(0,0,0,0); - m_applistverticalLayout->setSpacing(0); + m_appListVerticalLayout = new QVBoxLayout(m_noticeAppFrame); + m_appListVerticalLayout->setContentsMargins(0, 0, 0, 0); + m_appListVerticalLayout->setSpacing(0); NoticeLayout->addWidget(m_noticeLabel); NoticeLayout->addWidget(m_getNoticeFrame); @@ -206,26 +204,26 @@ void Notice::initNotFaze(QFrame *frame) QHBoxLayout *autoLyt = new QHBoxLayout(autoOpenFrame); autoLyt->setContentsMargins(16, 0, 16, 0); QLabel *autoOpenLabel = new QLabel(tr("Automatically turn on"), autoOpenFrame); - m_openTimeHCombox = new QComboBox(autoOpenFrame); - m_openTimeHCombox->setObjectName("opentimehour"); - m_openTimeHCombox->setFixedWidth(64); - m_openTimeMCombox = new QComboBox(autoOpenFrame); - m_openTimeMCombox->setObjectName("opentimeminute"); - m_openTimeMCombox->setFixedWidth(64); - m_closeTimeHCombox = new QComboBox(autoOpenFrame); - m_closeTimeHCombox->setObjectName("closetimehour"); - m_closeTimeHCombox->setFixedWidth(64); - m_closeTimeMCombox = new QComboBox(autoOpenFrame); - m_closeTimeMCombox->setObjectName("closetimeminute"); - m_closeTimeMCombox->setFixedWidth(64); + m_openTimeHComboBox = new QComboBox(autoOpenFrame); + m_openTimeHComboBox->setObjectName("opentimehour"); + m_openTimeHComboBox->setFixedWidth(64); + m_openTimeMComboBox = new QComboBox(autoOpenFrame); + m_openTimeMComboBox->setObjectName("opentimeminute"); + m_openTimeMComboBox->setFixedWidth(64); + m_closeTimeHComboBox = new QComboBox(autoOpenFrame); + m_closeTimeHComboBox->setObjectName("closetimehour"); + m_closeTimeHComboBox->setFixedWidth(64); + m_closeTimeMComboBox = new QComboBox(autoOpenFrame); + m_closeTimeMComboBox->setObjectName("closetimeminute"); + m_closeTimeMComboBox->setFixedWidth(64); for (int i = 0; i < 24; i++) { - m_openTimeHCombox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); - m_closeTimeHCombox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); + m_openTimeHComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); + m_closeTimeHComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); } for (int i = 0; i < 60; i++) { - m_openTimeMCombox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); - m_closeTimeMCombox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); + m_openTimeMComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); + m_closeTimeMComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); } QLabel * label_1 = new QLabel(autoOpenFrame); @@ -242,13 +240,13 @@ void Notice::initNotFaze(QFrame *frame) autoLyt->addWidget(autoOpenLabel); autoLyt->addStretch(); - autoLyt->addWidget(m_openTimeHCombox); + autoLyt->addWidget(m_openTimeHComboBox); autoLyt->addWidget(label_2); - autoLyt->addWidget(m_openTimeMCombox); + autoLyt->addWidget(m_openTimeMComboBox); autoLyt->addWidget(label_1); - autoLyt->addWidget(m_closeTimeHCombox); + autoLyt->addWidget(m_closeTimeHComboBox); autoLyt->addWidget(label_3); - autoLyt->addWidget(m_closeTimeMCombox); + autoLyt->addWidget(m_closeTimeMComboBox); autoLyt->addSpacing(24); autoLyt->addWidget(m_autoOpenSwitchBtn); @@ -263,9 +261,9 @@ void Notice::initNotFaze(QFrame *frame) setFrame(fullScreenFrame, m_fullScreenSwitchBtn, tr("Automatically open in full screen mode")); QFrame *allowAlarmrRemindersFrame = new QFrame(frame); - m_allowAlarmrSwitchBtn= new KSwitchButton(); - m_allowAlarmrSwitchBtn->setObjectName("allowAlarmr"); - setFrame(allowAlarmrRemindersFrame, m_allowAlarmrSwitchBtn, tr("Allow automatic alarm reminders in Do Not Disturb mode")); + m_allowAlarmSwitchBtn= new KSwitchButton(); + m_allowAlarmSwitchBtn->setObjectName("allowAlarmr"); + setFrame(allowAlarmrRemindersFrame, m_allowAlarmSwitchBtn, tr("Allow automatic alarm reminders in Do Not Disturb mode")); notFazeLyt->addWidget(autoOpenFrame); notFazeLyt->addWidget(line_1); @@ -289,7 +287,6 @@ void Notice::setFrame(QFrame *frame, KSwitchButton *btn, QString str) hLyt->addWidget(label); hLyt->addStretch(); hLyt->addWidget(btn); - } @@ -303,24 +300,24 @@ void Notice::initSearchText() void Notice::initConnection() { if (m_globalSettings) { - connect(m_openTimeHCombox, QOverload::of(&QComboBox::currentIndexChanged), this, [&](const QString &text){ + connect(m_openTimeHComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, [&](const QString &text){ //Utils::buriedSettings(name(), "open time(hour) when auto turn on do not disturb mode", QString("settings"), text); - m_globalSettings->setScheduleTurnOnDNDTime(QTime().fromString(QString("%1%2%3").arg(text).arg(":").arg(m_openTimeMCombox->currentText()), "hh:mm")); + m_globalSettings->setScheduleTurnOnDNDTime(QTime::fromString(text + ":" + m_openTimeMComboBox->currentText(), "hh:mm")); }); - connect(m_openTimeMCombox, QOverload::of(&QComboBox::currentIndexChanged), this, [&](const QString &text){ + connect(m_openTimeMComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, [&](const QString &text){ //Utils::buriedSettings(name(), "open time(minute) when auto turn on do not disturb mode", QString("settings"), m_openTimeMCombox->currentText()); - m_globalSettings->setScheduleTurnOnDNDTime(QTime().fromString(QString("%1%2%3").arg(text).arg(":").arg(m_openTimeHCombox->currentText()), "mm:hh")); + m_globalSettings->setScheduleTurnOnDNDTime(QTime::fromString(text + m_openTimeHComboBox->currentText(), "mm:hh")); }); - connect(m_closeTimeHCombox, QOverload::of(&QComboBox::currentIndexChanged), this, [&](const QString &text){ + connect(m_closeTimeHComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, [&](const QString &text){ //Utils::buriedSettings(name(), "close time(hour) when auto turn on do not disturb mode", QString("settings"), m_closeTimeMCombox->currentText()); - m_globalSettings->setScheduleTurnOffDNDTime(QTime().fromString(QString("%1%2%3").arg(text).arg(":").arg(m_closeTimeMCombox->currentText()), "hh:mm")); + m_globalSettings->setScheduleTurnOffDNDTime(QTime::fromString(text + ":" + m_closeTimeMComboBox->currentText(), "hh:mm")); }); - connect(m_closeTimeMCombox, QOverload::of(&QComboBox::currentIndexChanged), this, [&](const QString &text){ + connect(m_closeTimeMComboBox, QOverload::of(&QComboBox::currentIndexChanged), this, [&](const QString &text){ //Utils::buriedSettings(name(), "close time(minute) when auto turn on do not disturb mode", QString("settings"), m_closeTimeMCombox->currentText()); - m_globalSettings->setScheduleTurnOffDNDTime(QTime().fromString(QString("%1%2%3").arg(text).arg(":").arg(m_closeTimeHCombox->currentText()), "mm:hh")); + m_globalSettings->setScheduleTurnOffDNDTime(QTime::fromString(text + ":" + m_closeTimeHComboBox->currentText(), "mm:hh")); }); connect(m_autoOpenSwitchBtn, &KSwitchButton::stateChanged, [&](bool state) { @@ -336,7 +333,7 @@ void Notice::initConnection() //Utils::buriedSettings(name(), "whether auto turn on do not disturb mode", QString("settings"), state ? "true" : "false"); m_globalSettings->setDNDWhileFullScreen(state); }); - connect(m_allowAlarmrSwitchBtn, &KSwitchButton::stateChanged, [&](bool state) { + connect(m_allowAlarmSwitchBtn, &KSwitchButton::stateChanged, [&](bool state) { //Utils::buriedSettings(name(), "whether auto turn on do not disturb mode", QString("settings"), state ? "true" : "false"); m_globalSettings->setNotifyAlarmWhileDND(state); }); @@ -354,22 +351,22 @@ void Notice::initConnection() setComBoxStatus(state); }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::scheduleTurnOnDNDTimeChanged, this, [&](QTime time) { - m_openTimeHCombox->blockSignals(true); - m_openTimeHCombox->setCurrentText(time.toString("hh")); - m_openTimeHCombox->blockSignals(false); + m_openTimeHComboBox->blockSignals(true); + m_openTimeHComboBox->setCurrentText(time.toString("hh")); + m_openTimeHComboBox->blockSignals(false); - m_openTimeMCombox->blockSignals(true); - m_openTimeMCombox->setCurrentText(time.toString("mm")); - m_openTimeMCombox->blockSignals(false); + m_openTimeMComboBox->blockSignals(true); + m_openTimeMComboBox->setCurrentText(time.toString("mm")); + m_openTimeMComboBox->blockSignals(false); }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::scheduleTurnOffDNDTimeChanged, this, [&](QTime time) { - m_closeTimeHCombox->blockSignals(true); - m_closeTimeHCombox->setCurrentText(time.toString("hh")); - m_closeTimeHCombox->blockSignals(false); + m_closeTimeHComboBox->blockSignals(true); + m_closeTimeHComboBox->setCurrentText(time.toString("hh")); + m_closeTimeHComboBox->blockSignals(false); - m_closeTimeMCombox->blockSignals(true); - m_closeTimeMCombox->setCurrentText(time.toString("mm")); - m_closeTimeMCombox->blockSignals(false); + m_closeTimeMComboBox->blockSignals(true); + m_closeTimeMComboBox->setCurrentText(time.toString("mm")); + m_closeTimeMComboBox->blockSignals(false); }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::DNDWhileMultiScreenChanged, this, [&](bool state) { m_multiScreenSwitchBtn->blockSignals(true); @@ -382,9 +379,9 @@ void Notice::initConnection() m_fullScreenSwitchBtn->blockSignals(false); }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::notifyAlarmWhileDNDChanged, this, [&](bool state) { - m_allowAlarmrSwitchBtn->blockSignals(true); - m_allowAlarmrSwitchBtn->setChecked(state); - m_allowAlarmrSwitchBtn->blockSignals(false); + m_allowAlarmSwitchBtn->blockSignals(true); + m_allowAlarmSwitchBtn->setChecked(state); + m_allowAlarmSwitchBtn->blockSignals(false); }); connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::receiveNotificationsFromAppsChanged, this, [&](bool state) { m_enableSwitchBtn->blockSignals(true); @@ -405,20 +402,20 @@ void Notice::initNoticeStatus() m_autoOpenSwitchBtn->blockSignals(false); QTime openTime = m_globalSettings->scheduleTurnOnDNDTime(); - m_openTimeHCombox->blockSignals(true); - m_openTimeHCombox->setCurrentText(openTime.toString("hh")); - m_openTimeHCombox->blockSignals(false); - m_openTimeMCombox->blockSignals(true); - m_openTimeMCombox->setCurrentText(openTime.toString("mm")); - m_openTimeMCombox->blockSignals(false); + m_openTimeHComboBox->blockSignals(true); + m_openTimeHComboBox->setCurrentText(openTime.toString("hh")); + m_openTimeHComboBox->blockSignals(false); + m_openTimeMComboBox->blockSignals(true); + m_openTimeMComboBox->setCurrentText(openTime.toString("mm")); + m_openTimeMComboBox->blockSignals(false); QTime closeTime = m_globalSettings->scheduleTurnOffDNDTime(); - m_closeTimeHCombox->blockSignals(true); - m_closeTimeHCombox->setCurrentText(closeTime.toString("hh")); - m_closeTimeHCombox->blockSignals(false); - m_closeTimeMCombox->blockSignals(true); - m_closeTimeMCombox->setCurrentText(closeTime.toString("mm")); - m_closeTimeMCombox->blockSignals(false); + m_closeTimeHComboBox->blockSignals(true); + m_closeTimeHComboBox->setCurrentText(closeTime.toString("hh")); + m_closeTimeHComboBox->blockSignals(false); + m_closeTimeMComboBox->blockSignals(true); + m_closeTimeMComboBox->setCurrentText(closeTime.toString("mm")); + m_closeTimeMComboBox->blockSignals(false); m_multiScreenSwitchBtn->blockSignals(true); m_multiScreenSwitchBtn->setChecked(m_globalSettings->DNDWhileMultiScreen()); @@ -426,9 +423,9 @@ void Notice::initNoticeStatus() m_fullScreenSwitchBtn->blockSignals(true); m_fullScreenSwitchBtn->setChecked(m_globalSettings->DNDWhileFullScreen()); m_fullScreenSwitchBtn->blockSignals(false); - m_allowAlarmrSwitchBtn->blockSignals(true); - m_allowAlarmrSwitchBtn->setChecked(m_globalSettings->notifyAlarmWhileDND()); - m_allowAlarmrSwitchBtn->blockSignals(false); + m_allowAlarmSwitchBtn->blockSignals(true); + m_allowAlarmSwitchBtn->setChecked(m_globalSettings->notifyAlarmWhileDND()); + m_allowAlarmSwitchBtn->blockSignals(false); m_enableSwitchBtn->blockSignals(true); m_enableSwitchBtn->setChecked(m_globalSettings->receiveNotificationsFromApps()); m_enableSwitchBtn->blockSignals(false); @@ -463,9 +460,6 @@ void Notice::initItemUi(const QString &desktopPath, UkuiNotification::SingleAppl QLabel *iconLabel = new QLabel(baseWidget); iconLabel->setFixedSize(32, 32); - if (fileName == "ukui-flash-disk") - iconName = "drive-removable-media-usb"; - setAppIcon(iconLabel, iconName); connect(m_themeSetting, &QGSettings::changed, [&](const QString &key){ if (key == "iconThemeName") @@ -479,7 +473,7 @@ void Notice::initItemUi(const QString &desktopPath, UkuiNotification::SingleAppl QLabel *nameLabel = new QLabel(baseWidget); nameLabel->setText(localName); - ukToolButton *setBtn = new ukToolButton(baseWidget); + ToolButton *setBtn = new ToolButton(baseWidget); setBtn->setProperty("useButtonPalette", true); setBtn->setPopupMode(QToolButton::InstantPopup); setBtn->setFixedSize(QSize(36, 36)); @@ -496,15 +490,15 @@ void Notice::initItemUi(const QString &desktopPath, UkuiNotification::SingleAppl devHorLayout->addWidget(setBtn); devHorLayout->addWidget(appSwitch); - m_applistverticalLayout->addWidget(baseWidget); - if (m_applistverticalLayout->count() >= 2) { + m_appListVerticalLayout->addWidget(baseWidget); + if (m_appListVerticalLayout->count() >= 2) { QFrame *line = new QFrame(m_pluginWidget); line->setMinimumSize(QSize(0, 1)); line->setMaximumSize(QSize(16777215, 1)); line->setLineWidth(0); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); - m_applistverticalLayout->insertWidget(m_applistverticalLayout->count() - 1, line); + m_appListVerticalLayout->insertWidget(m_appListVerticalLayout->count() - 1, line); } @@ -513,7 +507,7 @@ void Notice::initItemUi(const QString &desktopPath, UkuiNotification::SingleAppl appSwitch->blockSignals(false); menu->blockSignals(true); - menu->initStaus(settings); + menu->initStatus(settings); menu->blockSignals(false); connect(appSwitch, &KSwitchButton::stateChanged, [=](bool state) { @@ -586,13 +580,13 @@ void Notice::initItemUi(const QString &desktopPath, UkuiNotification::SingleAppl void Notice::setAppIcon(QLabel *iconlabel, const QString &icon) { - QFileInfo iconfile(QString("/usr/share/pixmaps/"+ icon + ".png")); + QFileInfo iconFile(QString("/usr/share/pixmaps/" + icon + ".png")); QPixmap pixmap; - QIcon currenticon = QIcon::fromTheme(icon); - if (!currenticon.isNull()) { - pixmap = currenticon.pixmap(QSize(32, 32)); - } else if (iconfile.exists()) { - pixmap = QPixmap(iconfile.filePath()).scaled(32, 32); + QIcon currentIcon = QIcon::fromTheme(icon); + if (!currentIcon.isNull()) { + pixmap = currentIcon.pixmap(QSize(32, 32)); + } else if (iconFile.exists()) { + pixmap = QPixmap(iconFile.filePath()).scaled(32, 32); } else { pixmap = QPixmap(QString(":/img/plugins/autoboot/desktop.png")); } @@ -606,16 +600,16 @@ void Notice::setHiddenNoticeApp(bool status) void Notice::setComBoxStatus(bool status) { - m_openTimeHCombox->setEnabled(status); - m_closeTimeHCombox->setEnabled(status); - m_openTimeMCombox->setEnabled(status); - m_closeTimeMCombox->setEnabled(status); + m_openTimeHComboBox->setEnabled(status); + m_closeTimeHComboBox->setEnabled(status); + m_openTimeMComboBox->setEnabled(status); + m_closeTimeMComboBox->setEnabled(status); } -void ukToolButton::paintEvent(QPaintEvent *event) +void ToolButton::paintEvent(QPaintEvent *event) { - QPalette paltte; - paltte.setColor(QPalette::Button, paltte.base().color()); - this->setPalette(paltte); + QPalette palette; + palette.setColor(QPalette::Button, palette.base().color()); + this->setPalette(palette); QToolButton::paintEvent(event); } diff --git a/notification-ukcc-plugin/notification-ukcc-plugin.h b/notification-ukcc-plugin/notification-ukcc-plugin.h index 81dbffd..e56f248 100644 --- a/notification-ukcc-plugin/notification-ukcc-plugin.h +++ b/notification-ukcc-plugin/notification-ukcc-plugin.h @@ -36,7 +36,7 @@ public: int pluginTypes() Q_DECL_OVERRIDE; QWidget * pluginUi() Q_DECL_OVERRIDE; const QString name() const Q_DECL_OVERRIDE; - QString translationPath() const; + QString translationPath() const override; bool isShowOnHomePage() const Q_DECL_OVERRIDE; QIcon icon() const Q_DECL_OVERRIDE; bool isEnable() const Q_DECL_OVERRIDE; @@ -71,17 +71,17 @@ private: KSwitchButton *m_autoOpenSwitchBtn = nullptr; KSwitchButton *m_multiScreenSwitchBtn = nullptr; KSwitchButton *m_fullScreenSwitchBtn = nullptr; - KSwitchButton *m_allowAlarmrSwitchBtn = nullptr; + KSwitchButton *m_allowAlarmSwitchBtn = nullptr; KSwitchButton *m_enableSwitchBtn = nullptr; - QComboBox *m_openTimeHCombox = nullptr; - QComboBox *m_openTimeMCombox = nullptr; - QComboBox *m_closeTimeHCombox = nullptr; - QComboBox *m_closeTimeMCombox = nullptr; + QComboBox *m_openTimeHComboBox = nullptr; + QComboBox *m_openTimeMComboBox = nullptr; + QComboBox *m_closeTimeHComboBox = nullptr; + QComboBox *m_closeTimeMComboBox = nullptr; QGSettings *m_themeSetting = nullptr; - QVBoxLayout *m_applistverticalLayout = nullptr; + QVBoxLayout *m_appListVerticalLayout = nullptr; UkuiNotification::NotificationGlobalSettings *m_globalSettings = nullptr;