Feature:Add web-engine settings key.
This commit is contained in:
parent
53c07dd9c2
commit
25d8634ed4
|
@ -5,5 +5,10 @@
|
||||||
<summary>search method</summary>
|
<summary>search method</summary>
|
||||||
<description>Is current search-method index-search.</description>
|
<description>Is current search-method index-search.</description>
|
||||||
</key>
|
</key>
|
||||||
|
<key name="web-engine" type="s">
|
||||||
|
<default>"baidu"</default>
|
||||||
|
<summary>web engine</summary>
|
||||||
|
<description>Web engine to search keyword online.</description>
|
||||||
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
</schemalist>
|
</schemalist>
|
||||||
|
|
|
@ -2,3 +2,4 @@ usr/bin/ukui-search
|
||||||
etc/xdg/autostart/*.desktop
|
etc/xdg/autostart/*.desktop
|
||||||
usr/share/applications/*.desktop
|
usr/share/applications/*.desktop
|
||||||
src/.qm/*.qm usr/share/ukui-search/translations
|
src/.qm/*.qm usr/share/ukui-search/translations
|
||||||
|
usr/share/glib-2.0/schemas/*.xml
|
||||||
|
|
|
@ -475,12 +475,19 @@ void MainWindow::initGsettings()
|
||||||
if (key == SEARCH_METHOD_KEY) {
|
if (key == SEARCH_METHOD_KEY) {
|
||||||
bool is_index_search = m_search_gsettings->get(SEARCH_METHOD_KEY).toBool();
|
bool is_index_search = m_search_gsettings->get(SEARCH_METHOD_KEY).toBool();
|
||||||
this->setSearchMethod(is_index_search);
|
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)) {
|
if (m_search_gsettings->keys().contains(SEARCH_METHOD_KEY)) {
|
||||||
bool is_index_search = m_search_gsettings->get(SEARCH_METHOD_KEY).toBool();
|
bool is_index_search = m_search_gsettings->get(SEARCH_METHOD_KEY).toBool();
|
||||||
this->setSearchMethod(is_index_search);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,9 @@
|
||||||
#include "xatom-helper.h"
|
#include "xatom-helper.h"
|
||||||
#include "create-index-ask-dialog.h"
|
#include "create-index-ask-dialog.h"
|
||||||
|
|
||||||
|
|
||||||
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
||||||
#define SEARCH_METHOD_KEY "indexSearch"
|
#define SEARCH_METHOD_KEY "indexSearch"
|
||||||
|
#define WEB_ENGINE_KEY "webEngine"
|
||||||
|
|
||||||
class SearchResult;
|
class SearchResult;
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
|
@ -99,8 +99,6 @@ private:
|
||||||
SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout
|
SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout
|
||||||
SeachBarWidget * m_searchWidget = nullptr; // Search bar
|
SeachBarWidget * m_searchWidget = nullptr; // Search bar
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QStringList m_dirList;
|
QStringList m_dirList;
|
||||||
|
|
||||||
QQueue<QString> *m_search_result_file = nullptr;
|
QQueue<QString> *m_search_result_file = nullptr;
|
||||||
|
|
|
@ -42,6 +42,16 @@ SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent)
|
||||||
m_hints.decorations = MWM_DECOR_BORDER;
|
m_hints.decorations = MWM_DECOR_BORDER;
|
||||||
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
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();
|
initUi();
|
||||||
refreshIndexState();
|
refreshIndexState();
|
||||||
setupBlackList(GlobalSettings::getInstance()->getBlockDirs());
|
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()
|
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);
|
m_engineBtnGroup->blockSignals(true);
|
||||||
if (!engine.isEmpty()) {
|
if (!engine.isEmpty()) {
|
||||||
if (engine == "360") {
|
if (engine == "360") {
|
||||||
|
@ -341,7 +356,11 @@ void SettingsWidget::resetWebEngine()
|
||||||
*/
|
*/
|
||||||
void SettingsWidget::setWebEngine(const QString& engine)
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,6 +35,9 @@
|
||||||
#include <libsearch.h>
|
#include <libsearch.h>
|
||||||
#include "xatom-helper.h"
|
#include "xatom-helper.h"
|
||||||
|
|
||||||
|
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
||||||
|
#define WEB_ENGINE_KEY "webEngine"
|
||||||
|
|
||||||
class SettingsWidget : public QWidget
|
class SettingsWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -107,6 +110,8 @@ private:
|
||||||
|
|
||||||
int m_blockdirs = 0; //黑名单文件夹数量
|
int m_blockdirs = 0; //黑名单文件夹数量
|
||||||
|
|
||||||
|
QGSettings * m_web_engine_gsettings = nullptr;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void settingWidgetClosed();
|
void settingWidgetClosed();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue