mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-15 05:12:04 +08:00
修复中文环境无法显示通知的问题
This commit is contained in:
29
widget.cpp
29
widget.cpp
@@ -1,3 +1,4 @@
|
||||
#include <libnotify/notify.h>
|
||||
#include "widget.h"
|
||||
#include "ui_widget.h"
|
||||
#include <QDebug>
|
||||
@@ -301,20 +302,32 @@ DTitlebar* Widget::getTitlebar()
|
||||
return ui->titlebar;
|
||||
}
|
||||
|
||||
static NotifyNotification *_notify = nullptr;
|
||||
|
||||
void Widget::sendNotification(const QString &message, const int msTimeout, const QString &icon)
|
||||
{
|
||||
system((QString("notify-send --icon=%1 --expire-time=%2 --app-name=").arg(icon).arg(msTimeout) +
|
||||
tr("Spark\\ Store") +
|
||||
" '" + message + "'"
|
||||
).toUtf8());
|
||||
if(_notify == nullptr)
|
||||
{
|
||||
_notify = notify_notification_new(tr("Spark\\ Store").toLocal8Bit(), message.toLocal8Bit(), icon.toLocal8Bit());
|
||||
notify_notification_set_timeout(_notify, msTimeout);
|
||||
}
|
||||
else
|
||||
notify_notification_update(_notify, tr("Spark\\ Store").toLocal8Bit(), message.toLocal8Bit(), icon.toLocal8Bit());
|
||||
|
||||
notify_notification_show(_notify, nullptr);
|
||||
}
|
||||
|
||||
void Widget::sendNotification(const char *message, const int msTimeout, const QString &icon)
|
||||
{
|
||||
system((QString("notify-send --icon=%1 --expire-time=%2 --app-name=").arg(icon).arg(msTimeout) +
|
||||
tr("Spark\\ Store") +
|
||||
" '" + message + "'"
|
||||
).toUtf8());
|
||||
if(_notify == nullptr)
|
||||
{
|
||||
_notify = notify_notification_new(tr("Spark\\ Store").toLocal8Bit(), message, icon.toLocal8Bit());
|
||||
notify_notification_set_timeout(_notify, msTimeout);
|
||||
}
|
||||
else
|
||||
notify_notification_update(_notify, tr("Spark\\ Store").toLocal8Bit(), message, icon.toLocal8Bit());
|
||||
|
||||
notify_notification_show(_notify, nullptr);
|
||||
}
|
||||
|
||||
void Widget::updateUI()
|
||||
|
||||
Reference in New Issue
Block a user