diff --git a/data/org.ukui.search.data.gschema.xml b/data/org.ukui.search.data.gschema.xml
index 2494b22..f4f0158 100644
--- a/data/org.ukui.search.data.gschema.xml
+++ b/data/org.ukui.search.data.gschema.xml
@@ -5,5 +5,10 @@
search method
Is current search-method index-search.
+
+ "baidu"
+ web engine
+ Web engine to search keyword online.
+
diff --git a/debian/ukui-search.install b/debian/ukui-search.install
index db54699..d7f1780 100644
--- a/debian/ukui-search.install
+++ b/debian/ukui-search.install
@@ -2,3 +2,4 @@ usr/bin/ukui-search
etc/xdg/autostart/*.desktop
usr/share/applications/*.desktop
src/.qm/*.qm usr/share/ukui-search/translations
+usr/share/glib-2.0/schemas/*.xml
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 66c65ab..0b7466e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -475,12 +475,19 @@ void MainWindow::initGsettings()
if (key == SEARCH_METHOD_KEY) {
bool is_index_search = m_search_gsettings->get(SEARCH_METHOD_KEY).toBool();
this->setSearchMethod(is_index_search);
+ } else if (key == WEB_ENGINE_KEY) {
+ QString web_engine = m_search_gsettings->get(WEB_ENGINE_KEY).toString();
+ GlobalSettings::getInstance()->setValue(WEB_ENGINE, web_engine);
}
});
if (m_search_gsettings->keys().contains(SEARCH_METHOD_KEY)) {
bool is_index_search = m_search_gsettings->get(SEARCH_METHOD_KEY).toBool();
this->setSearchMethod(is_index_search);
}
+ if (m_search_gsettings->keys().contains(WEB_ENGINE_KEY)) {
+ QString web_engine = m_search_gsettings->get(WEB_ENGINE_KEY).toString();
+ GlobalSettings::getInstance()->setValue(WEB_ENGINE, web_engine);
+ }
}
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index fea8092..8b98989 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -54,9 +54,9 @@
#include "xatom-helper.h"
#include "create-index-ask-dialog.h"
-
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
#define SEARCH_METHOD_KEY "indexSearch"
+#define WEB_ENGINE_KEY "webEngine"
class SearchResult;
class MainWindow : public QMainWindow
@@ -99,8 +99,6 @@ private:
SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout
SeachBarWidget * m_searchWidget = nullptr; // Search bar
-
-
QStringList m_dirList;
QQueue *m_search_result_file = nullptr;
diff --git a/src/settings-widget.cpp b/src/settings-widget.cpp
index 0581fac..210d468 100644
--- a/src/settings-widget.cpp
+++ b/src/settings-widget.cpp
@@ -42,6 +42,16 @@ SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent)
m_hints.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
+ const QByteArray id(UKUI_SEARCH_SCHEMAS);
+ if (QGSettings::isSchemaInstalled(id)) {
+ m_web_engine_gsettings = new QGSettings(id);
+ connect(m_web_engine_gsettings, &QGSettings::changed, this, [ = ](const QString &key) {
+ if (key == WEB_ENGINE_KEY) {
+ resetWebEngine();
+ }
+ });
+ }
+
initUi();
refreshIndexState();
setupBlackList(GlobalSettings::getInstance()->getBlockDirs());
@@ -315,11 +325,16 @@ void SettingsWidget::onBtnDelClicked(const QString& path) {
}
/**
- * @brief SettingsWidget::resetWebEngine 获取当前的搜索引擎并反应在UI控件上
+ * @brief SettingsWidget::resetWebEngine 获取当前的搜索引擎并反映在UI控件上
*/
void SettingsWidget::resetWebEngine()
{
- QString engine = GlobalSettings::getInstance()->getValue(WEB_ENGINE).toString();
+ QString engine;
+ if (m_web_engine_gsettings && m_web_engine_gsettings->keys().contains(WEB_ENGINE_KEY)) {
+ engine = m_web_engine_gsettings->get(WEB_ENGINE_KEY).toString();
+ } else {
+ engine = GlobalSettings::getInstance()->getValue(WEB_ENGINE).toString();
+ }
m_engineBtnGroup->blockSignals(true);
if (!engine.isEmpty()) {
if (engine == "360") {
@@ -341,7 +356,11 @@ void SettingsWidget::resetWebEngine()
*/
void SettingsWidget::setWebEngine(const QString& engine)
{
- GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine);
+ if (m_web_engine_gsettings && m_web_engine_gsettings->keys().contains(WEB_ENGINE_KEY)) {
+ m_web_engine_gsettings->set(WEB_ENGINE_KEY, engine);
+ } else {
+ GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine);
+ }
}
/**
diff --git a/src/settings-widget.h b/src/settings-widget.h
index fdb1c87..39787ad 100644
--- a/src/settings-widget.h
+++ b/src/settings-widget.h
@@ -35,6 +35,9 @@
#include
#include "xatom-helper.h"
+#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
+#define WEB_ENGINE_KEY "webEngine"
+
class SettingsWidget : public QWidget
{
Q_OBJECT
@@ -107,6 +110,8 @@ private:
int m_blockdirs = 0; //黑名单文件夹数量
+ QGSettings * m_web_engine_gsettings = nullptr;
+
Q_SIGNALS:
void settingWidgetClosed();