/
util.h
153 lines (119 loc) · 4.63 KB
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
/*
Copyright 2011-2012 Heikki Holstila <heikki.holstila@gmail.com>
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 TextRender;
27
class QQuickView;
28
29
30
31
class Util : public QObject
{
Q_OBJECT
32
Q_PROPERTY(QString windowTitle READ windowTitle NOTIFY windowTitleChanged)
33
Q_PROPERTY(int windowOrientation READ windowOrientation WRITE setWindowOrientation NOTIFY windowOrientationChanged)
34
35
Q_PROPERTY(bool canPaste READ canPaste NOTIFY clipboardOrSelectionChanged)
Q_PROPERTY(bool terminalHasSelection READ terminalHasSelection NOTIFY clipboardOrSelectionChanged)
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Q_PROPERTY(QString fontFamily READ fontFamily CONSTANT)
Q_PROPERTY(int uiFontSize READ uiFontSize CONSTANT)
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
Q_PROPERTY(int dragMode READ dragMode WRITE setDragMode NOTIFY dragModeChanged)
Q_PROPERTY(int keyboardMode READ keyboardMode WRITE setKeyboardMode NOTIFY keyboardModeChanged)
Q_PROPERTY(int keyboardFadeOutDelay READ keyboardFadeOutDelay WRITE setKeyboardFadeOutDelay NOTIFY keyboardFadeOutDelayChanged)
Q_PROPERTY(QString keyboardLayout READ keyboardLayout WRITE setKeyboardLayout NOTIFY keyboardLayoutChanged)
Q_PROPERTY(int extraLinesFromCursor READ extraLinesFromCursor CONSTANT)
Q_PROPERTY(QString charset READ charset CONSTANT)
Q_PROPERTY(int keyboardMargins READ keyboardMargins CONSTANT)
Q_PROPERTY(int orientationMode READ orientationMode WRITE setOrientationMode NOTIFY orientationModeChanged)
Q_PROPERTY(bool showWelcomeScreen READ showWelcomeScreen WRITE setShowWelcomeScreen NOTIFY showWelcomeScreenChanged)
Q_ENUMS(KeyboardMode)
Q_ENUMS(DragMode)
Q_ENUMS(OrientationMode)
51
52
public:
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
enum KeyboardMode {
KeyboardOff,
KeyboardFade,
KeyboardMove
};
enum DragMode {
DragOff,
DragGestures,
DragScroll,
DragSelect
};
enum OrientationMode {
OrientationAuto,
OrientationLandscape,
OrientationPortrait
};
72
73
explicit Util(QSettings* settings, QObject *parent = 0);
virtual ~Util();
74
75
void setWindow(QQuickView* win);
76
void setWindowTitle(QString title);
77
QString windowTitle();
78
79
int windowOrientation();
void setWindowOrientation(int orientation);
80
void setTerm(Terminal* term);
81
82
83
84
85
Q_INVOKABLE void openNewWindow();
Q_INVOKABLE QString versionString();
Q_INVOKABLE QString configPath();
86
QVariant settingsValue(QString key, const QVariant &defaultValue = QVariant());
87
void setSettingsValue(QString key, QVariant value);
88
89
90
91
92
int uiFontSize();
int fontSize();
void setFontSize(int size);
93
94
95
96
97
98
Q_INVOKABLE void keyPressFeedback();
Q_INVOKABLE void keyReleaseFeedback();
Q_INVOKABLE void notifyText(QString text);
Q_INVOKABLE void copyTextToClipboard(QString str);
99
100
101
bool canPaste();
bool terminalHasSelection();
102
103
104
void bellAlert();
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
QString fontFamily();
int dragMode();
void setDragMode(int mode);
int keyboardMode();
void setKeyboardMode(int mode);
int keyboardFadeOutDelay();
void setKeyboardFadeOutDelay(int delay);
QString keyboardLayout();
void setKeyboardLayout(const QString &layout);
int extraLinesFromCursor();
QString charset();
int keyboardMargins();
int orientationMode();
void setOrientationMode(int mode);
bool showWelcomeScreen();
void setShowWelcomeScreen(bool value);
129
130
signals:
void visualBell();
131
void notify(QString msg);
132
133
void clipboardOrSelectionChanged();
void windowTitleChanged();
134
void windowOrientationChanged();
135
136
137
138
139
140
141
void fontSizeChanged();
void dragModeChanged();
void keyboardModeChanged();
void keyboardFadeOutDelayChanged();
void keyboardLayoutChanged();
void orientationModeChanged();
void showWelcomeScreenChanged();
142
143
144
145
146
147
148
private:
Q_DISABLE_COPY(Util)
QString iCurrentWinTitle;
QSettings* iSettings;
149
QQuickView* iWindow;
150
151
152
153
Terminal* iTerm;
};
#endif // UTIL_H