修复一些通知配置项接口的问题
This commit is contained in:
parent
9d60697046
commit
c9bcd67463
|
@ -96,7 +96,7 @@ set_target_properties(ukui-notification PROPERTIES
|
|||
install(TARGETS ukui-notification
|
||||
EXPORT ukui-notification
|
||||
PUBLIC_HEADER DESTINATION ${HEADERS_INSTALL_DIR}
|
||||
LIBRARY DESTINATION /usr/lib
|
||||
LIBRARY DESTINATION /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
|
||||
)
|
||||
install(EXPORT ukui-notification
|
||||
FILE ukui-notification-targets.cmake
|
||||
|
|
|
@ -178,7 +178,8 @@ bool NotificationClientPrivate::invokeAction(uint id, const QString &action_key)
|
|||
NotificationClient::NotificationClient(QObject *parent) : QObject(parent), d(new NotificationClientPrivate(this))
|
||||
{
|
||||
qRegisterMetaType<PopupNotification>("PopupNotification");
|
||||
qRegisterMetaType<UkuiNotification::PopupNotification>("UkuiNotification::PopupNotification");
|
||||
qRegisterMetaType<UkuiNotification::PopupNotification>("const UkuiNotification::PopupNotification&");
|
||||
qRegisterMetaType<UkuiNotification::ActionList>("ActionList");
|
||||
qmlRegisterUncreatableType<UkuiNotification::NotificationCloseReason>("org.ukui.notification.client", 1, 0, "NotificationCloseReason", "");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class ApplicationsSettingsPrivate
|
|||
{
|
||||
friend class ApplicationsSettings;
|
||||
private:
|
||||
ApplicationsSettingsHash m_cache;
|
||||
ApplicationsSettingsMap m_cache;
|
||||
QJsonObject m_settingsData;
|
||||
};
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ ApplicationsSettings::~ApplicationsSettings()
|
|||
}
|
||||
}
|
||||
|
||||
SingleApplicationSettings &ApplicationsSettings::creatSettings(const PopupNotification ¬ification)
|
||||
SingleApplicationSettings *ApplicationsSettings::creatSettings(const PopupNotification ¬ification)
|
||||
{
|
||||
QString desktopEntry = notification.desktopEntry();
|
||||
if(desktopEntry.isEmpty()) {
|
||||
|
@ -55,15 +55,14 @@ SingleApplicationSettings &ApplicationsSettings::creatSettings(const PopupNotifi
|
|||
if(d->m_cache.contains(desktopEntry)) {
|
||||
return d->m_cache[desktopEntry];
|
||||
}
|
||||
d->m_cache[desktopEntry].init(desktopEntry);
|
||||
return d->m_cache[desktopEntry];
|
||||
return d->m_cache.insert(desktopEntry, new SingleApplicationSettings(desktopEntry)).value();
|
||||
}
|
||||
|
||||
ApplicationsSettingsHash &ApplicationsSettings::getAllApplicationsSettings()
|
||||
ApplicationsSettingsMap &ApplicationsSettings::getAllApplicationsSettings()
|
||||
{
|
||||
for(const QString &desktopEntry : d->m_settingsData.keys()) {
|
||||
if(!d->m_cache.contains(desktopEntry)) {
|
||||
d->m_cache[desktopEntry].init(desktopEntry);
|
||||
d->m_cache.insert(desktopEntry, new SingleApplicationSettings(desktopEntry));
|
||||
}
|
||||
}
|
||||
return d->m_cache;
|
||||
|
@ -89,6 +88,11 @@ bool ApplicationsSettings::setAppSetting(const QString &appDesktopName, Settings
|
|||
|
||||
void ApplicationsSettings::clearCache()
|
||||
{
|
||||
ApplicationsSettingsMap::const_iterator i = d->m_cache.constBegin();
|
||||
while(i != d->m_cache.constEnd()) {
|
||||
++i;
|
||||
delete i.value();
|
||||
}
|
||||
d->m_cache.clear();
|
||||
}
|
||||
|
||||
|
@ -106,7 +110,6 @@ void ApplicationsSettings::settingsDataChanged()
|
|||
}
|
||||
}
|
||||
Q_EMIT settingsUpdated();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "single-application-settings.h"
|
||||
#include "popup-notification.h"
|
||||
namespace UkuiNotification{
|
||||
typedef QHash<QString, SingleApplicationSettings> ApplicationsSettingsHash;
|
||||
typedef QMap<QString, SingleApplicationSettings*> ApplicationsSettingsMap;
|
||||
class ApplicationsSettingsPrivate;
|
||||
/**
|
||||
* SingleApplicationSettings 工厂
|
||||
|
@ -21,8 +21,13 @@ public:
|
|||
static ApplicationsSettings *self();
|
||||
~ApplicationsSettings();
|
||||
|
||||
SingleApplicationSettings &creatSettings(const PopupNotification ¬ification);
|
||||
ApplicationsSettingsHash &getAllApplicationsSettings();
|
||||
/**
|
||||
* 获取某条通知的配置
|
||||
* @param notification 表示一条通知
|
||||
* @return 返回的指针不需要使用者回收
|
||||
*/
|
||||
SingleApplicationSettings *creatSettings(const PopupNotification ¬ification);
|
||||
ApplicationsSettingsMap &getAllApplicationsSettings();
|
||||
/**
|
||||
* @brief getAppSettings
|
||||
* 获取当前用户某个应用通知相关配置信息。
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#define NotificationSettingsPrivate_H
|
||||
|
||||
#include "settings-manager.h"
|
||||
#include <UkuiSearchAppInfoTable>
|
||||
#include <application-info.h>
|
||||
#include <QJsonObject>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QList>
|
||||
|
@ -47,15 +47,13 @@ private:
|
|||
/**
|
||||
* @brief getAppInfo
|
||||
* 从搜索应用数据库服务中获取desktop信息。
|
||||
* @param appInfo
|
||||
* appInfo中的key为QString类型的desktop文件路径,value为QStringList类型的数据集,目前依次包括local_name、icon,可扩展
|
||||
*/
|
||||
void getAppInfo(QMap<QString, QStringList> &appInfoMap);
|
||||
QStringList getAppInfo();
|
||||
|
||||
void initSettingsData(QJsonObject &data);
|
||||
|
||||
public Q_SLOTS:
|
||||
void desktopFileAdd(const QVector<UkuiSearch::AppInfoResult> &data);
|
||||
void desktopFileAdd(const QStringList &data);
|
||||
void desktopFileDelete(const QStringList &data);
|
||||
Q_SIGNALS:
|
||||
void settingsUpdateFinished();
|
||||
|
@ -65,7 +63,7 @@ private:
|
|||
void save2SettingsFile(const QJsonObject &jsonDocData);
|
||||
QJsonObject m_settingsData;
|
||||
QFileSystemWatcher *m_watcher = nullptr;
|
||||
UkuiSearch::AppInfoTable * m_appDataServiceClient = nullptr;
|
||||
UkuiSearch::ApplicationInfo * m_applicationInfo = nullptr;
|
||||
QJsonObject m_applicationDefaultSettings;
|
||||
};
|
||||
|
||||
|
|
|
@ -38,15 +38,11 @@ void SettingsManagerPrivate::init()
|
|||
m_watcher = new QFileSystemWatcher(this);
|
||||
connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &SettingsManagerPrivate::checkAndLoad);
|
||||
//TODO 应用数据服务接口更新中
|
||||
m_appDataServiceClient = new UkuiSearch::AppInfoTable(this);
|
||||
connect(m_appDataServiceClient, &UkuiSearch::AppInfoTable::DBOpenFailed, this, [&](){
|
||||
qWarning() << "SettingsManagerPrivate: app database server open failed! " << m_appDataServiceClient->lastError();
|
||||
});
|
||||
m_applicationInfo = new UkuiSearch::ApplicationInfo(this);
|
||||
if (qApp->property("IS_UKUI_NOTIFICATION_SERVICE").toBool()) {
|
||||
connect(m_appDataServiceClient, &UkuiSearch::AppInfoTable::appDBItems2BAdd, this,
|
||||
&SettingsManagerPrivate::desktopFileAdd);
|
||||
connect(m_applicationInfo, &UkuiSearch::ApplicationInfo::appDBItems2BAdd, this,&SettingsManagerPrivate::desktopFileAdd);
|
||||
}
|
||||
connect(m_appDataServiceClient, &UkuiSearch::AppInfoTable::appDBItems2BDelete, this, &SettingsManagerPrivate::desktopFileDelete);
|
||||
connect(m_applicationInfo, &UkuiSearch::ApplicationInfo::appDBItems2BDelete, this, &SettingsManagerPrivate::desktopFileDelete);
|
||||
checkAndLoad();
|
||||
}
|
||||
void SettingsManagerPrivate::checkAndLoad()
|
||||
|
@ -141,16 +137,11 @@ void SettingsManagerPrivate::updateSettingsFile()
|
|||
Q_EMIT settingsUpdateFinished();
|
||||
}
|
||||
|
||||
void SettingsManagerPrivate::getAppInfo(QMap<QString, QStringList> &appInfoMap)
|
||||
QStringList SettingsManagerPrivate::getAppInfo()
|
||||
{
|
||||
QVector<UkuiSearch::AppInfoResult> appInfoResults;
|
||||
if (!m_appDataServiceClient->getAppInfoResults(appInfoResults)) {
|
||||
qWarning() << "SettingsManagerPrivate: Error getAppInfoResults." << m_appDataServiceClient->lastError();
|
||||
return;
|
||||
}
|
||||
for (UkuiSearch::AppInfoResult &appInfo : appInfoResults) {
|
||||
appInfoMap.insert(appInfo.desktopPath, QStringList() << appInfo.appLocalName << appInfo.iconName);
|
||||
}
|
||||
QStringList info = m_applicationInfo->getInfo(UkuiSearch::ApplicationProperties{}).keys();
|
||||
qWarning() << info;
|
||||
return info;
|
||||
}
|
||||
|
||||
void SettingsManagerPrivate::initSettingsData(QJsonObject &data)
|
||||
|
@ -167,20 +158,17 @@ void SettingsManagerPrivate::initSettingsData(QJsonObject &data)
|
|||
|
||||
//应用设置
|
||||
QJsonObject applicationsSettings;
|
||||
QMap<QString, QStringList> appInfoMap;
|
||||
getAppInfo(appInfoMap);
|
||||
for (auto info = appInfoMap.begin(); info != appInfoMap.end(); info++) {
|
||||
applicationsSettings.insert(info.key(), m_applicationDefaultSettings);
|
||||
for (const QString &desktopFile : getAppInfo()) {
|
||||
applicationsSettings.insert(desktopFile, m_applicationDefaultSettings);
|
||||
}
|
||||
data.insert(QStringLiteral("Applications"), applicationsSettings);
|
||||
//TODO: 配置文件中增加应用local Name?
|
||||
}
|
||||
|
||||
void SettingsManagerPrivate::desktopFileAdd(const QVector<UkuiSearch::AppInfoResult> &data)
|
||||
void SettingsManagerPrivate::desktopFileAdd(const QStringList &data)
|
||||
{
|
||||
QJsonObject applicationsSettings = m_settingsData.value(QStringLiteral("Applications")).toObject();
|
||||
for (const UkuiSearch::AppInfoResult &ri : data) {
|
||||
applicationsSettings.insert(ri.desktopPath, m_applicationDefaultSettings);
|
||||
for (const QString &desktopPath : data) {
|
||||
applicationsSettings.insert(desktopPath, m_applicationDefaultSettings);
|
||||
}
|
||||
m_settingsData.insert(QStringLiteral("Applications"), applicationsSettings);
|
||||
|
||||
|
@ -198,7 +186,7 @@ void SettingsManagerPrivate::desktopFileDelete(const QStringList &data)
|
|||
if (data.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (qApp->property("IS_UKUI_NOTIFICATION_SERVICE").toBool()) {
|
||||
if (qApp->property("IS_UKUI_NOTIFICATION_SERVER").toBool()) {
|
||||
QJsonObject applicationsSettings = m_settingsData.value(QStringLiteral("Applications")).toObject();
|
||||
for (const QString &app : data) {
|
||||
applicationsSettings.remove(app);
|
||||
|
|
|
@ -26,7 +26,6 @@ using namespace UkuiNotification;
|
|||
|
||||
SingleApplicationSettingsPrivate::SingleApplicationSettingsPrivate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SingleApplicationSettingsPrivate::SingleApplicationSettingsPrivate(const SingleApplicationSettingsPrivate &other)
|
||||
|
@ -44,23 +43,27 @@ SingleApplicationSettings::SingleApplicationSettings(const QString &desktopEntry
|
|||
: QObject(parent)
|
||||
, d(new SingleApplicationSettingsPrivate)
|
||||
{
|
||||
init(desktopEntry);
|
||||
d->m_desktopEntry = desktopEntry;
|
||||
init();
|
||||
}
|
||||
|
||||
SingleApplicationSettings::SingleApplicationSettings(const SingleApplicationSettings &other)
|
||||
: d(new SingleApplicationSettingsPrivate(*other.d))
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
SingleApplicationSettings &SingleApplicationSettings::operator=(const SingleApplicationSettings &other)
|
||||
{
|
||||
*d = *other.d;
|
||||
init();
|
||||
return *this;
|
||||
}
|
||||
SingleApplicationSettings &SingleApplicationSettings::operator=(SingleApplicationSettings &&other) Q_DECL_NOEXCEPT
|
||||
{
|
||||
d = other.d;
|
||||
other.d = nullptr;
|
||||
init();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -72,10 +75,9 @@ SingleApplicationSettings::~SingleApplicationSettings()
|
|||
}
|
||||
}
|
||||
|
||||
void SingleApplicationSettings::init(const QString &desktopEntry)
|
||||
void SingleApplicationSettings::init()
|
||||
{
|
||||
d->m_desktopEntry = desktopEntry;
|
||||
d->m_settings = ApplicationsSettings::self()->getAppSettings(desktopEntry);
|
||||
d->m_settings = ApplicationsSettings::self()->getAppSettings(d->m_desktopEntry);
|
||||
if(d->m_desktopEntry != QStringLiteral("default") && !d->m_desktopEntry.isEmpty()) {
|
||||
connect(ApplicationsSettings::self(), &ApplicationsSettings::applicationUninstalled, this, &SingleApplicationSettings::appUninstalled);
|
||||
connect(ApplicationsSettings::self(), &ApplicationsSettings::settingsUpdated, this, &SingleApplicationSettings::settingsDataChanged);
|
||||
|
@ -118,25 +120,25 @@ void SingleApplicationSettings::settingsDataChanged()
|
|||
QJsonValue value = data.value(name);
|
||||
if(d->m_settings.value(name) != value) {
|
||||
d->m_settings.insert(name, value);
|
||||
}
|
||||
switch (property) {
|
||||
case SettingsProperty::AllowNotify:
|
||||
Q_EMIT allowNotifyChanged(value.toVariant().toBool());
|
||||
break;
|
||||
case SettingsProperty::AllowSound:
|
||||
Q_EMIT allowSoundChanged(value.toVariant().toBool());
|
||||
break;
|
||||
case SettingsProperty::ShowContentOnLockScreen:
|
||||
Q_EMIT showContentOnLockScreenChanged(value.toVariant().toBool());
|
||||
break;
|
||||
case SettingsProperty::ShowNotificationOnLockScreen:
|
||||
Q_EMIT showNotificationOnLockScreenChanged(value.toVariant().toBool());
|
||||
break;
|
||||
case SettingsProperty::PopupStyle:
|
||||
Q_EMIT popupStyleChanged(SettingsPropertiesInfo::fromName(value.toString()).property());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (property) {
|
||||
case SettingsProperty::AllowNotify:
|
||||
Q_EMIT allowNotifyChanged(value.toVariant().toBool());
|
||||
break;
|
||||
case SettingsProperty::AllowSound:
|
||||
Q_EMIT allowSoundChanged(value.toVariant().toBool());
|
||||
break;
|
||||
case SettingsProperty::ShowContentOnLockScreen:
|
||||
Q_EMIT showContentOnLockScreenChanged(value.toVariant().toBool());
|
||||
break;
|
||||
case SettingsProperty::ShowNotificationOnLockScreen:
|
||||
Q_EMIT showNotificationOnLockScreenChanged(value.toVariant().toBool());
|
||||
break;
|
||||
case SettingsProperty::PopupStyle:
|
||||
Q_EMIT popupStyleChanged(SettingsPropertiesInfo::fromName(value.toString()).property());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,6 +152,7 @@ void SingleApplicationSettings::appUninstalled(const QString &desktopEntry)
|
|||
|
||||
void SingleApplicationSettings::setAllowNotify(bool enable)
|
||||
{
|
||||
qWarning() << d->m_desktopEntry << enable;
|
||||
ApplicationsSettings::self()->setAppSetting(d->m_desktopEntry, SettingsProperty::AllowNotify, enable);
|
||||
}
|
||||
|
||||
|
@ -173,5 +176,10 @@ void SingleApplicationSettings::setPopupStyle(SettingsProperty::Property style)
|
|||
ApplicationsSettings::self()->setAppSetting(d->m_desktopEntry, SettingsProperty::PopupStyle, style);
|
||||
}
|
||||
|
||||
QString SingleApplicationSettings::desktopEntry() const
|
||||
{
|
||||
return d->m_desktopEntry;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ public:
|
|||
SingleApplicationSettings &operator=(SingleApplicationSettings &&other) Q_DECL_NOEXCEPT;
|
||||
~SingleApplicationSettings();
|
||||
|
||||
void init(const QString &desktopEntry);
|
||||
|
||||
bool allowNotify() const;
|
||||
void setAllowNotify(bool enable);
|
||||
|
||||
|
@ -44,6 +42,8 @@ public:
|
|||
SettingsProperty::Property popupStyle() const;
|
||||
void setPopupStyle(SettingsProperty::Property style);
|
||||
|
||||
QString desktopEntry() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void allowNotifyChanged(bool);
|
||||
void allowSoundChanged(bool);
|
||||
|
@ -53,6 +53,7 @@ Q_SIGNALS:
|
|||
void uninstalled();
|
||||
|
||||
private Q_SLOTS:
|
||||
void init();
|
||||
void settingsDataChanged();
|
||||
void appUninstalled(const QString &desktopEntry);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ class PopupNotificationPrivate;
|
|||
typedef QList<QPair<QString, QString>> ActionList;
|
||||
class UKUINOTIFICATION_EXPORT PopupNotification
|
||||
{
|
||||
friend class NotificationSettingsTest;
|
||||
Q_GADGET
|
||||
Q_PROPERTY(uint id READ id)
|
||||
Q_PROPERTY(QString applicationName READ applicationName WRITE setApplicationName)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
prefix=/usr
|
||||
exec_prefix=${prefix}
|
||||
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
libdir=${prefix}/lib/@CMAKE_LIBRARY_ARCHITECTURE@
|
||||
includedir=${prefix}/include/ukui-notification
|
||||
|
||||
Name: ukui-notification
|
||||
|
|
|
@ -12,7 +12,7 @@ NotificationServerApplication::NotificationServerApplication(int &argc, char **a
|
|||
: QtSingleCoreApplication(applicationName, argc, argv)
|
||||
{
|
||||
setApplicationVersion(NOTIFICATION_SERVER_VERSION);
|
||||
qApp->setProperty("IS_UKUI_NOTIFICATION_SERVICE", true);
|
||||
qApp->setProperty("IS_UKUI_NOTIFICATION_SERVER", true);
|
||||
if (!this->isRunning()) {
|
||||
connect(this, &QtSingleCoreApplication::messageReceived, [=](QString msg) {
|
||||
this->parseCmd(msg, true);
|
||||
|
|
|
@ -23,7 +23,7 @@ foreach(PC_LIB IN ITEMS ${UKUI_NOTIFICATION_PC_PKGS})
|
|||
endforeach()
|
||||
|
||||
include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||
include_directories(../libukui-notification)
|
||||
include_directories(../libukui-notification/notification-settings)
|
||||
|
||||
target_link_libraries(notification-ukcc-plugin
|
||||
PRIVATE
|
||||
|
@ -33,6 +33,5 @@ target_link_libraries(notification-ukcc-plugin
|
|||
ukui-notification
|
||||
ukcc
|
||||
)
|
||||
|
||||
install(TARGETS notification-ukcc-plugin DESTINATION /usr/lib/x86_64-linux-gnu/ukui-control-center)
|
||||
install(TARGETS notification-ukcc-plugin DESTINATION /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/ukui-control-center)
|
||||
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef APPDETAIL_H
|
||||
#define APPDETAIL_H
|
||||
|
||||
#define MESSAGES_KEY "messages"
|
||||
#define VOICE_KEY "voice"
|
||||
#define MAXIMINE_KEY "maximize"
|
||||
#define NAME_KEY_US "name-us"
|
||||
#define NAME_KEY_CN "name-cn"
|
||||
|
||||
#endif // APPDETAIL_H
|
|
@ -11,19 +11,19 @@ NoticeMenu::NoticeMenu(QWidget *parent) :
|
|||
setConnect();
|
||||
}
|
||||
|
||||
void NoticeMenu::initStaus(const UkuiNotification::SingleApplicationSettings &settings)
|
||||
void NoticeMenu::initStaus(UkuiNotification::SingleApplicationSettings *settings)
|
||||
{
|
||||
m_voiceBtn->blockSignals(true);
|
||||
m_showBtn->blockSignals(true);
|
||||
m_detailBtn->blockSignals(true);
|
||||
m_styleGrounp->blockSignals(true);
|
||||
|
||||
m_voiceBtn->setChecked(settings.allowSound());
|
||||
m_detailBtn->setChecked(settings.showContentOnLockScreen());
|
||||
m_showBtn->setChecked(settings.showNotificationOnLockScreen());
|
||||
m_voiceBtn->setChecked(settings->allowSound());
|
||||
m_detailBtn->setChecked(settings->showContentOnLockScreen());
|
||||
m_showBtn->setChecked(settings->showNotificationOnLockScreen());
|
||||
|
||||
int styleId = 0;
|
||||
UkuiNotification::SettingsProperty::Property style = settings.popupStyle();
|
||||
UkuiNotification::SettingsProperty::Property style = settings->popupStyle();
|
||||
if (style == UkuiNotification::SettingsProperty::TransientPopup) {
|
||||
styleId = 0;
|
||||
} else if (style == UkuiNotification::SettingsProperty::ResidentPopup) {
|
||||
|
|
|
@ -18,7 +18,7 @@ class NoticeMenu : public QMenu
|
|||
public:
|
||||
NoticeMenu(QWidget *parent = nullptr);
|
||||
|
||||
void initStaus(const UkuiNotification::SingleApplicationSettings &settings);
|
||||
void initStaus(UkuiNotification::SingleApplicationSettings *settings);
|
||||
void setVoiceEnable(bool state);
|
||||
void setDetailShowOnLockScreenEnable(bool state);
|
||||
void setShowOnLockScreenEnable(bool state);
|
||||
|
|
|
@ -17,7 +17,6 @@ public:
|
|||
ukToolButton(QWidget *parent = nullptr):
|
||||
QToolButton(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -427,13 +426,15 @@ void Notice::initNoticeStatus()
|
|||
|
||||
void Notice::initListUI()
|
||||
{
|
||||
UkuiNotification::ApplicationsSettingsHash &appDataHash = UkuiNotification::ApplicationsSettings::self()->getAllApplicationsSettings();
|
||||
for (auto &key : appDataHash.keys()) {
|
||||
initItemUi(key, appDataHash[key]);
|
||||
UkuiNotification::ApplicationsSettingsMap appDataMap = UkuiNotification::ApplicationsSettings::self()->getAllApplicationsSettings();
|
||||
UkuiNotification::ApplicationsSettingsMap::const_iterator i = appDataMap.constBegin();
|
||||
while(i != appDataMap.constEnd()) {
|
||||
initItemUi(i.key(), i.value());
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void Notice::initItemUi(const QString &desktopPath, const UkuiNotification::SingleApplicationSettings &settings)
|
||||
void Notice::initItemUi(const QString &desktopPath, UkuiNotification::SingleApplicationSettings *settings)
|
||||
{
|
||||
QString localName = m_appInfo->getInfo(desktopPath, UkuiSearch::ApplicationProperty::LocalName).toString();
|
||||
QString iconName = m_appInfo->getInfo(desktopPath, UkuiSearch::ApplicationProperty::Icon).toString();
|
||||
|
@ -495,7 +496,7 @@ void Notice::initItemUi(const QString &desktopPath, const UkuiNotification::Sing
|
|||
|
||||
|
||||
appSwitch->blockSignals(true);
|
||||
appSwitch->setChecked(settings.allowNotify());
|
||||
appSwitch->setChecked(settings->allowNotify());
|
||||
appSwitch->blockSignals(false);
|
||||
|
||||
menu->blockSignals(true);
|
||||
|
@ -507,32 +508,32 @@ void Notice::initItemUi(const QString &desktopPath, const UkuiNotification::Sing
|
|||
UkuiNotification::ApplicationsSettings::self()->setAppSetting(desktopPath, UkuiNotification::SettingsProperty::AllowNotify, state);
|
||||
});
|
||||
|
||||
connect(&settings, &UkuiNotification::SingleApplicationSettings::allowNotifyChanged, [=](bool state) {
|
||||
connect(settings, &UkuiNotification::SingleApplicationSettings::allowNotifyChanged, [=](bool state) {
|
||||
appSwitch->blockSignals(true);
|
||||
appSwitch->setChecked(state);
|
||||
appSwitch->blockSignals(false);
|
||||
});
|
||||
connect(&settings, &UkuiNotification::SingleApplicationSettings::allowSoundChanged, [=](bool state) {
|
||||
connect(settings, &UkuiNotification::SingleApplicationSettings::allowSoundChanged, [=](bool state) {
|
||||
menu->blockSignals(true);
|
||||
menu->setVoiceEnable(state);
|
||||
menu->blockSignals(false);
|
||||
});
|
||||
connect(&settings, &UkuiNotification::SingleApplicationSettings::showContentOnLockScreenChanged, [=](bool state) {
|
||||
connect(settings, &UkuiNotification::SingleApplicationSettings::showContentOnLockScreenChanged, [=](bool state) {
|
||||
menu->blockSignals(true);
|
||||
menu->setDetailShowOnLockScreenEnable(state);
|
||||
menu->blockSignals(false);
|
||||
});
|
||||
connect(&settings, &UkuiNotification::SingleApplicationSettings::showNotificationOnLockScreenChanged, [=](bool state) {
|
||||
connect(settings, &UkuiNotification::SingleApplicationSettings::showNotificationOnLockScreenChanged, [=](bool state) {
|
||||
menu->blockSignals(true);
|
||||
menu->setShowOnLockScreenEnable(state);
|
||||
menu->blockSignals(false);
|
||||
});
|
||||
connect(&settings, &UkuiNotification::SingleApplicationSettings::popupStyleChanged, [=](UkuiNotification::SettingsProperty::Property style) {
|
||||
connect(settings, &UkuiNotification::SingleApplicationSettings::popupStyleChanged, [=](UkuiNotification::SettingsProperty::Property style) {
|
||||
menu->blockSignals(true);
|
||||
menu->setPopupStyle(style);
|
||||
menu->blockSignals(false);
|
||||
});
|
||||
connect(&settings, &UkuiNotification::SingleApplicationSettings::uninstalled, [=]() {
|
||||
connect(settings, &UkuiNotification::SingleApplicationSettings::uninstalled, [=]() {
|
||||
baseWidget->hide();
|
||||
});
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#include <ukcc/widgets/titlelabel.h>
|
||||
#include <ukcc/widgets/lightlabel.h>
|
||||
|
||||
#include "notification-settings/applications-settings.h"
|
||||
#include "notification-settings/notification-global-settings.h"
|
||||
#include "applications-settings.h"
|
||||
#include "notification-global-settings.h"
|
||||
|
||||
using namespace kdk;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
void initConnection();
|
||||
void initNoticeStatus();
|
||||
void initListUI();
|
||||
void initItemUi(const QString &desktopPath, const UkuiNotification::SingleApplicationSettings &settings);
|
||||
void initItemUi(const QString &desktopPath, UkuiNotification::SingleApplicationSettings *settings);
|
||||
void setAppIcon(QLabel *iconlabel, const QString &icon);
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
set(notificationClientTest_SRCS
|
||||
notification-client-test.cpp
|
||||
notification-client-test.h
|
||||
main.cpp)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/libukui-notification)
|
||||
add_executable(notification-client-test ${notificationClientTest_SRCS})
|
||||
main.cpp notification-settings-test.cpp notification-settings-test.h)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/libukui-notification ${CMAKE_SOURCE_DIR}/libukui-notification/notification-settings)
|
||||
|
||||
target_link_libraries(notification-client-test PRIVATE
|
||||
message(${notificationClientTest_SRCS}, "123123")
|
||||
add_executable(ukui-notification-test ${notificationClientTest_SRCS})
|
||||
|
||||
target_link_libraries(ukui-notification-test PRIVATE
|
||||
Qt${QT_MAJOR_VERSION}::Core
|
||||
Qt${QT_MAJOR_VERSION}::Gui
|
||||
ukui-notification
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include "notification-client-test.h"
|
||||
#include "notification-settings-test.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
NotificationClientTest ct;
|
||||
// NotificationClientTest ct;
|
||||
NotificationSettingsTest setting;
|
||||
return app.exec();
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
//
|
||||
// Created by zpf on 2023/3/16.
|
||||
//
|
||||
|
||||
#include "notification-settings-test.h"
|
||||
#include "popup-notification.h"
|
||||
|
||||
NotificationSettingsTest::NotificationSettingsTest(QObject *parent) : QObject(parent)
|
||||
{
|
||||
UkuiNotification::ApplicationsSettingsMap &map = UkuiNotification::ApplicationsSettings::self()->getAllApplicationsSettings();
|
||||
for(const QString &key : map.keys()) {
|
||||
initConnection(map.value(key));
|
||||
}
|
||||
m_globalSettings = new UkuiNotification::NotificationGlobalSettings(this);
|
||||
connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::scheduleTurnOnDNDChanged, this, [&](bool value){
|
||||
qDebug() << "scheduleTurnOnDNDChanged" << value;
|
||||
});
|
||||
connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::scheduleTurnOnDNDTimeChanged, this, [&](QTime value){
|
||||
qDebug() << "scheduleTurnOnDNDTimeChanged" << value;
|
||||
});
|
||||
connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::scheduleTurnOffDNDTimeChanged, this, [&](QTime value){
|
||||
qDebug() << "scheduleTurnOffDNDTimeChanged" << value;
|
||||
});
|
||||
connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::DNDWhileMultiScreenChanged, this, [&](bool value){
|
||||
qDebug() << "DNDWhileMultiScreenChanged" << value;
|
||||
});
|
||||
connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::DNDWhileFullScreenChanged, this, [&](bool value){
|
||||
qDebug() << "DNDWhileFullScreenChanged" << value;
|
||||
});
|
||||
connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::notifyAlarmWhileDNDChanged, this, [&](bool value){
|
||||
qDebug() << "notifyAlarmWhileDNDChanged" << value;
|
||||
});
|
||||
connect(m_globalSettings, &UkuiNotification::NotificationGlobalSettings::receiveNotificationsFromAppsChanged, this, [&](bool value){
|
||||
qDebug() << "receiveNotificationsFromAppsChanged" << value;
|
||||
});
|
||||
}
|
||||
|
||||
NotificationSettingsTest::~NotificationSettingsTest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NotificationSettingsTest::initConnection(UkuiNotification::SingleApplicationSettings *setting)
|
||||
{
|
||||
connect(setting, &UkuiNotification::SingleApplicationSettings::allowNotifyChanged, this, [&](bool value){
|
||||
qDebug() << "allowNotifyChanged" << value;
|
||||
});
|
||||
connect(setting, &UkuiNotification::SingleApplicationSettings::allowSoundChanged, this, [&](bool value){
|
||||
qDebug() << "allowSoundChanged" << value;
|
||||
});
|
||||
connect(setting, &UkuiNotification::SingleApplicationSettings::showContentOnLockScreenChanged, this, [&](bool value){
|
||||
qDebug() << "showContentOnLockScreenChanged" << value;
|
||||
});
|
||||
connect(setting, &UkuiNotification::SingleApplicationSettings::showNotificationOnLockScreenChanged, this, [&](bool value){
|
||||
qDebug() << "showNotificationOnLockScreenChanged" << value;
|
||||
});
|
||||
connect(setting, &UkuiNotification::SingleApplicationSettings::popupStyleChanged, this, [&](UkuiNotification::SettingsProperty::Property value){
|
||||
qDebug() << "popupStyleChanged" << value;
|
||||
});
|
||||
connect(setting, &UkuiNotification::SingleApplicationSettings::uninstalled, this, [&](){
|
||||
qDebug() << "uninstalled";
|
||||
});
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// Created by zpf on 2023/3/16.
|
||||
//
|
||||
|
||||
#ifndef UKUI_NOTIFICATION_NOTIFICATION_SETTINGS_TEST_H
|
||||
#define UKUI_NOTIFICATION_NOTIFICATION_SETTINGS_TEST_H
|
||||
#include <QObject>
|
||||
#include "applications-settings.h"
|
||||
#include "notification-global-settings.h"
|
||||
|
||||
class NotificationSettingsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NotificationSettingsTest(QObject *parent = nullptr);
|
||||
~NotificationSettingsTest();
|
||||
|
||||
void initConnection(UkuiNotification::SingleApplicationSettings *setting);
|
||||
private:
|
||||
UkuiNotification::NotificationGlobalSettings *m_globalSettings = nullptr;
|
||||
};
|
||||
|
||||
|
||||
#endif //UKUI_NOTIFICATION_NOTIFICATION_SETTINGS_TEST_H
|
Loading…
Reference in New Issue