mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 04:42:03 +08:00
添加chatGPT帮忙写的通知推送
This commit is contained in:
@@ -330,7 +330,7 @@ void AppIntoPage::on_pushButton_3_clicked()
|
|||||||
void AppIntoPage::on_shareButton_clicked()
|
void AppIntoPage::on_shareButton_clicked()
|
||||||
{
|
{
|
||||||
qDebug() << "Share" << spk;
|
qDebug() << "Share" << spk;
|
||||||
|
Utils::sendNotification("spark-store",tr("Spark Store"),tr("The URL has been copied to the clipboard"));
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
clipboard->setText(spk.toString());
|
clipboard->setText(spk.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "backend/sparkapi.h"
|
#include "backend/sparkapi.h"
|
||||||
#include "backend/image_show.h"
|
#include "backend/image_show.h"
|
||||||
#include "widgets/downloadlistwidget.h"
|
#include "widgets/downloadlistwidget.h"
|
||||||
|
#include "utils/utils.h"
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class AppIntoPage;
|
class AppIntoPage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ SOURCES += \
|
|||||||
mainwindow-dtk.cpp \
|
mainwindow-dtk.cpp \
|
||||||
backend/sparkapi.cpp \
|
backend/sparkapi.cpp \
|
||||||
pages/settingspage.cpp \
|
pages/settingspage.cpp \
|
||||||
|
utils/utils.cpp \
|
||||||
utils/widgetanimation.cpp \
|
utils/widgetanimation.cpp \
|
||||||
widgets/common/webenginepage.cpp \
|
widgets/common/webenginepage.cpp \
|
||||||
widgets/common/webengineview.cpp \
|
widgets/common/webengineview.cpp \
|
||||||
@@ -63,6 +64,7 @@ HEADERS += \
|
|||||||
mainwindow-dtk.h \
|
mainwindow-dtk.h \
|
||||||
backend/sparkapi.h \
|
backend/sparkapi.h \
|
||||||
pages/settingspage.h \
|
pages/settingspage.h \
|
||||||
|
utils/utils.h \
|
||||||
utils/widgetanimation.h \
|
utils/widgetanimation.h \
|
||||||
widgets/common/webenginepage.h \
|
widgets/common/webenginepage.h \
|
||||||
widgets/common/webengineview.h \
|
widgets/common/webengineview.h \
|
||||||
|
|||||||
26
src/utils/utils.cpp
Normal file
26
src/utils/utils.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
Utils::Utils()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//这个函数是chatGPT写的
|
||||||
|
void Utils::sendNotification(QString icon,QString title,QString body)
|
||||||
|
{
|
||||||
|
QDBusInterface iface("org.freedesktop.Notifications",
|
||||||
|
"/org/freedesktop/Notifications",
|
||||||
|
"org.freedesktop.Notifications");
|
||||||
|
|
||||||
|
QVariantList args;
|
||||||
|
args << QCoreApplication::applicationName() // the name of the application
|
||||||
|
<< (uint)0 // replaces the previous notification with the same ID
|
||||||
|
<< icon // the application icon of the notification
|
||||||
|
<< title // the title of the notification
|
||||||
|
<< body // the body of the notification
|
||||||
|
<< QStringList() // no actions
|
||||||
|
<< QVariantMap() // no hints
|
||||||
|
<< -1; // no timeout
|
||||||
|
|
||||||
|
iface.callWithArgumentList(QDBus::AutoDetect, "Notify", args);
|
||||||
|
}
|
||||||
14
src/utils/utils.h
Normal file
14
src/utils/utils.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef UTILS_H
|
||||||
|
#define UTILS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtDBus>
|
||||||
|
|
||||||
|
class Utils
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Utils();
|
||||||
|
static void sendNotification(QString icon,QString title,QString body);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // UTILS_H
|
||||||
Reference in New Issue
Block a user