-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctxindicator.h
71 lines (58 loc) · 1.68 KB
/
ctxindicator.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
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <gtk/gtk.h>
#include <libappindicator/app-indicator.h>
#include <QByteArray>
#include <QDebug>
#include <QObject>
#include <QString>
#include <QTemporaryDir>
#include <QThread>
class GTKWorker : public QObject {
Q_OBJECT
public slots:
void init() {
qDebug() << "start run gtk_main():" << QThread::currentThreadId();
gtk_main();
}
};
class CtxIndicator : public QObject {
Q_OBJECT
public:
CtxIndicator(int argc, char *argv[]);
~CtxIndicator();
public:
void initGTK(int argc, char *argv[]);
void initCtxIndicator();
static void activate_action(GtkMenuItem *item, void *p_ctxIndicator);
static void toggleCtx(GtkMenuItem *item, void *p_ctxIndicator);
void emitAction(QString actionName);
void emitCtxIndexChanged(const int &index);
void addCtxAction(const QString &name);
void addAction(const QString &name);
GtkMenuItem *findCtxMenuItem(const int &index);
QString getIndicatorIconPath();
public slots:
void setIndicatorLabel(const QString &label);
void addCtxsToIndicatorMenu(const QStringList &ctxs);
void updateCtxActionName(const int &ctxIndex, const QString &ctxName);
void activeCtx(const int &ctxIndex);
public:
QThread gtkWorkerThread;
GTKWorker gtkWorker;
GtkWidget *window;
AppIndicator *indicator;
GtkWidget *indicatorMenu;
GtkWidget *ctxMenu;
GtkWidget *menuItemSWitchContext;
GtkWidget *lastCtxWidget = nullptr;
int lastCtxIndex = -1;
bool NO_EMIT_FLAG = false;
QTemporaryDir tempDir;
gchar *iconName = const_cast<char *>("kbugscontext");
signals:
void run();
void actionActive(QString &actionName);
void ctxIndexChanged(const int &index);
};
#endif // CONTROLLER_H