forked from nemomobile/fingerterm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
112 lines (85 loc) · 3.18 KB
/
util.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
/*
Copyright 2011-2012 Heikki Holstila <[email protected]>
This file is part of FingerTerm.
FingerTerm 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, either version 2 of the License, or
(at your option) any later version.
FingerTerm 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 FingerTerm. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UTIL_H
#define UTIL_H
#include <QtCore>
class Terminal;
class MainWindow;
class TextRender;
class QQuickView;
class Util : public QObject
{
Q_OBJECT
public:
explicit Util(QSettings* settings, QObject *parent = 0);
virtual ~Util();
void setWindow(QQuickView* win);
void setWindowTitle(QString title);
Q_INVOKABLE QString currentWindowTitle();
void setTerm(Terminal* term) { iTerm = term; }
void setRenderer(TextRender* r) { iRenderer = r; }
Q_INVOKABLE void windowMinimize();
Q_INVOKABLE void openNewWindow();
Q_INVOKABLE void updateSwipeLock(bool suggestedState);
Q_INVOKABLE QString versionString();
Q_INVOKABLE QString configPath();
Q_INVOKABLE QVariant settingsValue(QString key);
Q_INVOKABLE void setSettingsValue(QString key, QVariant value);
Q_INVOKABLE int uiFontSize();
Q_INVOKABLE bool isHarmattan();
Q_INVOKABLE void keyPressFeedback();
Q_INVOKABLE void keyReleaseFeedback();
Q_INVOKABLE void notifyText(QString text);
Q_INVOKABLE void copyTextToClipboard(QString str);
Q_INVOKABLE bool canPaste();
Q_INVOKABLE bool terminalHasSelection();
void bellAlert();
void selectionFinished();
bool allowGestures() { return iAllowGestures; }
void setAllowGestures(bool a) { if(iAllowGestures!=a) { iAllowGestures=a; emit allowGesturesChanged(); } }
Q_PROPERTY(bool allowGestures READ allowGestures WRITE setAllowGestures NOTIFY allowGesturesChanged)
static bool charIsHexDigit(QChar ch);
public slots:
void onMainWinFocusChanged(bool in);
void mousePress(float eventX, float eventY);
void mouseMove(float eventX, float eventY);
void mouseRelease(float eventX, float eventY);
signals:
void visualBell();
void allowGesturesChanged();
void gestureNotify(QString msg);
void clipboardOrSelectionChanged();
void windowTitleChanged();
private:
Q_DISABLE_COPY(Util)
enum PanGesture { PanNone, PanLeft, PanRight, PanUp, PanDown };
void enableSwipe();
void disableSwipe();
bool swipeModeSet;
bool swipeAllowed;
void scrollBackBuffer(QPointF now, QPointF last);
void doGesture(PanGesture gesture);
void clearNotifications();
void selectionHelper(QPointF scenePos);
QPointF dragOrigin;
bool iAllowGestures;
bool newSelection;
QString iCurrentWinTitle;
QSettings* iSettings;
MainWindow* iWindow;
Terminal* iTerm;
TextRender* iRenderer;
};
#endif // UTIL_H