2021-01-29 11:43:07 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: zhangzihao <zhangzihao@kylinos.cn>
|
|
|
|
* Modified by: zhangpengfei <zhangpengfei@kylinos.cn>
|
|
|
|
*
|
|
|
|
*/
|
2020-12-28 20:29:13 +08:00
|
|
|
#ifndef GLOBALSETTINGS_H
|
|
|
|
#define GLOBALSETTINGS_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-01-03 16:58:26 +08:00
|
|
|
#include <QSettings>
|
|
|
|
#include <QMutex>
|
|
|
|
#include <QVector>
|
2021-03-20 15:37:54 +08:00
|
|
|
#include <QDir>
|
2021-05-17 20:54:48 +08:00
|
|
|
#include <QFileSystemWatcher>
|
2021-01-04 14:21:45 +08:00
|
|
|
//#include <QGSettings>
|
|
|
|
//If use pkg_config, it wont build succes,why?????????
|
|
|
|
//My demo can build access yet.
|
|
|
|
//MouseZhangZh
|
|
|
|
#include <QGSettings/QGSettings>
|
2021-03-30 09:23:57 +08:00
|
|
|
#include <QDBusConnection>
|
|
|
|
#include <QDBusInterface>
|
2021-05-12 15:58:38 +08:00
|
|
|
#include <QApplication>
|
2021-01-04 14:21:45 +08:00
|
|
|
#include "libsearch_global.h"
|
2021-07-06 16:53:32 +08:00
|
|
|
#include "file-utils.h"
|
2020-12-28 20:29:13 +08:00
|
|
|
|
2021-01-04 14:21:45 +08:00
|
|
|
#define CONTROL_CENTER_PERSONALISE_GSETTINGS_ID "org.ukui.control-center.personalise"
|
|
|
|
#define TRANSPARENCY_KEY "transparency"
|
2021-04-13 15:40:19 +08:00
|
|
|
#define THEME_GSETTINGS_ID "org.ukui.style"
|
|
|
|
#define STYLE_NAME_KEY "styleName"
|
2021-04-20 16:24:07 +08:00
|
|
|
#define FONT_SIZE_KEY "systemFontSize"
|
2021-05-12 15:58:38 +08:00
|
|
|
#define ICON_THEME_KEY "iconThemeName"
|
2021-05-13 11:17:07 +08:00
|
|
|
|
2022-11-28 18:11:55 +08:00
|
|
|
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
|
|
|
#define FILE_INDEX_ENABLE_KEY "fileIndexEnable"
|
|
|
|
#define WEB_ENGINE_KEY "webEngine"
|
|
|
|
#define CONTENT_FUZZY_SEARCH_KEY "contentFuzzySearch"
|
|
|
|
|
2021-02-22 20:30:06 +08:00
|
|
|
#define WEB_ENGINE "web_engine"
|
2021-02-04 20:01:21 +08:00
|
|
|
#define PATH_EMPTY 1;
|
|
|
|
#define PATH_NOT_IN_HOME 2;
|
|
|
|
#define PATH_PARENT_BLOCKED 3;
|
2021-01-04 14:21:45 +08:00
|
|
|
|
2021-03-30 09:23:57 +08:00
|
|
|
#define BLOCK_DIRS QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-block-dirs.conf"
|
|
|
|
#define SEARCH_HISTORY QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-history.conf"
|
|
|
|
//#define CLOUD_HISTORY "history"
|
|
|
|
//#define CLOUD_APPLICATIONS "applications"
|
2021-03-20 15:37:54 +08:00
|
|
|
|
2021-12-14 14:43:35 +08:00
|
|
|
namespace UkuiSearch {
|
2022-11-28 18:11:55 +08:00
|
|
|
/**
|
|
|
|
* @brief The GlobalSettings class
|
|
|
|
* 用于同步搜索应用的全局设置
|
|
|
|
* 不要作为文件索引或应用数据等服务设置使用
|
|
|
|
*/
|
2021-04-26 15:06:47 +08:00
|
|
|
class LIBSEARCH_EXPORT GlobalSettings : public QObject {
|
2020-12-28 20:29:13 +08:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-01-03 16:58:26 +08:00
|
|
|
static GlobalSettings *getInstance();
|
|
|
|
const QVariant getValue(const QString&);
|
2021-01-08 19:08:24 +08:00
|
|
|
/**
|
|
|
|
* @brief setBlockDirs
|
|
|
|
* set path for blacklist,return true if success,otherwise return false.
|
|
|
|
* @param path path to be blocked
|
|
|
|
* @param returnMessage this message will be set when return false.
|
2021-01-10 09:23:02 +08:00
|
|
|
* @param true to remove blocking,false to set blocking,default set false.
|
2021-01-08 19:08:24 +08:00
|
|
|
* @return
|
|
|
|
*/
|
2021-04-26 15:06:47 +08:00
|
|
|
bool setBlockDirs(const QString& path, int &returnCode, bool remove = false);
|
2021-01-08 19:08:24 +08:00
|
|
|
QStringList getBlockDirs();
|
2021-03-30 09:23:57 +08:00
|
|
|
void setSearchRecord(const QString &word, const QDateTime &time);
|
|
|
|
QStringList getSearchRecord();
|
|
|
|
void updateSearchHistory(QString key);
|
2021-01-03 16:58:26 +08:00
|
|
|
|
2022-11-28 18:11:55 +08:00
|
|
|
Q_SIGNALS:
|
|
|
|
void valueChanged(const QString&);
|
|
|
|
void transparencyChanged(const double&);
|
|
|
|
void styleChanged(const QString&);
|
|
|
|
void fileSearchEnableChanged(bool);
|
|
|
|
void webSearchEngineChanged(const QString&);
|
|
|
|
void contentFuzzySearchEnableChanged(bool);
|
|
|
|
|
2021-01-03 16:58:26 +08:00
|
|
|
private:
|
|
|
|
explicit GlobalSettings(QObject *parent = nullptr);
|
2021-02-27 10:51:19 +08:00
|
|
|
~GlobalSettings() = default;
|
2022-11-28 18:11:55 +08:00
|
|
|
void setValue(const QString&, const QVariant&);
|
2021-01-03 16:58:26 +08:00
|
|
|
|
2022-11-28 18:11:55 +08:00
|
|
|
QGSettings *m_transGsettings;
|
|
|
|
QGSettings *m_themeGsettings;
|
|
|
|
QGSettings *m_searchGsettings;
|
|
|
|
QSettings *m_blockDirsSettings;
|
|
|
|
QSettings *m_searchRecordSettings;
|
2021-01-03 16:58:26 +08:00
|
|
|
QMap<QString, QVariant> m_cache;
|
2021-03-30 09:23:57 +08:00
|
|
|
QStringList m_history;
|
2021-05-17 20:54:48 +08:00
|
|
|
QFileSystemWatcher *m_confWatcher;
|
2021-01-03 16:58:26 +08:00
|
|
|
|
|
|
|
QMutex m_mutex;
|
2021-05-12 15:01:20 +08:00
|
|
|
// size_t test = 0;
|
|
|
|
|
2021-01-03 16:58:26 +08:00
|
|
|
|
2020-12-28 20:29:13 +08:00
|
|
|
};
|
|
|
|
|
2021-04-30 16:28:50 +08:00
|
|
|
}
|
|
|
|
|
2020-12-28 20:29:13 +08:00
|
|
|
#endif // GLOBALSETTINGS_H
|