Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ParameterTerminal.cpp
1#include "ParameterTerminal.h"
2#include <QApplication>
3#include <QDebug>
4#include <QSettings>
5
6CParameterTerminal::CParameterTerminal()
7{
8 m_Font = QApplication::font();
9#ifdef Q_OS_MACOS
10 font.setFamily(QStringLiteral("Monaco"));
11#elif defined(Q_WS_QWS)
12 font.setFamily(QStringLiteral("fixed"));
13#else
14 m_Font.setFamily(QStringLiteral("Monospace"));
15#endif
16 m_Font.setStyleHint(QFont::TypeWriter);
17 m_Font.setPointSize(12);
18
19 m_bSizeHint = false;
20 m_szColorScheme = "GreenOnBlack";
21 m_CursorShape = Konsole::Emulation::KeyboardCursorShape::BlockCursor;
22 m_ScrollBarPosition = QTermWidget::ScrollBarRight;
23 m_nTransparency = 0;
24 m_bFlowControl = false;
25 m_bFlowControlWarning = false;
26 m_bMotionAfterPasting = false;
27 m_bDisableBracketedPasteMode = false;
28 m_bDirectional = true;
29
30#if defined (Q_OS_LINUX)
31 m_szKeyBindings = "linux";
32#else
33 szKeyBindings = "default";
34#endif
35 m_szTextCodec = "UTF-8";
36 m_nHistorySize = 1000;
37}
38
39int CParameterTerminal::Load(QSettings &set)
40{
41 m_Font.fromString(set.value("Terminal/Font", m_Font.toString()).toString());
42 SetSizeHint(set.value("Terminal/SizeHint", GetSizeHint()).toBool());
43 m_szColorScheme = set.value("Terminal/ColorScheme", m_szColorScheme).toString();
44 m_nTransparency = set.value("Terminal/Transparency",
45 m_nTransparency).toInt();
46 m_bFlowControl = set.value("Terminal/flowControl", m_bFlowControl).toBool();
47 m_bFlowControlWarning = set.value("Terminal/flowControlWarning",
48 m_bFlowControlWarning).toBool();
49 m_bMotionAfterPasting = set.value("Terminal/motionAfterPasting",
50 m_bMotionAfterPasting).toBool();
51 m_bDirectional = set.value("Terminal/Directional", m_bDirectional).toBool();
52 m_bDisableBracketedPasteMode = set.value("Terminal/disableBracketedPasteMode",
53 m_bDisableBracketedPasteMode).toBool();
54 m_BackgroupImage = set.value("Terminal/BackgroupImage",
55 m_BackgroupImage).toString();
56 m_CursorShape = static_cast<Konsole::Emulation::KeyboardCursorShape>(
57 set.value("Terminal/cursorShape",static_cast<int>(m_CursorShape)).toInt());
58 m_ScrollBarPosition = static_cast<QTermWidget::ScrollBarPosition>
59 (set.value("Terminal/scrollBarPosition",
60 static_cast<int>(m_ScrollBarPosition)).toInt());
61 m_szKeyBindings = set.value("Terminal/KeyBindings", m_szKeyBindings).toString();
62 m_szTextCodec = set.value("Terminal/TextCodec", m_szTextCodec).toString();
63 m_nHistorySize = set.value("Terminal/HistorySize", m_nHistorySize).toInt();
64 return CParameterConnecter::Load(set);
65}
66
67int CParameterTerminal::Save(QSettings &set)
68{
69 set.setValue("Terminal/Font", m_Font.toString());
70 set.setValue("Terminal/SizeHint", GetSizeHint());
71 set.setValue("Terminal/ColorScheme", m_szColorScheme);
72 set.setValue("Terminal/Transparency", m_nTransparency);
73 set.setValue("Terminal/flowControl", m_bFlowControl);
74 set.setValue("Terminal/flowControlWarning", m_bFlowControlWarning);
75 set.setValue("Terminal/motionAfterPasting", m_bMotionAfterPasting);
76 set.setValue("Terminal/Directional", m_bDirectional);
77 set.setValue("Terminal/disableBracketedPasteMode", m_bDisableBracketedPasteMode);
78 set.setValue("Terminal/BackgroupImage", m_BackgroupImage);
79 set.setValue("Terminal/cursorShape", static_cast<int>(m_CursorShape));
80 set.setValue("Terminal/scrollBarPosition",
81 static_cast<int>(m_ScrollBarPosition));
82 set.setValue("Terminal/KeyBindings", m_szKeyBindings);
83 set.setValue("Terminal/TextCodec", m_szTextCodec);
84 set.setValue("Terminal/HistorySize", m_nHistorySize);
85 return CParameterConnecter::Save(set);
86}
87
88int CParameterTerminal::GetHistorySize() const
89{
90 return m_nHistorySize;
91}
92
93void CParameterTerminal::SetHistorySize(int newHistorySize)
94{
95 if(m_nHistorySize == newHistorySize)
96 return;
97 m_nHistorySize = newHistorySize;
98 SetModified(true);
99}
100
101const QString &CParameterTerminal::GetTextCodec() const
102{
103 return m_szTextCodec;
104}
105
106void CParameterTerminal::SetTextCodec(const QString &newTextCodec)
107{
108 if(m_szTextCodec == newTextCodec)
109 return;
110 m_szTextCodec = newTextCodec;
111 SetModified(true);
112}
113
114const QString &CParameterTerminal::GetKeyBindings() const
115{
116 return m_szKeyBindings;
117}
118
119void CParameterTerminal::SetKeyBindings(const QString &newSzKeyBindings)
120{
121 if(m_szKeyBindings == newSzKeyBindings)
122 return;
123 m_szKeyBindings = newSzKeyBindings;
124 SetModified(true);
125}
126
127bool CParameterTerminal::GetDirectional() const
128{
129 return m_bDirectional;
130}
131
132void CParameterTerminal::SetDirectional(bool newBiDirectional)
133{
134 if(m_bDirectional == newBiDirectional)
135 return;
136 m_bDirectional = newBiDirectional;
137 SetModified(true);
138}
139
140bool CParameterTerminal::GetDisableBracketedPasteMode() const
141{
142 return m_bDisableBracketedPasteMode;
143}
144
145void CParameterTerminal::SetDisableBracketedPasteMode(bool newDisableBracketedPasteMode)
146{
147 if(m_bDisableBracketedPasteMode == newDisableBracketedPasteMode)
148 return;
149 m_bDisableBracketedPasteMode = newDisableBracketedPasteMode;
150 SetModified(true);
151}
152
153bool CParameterTerminal::GetMotionAfterPasting() const
154{
155 return m_bMotionAfterPasting;
156}
157
158void CParameterTerminal::SetMotionAfterPasting(bool newMotionAfterPasting)
159{
160 if(m_bMotionAfterPasting == newMotionAfterPasting)
161 return;
162 m_bMotionAfterPasting = newMotionAfterPasting;
163 SetModified(true);
164}
165
166bool CParameterTerminal::GetFlowControlWarning() const
167{
168 return m_bFlowControlWarning;
169}
170
171void CParameterTerminal::SetFlowControlWarning(bool newFlowControlWarning)
172{
173 if(m_bFlowControlWarning == newFlowControlWarning)
174 return;
175 m_bFlowControlWarning = newFlowControlWarning;
176 SetModified(true);
177}
178
179bool CParameterTerminal::GetFlowControl() const
180{
181 return m_bFlowControl;
182}
183
184void CParameterTerminal::SetFlowControl(bool newFlowControl)
185{
186 if(m_bFlowControl == newFlowControl)
187 return;
188 m_bFlowControl = newFlowControl;
189 SetModified(true);
190}
191
192const QString &CParameterTerminal::GetBackgroupImage() const
193{
194 return m_BackgroupImage;
195}
196
197void CParameterTerminal::SetBackgroupImage(const QString &newBackgroupImage)
198{
199 if(m_BackgroupImage == newBackgroupImage)
200 return;
201 m_BackgroupImage = newBackgroupImage;
202 SetModified(true);
203}
204
205int CParameterTerminal::GetTransparency() const
206{
207 return m_nTransparency;
208}
209
210void CParameterTerminal::SetTransparency(int newTermTransparency)
211{
212 if(m_nTransparency == newTermTransparency)
213 return;
214 m_nTransparency = newTermTransparency;
215 SetModified(true);
216}
217
218QTermWidget::ScrollBarPosition CParameterTerminal::GetScrollBarPosition() const
219{
220 return m_ScrollBarPosition;
221}
222
223void CParameterTerminal::SetScrollBarPosition(QTermWidget::ScrollBarPosition newScrollBarPosition)
224{
225 if(m_ScrollBarPosition == newScrollBarPosition)
226 return;
227 m_ScrollBarPosition = newScrollBarPosition;
228 SetModified(true);
229}
230
231Konsole::Emulation::KeyboardCursorShape CParameterTerminal::GetCursorShape() const
232{
233 return m_CursorShape;
234}
235
236void CParameterTerminal::SetCursorShape(Konsole::Emulation::KeyboardCursorShape newCursorShape)
237{
238 if(m_CursorShape == newCursorShape)
239 return;
240 m_CursorShape = newCursorShape;
241 SetModified(true);
242}
243
244const QString &CParameterTerminal::GetColorScheme() const
245{
246 return m_szColorScheme;
247}
248
249void CParameterTerminal::SetColorScheme(const QString &newColorScheme)
250{
251 if(m_szColorScheme == newColorScheme)
252 return;
253 m_szColorScheme = newColorScheme;
254 SetModified(true);
255}
256
257bool CParameterTerminal::GetSizeHint() const
258{
259 return m_bSizeHint;
260}
261
262void CParameterTerminal::SetSizeHint(bool newSizeHint)
263{
264 if(m_bSizeHint == newSizeHint)
265 return;
266 m_bSizeHint = newSizeHint;
267 SetModified(true);
268}
269
270const QFont &CParameterTerminal::GetFont() const
271{
272 return m_Font;
273}
274
275void CParameterTerminal::SetFont(const QFont &newFont)
276{
277 if(m_Font == newFont)
278 return;
279 m_Font = newFont;
280 SetModified(true);
281}
virtual int Load(QSettings &set) override
Load from storage.
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.
virtual int Save(QString szFile=QString(), bool bForce=true)
Save to file.
Definition Parameter.cpp:44
virtual int Load(QString szFile=QString())
Load from file.
Definition Parameter.cpp:33