forked from openkylin/ukui-search
Modified file index switch gsettings.
This commit is contained in:
parent
772458b8da
commit
407251b865
|
@ -1,9 +1,9 @@
|
|||
<schemalist gettext-domain="ukui-search">
|
||||
<schema id="org.ukui.search.settings" path="/org/ukui/ukui-search/settings/">
|
||||
<key name="index-search" type="b">
|
||||
<key name="file-index-enable" type="b">
|
||||
<default>false</default>
|
||||
<summary>search method</summary>
|
||||
<description>Is current search-method index-search.</description>
|
||||
<summary>file index switch</summary>
|
||||
<description>Enable or disable file index service.</description>
|
||||
</key>
|
||||
<key name="web-engine" type="s">
|
||||
<default>"baidu"</default>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#define MAIN_MARGINS 0, 0, 0, 0
|
||||
#define TITLE_MARGINS 0,0,0,0
|
||||
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
||||
#define SEARCH_METHOD_KEY "indexSearch"
|
||||
#define SEARCH_METHOD_KEY "file-index-enable"
|
||||
#define WEB_ENGINE_KEY "webEngine"
|
||||
#define WINDOW_WIDTH 700
|
||||
#define WINDOW_HEIGHT 610
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
#include "search-method-manager.h"
|
||||
#include "file-index-manager.h"
|
||||
using namespace UkuiSearch;
|
||||
static SearchMethodManager* global_instance = nullptr;
|
||||
SearchMethodManager::SearchMethodManager() : m_semaphore(INDEX_SEM, 1, QSystemSemaphore::AccessMode::Create)
|
||||
static FileIndexManager* global_instance = nullptr;
|
||||
FileIndexManager::FileIndexManager(QObject *parent) : QObject(parent), m_semaphore(INDEX_SEM, 1, QSystemSemaphore::AccessMode::Create)
|
||||
{
|
||||
m_fi = FirstIndex::getInstance();
|
||||
m_iw = InotifyWatch::getInstance();
|
||||
}
|
||||
|
||||
SearchMethodManager *SearchMethodManager::getInstance()
|
||||
FileIndexManager *FileIndexManager::getInstance()
|
||||
{
|
||||
if(!global_instance) {
|
||||
global_instance = new SearchMethodManager();
|
||||
global_instance = new FileIndexManager();
|
||||
}
|
||||
return global_instance;
|
||||
}
|
||||
|
||||
void SearchMethodManager::searchMethod(FileUtils::SearchMethod sm) {
|
||||
void FileIndexManager::searchMethod(FileUtils::SearchMethod sm) {
|
||||
qWarning() << "searchMethod start: " << static_cast<int>(sm);
|
||||
if(FileUtils::SearchMethod::INDEXSEARCH == sm || FileUtils::SearchMethod::DIRECTSEARCH == sm) {
|
||||
FileUtils::searchMethod = sm;
|
|
@ -1,17 +1,19 @@
|
|||
#ifndef SEARCHMETHODMANAGER_H
|
||||
#define SEARCHMETHODMANAGER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSystemSemaphore>
|
||||
#include "first-index.h"
|
||||
//#include "inotify-index.h"
|
||||
#include "inotify-watch.h"
|
||||
namespace UkuiSearch {
|
||||
class SearchMethodManager {
|
||||
class FileIndexManager : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static SearchMethodManager *getInstance();
|
||||
static FileIndexManager *getInstance();
|
||||
void searchMethod(FileUtils::SearchMethod sm);
|
||||
private:
|
||||
SearchMethodManager();
|
||||
FileIndexManager(QObject *parent = nullptr);
|
||||
FirstIndex *m_fi;
|
||||
// InotifyIndex* m_ii;
|
||||
InotifyWatch *m_iw = nullptr;
|
|
@ -13,13 +13,14 @@ HEADERS += \
|
|||
$$PWD/pending-file-queue.h \
|
||||
$$PWD/pending-file.h \
|
||||
$$PWD/search-manager.h \
|
||||
$$PWD/search-method-manager.h \
|
||||
$$PWD/file-index-manager.h \
|
||||
$$PWD/traverse_bfs.h \
|
||||
$$PWD/ukui-search-qdbus.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/construct-document.cpp \
|
||||
$$PWD/document.cpp \
|
||||
$$PWD/file-index-manager.cpp \
|
||||
$$PWD/file-reader.cpp \
|
||||
$$PWD/file-search-plugin.cpp \
|
||||
$$PWD/first-index.cpp \
|
||||
|
@ -30,7 +31,6 @@ SOURCES += \
|
|||
$$PWD/pending-file-queue.cpp \
|
||||
$$PWD/pending-file.cpp \
|
||||
$$PWD/search-manager.cpp \
|
||||
$$PWD/search-method-manager.cpp \
|
||||
$$PWD/traverse_bfs.cpp \
|
||||
$$PWD/ukui-search-qdbus.cpp
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "plugininterface/search-plugin-iface.h"
|
||||
#include "plugininterface/data-queue.h"
|
||||
#include "index/search-method-manager.h"
|
||||
#include "index/file-index-manager.h"
|
||||
#include "index/first-index.h"
|
||||
#include "index/ukui-search-qdbus.h"
|
||||
#include "index/search-manager.h"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <ukcc/widgets/titlelabel.h>
|
||||
|
||||
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
||||
#define SEARCH_METHOD_KEY "indexSearch"
|
||||
#define SEARCH_METHOD_KEY "file-index-enable"
|
||||
#define WEB_ENGINE_KEY "webEngine"
|
||||
//TODO
|
||||
#define CONFIG_FILE "/.config/org.ukui/ukui-search/ukui-search-block-dirs.conf"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "ukui-search-service.h"
|
||||
#include "dir-watcher.h"
|
||||
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
||||
#define SEARCH_METHOD_KEY "indexSearch"
|
||||
#define SEARCH_METHOD_KEY "file-index-enable"
|
||||
using namespace UkuiSearch;
|
||||
UkuiSearchService::UkuiSearchService(int &argc, char *argv[], const QString &applicationName): QtSingleApplication (applicationName, argc, argv)
|
||||
{
|
||||
|
@ -96,7 +96,8 @@ void UkuiSearchService::setSearchMethodByGsettings()
|
|||
} else {
|
||||
FileUtils::searchMethod = FileUtils::SearchMethod::DIRECTSEARCH;
|
||||
}
|
||||
SearchMethodManager::getInstance()->searchMethod(FileUtils::searchMethod);
|
||||
FileIndexManager::getInstance()->searchMethod(FileUtils::searchMethod);
|
||||
|
||||
}
|
||||
|
||||
void UkuiSearchService::indexServiceSwitch(bool startIndex)
|
||||
|
@ -106,7 +107,7 @@ void UkuiSearchService::indexServiceSwitch(bool startIndex)
|
|||
} else {
|
||||
FileUtils::searchMethod = FileUtils::SearchMethod::DIRECTSEARCH;
|
||||
}
|
||||
SearchMethodManager::getInstance()->searchMethod(FileUtils::searchMethod);
|
||||
FileIndexManager::getInstance()->searchMethod(FileUtils::searchMethod);
|
||||
|
||||
const QByteArray id(UKUI_SEARCH_SCHEMAS);
|
||||
if(QGSettings::isSchemaInstalled(id)) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <QCommandLineParser>
|
||||
#include <QGSettings/QGSettings>
|
||||
#include "qtsingleapplication.h"
|
||||
#include "search-method-manager.h"
|
||||
#include "file-index-manager.h"
|
||||
#include "common.h"
|
||||
namespace UkuiSearch {
|
||||
|
||||
|
|
Loading…
Reference in New Issue