| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 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 |