Changeset View
Standalone View
src/notifybysnore.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | Copyright (C) 2019 Piyush Aggarwal <piyushaggarwal002@gmail.com> | ||||
3 | | ||||
4 | This program is free software; you can redistribute it and/or modify it | ||||
5 | under the terms of the GNU Library General Public License as published by | ||||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||||
7 | option) any later version. | ||||
8 | | ||||
9 | This program is distributed in the hope that it will be useful, but WITHOUT | ||||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||||
12 | License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU General Public License | ||||
15 | along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||
16 | */ | ||||
17 | | ||||
18 | #ifndef NOTIFYBYSNORE_H | ||||
19 | #define NOTIFYBYSNORE_H | ||||
20 | | ||||
21 | #include "knotificationplugin.h" | ||||
22 | | ||||
23 | #include <QPointer> | ||||
24 | #include <QLocalServer> | ||||
25 | #include <QProcess> | ||||
26 | #include <QString> | ||||
27 | #include <QTemporaryDir> | ||||
28 | | ||||
29 | /** Windows notification backend - inspired by Android notification backend. */ | ||||
pino: extra empty line | |||||
30 | class NotifyBySnore : public KNotificationPlugin | ||||
31 | { | ||||
32 | Q_OBJECT | ||||
33 | | ||||
34 | public: | ||||
35 | explicit NotifyBySnore(QObject *parent = nullptr); | ||||
36 | ~NotifyBySnore() override; | ||||
37 | | ||||
38 | QString optionName() override { return QStringLiteral("Popup"); } | ||||
39 | void notify(KNotification *notification, KNotifyConfig *config) override; | ||||
40 | void close(KNotification * notification) override; | ||||
41 | void update(KNotification *notification, KNotifyConfig *config) override; | ||||
42 | private: | ||||
43 | QHash<int, QPointer<KNotification>> m_notifications; | ||||
44 | QString program = QStringLiteral("SnoreToast.exe"); | ||||
45 | QLocalServer server; | ||||
pino: QMap -> QHash | |||||
The amount of notifications should be small in which case a map has a better performance. vonreth: The amount of notifications should be small in which case a map has a better performance. | |||||
I referred to this: https://woboq.com/blog/qmap_qhash_benchmark.html brute4s99: I referred to this: https://woboq.com/blog/qmap_qhash_benchmark.html | |||||
All the other KNotificationPlugins in knotification use QHash for indexing the KNotification objects, FWIW, so at least using QHash would keep a bit of consistency. pino: All the other `KNotificationPlugin`s in knotification use QHash for indexing the… | |||||
shubham: I doubt this compiles...You can't initialise variables inside the class | |||||
vonreth: Have you heard of this new c++ standard? C++11? | |||||
46 | QTemporaryDir iconDir; | ||||
Isn't LibSnore abstracting this? Why do we need to call the exe instead of using some method in LibSnore? albertvaka: Isn't LibSnore abstracting this? Why do we need to call the exe instead of using some method in… | |||||
Libsnore is something different, yes its an abstract "notification framework" but ... its basically unmaintained and the windows 8+ notifications use exactly this executable.... vonreth: Libsnore is something different, yes its an abstract "notification framework" but ... its… | |||||
47 | }; | ||||
I guess you could use both, server and icon dir as non pointer members, that way they would exist as long as NotifyBySnore exists. vonreth: I guess you could use both, server and icon dir as non pointer members, that way they would… | |||||
48 | | ||||
49 | #endif // NOTIFYBYSNORE_H | ||||
sredman: Delete commented code | |||||
there is no need to keep a pointer to a Q(Core)Application, just use qApp instead (already provided by QCoreApplication) pino: there is no need to keep a pointer to a Q(Core)Application, just use `qApp` instead (already… |
extra empty line