forked from lmq3342xja/fcitx-qimpanel
-
Notifications
You must be signed in to change notification settings - Fork 4
/
main_controller.h
125 lines (109 loc) · 3.27 KB
/
main_controller.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
/*
* Copyright (C) 2013 National University of Defense Technology(NUDT) & Kylin Ltd.
*
* Authors:
* lenky gao [email protected]/[email protected]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __MAIN_CONTROLLER_H__
#define __MAIN_CONTROLLER_H__
#include "config.h"
#ifdef IS_QT_5
#include <QQuickWidget>
#include <QQmlContext>
#endif
#ifdef IS_QT_4
#include <QDeclarativeView>
#include <QtDeclarative/QDeclarativeContext>
#endif
#include <QSystemTrayIcon>
#include <QSocketNotifier>
#include "main_model.h"
#include "system_tray_menu.h"
#include "kimpanelagent.h"
#include "toplevel.h"
#include "skin/skinbase.h"
#include "my_action.h"
//必须与FcitxCandidateLayoutHint的定义一致
enum CandidateLayout {
CLH_NotSet,
CLH_Vertical,
CLH_Horizontal
};
class MainController : public QObject
{
Q_OBJECT
// 定义Interface名称为"com.test.hotel"
Q_CLASSINFO("D-Bus Interface", "com.fcitx_qimpanel.hotel")
public:
static MainController* self();
virtual ~MainController();
void init();
void loadCfg();
bool isUbuntuKylin_os();
private:
explicit MainController();
static MainController *mSelf;
private:
TopLevel *mTopLevel;
MainModel *mModel;
PanelAgent *mAgent;
SkinBase *mSkinBase;
#ifdef IS_QT_5
QQuickWidget *mView;
#endif
#ifdef IS_QT_4
QDeclarativeView *mView;
#endif
QUrl mUrl;
QTimer *mTimer;
QSystemTrayIcon *mSystemTray;
SystemTrayMenu *mTrayMenu;
bool mIsHorizontal;
QString mSkinName;
private:
QSocketNotifier *mSocketNotifier;
private slots:
// void handleSig();
public:
int mSigFd[2];
public:
void setSkinBase(SkinBase *skinBase, int skinType);
QString getSkinName();
void setSkinName(QString skinName);
SystemTrayMenu* getTrayMenu();
void creatDBusService();
public slots:
void updateProperty(const KimpanelProperty &prop);
void updatePreeditText(const QString inputString,
QList<TextAttribute> attributes);
void updateLookupTable(const KimpanelLookupTable &lookup_table);
void updateLookupTableFull(const KimpanelLookupTable &lookup_table,
int cursor, int layout);
void updateSpotLocation(int x, int y);
void updateSpotRect(int x, int y, int w, int h);
void showPreedit(bool to_show);
void showAux(bool to_show);
void updateAux(const QString &text, const QList<TextAttribute> &attr);
void showLookupTable(bool to_show);
void updateLookupTableCursor(int pos);
void updatePreeditCaret(int pos);
void qtDbusSot_restartQimpanel();
int qtDbusSot_exitQimpanel(int arg);
public:
Q_INVOKABLE void getPrevPage();
Q_INVOKABLE void getNextPage();
Q_INVOKABLE void selectCandidate(int index);
};
#endif // __MAIN_CONTROLLER_H__