From 271a7e33f4e0c077f2dc4a7b1b48b62975abe1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=9A=E5=AD=90?= Date: Sun, 11 Dec 2022 20:40:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0chatGPT=E5=B8=AE=E5=BF=99?= =?UTF-8?q?=E5=86=99=E7=9A=84=E9=80=9A=E7=9F=A5=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/appintopage.cpp | 2 +- src/pages/appintopage.h | 1 + src/spark-store.pro | 2 ++ src/utils/utils.cpp | 26 ++++++++++++++++++++++++++ src/utils/utils.h | 14 ++++++++++++++ 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/utils/utils.cpp create mode 100644 src/utils/utils.h diff --git a/src/pages/appintopage.cpp b/src/pages/appintopage.cpp index 35a52b7..e22877b 100644 --- a/src/pages/appintopage.cpp +++ b/src/pages/appintopage.cpp @@ -330,7 +330,7 @@ void AppIntoPage::on_pushButton_3_clicked() void AppIntoPage::on_shareButton_clicked() { qDebug() << "Share" << spk; - + Utils::sendNotification("spark-store",tr("Spark Store"),tr("The URL has been copied to the clipboard")); QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(spk.toString()); } diff --git a/src/pages/appintopage.h b/src/pages/appintopage.h index f6012fe..d5a7b11 100644 --- a/src/pages/appintopage.h +++ b/src/pages/appintopage.h @@ -9,6 +9,7 @@ #include "backend/sparkapi.h" #include "backend/image_show.h" #include "widgets/downloadlistwidget.h" +#include "utils/utils.h" namespace Ui { class AppIntoPage; } diff --git a/src/spark-store.pro b/src/spark-store.pro index 605a710..078ba1d 100644 --- a/src/spark-store.pro +++ b/src/spark-store.pro @@ -44,6 +44,7 @@ SOURCES += \ mainwindow-dtk.cpp \ backend/sparkapi.cpp \ pages/settingspage.cpp \ + utils/utils.cpp \ utils/widgetanimation.cpp \ widgets/common/webenginepage.cpp \ widgets/common/webengineview.cpp \ @@ -63,6 +64,7 @@ HEADERS += \ mainwindow-dtk.h \ backend/sparkapi.h \ pages/settingspage.h \ + utils/utils.h \ utils/widgetanimation.h \ widgets/common/webenginepage.h \ widgets/common/webengineview.h \ diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp new file mode 100644 index 0000000..f475c1f --- /dev/null +++ b/src/utils/utils.cpp @@ -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); +} diff --git a/src/utils/utils.h b/src/utils/utils.h new file mode 100644 index 0000000..336bbf1 --- /dev/null +++ b/src/utils/utils.h @@ -0,0 +1,14 @@ +#ifndef UTILS_H +#define UTILS_H + +#include +#include + +class Utils +{ +public: + Utils(); + static void sendNotification(QString icon,QString title,QString body); +}; + +#endif // UTILS_H