Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
ParameterApp.cpp
1#include "ParameterApp.h"
2#include <QSettings>
3#include <QDir>
4#include "RabbitCommonDir.h"
5#ifdef HAVE_ICE
6 #include "Ice.h"
7#endif
8
9CParameterApp::CParameterApp(QObject *parent) : QObject(parent),
10 m_bReceiveShortCut(false),
11 m_bSaveMainWindowStatus(true),
12 m_TabPosition(QTabWidget::North),
13 m_bEnableTabToolTip(true),
14 m_bEnableTabIcon(true),
15 m_nRecentMenuMaxCount(10),
16 m_SystemTrayIconType(SystemTrayIconMenuType::MenuBar),
17 m_bEnableSystemTrayIcon(true),
18 m_bOpenLasterClose(false),
19 m_bFavoriteEdit(false),
20 m_bStatusBar(true),
21 m_bTabBar(true),
22 m_bMenuBar(true),
23 m_bMessageBoxDisplayInfomation(true)
24{
25}
26
27CParameterApp::~CParameterApp()
28{
29 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
30 QSettings::IniFormat);
31 if(GetSaveMainWindowStatus())
32 {
33 set.setValue("MainWindow/Status/Bar", GetStatusBar());
34 set.setValue("MainWindow/TabBar", GetTabBar());
35 set.setValue("MainWindow/MenuBar", GetMenuBar());
36 // Geometry and status is saved MainWindow::closeEvent()
37 }
38}
39
40int CParameterApp::Load()
41{
42 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
43 QSettings::IniFormat);
44
45 SetReceiveShortCut(set.value("MainWindow/ReceiveShortCurt",
46 GetReceiveShortCut()).toBool());
47 SetSaveMainWindowStatus(set.value("MainWindow/Status/Enable",
48 GetSaveMainWindowStatus()).toBool());
49 SetTabPosition(static_cast<QTabWidget::TabPosition>(
50 set.value("MainWindow/View/TabView/Tab/Position",
51 GetTabPosition()).toInt()));
52 SetEnableTabToolTip(set.value("MainWindow/View/TabView/Tab/Enable/ToolTip",
53 GetEnableTabToolTip()).toBool());
54 SetEnableTabIcon(set.value("MainWindow/View/TabView/Tab/Enable/Icon",
55 GetEnableTabIcon()).toBool());
56
57 SetRecentMenuMaxCount(set.value("MainWindow/Recent/Max",
58 GetRecentMenuMaxCount()).toInt());
59
60 //NOTE: The order cannot be changed
61 SetEnableSystemTrayIcon(set.value("MainWindow/SystemTrayIcon/Enable",
62 GetEnableSystemTrayIcon()).toBool());
63 SetSystemTrayIconMenuType(static_cast<SystemTrayIconMenuType>(
64 set.value("MainWindow/SystemTrayIcon/MenuType",
65 static_cast<int>(GetSystemTrayIconMenuType())).toInt()));
66
67 SetOpenLasterClose(set.value("MainWindow/OpenLasterClose",
68 GetOpenLasterClose()).toBool());
69 SetFavoriteEdit(set.value("MainWindow/Favorite/Double/Edit",
70 GetFavoriteEdit()).toBool());
71
72 SetStatusBar(set.value("MainWindow/Status/Bar",
73 GetStatusBar()).toBool());
74
75 SetTabBar(set.value("MainWindow/TabBar",
76 GetTabBar()).toBool());
77
78 SetMenuBar(set.value("MainWindow/MenuBar",
79 GetMenuBar()).toBool());
80
81 SetMessageBoxDisplayInformation(
82 set.value("MainWindow/MessageBoxDisplayInformation",
83 GetMessageBoxDisplayInformation()).toBool());
84
85#ifdef HAVE_ICE
86 return CICE::Instance()->GetParameter()->Load(set);
87#endif
88 return 0;
89}
90
91int CParameterApp::Save()
92{
93 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
94 QSettings::IniFormat);
95
96 set.setValue("MainWindow/ReceiveShortCurt", GetReceiveShortCut());
97 set.setValue("MainWindow/Status/Enable", GetSaveMainWindowStatus());
98 set.setValue("MainWindow/View/TabView/Tab/Position", GetTabPosition());
99 set.setValue("MainWindow/View/TabView/Tab/Enable/ToolTip", GetEnableTabToolTip());
100 set.setValue("MainWindow/View/TabView/Tab/Enable/Icon", GetEnableTabIcon());
101 set.setValue("MainWindow/Recent/Max", GetRecentMenuMaxCount());
102 set.setValue("MainWindow/SystemTrayIcon/Enable", GetEnableSystemTrayIcon());
103 set.setValue("MainWindow/SystemTrayIcon/MenuType",
104 static_cast<int>(GetSystemTrayIconMenuType()));
105 set.setValue("MainWindow/OpenLasterClose", GetOpenLasterClose());
106 set.setValue("MainWindow/Favorite/Double/Edit", GetFavoriteEdit());
107 set.setValue("MainWindow/MessageBoxDisplayInformation", GetMessageBoxDisplayInformation());
108
109#ifdef HAVE_ICE
110 return CICE::Instance()->GetParameter()->Save(set);
111#endif
112 return 0;
113}
114
115bool CParameterApp::GetReceiveShortCut() const
116{
117 return m_bReceiveShortCut;
118}
119
120void CParameterApp::SetReceiveShortCut(bool newReceiveShortCut)
121{
122 if (m_bReceiveShortCut == newReceiveShortCut)
123 return;
124 m_bReceiveShortCut = newReceiveShortCut;
125 emit sigReceiveShortCutChanged();
126}
127
128bool CParameterApp::GetSaveMainWindowStatus() const
129{
130 return m_bSaveMainWindowStatus;
131}
132
133void CParameterApp::SetSaveMainWindowStatus(bool newSaveMainWindowStatus)
134{
135 if (m_bSaveMainWindowStatus == newSaveMainWindowStatus)
136 return;
137 m_bSaveMainWindowStatus = newSaveMainWindowStatus;
138 emit sigSaveMainWindowStatusChanged();
139}
140
141const QTabWidget::TabPosition &CParameterApp::GetTabPosition() const
142{
143 return m_TabPosition;
144}
145
146void CParameterApp::SetTabPosition(const QTabWidget::TabPosition &newTabPosition)
147{
148 if (m_TabPosition == newTabPosition)
149 return;
150 m_TabPosition = newTabPosition;
151 emit sigTabPositionChanged();
152}
153
154const bool CParameterApp::GetEnableTabToolTip() const
155{
156 return m_bEnableTabToolTip;
157}
158
159void CParameterApp::SetEnableTabToolTip(bool bEnable)
160{
161 if(m_bEnableTabToolTip == bEnable)
162 return;
163 m_bEnableTabToolTip = bEnable;
164 emit sigEnableTabToolTipChanged();
165}
166
167const bool CParameterApp::GetEnableTabIcon() const
168{
169 return m_bEnableTabIcon;
170}
171
172void CParameterApp::SetEnableTabIcon(bool bEnable)
173{
174 if(m_bEnableTabIcon == bEnable)
175 return;
176 m_bEnableTabIcon = bEnable;
177 emit sigEnableTabIconChanged();
178}
179
180int CParameterApp::GetRecentMenuMaxCount() const
181{
182 return m_nRecentMenuMaxCount;
183}
184
185void CParameterApp::SetRecentMenuMaxCount(int newRecentMenuMaxCount)
186{
187 if (m_nRecentMenuMaxCount == newRecentMenuMaxCount)
188 return;
189 m_nRecentMenuMaxCount = newRecentMenuMaxCount;
190 emit sigRecentMenuMaxCountChanged(m_nRecentMenuMaxCount);
191}
192
193CParameterApp::SystemTrayIconMenuType CParameterApp::GetSystemTrayIconMenuType() const
194{
195 return m_SystemTrayIconType;
196}
197
198void CParameterApp::SetSystemTrayIconMenuType(SystemTrayIconMenuType newSystemTrayIconType)
199{
200 if(m_SystemTrayIconType == newSystemTrayIconType)
201 return;
202 m_SystemTrayIconType = newSystemTrayIconType;
203 emit sigSystemTrayIconTypeChanged();
204}
205
206bool CParameterApp::GetEnableSystemTrayIcon() const
207{
208 return m_bEnableSystemTrayIcon;
209}
210
211int CParameterApp::SetEnableSystemTrayIcon(bool bShow)
212{
213 if(m_bEnableSystemTrayIcon == bShow)
214 return 0;
215 m_bEnableSystemTrayIcon = bShow;
216 emit sigEnableSystemTrayIcon();
217 return 0;
218}
219
220bool CParameterApp::GetOpenLasterClose() const
221{
222 return m_bOpenLasterClose;
223}
224
225void CParameterApp::SetOpenLasterClose(bool newOpenLasterClose)
226{
227 if (m_bOpenLasterClose == newOpenLasterClose)
228 return;
229 m_bOpenLasterClose = newOpenLasterClose;
230 emit sigOpenLasterCloseChanged(m_bOpenLasterClose);
231}
232
233bool CParameterApp::GetFavoriteEdit() const
234{
235 return m_bFavoriteEdit;
236}
237
238void CParameterApp::SetFavoriteEdit(bool newFavoriteEdit)
239{
240 m_bFavoriteEdit = newFavoriteEdit;
241 emit sigFavoriteEditChanged(m_bFavoriteEdit);
242}
243
244bool CParameterApp::GetStatusBar() const
245{
246 return m_bStatusBar;
247}
248
249void CParameterApp::SetStatusBar(bool checked)
250{
251 m_bStatusBar = checked;
252}
253
254bool CParameterApp::GetTabBar() const
255{
256 return m_bTabBar;
257}
258
259void CParameterApp::SetTabBar(bool checked)
260{
261 m_bTabBar = checked;
262}
263
264bool CParameterApp::GetMenuBar() const
265{
266 return m_bMenuBar;
267}
268
269void CParameterApp::SetMenuBar(bool checked)
270{
271 m_bMenuBar = checked;
272}
273
274const bool CParameterApp::GetMessageBoxDisplayInformation() const
275{
276 return m_bMessageBoxDisplayInfomation;
277}
278
279void CParameterApp::SetMessageBoxDisplayInformation(bool bEnable)
280{
281 if(m_bMessageBoxDisplayInfomation == bEnable)
282 return;
283 m_bMessageBoxDisplayInfomation = bEnable;
284}
static CICE * Instance()
Single instance.
Definition Ice.cpp:55