Debian Codegraph @

src/gui/TrayIcon.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2019 Damir Porobic <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public 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, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef KSNIP_TRAYICON_H
21 #define KSNIP_TRAYICON_H
22
23 #include <QSystemTrayIcon>
24 #include <QMenu>
25 #include <QDesktopServices>
26 #include <QUrl>
27
28 #include "INotificationService.h"
29 #include "src/backend/config/IConfig.h"
30 #include "src/common/enum/CaptureModes.h"
31 #include "src/common/loader/IIconLoader.h"
32 #include "src/common/helper/PathHelper.h"
33
34 class TrayIcon : public QSystemTrayIcon, public INotificationService
35 {
36 Q_OBJECT
37 public:
38 explicit TrayIcon(const QSharedPointer<IConfig> &config, const QSharedPointer<IIconLoader> &iconLoader, QObject *parent);
39 ~TrayIcon() override;
40 void setCaptureActions(const QList<QAction*> &captureActions);
41 void setOpenAction(QAction *action);
42 void setSaveAction(QAction *action);
43 void setPasteAction(QAction *action);
44 void setCopyAction(QAction *action);
45 void setUploadAction(QAction *action);
46 void setQuitAction(QAction *action);
47 void setActionsMenu(QMenu *actionsMenu);
48 void setEnabled(bool enabled);
49 void showInfo(const QString &title, const QString &message, const QString &contentUrl) override;
50 void showWarning(const QString &title, const QString &message, const QString &contentUrl) override;
51 void showCritical(const QString &title, const QString &message, const QString &contentUrl) override;
52
53 signals:
54 void showEditorTriggered() const;
55
56 private:
57 QSharedPointer<IConfig> mConfig;
58 QMenu mMenu;
59 QList<QAction*> mCaptureActions;
60 QAction *mOpenAction;
61 QAction *mSaveAction;
62 QAction *mPasteAction;
63 QAction *mCopyAction;
64 QAction *mUploadAction;
65 QAction *mShowEditorAction;
66 QAction *mQuitAction;
67 QMenu *mActionsMenu;
68 QString mToastContentUrl;
69
70 void setupMenu();
71 void triggerDefaultCaptureMode() const;
72
73 private slots:
74 void activatedDefaultAction(ActivationReason reason) const;
75 void openContentUrl();
76 void showMessage(const QString &title, const QString &message, const QString &contentUrl, QSystemTrayIcon::MessageIcon messageIcon);
77 };
78
79 #endif //KSNIP_TRAYICON_H