3#include <QStandardPaths>
4#include <QLoggingCategory>
5#include <QWebEngineProfile>
6#include "ParameterWebBrowser.h"
8static Q_LOGGING_CATEGORY(log,
"WebBrowser.Parameter")
12 , m_MediaDevices(
this)
13 , m_bOpenPrevious(
false)
14 , m_bShowDownloadManager(
true)
15 , m_bShowDownloadLocation(
false)
16 , m_ClearHttpCache(
false)
17 , m_ClearCookie(
false)
18 , m_bPromptPrintFinished(
true)
19 , m_bAutoFillUserAndPassword(
false)
20 , m_nDatabaseViewLimit(100)
21 , m_nAddCompleterLines(10)
22 , m_WindowSize(600, 450)
23 , m_nBookmarkCurrentFolder(1)
24 , m_bBookmarkShowEditor(
true)
26 SetHomeUrl(
"https://github.com/KangLin");
27 SetTabUrl(
"https://github.com/KangLin/RabbitRemoteControl");
29 SetDownloadFolder(QWebEngineProfile::defaultProfile()->downloadPath());
30 qDebug(log) <<
"Download folder:" << GetDownloadFolder();
31 if(QLocale::system().language() == QLocale::Language::Chinese)
32 SetSearchEngine(
"https://www.bing.com/search?q=%s");
34 SetSearchEngine(
"https://www.google.com/search?q=%s");
35 SetSearchRelaceString(
"%s");
36 QStringList searchEngines;
37 searchEngines <<
"https://www.bing.com/search?q=%s"
38 <<
"https://www.google.com/search?q=%s"
39 <<
"https://www.baidu.com/s?wd=%s";
40 SetSearchEngineList(searchEngines);
43CParameterWebBrowser::~CParameterWebBrowser()
46int CParameterWebBrowser::OnLoad(QSettings &set)
49 SetHomeUrl(set.value(
"Url/Home", GetHomeUrl()).toString());
50 SetTabUrl(set.value(
"Url/Tab", GetTabUrl()).toString());
51 SetOpenPrevious(set.value(
"OpenPrevious/Enable", GetOpenPrevious()).toBool());
52 SetDownloadFolder(set.value(
"Download/Folder", GetDownloadFolder()).toString());
53 SetShowDownloadManager(set.value(
"Download/Show/Manager", GetShowDownloadManager()).toBool());
54 SetShowDownloadLocation(set.value(
"Download/Show/Location", GetShowDownloadLocation()).toBool());
55 SetClearHttpCache(set.value(
"Clear/HttpCache", GetClearHttpCache()).toBool());
56 SetClearCookie(set.value(
"Clear/Cookie", GetClearCookie()).toBool());
57 SetSearchEngine(set.value(
"SearchEngine", GetSearchEngine()).toString());
58 SetSearchRelaceString(set.value(
"SearchEngine/SearchEngine", GetSearchRelaceString()).toString());
59 SetSearchEngineList(set.value(
"SearchEngine/List", GetSearchEngineList()).toStringList());
60 SetAutoFillUserAndPassword(set.value(
"AutoFillUserPassword", GetAutoFillUserAndPassword()).toBool());
61 SetPromptPrintFinished(set.value(
"Print/Finished", GetPromptPrintFinished()).toBool());
62 SetDatabaseViewLimit(set.value(
"Database/View/Limit", GetDatabaseViewLimit()).toInt());
63 SetAddCompleterLines(set.value(
"AddCompleter/Lines", GetAddCompleterLines()).toInt());
64 SetWindowSize(set.value(
"WindowSize", GetWindowSize()).toSize());
65 SetBookmarkShowEditor(set.value(
"Bookmark/ShowEditor", GetBookmarkShowEditor()).toBool());
66 SetBookmarkCurrentFolder(set.value(
"Bookmark/CurrentFolder", GetBookmarkCurrentFolder()).toInt());
70int CParameterWebBrowser::OnSave(QSettings &set)
73 set.setValue(
"Url/Home", GetHomeUrl());
74 set.setValue(
"Url/Tab", GetTabUrl());
75 set.setValue(
"OpenPrevious/Enable", GetOpenPrevious());
76 set.setValue(
"Download/Folder", GetDownloadFolder());
77 set.setValue(
"Download/Show/Manager", GetShowDownloadManager());
78 set.setValue(
"Download/Show/Location", GetShowDownloadLocation());
79 set.setValue(
"Clear/HttpCache", GetClearHttpCache());
80 set.setValue(
"Clear/Cookie", GetClearCookie());
81 set.setValue(
"SearchEngine", GetSearchEngine());
82 set.setValue(
"SearchEngine/SearchEngine", GetSearchRelaceString());
83 set.setValue(
"SearchEngine/List", GetSearchEngineList());
84 set.setValue(
"AutoFillUserPassword", GetAutoFillUserAndPassword());
85 set.setValue(
"Print/Finished", GetPromptPrintFinished());
86 set.setValue(
"Database/View/Limit", GetDatabaseViewLimit());
87 set.setValue(
"AddCompleter/Lines", GetAddCompleterLines());
88 set.setValue(
"WindowSize", GetWindowSize());
89 set.setValue(
"Bookmark/ShowEditor", GetBookmarkShowEditor());
90 set.setValue(
"Bookmark/CurrentFolder", GetBookmarkCurrentFolder());
94void CParameterWebBrowser::slotSetGlobalParameters()
98 QString szErr =
"The CParameterClient is null";
99 qCritical(log) << szErr;
100 Q_ASSERT_X(
false,
"CParameterWebBrowser", szErr.toStdString().c_str());
103 m_Record = pPlugin->m_Record;
104 m_MediaDevices = pPlugin->m_MediaDevices;
107QString CParameterWebBrowser::GetHomeUrl()
112int CParameterWebBrowser::SetHomeUrl(
const QString& url)
114 if(m_szHomeUrl == url)
121QString CParameterWebBrowser::GetTabUrl()
126int CParameterWebBrowser::SetTabUrl(
const QString& url)
128 if(m_szTabUrl == url)
135bool CParameterWebBrowser::GetOpenPrevious()
137 return m_bOpenPrevious;
140void CParameterWebBrowser::SetOpenPrevious(
bool bOpen)
142 if(m_bOpenPrevious == bOpen)
144 m_bOpenPrevious = bOpen;
148QString CParameterWebBrowser::GetDownloadFolder()
150 return m_szDownloadFolder;
153int CParameterWebBrowser::SetDownloadFolder(
const QString& folder)
155 if(m_szDownloadFolder == folder)
157 m_szDownloadFolder = folder;
159 emit sigDownloadFolderChanged();
163bool CParameterWebBrowser::GetShowDownloadManager()
const
165 return m_bShowDownloadManager;
168void CParameterWebBrowser::SetShowDownloadManager(
bool newShowDownloadManager)
170 if(m_bShowDownloadManager == newShowDownloadManager)
172 m_bShowDownloadManager = newShowDownloadManager;
176bool CParameterWebBrowser::GetShowDownloadLocation()
const
178 return m_bShowDownloadLocation;
181void CParameterWebBrowser::SetShowDownloadLocation(
bool newShowDownloadLocation)
183 if(m_bShowDownloadLocation == newShowDownloadLocation)
185 m_bShowDownloadLocation = newShowDownloadLocation;
189bool CParameterWebBrowser::GetClearCookie()
const
191 return m_ClearCookie;
194void CParameterWebBrowser::SetClearCookie(
bool newClearCookie)
196 if(m_ClearCookie == newClearCookie)
198 m_ClearCookie = newClearCookie;
202bool CParameterWebBrowser::GetClearHttpCache()
const
204 return m_ClearHttpCache;
207void CParameterWebBrowser::SetClearHttpCache(
bool newClearHttpCache)
209 if(m_ClearHttpCache == newClearHttpCache)
211 m_ClearHttpCache = newClearHttpCache;
215QString CParameterWebBrowser::GetSearchEngine()
const
217 return m_szSearchEngine;
220void CParameterWebBrowser::SetSearchEngine(
const QString &newSearchEngine)
222 if(m_szSearchEngine == newSearchEngine)
224 m_szSearchEngine = newSearchEngine;
228QString CParameterWebBrowser::GetSearchRelaceString()
const
230 return m_szSearchRelaceString;
233void CParameterWebBrowser::SetSearchRelaceString(
const QString &newSearchRelaceString)
235 if(m_szSearchRelaceString == newSearchRelaceString)
237 m_szSearchRelaceString = newSearchRelaceString;
241QStringList CParameterWebBrowser::GetSearchEngineList()
const
243 return m_SearchEngineList;
246void CParameterWebBrowser::SetSearchEngineList(
const QStringList &newSearchEngineList)
248 if(m_SearchEngineList == newSearchEngineList)
250 m_SearchEngineList = newSearchEngineList;
254bool CParameterWebBrowser::GetPromptPrintFinished()
const
256 return m_bPromptPrintFinished;
259void CParameterWebBrowser::SetPromptPrintFinished(
bool newPromptPrintFinished)
261 if(m_bPromptPrintFinished == newPromptPrintFinished)
263 m_bPromptPrintFinished = newPromptPrintFinished;
267bool CParameterWebBrowser::GetAutoFillUserAndPassword()
const
269 return m_bAutoFillUserAndPassword;
272void CParameterWebBrowser::SetAutoFillUserAndPassword(
bool newAutoFillUserAndPassword)
274 if(m_bAutoFillUserAndPassword == newAutoFillUserAndPassword)
276 m_bAutoFillUserAndPassword = newAutoFillUserAndPassword;
280int CParameterWebBrowser::GetDatabaseViewLimit()
const
282 return m_nDatabaseViewLimit;
285void CParameterWebBrowser::SetDatabaseViewLimit(
int newLimit)
287 if(m_nDatabaseViewLimit == newLimit)
289 m_nDatabaseViewLimit = newLimit;
293int CParameterWebBrowser::GetAddCompleterLines()
const
295 return m_nAddCompleterLines;
298void CParameterWebBrowser::SetAddCompleterLines(
int newAddCompleterLines)
300 if(m_nAddCompleterLines == newAddCompleterLines)
302 m_nAddCompleterLines = newAddCompleterLines;
306QSize CParameterWebBrowser::GetWindowSize()
const
311void CParameterWebBrowser::SetWindowSize(
const QSize &newWindowSize)
313 if(m_WindowSize == newWindowSize)
315 m_WindowSize = newWindowSize;
319int CParameterWebBrowser::GetBookmarkCurrentFolder()
const
321 return m_nBookmarkCurrentFolder;
324void CParameterWebBrowser::SetBookmarkCurrentFolder(
int newCurrentBookmarkFolder)
326 if(m_nBookmarkCurrentFolder == newCurrentBookmarkFolder)
328 m_nBookmarkCurrentFolder = newCurrentBookmarkFolder;
332bool CParameterWebBrowser::GetBookmarkShowEditor()
const
334 return m_bBookmarkShowEditor;
337void CParameterWebBrowser::SetBookmarkShowEditor(
bool newBookmarkShowEditor)
339 if(m_bBookmarkShowEditor == newBookmarkShowEditor)
341 m_bBookmarkShowEditor = newBookmarkShowEditor;
Operational parameter interface.
CParameterPlugin * GetGlobalParameters()
Get CParameterPlugin.
Global parameters of plugins.
int SetModified(bool bModified=true)
When setting parameters, if there is a modification, it is called.