-
Notifications
You must be signed in to change notification settings - Fork 82
/
SystrayIcon.h
executable file
·152 lines (142 loc) · 5.9 KB
/
SystrayIcon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/** \file SystrayIcon.h
\brief Define the class of the systray icon
\author alpha_one_x86
\licence GPL3, see the file COPYING */
#ifndef SYSTRAY_ICON_H
#define SYSTRAY_ICON_H
#include <QSystemTrayIcon>
#include <QObject>
#include <QAction>
#include <QMenu>
#include <QTimer>
#include <QDropEvent>
#include <QList>
#include <QUrl>
#ifdef Q_OS_WIN32
#define TREEMENU
#endif
#include "Environment.h"
/** \brief The systray icon
This class provide a systray icon and its functions */
class SystrayIcon : public QSystemTrayIcon
{
Q_OBJECT
public:
/// \brief Initiate and show the icon in the systray
SystrayIcon(QObject * parent = 0);
/// \brief Hide and destroy the icon in the systray
~SystrayIcon();
public slots:
/// \brief For show a message linked to the systray icon
void showSystrayMessage(const std::string& text);
/** \brief Send that's caught state have changed for CatchedState::Uncatched or CatchedState::Semicatched or CatchedState::Catched
\see CatchState
\see tryCatchCopy()
\see tryUncatchCopy()
\param state is the new state */
void listenerReady(const Ultracopier::ListeningState &state,const bool &havePlugin,const bool &someAreInWaitOfReply);
void pluginLoaderReady(const Ultracopier::CatchState &state,const bool &havePlugin,const bool &someAreInWaitOfReply);
void addCopyEngine(const std::string &name,const bool &canDoOnlyCopy);
void removeCopyEngine(const std::string &name);
#ifdef ULTRACOPIER_INTERNET_SUPPORT
void newUpdate(const std::string &version);
#endif
void changeToUltimate();
private:
#ifdef ULTRACOPIER_INTERNET_SUPPORT
std::string lastVersion;
#endif
QMenu* systrayMenu; ///< Pointer on the menu
#ifdef TREEMENU
QMenu* copyMenu; ///< Pointer on the copy menu (move or copy)
#else
std::vector<QAction*> actions;
#endif
QAction* actionMenuQuit; ///< Pointer on the Quit action
#ifdef ULTRACOPIER_DEBUG
QAction* actionSaveBugReport;
#endif
QAction* actionMenuAbout; ///< Pointer on the About action
QAction* actionOptions; ///< Pointer on the Options action
QAction* actionProductKey; ///< Pointer on the Product key action
QIcon IconQuit; ///< Pointer on the icon for quit
#ifdef ULTRACOPIER_DEBUG
QIcon IconSaveBugReport;
#endif
QIcon IconInfo; ///< Pointer on the icon for info
QIcon IconAdd; ///< Pointer on the icon for add
QIcon IconOptions; ///< Pointer on the options
/// \brief To update the systray icon
void updateSystrayIcon();
void showTryCatchMessageWithNoListener();
struct EngineEntry
{
bool canDoOnlyCopy;
std::string name;
};
std::vector<EngineEntry> engineEntryList;
// To store the current catch state
Ultracopier::ListeningState stateListener;
Ultracopier::CatchState statePluginLoader;
bool haveListenerInfo,havePluginLoaderInfo;
bool haveListener,havePluginLoader;
QTimer timerCheckSetTooltip;
void addEngineAction(const QString &name, const QIcon &icon, const QString &label, QMenu *menu, void (SystrayIcon::*query)());
/** \brief drag event processing (impossible with Qt on systray)
need setAcceptDrops(true); into the constructor
need implementation to accept the drop:
void dragEnterEvent(QDragEnterEvent* event);
void dragMoveEvent(QDragMoveEvent* event);
void dragLeaveEvent(QDragLeaveEvent* event);
*/
void dropEvent(QDropEvent *event);
/** \brief accept all event to allow the drag and drop
\see dropEvent() */
void dragEnterEvent(QDragEnterEvent* event);
/** \brief accept all event to allow the drag and drop
\see dropEvent() */
void dragMoveEvent(QDragMoveEvent* event);
/** \brief accept all event to allow the drag and drop
\see dropEvent() */
void dragLeaveEvent(QDragLeaveEvent* event);
private slots:
/// \brief To update the current themes
void updateCurrentTheme();
/** \brief To catch an action on the systray icon
\param reason Why it activated */
void CatchAction(QSystemTrayIcon::ActivationReason reason);
/// \brief To catch copy menu action
void CatchCopyQuery();
/// \brief To catch move menu action
void CatchMoveQuery();
/// \brief To catch transfer menu action
void CatchTransferQuery();
/// \brief to retranslate the ui
void retranslateTheUI();
void reloadEngineList();
void checkSetTooltip();
#ifdef ULTRACOPIER_INTERNET_SUPPORT
void messageClicked();
#endif
signals:
/// \brief Quit ultracopier
void quit() const;
/// \brief Try catch the copy/move with plugin compatible
void tryCatchCopy() const;
/// \brief Try uncatch the copy/move with plugin compatible
void tryUncatchCopy() const;
/// \brief Show the help dialog
void showHelp() const;
/// \brief Show the help option
void showOptions() const;
/// \brief Show the help option
void showProductKey() const;
/** \brief Add window copy or window move
\param mode Can be CopyMode::Copy or CopyMode::Move
\return The core object of the new window created */
void addWindowCopyMove(Ultracopier::CopyMode mode,std::string name) const;
void addWindowTransfer(std::string name) const;
void urlDropped(std::vector<std::string> urls) const;
void saveBugReport() const;
};
#endif // SYSTRAY_ICON_H