forked from openkylin/ukui-search
Merge pull request #207 from mammonsama666/0420-dev
Feature:Add web-engine settings key.
This commit is contained in:
commit
75f4eade12
|
@ -5,5 +5,10 @@
|
|||
<summary>search method</summary>
|
||||
<description>Is current search-method index-search.</description>
|
||||
</key>
|
||||
<key name="web-engine" type="s">
|
||||
<default>"baidu"</default>
|
||||
<summary>web engine</summary>
|
||||
<description>Web engine to search keyword online.</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -214,6 +214,16 @@ void MainWindow::initUi()
|
|||
return;
|
||||
}
|
||||
m_settingsWidget = new SettingsWidget();
|
||||
connect(this, &MainWindow::webEngineChanged, m_settingsWidget, [ = ]() {
|
||||
m_settingsWidget->resetWebEngine();
|
||||
});
|
||||
connect(m_settingsWidget, &SettingsWidget::webEngineChanged, this, [ = ](const QString &engine) {
|
||||
if (m_search_gsettings && m_search_gsettings->keys().contains(WEB_ENGINE_KEY)) {
|
||||
m_search_gsettings->set(WEB_ENGINE_KEY, engine);
|
||||
} else {
|
||||
GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine);
|
||||
}
|
||||
});
|
||||
centerToScreen(m_settingsWidget);
|
||||
m_settingsWidget->show();
|
||||
connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() {
|
||||
|
@ -475,12 +485,20 @@ 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);
|
||||
Q_EMIT this->webEngineChanged();
|
||||
}
|
||||
});
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<QString> *m_search_result_file = nullptr;
|
||||
|
@ -133,6 +131,7 @@ protected:
|
|||
|
||||
Q_SIGNALS:
|
||||
void searchMethodChanged(FileUtils::SearchMethod);
|
||||
void webEngineChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
|
|
|
@ -315,7 +315,7 @@ void SettingsWidget::onBtnDelClicked(const QString& path) {
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief SettingsWidget::resetWebEngine 获取当前的搜索引擎并反应在UI控件上
|
||||
* @brief SettingsWidget::resetWebEngine 获取当前的搜索引擎并反映在UI控件上
|
||||
*/
|
||||
void SettingsWidget::resetWebEngine()
|
||||
{
|
||||
|
@ -341,7 +341,8 @@ void SettingsWidget::resetWebEngine()
|
|||
*/
|
||||
void SettingsWidget::setWebEngine(const QString& engine)
|
||||
{
|
||||
GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine);
|
||||
// GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine);
|
||||
Q_EMIT this->webEngineChanged(engine);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
void setIndexState(bool);
|
||||
void setIndexNum(int);
|
||||
void showWidget();
|
||||
void resetWebEngine();
|
||||
|
||||
private:
|
||||
void initUi();
|
||||
|
@ -54,7 +55,6 @@ private:
|
|||
void paintEvent(QPaintEvent *);
|
||||
void resize();
|
||||
void showWarningDialog(const int&);
|
||||
void resetWebEngine();
|
||||
|
||||
MotifWmHints m_hints;
|
||||
|
||||
|
@ -109,6 +109,7 @@ private:
|
|||
|
||||
Q_SIGNALS:
|
||||
void settingWidgetClosed();
|
||||
void webEngineChanged(const QString&);
|
||||
|
||||
private Q_SLOTS:
|
||||
// void onBtnConfirmClicked();
|
||||
|
|
Loading…
Reference in New Issue