Modified index path.

This commit is contained in:
iaom 2021-05-25 09:17:54 +08:00
parent db105cf4ca
commit fdcb6e66ff
45 changed files with 221 additions and 247 deletions

18
debian/changelog vendored
View File

@ -1,3 +1,21 @@
ukui-search (0.4.0+0520) v101; urgency=medium
* Bug 55034,55545,55326,55496
* 任务29459
* 其他改动:
* Fix:Seletion is cleared when paletted changed.
- 修复收到palettechanged信号时列表选中状态消失的问题。
* Fix:Icon in detail view will not refresh when icon-theme changed.
- 修复主题图标改变时详情页图标未更新的问题。
* Fix:Index process crashed when parsing some wps templates.
- 修复了解析某些wps模板文件时索引崩溃的问题。
* Fix:Block list conf won't work.
- 修复了在控制面板设置黑名单不能及时生效的问题。
* Fix:Automatic completion won't work in next search after clicked actions in detial widget.
- 修复了点击详情页不会保存搜索历史记录的bug。
-- zhangpengfei <zhangpengfei@kylinos.cn> Thu, 20 May 2021 09:08:15 +0800
ukui-search (0.4.0+0508) v101; urgency=medium ukui-search (0.4.0+0508) v101; urgency=medium
* Bug 49153. * Bug 49153.

View File

@ -52,10 +52,10 @@ ChineseSegmentation *ChineseSegmentation::getInstance() {
return global_instance_chinese_segmentation; return global_instance_chinese_segmentation;
} }
QVector<SKeyWord> ChineseSegmentation::callSegement(QString str) { QVector<SKeyWord> ChineseSegmentation::callSegement(std::string s) {
std::string s; // std::string s;
s = str.toStdString(); // s = str.toStdString();
str.squeeze(); // str.squeeze();
const size_t topk = -1; const size_t topk = -1;
std::vector<cppjieba::KeywordExtractor::Word> keywordres; std::vector<cppjieba::KeywordExtractor::Word> keywordres;

View File

@ -47,7 +47,7 @@ class CHINESESEGMENTATION_EXPORT ChineseSegmentation {
public: public:
static ChineseSegmentation *getInstance(); static ChineseSegmentation *getInstance();
~ChineseSegmentation(); ~ChineseSegmentation();
QVector<SKeyWord> callSegement(QString str); QVector<SKeyWord> callSegement(std::string s);
void convert(std::vector<cppjieba::KeywordExtractor::Word>& keywordres, QVector<SKeyWord>& kw); void convert(std::vector<cppjieba::KeywordExtractor::Word>& keywordres, QVector<SKeyWord>& kw);
private: private:
static QMutex m_mutex; static QMutex m_mutex;

View File

@ -102,12 +102,12 @@ void AppMatch::getAllDesktopFilePath(QString path) {
} else { } else {
//过滤LXQt、KDE //过滤LXQt、KDE
QString filePathStr = fileInfo.filePath(); QString filePathStr = fileInfo.filePath();
if(filePathStr.contains("KDE", Qt::CaseInsensitive) || // if(filePathStr.contains("KDE", Qt::CaseInsensitive) ||
// filePathStr.contains("mate",Qt::CaseInsensitive)|| // filePathStr.contains("mate",Qt::CaseInsensitive)||
filePathStr.contains("LX", Qt::CaseInsensitive)) { // filePathStr.contains("LX", Qt::CaseInsensitive)) {
i++; // i++;
continue; // continue;
} // }
//过滤后缀不是.desktop的文件 //过滤后缀不是.desktop的文件
if(!filePathStr.endsWith(".desktop")) { if(!filePathStr.endsWith(".desktop")) {
i++; i++;

View File

@ -37,6 +37,14 @@ GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent) {
// m_settings->setAtomicSyncRequired(false); // m_settings->setAtomicSyncRequired(false);
m_block_dirs_settings = new QSettings(BLOCK_DIRS, QSettings::IniFormat, this); m_block_dirs_settings = new QSettings(BLOCK_DIRS, QSettings::IniFormat, this);
m_block_dirs_settings->setIniCodec(QTextCodec::codecForName("UTF-8")); m_block_dirs_settings->setIniCodec(QTextCodec::codecForName("UTF-8"));
// m_block_dirs_settings->setValue("These_are_block_dirs_conf_for_ukui_search","0");
// m_block_dirs_settings->sync();
// m_confWatcher = new QFileSystemWatcher(this);
// m_confWatcher->addPath(BLOCK_DIRS);
// connect(m_confWatcher, &QFileSystemWatcher::fileChanged, this, [ & ]() {
// m_block_dirs_settings->sync();
// m_confWatcher->addPath(BLOCK_DIRS);
// });
m_search_record_settings = new QSettings(SEARCH_HISTORY, QSettings::IniFormat, this); m_search_record_settings = new QSettings(SEARCH_HISTORY, QSettings::IniFormat, this);
m_search_record_settings->setIniCodec(QTextCodec::codecForName("UTF-8")); m_search_record_settings->setIniCodec(QTextCodec::codecForName("UTF-8"));

View File

@ -26,6 +26,7 @@
#include <QMutex> #include <QMutex>
#include <QVector> #include <QVector>
#include <QDir> #include <QDir>
#include <QFileSystemWatcher>
//#include <QGSettings> //#include <QGSettings>
//If use pkg_config, it wont build succes,why????????? //If use pkg_config, it wont build succes,why?????????
//My demo can build access yet. //My demo can build access yet.
@ -49,9 +50,13 @@
#define PATH_NOT_IN_HOME 2; #define PATH_NOT_IN_HOME 2;
#define PATH_PARENT_BLOCKED 3; #define PATH_PARENT_BLOCKED 3;
#define MAIN_SETTINGS QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search.conf" //#define MAIN_SETTINGS QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search.conf"
#define BLOCK_DIRS QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-block-dirs.conf" //#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 SEARCH_HISTORY QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-history.conf"
#define MAIN_SETTINGS "/media/用户保险箱/.ukui-search/ukui-search.conf"
#define BLOCK_DIRS "/media/用户保险箱/.ukui-search/ukui-search-block-dirs.conf"
#define SEARCH_HISTORY "/media/用户保险箱/.ukui-search/ukui-search-history.conf"
//#define CLOUD_HISTORY "history" //#define CLOUD_HISTORY "history"
//#define CLOUD_APPLICATIONS "applications" //#define CLOUD_APPLICATIONS "applications"
@ -102,6 +107,7 @@ private:
QSettings *m_search_record_settings; QSettings *m_search_record_settings;
QMap<QString, QVariant> m_cache; QMap<QString, QVariant> m_cache;
QStringList m_history; QStringList m_history;
QFileSystemWatcher *m_confWatcher;
QMutex m_mutex; QMutex m_mutex;
// size_t test = 0; // size_t test = 0;

View File

@ -111,7 +111,7 @@ void ConstructDocumentForContent::run() {
QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(m_path)); QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(m_path));
QString upTerm = QString::fromStdString(FileUtils::makeDocUterm(m_path.section("/", 0, -2, QString::SectionIncludeLeadingSep))); QString upTerm = QString::fromStdString(FileUtils::makeDocUterm(m_path.section("/", 0, -2, QString::SectionIncludeLeadingSep)));
QVector<SKeyWord> term = ChineseSegmentation::getInstance()->callSegement(content.left(20480000)); QVector<SKeyWord> term = ChineseSegmentation::getInstance()->callSegement(content.left(20480000).toStdString());
Document doc; Document doc;
doc.setData(content); doc.setData(content);

View File

@ -20,7 +20,7 @@
#include "document.h" #include "document.h"
#include <QDebug> #include <QDebug>
using namespace Zeeker; using namespace Zeeker;
void Document::setData(QString data) { void Document::setData(QString &data) {
if(data.isEmpty()) if(data.isEmpty())
return; return;
m_document.set_data(data.toStdString()); m_document.set_data(data.toStdString());

View File

@ -39,7 +39,7 @@ public:
m_index_text = other.m_index_text; m_index_text = other.m_index_text;
m_unique_term = other.m_unique_term; m_unique_term = other.m_unique_term;
} }
void setData(QString data); void setData(QString &data);
void addPosting(std::string term, QVector<size_t> offset, int weight = 1); void addPosting(std::string term, QVector<size_t> offset, int weight = 1);
void addPosting(std::string term, unsigned int offset, int weight = 1); void addPosting(std::string term, unsigned int offset, int weight = 1);
void addTerm(QString term); void addTerm(QString term);

View File

@ -138,7 +138,12 @@ void FirstIndex::run() {
// QtConcurrent::run([&](){ // QtConcurrent::run([&](){
sem.acquire(1); sem.acquire(1);
mutex1.unlock(); mutex1.unlock();
this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); QStringList pathList;
pathList.append("/media/用户保险箱");
pathList.append("/media/邮件保险箱");
pathList.append("/media/公共保险箱");
pathList.append("/media/备份保险箱");
this->setPath(pathList);
this->Traverse(); this->Traverse();
FileUtils::_max_index_count = this->q_index->length(); FileUtils::_max_index_count = this->q_index->length();
qDebug() << "max_index_count:" << FileUtils::_max_index_count; qDebug() << "max_index_count:" << FileUtils::_max_index_count;

View File

@ -32,8 +32,10 @@
#include <QStandardPaths> #include <QStandardPaths>
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/index_data").toStdString() //#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/index_data").toStdString()
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/content_index_data").toStdString() //#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/content_index_data").toStdString()
#define INDEX_PATH "/media/用户保险箱/.ukui-search/index_data"
#define CONTENT_INDEX_PATH "/media/用户保险箱/.ukui-search/content_index_data"
using namespace Zeeker; using namespace Zeeker;
@ -354,7 +356,7 @@ Document IndexGenerator::GenerateContentDocument(const QString &path) {
QString upTerm; QString upTerm;
FileReader::getTextContent(path, content); FileReader::getTextContent(path, content);
term = ChineseSegmentation::getInstance()->callSegement(content); term = ChineseSegmentation::getInstance()->callSegement(content.toStdString());
// QStringList term = content.split(""); // QStringList term = content.split("");
doc.setData(content); doc.setData(content);

View File

@ -7,7 +7,7 @@
#define CONTENT_INDEX_DATABASE_STATE "content_index_database_state" #define CONTENT_INDEX_DATABASE_STATE "content_index_database_state"
#define INDEX_DATABASE_STATE "index_database_state" #define INDEX_DATABASE_STATE "index_database_state"
#define INOTIFY_NORMAL_EXIT "inotify_normal_exit" #define INOTIFY_NORMAL_EXIT "inotify_normal_exit"
#define INDEX_STATUS QDir::homePath() + "/.config/org.ukui/ukui-search/ukui-search-index-status.conf" #define INDEX_STATUS "/media/用户保险箱/.ukui-search/ukui-search-index-status.conf"
namespace Zeeker { namespace Zeeker {
//fixme: we need a better way to record index status. //fixme: we need a better way to record index status.
class IndexStatusRecorder : public QObject class IndexStatusRecorder : public QObject

View File

@ -37,7 +37,7 @@
QFileInfo fi(tmp); \ QFileInfo fi(tmp); \
if(!fi.isSymLink()){ \ if(!fi.isSymLink()){ \
AddWatch(tmp); \ AddWatch(tmp); \
setPath(tmp); \ setPath(QStringList(tmp)); \
Traverse(); \ Traverse(); \
} }
@ -46,7 +46,7 @@
CREATE_FILE_NAME_INDEX \ CREATE_FILE_NAME_INDEX \
CREATE_FILE_CONTENT_INDEX CREATE_FILE_CONTENT_INDEX
using namespace Zeeker; using namespace Zeeker;
InotifyIndex::InotifyIndex(const QString& path) : Traverse_BFS(path) { InotifyIndex::InotifyIndex(const QStringList &pathList) : Traverse_BFS(pathList) {
qDebug() << "setInotifyMaxUserWatches start"; qDebug() << "setInotifyMaxUserWatches start";
UkuiSearchQDBus usQDBus; UkuiSearchQDBus usQDBus;
usQDBus.setInotifyMaxUserWatches(); usQDBus.setInotifyMaxUserWatches();
@ -61,7 +61,9 @@ InotifyIndex::~InotifyIndex() {
void InotifyIndex::firstTraverse() { void InotifyIndex::firstTraverse() {
QQueue<QString> bfs; QQueue<QString> bfs;
bfs.enqueue(this->path); for(QString path : this->m_pathList) {
this->AddWatch(path);
bfs.enqueue(path);
QFileInfoList list; QFileInfoList list;
QDir dir; QDir dir;
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
@ -77,6 +79,7 @@ void InotifyIndex::firstTraverse() {
} }
} }
} }
}
void InotifyIndex::DoSomething(const QFileInfo& fileInfo) { void InotifyIndex::DoSomething(const QFileInfo& fileInfo) {
qDebug() << fileInfo.fileName() << "-------" << fileInfo.absoluteFilePath(); qDebug() << fileInfo.fileName() << "-------" << fileInfo.absoluteFilePath();
@ -248,8 +251,8 @@ void InotifyIndex::run() {
m_fd = inotify_init(); m_fd = inotify_init();
qDebug() << "m_fd----------->" << m_fd; qDebug() << "m_fd----------->" << m_fd;
this->AddWatch(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); // this->AddWatch(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); // this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
this->firstTraverse(); this->firstTraverse();
int fifo_fd; int fifo_fd;

View File

@ -40,13 +40,13 @@ static InotifyIndex* global_instance_of_index = nullptr;
class InotifyIndex : public QThread, public Traverse_BFS { class InotifyIndex : public QThread, public Traverse_BFS {
Q_OBJECT Q_OBJECT
public: public:
static InotifyIndex* getInstance(const QString& path) { static InotifyIndex* getInstance(const QStringList &pathList) {
if(!global_instance_of_index) { if(!global_instance_of_index) {
global_instance_of_index = new InotifyIndex(path); global_instance_of_index = new InotifyIndex(pathList);
} }
return global_instance_of_index; return global_instance_of_index;
} }
InotifyIndex(const QString&); InotifyIndex(const QStringList &pathList);
~InotifyIndex(); ~InotifyIndex();
bool AddWatch(const QString&); bool AddWatch(const QString&);

View File

@ -301,7 +301,7 @@ int FileContentSearch::keywordSearchContent() {
ret.erase(ret.begin(), ret.end()); ret.erase(ret.begin(), ret.end());
::friso::ResultMap().swap(ret); ::friso::ResultMap().swap(ret);
*/ */
QVector<SKeyWord> sKeyWord = ChineseSegmentation::getInstance()->callSegement(m_keyword); QVector<SKeyWord> sKeyWord = ChineseSegmentation::getInstance()->callSegement(m_keyword.toStdString());
//Creat a query //Creat a query
std::string words; std::string words;
for(int i = 0; i < sKeyWord.size(); i++) { for(int i = 0; i < sKeyWord.size(); i++) {
@ -645,7 +645,7 @@ int FileContentSearchV4::keywordSearchContent()
ret.erase(ret.begin(), ret.end()); ret.erase(ret.begin(), ret.end());
::friso::ResultMap().swap(ret); ::friso::ResultMap().swap(ret);
*/ */
QVector<SKeyWord> sKeyWord = ChineseSegmentation::getInstance()->callSegement(m_keyword); QVector<SKeyWord> sKeyWord = ChineseSegmentation::getInstance()->callSegement(m_keyword.toStdString());
//Creat a query //Creat a query
std::string words; std::string words;
for(int i=0;i<sKeyWord.size();i++) for(int i=0;i<sKeyWord.size();i++)
@ -803,6 +803,7 @@ void DirectSearch::run() {
// QDir::Hidden // QDir::Hidden
dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); dir.setFilter(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
dir.setSorting(QDir::DirsFirst); dir.setSorting(QDir::DirsFirst);
QStringList blockList = GlobalSettings::getInstance()->getBlockDirs();
while(!bfs.empty()) { while(!bfs.empty()) {
dir.setPath(bfs.dequeue()); dir.setPath(bfs.dequeue());
list = dir.entryInfoList(); list = dir.entryInfoList();
@ -810,8 +811,6 @@ void DirectSearch::run() {
if (i.isDir() && (!(i.isSymLink()))) { if (i.isDir() && (!(i.isSymLink()))) {
bool findIndex = false; bool findIndex = false;
QStringList blockList = GlobalSettings::getInstance()->getBlockDirs();
for (QString j : blockList) { for (QString j : blockList) {
if (i.absoluteFilePath().startsWith(j.prepend("/"))) { if (i.absoluteFilePath().startsWith(j.prepend("/"))) {
findIndex = true; findIndex = true;

View File

@ -44,9 +44,11 @@
#include "chinese-segmentation.h" #include "chinese-segmentation.h"
#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/index_data").toStdString() //#define INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/index_data").toStdString()
#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/content_index_data").toStdString() //#define CONTENT_INDEX_PATH (QStandardPaths::writableLocation(QStandardPaths::HomeLocation)+"/.config/org.ukui/ukui-search/content_index_data").toStdString()
#define INDEX_PATH "/media/用户保险箱/.ukui-search/index_data"
#define CONTENT_INDEX_PATH "/media/用户保险箱/.ukui-search/content_index_data"
namespace Zeeker { namespace Zeeker {
struct SearchResultInfo{ struct SearchResultInfo{
std::string filePath; std::string filePath;

View File

@ -15,7 +15,12 @@ void SearchMethodManager::searchMethod(FileUtils::SearchMethod sm) {
qWarning() << "start inotify index"; qWarning() << "start inotify index";
// InotifyIndex ii("/home"); // InotifyIndex ii("/home");
// ii.start(); // ii.start();
this->m_ii = InotifyIndex::getInstance("/home"); QStringList pathList;
pathList.append("/media/用户保险箱");
pathList.append("/media/邮件保险箱");
pathList.append("/media/公共保险箱");
pathList.append("/media/备份保险箱");
this->m_ii = InotifyIndex::getInstance(pathList);
if(!this->m_ii->isRunning()) { if(!this->m_ii->isRunning()) {
this->m_ii->start(); this->m_ii->start();
} }

View File

@ -19,14 +19,18 @@
*/ */
#include "traverse_bfs.h" #include "traverse_bfs.h"
using namespace Zeeker; using namespace Zeeker;
Traverse_BFS::Traverse_BFS(const QString& path) { Traverse_BFS::Traverse_BFS(const QStringList& pathList) {
for(QString path : pathList) {
Q_ASSERT('/' == path.at(0)); Q_ASSERT('/' == path.at(0));
this->path = path; }
this->m_pathList = pathList;
} }
void Traverse_BFS::Traverse() { void Traverse_BFS::Traverse() {
QQueue<QString> bfs; QQueue<QString> bfs;
bfs.enqueue(this->path); for(QString path : m_pathList) {
bfs.enqueue(path);
QFileInfoList list; QFileInfoList list;
QDir dir; QDir dir;
// QDir::Hidden // QDir::Hidden
@ -43,7 +47,8 @@ void Traverse_BFS::Traverse() {
} }
} }
} }
}
void Traverse_BFS::setPath(const QString& path) {
this->path = path; void Traverse_BFS::setPath(const QStringList &pathList) {
this->m_pathList = pathList;
} }

View File

@ -31,10 +31,10 @@ public:
void Traverse(); void Traverse();
virtual ~Traverse_BFS() = default; virtual ~Traverse_BFS() = default;
virtual void DoSomething(const QFileInfo&) = 0; virtual void DoSomething(const QFileInfo&) = 0;
void setPath(const QString&); void setPath(const QStringList &pathList);
protected: protected:
Traverse_BFS(const QString&); Traverse_BFS(const QStringList &pathList);
QString path = "/home"; QStringList m_pathList;
private: private:
Traverse_BFS(const Traverse_BFS&) = delete; Traverse_BFS(const Traverse_BFS&) = delete;
void operator=(const Traverse_BFS&) = delete; void operator=(const Traverse_BFS&) = delete;

View File

@ -38,7 +38,7 @@ UkuiSearchQDBus::~UkuiSearchQDBus() {
//一键三连 //一键三连
void UkuiSearchQDBus::setInotifyMaxUserWatches() { void UkuiSearchQDBus::setInotifyMaxUserWatches() {
// /proc/sys/fs/inotify/max_user_watches // /proc/sys/fs/inotify/max_user_watches
this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep1"); // this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep1");
// sysctl // sysctl
this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep2"); this->tmpSystemQDBusInterface->call("setInotifyMaxUserWatchesStep2");
// /etc/sysctl.conf // /etc/sysctl.conf

View File

@ -4457,15 +4457,14 @@ bool bReadBuffer(FILE *pFile, ULONG ulStartBlock,
ULONG ulBegin, ulIndex; ULONG ulBegin, ulIndex;
size_t tLen; size_t tLen;
for(ulIndex = ulStartBlock; for(ulIndex = ulStartBlock;ulIndex != END_OF_CHAIN && tToRead != 0;ulIndex = aulBlockDepot[ulIndex]) {
ulIndex != END_OF_CHAIN && tToRead != 0;
ulIndex = aulBlockDepot[ulIndex]) {
if(ulIndex >= (ULONG)tBlockDepotLen) { if(ulIndex >= (ULONG)tBlockDepotLen) {
if(tBlockSize >= BIG_BLOCK_SIZE) { if(tBlockSize >= BIG_BLOCK_SIZE) {
qWarning() << "The Big Block Depot is damaged"; qWarning() << "The Big Block Depot is damaged";
} else { } else {
qWarning() << "The Small Block Depot is damaged"; qWarning() << "The Small Block Depot is damaged";
} }
return (tToRead == 0);
} }
if(ulOffset >= (ULONG)tBlockSize) { if(ulOffset >= (ULONG)tBlockSize) {
ulOffset -= tBlockSize; ulOffset -= tBlockSize;

View File

@ -24,12 +24,13 @@ public:
QIcon icon; QIcon icon;
QString name; QString name;
QVector<DescriptionInfo> description; QVector<DescriptionInfo> description;
QMap<QString,QString> actionMap;//action name and action key QStringList actionList; //all actions, take fist for double click action.
QString key;
}; };
virtual ~SearchPluginIface() {} virtual ~SearchPluginIface() {}
virtual QString getPluginName() = 0; virtual QString getPluginName() = 0;
virtual void KeywordSearch(QString keyword,QQueue<ResultInfo> *searchResult) = 0; virtual void KeywordSearch(QString keyword,QQueue<ResultInfo> *searchResult) = 0;
virtual void openAction(QString name, QString key) = 0; virtual void openAction(QString action, QString key) = 0;
}; };
} }

View File

@ -19,6 +19,7 @@
*/ */
#include "setting-match.h" #include "setting-match.h"
#include "file-utils.h" #include "file-utils.h"
#include <QProcessEnvironment>
using namespace Zeeker; using namespace Zeeker;
SettingsMatch::SettingsMatch(QObject *parent) : QObject(parent) { SettingsMatch::SettingsMatch(QObject *parent) : QObject(parent) {
xmlElement(); xmlElement();
@ -44,6 +45,8 @@ QStringList SettingsMatch::startMatchApp(const QString &source) {
void SettingsMatch::xmlElement() { void SettingsMatch::xmlElement() {
QString ChineseIndex; QString ChineseIndex;
QString EnglishIndex; QString EnglishIndex;
QString path = QProcessEnvironment::systemEnvironment().value("XDG_SESSION_TYPE");
QString version;
QFile file(QString::fromLocal8Bit("/usr/share/ukui-control-center/shell/res/search.xml")); QFile file(QString::fromLocal8Bit("/usr/share/ukui-control-center/shell/res/search.xml"));
if(!file.open(QIODevice::ReadOnly)) { if(!file.open(QIODevice::ReadOnly)) {
return; return;
@ -62,6 +65,12 @@ void SettingsMatch::xmlElement() {
QDomNodeList list = element.childNodes(); QDomNodeList list = element.childNodes();
for(int i = 0; i < list.count(); ++i) { for(int i = 0; i < list.count(); ++i) {
QDomNode n = list.at(i); QDomNode n = list.at(i);
if(n.nodeName()==QString::fromLocal8Bit("Environment")){
version=n.toElement().text();
if((version=="v101"&&path=="wayland")||(version=="hw990"&&path=="x11")){
break;
}
}
if(n.nodeName() == QString::fromLocal8Bit("ChinesePlugin")) { if(n.nodeName() == QString::fromLocal8Bit("ChinesePlugin")) {
ChineseIndex = n.toElement().text(); ChineseIndex = n.toElement().text();
} }

View File

@ -52,6 +52,9 @@ ContentWidget::~ContentWidget() {
* @brief initUI homepage和resultpage * @brief initUI homepage和resultpage
*/ */
void ContentWidget::initUI() { void ContentWidget::initUI() {
QPalette pal = palette();
pal.setColor(QPalette::Base, QColor(0, 0, 0, 0));
pal.setColor(QPalette::Window, QColor(0, 0, 0, 0)); //使用此palette的窗口背景将为透明
m_homePage = new QWidget(this); m_homePage = new QWidget(this);
m_homePageLyt = new QVBoxLayout(m_homePage); m_homePageLyt = new QVBoxLayout(m_homePage);
m_homePageLyt->setSpacing(0); m_homePageLyt->setSpacing(0);
@ -79,7 +82,6 @@ void ContentWidget::initUI() {
m_detailLyt = new QVBoxLayout(m_resultDetail); m_detailLyt = new QVBoxLayout(m_resultDetail);
m_resultList->setFixedWidth(236); m_resultList->setFixedWidth(236);
m_resultList->setFixedHeight(0); m_resultList->setFixedHeight(0);
m_resultList->setStyleSheet("QWidget{background:transparent;}");
m_listLyt->setContentsMargins(0, 0, 12, 0); m_listLyt->setContentsMargins(0, 0, 12, 0);
m_listLyt->setSpacing(0); m_listLyt->setSpacing(0);
m_resultListArea->setWidget(m_resultList); m_resultListArea->setWidget(m_resultList);
@ -89,10 +91,13 @@ void ContentWidget::initUI() {
clearLayout(m_homePageLyt); clearLayout(m_homePageLyt);
initHomePage(); initHomePage();
}); });
connect(m_detailView, &SearchDetailView::actionTriggerd, this, &ContentWidget::effectiveSearch);
m_resultDetailArea->setWidget(m_detailView); m_resultDetailArea->setWidget(m_detailView);
m_resultDetailArea->setWidgetResizable(true); m_resultDetailArea->setWidgetResizable(true);
m_resultListArea->setStyleSheet("QScrollArea{background: transparent;}"); m_resultListArea->setFrameShape(QFrame::NoFrame);
m_resultDetailArea->setStyleSheet("QScrollArea{background: transparent; border-radius: 4px;}"); m_resultDetailArea->setFrameShape(QFrame::NoFrame);
m_resultListArea->setPalette(pal);
m_resultDetailArea->setPalette(pal);
this->addWidget(m_homePage); this->addWidget(m_homePage);
this->addWidget(m_resultPage); this->addWidget(m_resultPage);
@ -226,7 +231,7 @@ void ContentWidget::initListView() {
this->resetListHeight(); this->resetListHeight();
}); });
connect(qApp, &QApplication::paletteChanged, this, [ = ](const QPalette &pal) { connect(qApp, &QApplication::paletteChanged, this, [ = ]() {
m_fileListView->refresh(); m_fileListView->refresh();
m_dirListView->refresh(); m_dirListView->refresh();
m_contentListView->refresh(); m_contentListView->refresh();
@ -279,7 +284,7 @@ void ContentWidget::setupConnect(SearchListView * listview) {
connect(listview, &SearchListView::currentSelectPos, [ = ](QPoint pos) { connect(listview, &SearchListView::currentSelectPos, [ = ](QPoint pos) {
m_resultListArea->ensureVisible(pos.x(), pos.y()); m_resultListArea->ensureVisible(pos.x(), pos.y());
}); });
connect(listview, &SearchListView::mousePressed, this, &ContentWidget::mousePressed); connect(listview, &SearchListView::mousePressed, this, &ContentWidget::effectiveSearch);
connect(listview, &SearchListView::currentRowChanged, this, &ContentWidget::onListViewRowChanged); connect(listview, &SearchListView::currentRowChanged, this, &ContentWidget::onListViewRowChanged);
connect(listview, &SearchListView::onRowDoubleClicked, this, &ContentWidget::onListViewRowDoubleClicked); connect(listview, &SearchListView::onRowDoubleClicked, this, &ContentWidget::onListViewRowDoubleClicked);
} }

View File

@ -109,7 +109,7 @@ private:
Q_SIGNALS: Q_SIGNALS:
void currentItemChanged(); void currentItemChanged();
void mousePressed(); void effectiveSearch();
private Q_SLOTS: private Q_SLOTS:
void clearLayout(QLayout *); void clearLayout(QLayout *);

View File

@ -25,7 +25,7 @@
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QDir> #include <QDir>
#define HOMEPAGE_SETTINGS QDir::homePath()+"/.config/org.ukui/ukui-search/ukui-search-homepage.conf" #define HOMEPAGE_SETTINGS "media/用户保险箱/.ukui-search/ukui-search-homepage.conf"
namespace Zeeker { namespace Zeeker {
class ConfigFile : public QObject { class ConfigFile : public QObject {
Q_OBJECT Q_OBJECT

View File

@ -53,8 +53,9 @@ void FolderListItem::initUi() {
m_iconLabel->setPixmap(QIcon::fromTheme("inode-directory").pixmap(QSize(16, 16))); m_iconLabel->setPixmap(QIcon::fromTheme("inode-directory").pixmap(QSize(16, 16)));
m_pathLabel->setText(m_path); m_pathLabel->setText(m_path);
m_delLabel->setText(tr("Delete the folder out of blacklist")); m_delLabel->setText(tr("Delete the folder out of blacklist"));
m_pathLabel->setStyleSheet("QLabel{color: palette(text); background: transparent;}"); QPalette pal = palette();
m_delLabel->setStyleSheet("QLabel{color: #3790FA; background: transparent;}"); pal.setColor(QPalette::WindowText, QColor(55, 144, 250, 255));
m_delLabel->setPalette(pal);
m_delLabel->setCursor(QCursor(Qt::PointingHandCursor)); m_delLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_delLabel->installEventFilter(this); m_delLabel->installEventFilter(this);
m_delLabel->hide(); m_delLabel->hide();

View File

@ -56,7 +56,6 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
m_type = type; m_type = type;
m_widget = new QWidget(this); m_widget = new QWidget(this);
m_widget->setObjectName("MainWidget"); m_widget->setObjectName("MainWidget");
// m_widget->setStyleSheet("QWidget#MainWidget{background: rgba(0, 0, 0, 0.05); border-radius: 4px;}");
m_widget->installEventFilter(this); m_widget->installEventFilter(this);
m_iconlabel = new QLabel(m_widget); m_iconlabel = new QLabel(m_widget);
m_namelabel = new QLabel(m_widget); m_namelabel = new QLabel(m_widget);

View File

@ -91,48 +91,52 @@ void OptionView::setupOptions(const int& type, bool is_appInstalled) {
void OptionView::initUI() { void OptionView::initUI() {
QPalette pal = palette();
pal.setColor(QPalette::WindowText, NORMAL_COLOR);
pal.setColor(QPalette::Light, HOVER_COLOR);
pal.setColor(QPalette::Dark, PRESS_COLOR);
m_optionFrame = new QFrame(this); m_optionFrame = new QFrame(this);
m_optionLyt = new QVBoxLayout(m_optionFrame); m_optionLyt = new QVBoxLayout(m_optionFrame);
m_optionLyt->setContentsMargins(8, 0, 0, 0); m_optionLyt->setContentsMargins(8, 0, 0, 0);
m_openLabel = new QLabel(m_optionFrame); m_openLabel = new QLabel(m_optionFrame);
m_openLabel->setText(tr("Open")); //打开 m_openLabel->setText(tr("Open")); //打开
m_openLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_openLabel->setPalette(pal);
m_openLabel->setCursor(QCursor(Qt::PointingHandCursor)); m_openLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_openLabel->installEventFilter(this); m_openLabel->installEventFilter(this);
m_optionLyt->addWidget(m_openLabel); m_optionLyt->addWidget(m_openLabel);
m_shortcutLabel = new QLabel(m_optionFrame); m_shortcutLabel = new QLabel(m_optionFrame);
m_shortcutLabel->setText(tr("Add Shortcut to Desktop")); //添加到桌面快捷方式 m_shortcutLabel->setText(tr("Add Shortcut to Desktop")); //添加到桌面快捷方式
m_shortcutLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_shortcutLabel->setPalette(pal);
m_shortcutLabel->setCursor(QCursor(Qt::PointingHandCursor)); m_shortcutLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_shortcutLabel->installEventFilter(this); m_shortcutLabel->installEventFilter(this);
m_optionLyt->addWidget(m_shortcutLabel); m_optionLyt->addWidget(m_shortcutLabel);
m_panelLabel = new QLabel(m_optionFrame); m_panelLabel = new QLabel(m_optionFrame);
m_panelLabel->setText(tr("Add Shortcut to Panel")); //添加到任务栏快捷方式 m_panelLabel->setText(tr("Add Shortcut to Panel")); //添加到任务栏快捷方式
m_panelLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_panelLabel->setPalette(pal);
m_panelLabel->setCursor(QCursor(Qt::PointingHandCursor)); m_panelLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_panelLabel->installEventFilter(this); m_panelLabel->installEventFilter(this);
m_optionLyt->addWidget(m_panelLabel); m_optionLyt->addWidget(m_panelLabel);
m_openPathLabel = new QLabel(m_optionFrame); m_openPathLabel = new QLabel(m_optionFrame);
m_openPathLabel->setText(tr("Open path")); //打开所在路径 m_openPathLabel->setText(tr("Open path")); //打开所在路径
m_openPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_openPathLabel->setPalette(pal);
m_openPathLabel->setCursor(QCursor(Qt::PointingHandCursor)); m_openPathLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_openPathLabel->installEventFilter(this); m_openPathLabel->installEventFilter(this);
m_optionLyt->addWidget(m_openPathLabel); m_optionLyt->addWidget(m_openPathLabel);
m_copyPathLabel = new QLabel(m_optionFrame); m_copyPathLabel = new QLabel(m_optionFrame);
m_copyPathLabel->setText(tr("Copy path")); //复制所在路径 m_copyPathLabel->setText(tr("Copy path")); //复制所在路径
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_copyPathLabel->setPalette(pal);
m_copyPathLabel->setCursor(QCursor(Qt::PointingHandCursor)); m_copyPathLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_copyPathLabel->installEventFilter(this); m_copyPathLabel->installEventFilter(this);
m_optionLyt->addWidget(m_copyPathLabel); m_optionLyt->addWidget(m_copyPathLabel);
m_installLabel = new QLabel(m_optionFrame); m_installLabel = new QLabel(m_optionFrame);
m_installLabel->setText(tr("Install")); //复制所在路径 m_installLabel->setText(tr("Install")); //复制所在路径
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_installLabel->setPalette(pal);
m_installLabel->setCursor(QCursor(Qt::PointingHandCursor)); m_installLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_installLabel->installEventFilter(this); m_installLabel->installEventFilter(this);
m_optionLyt->addWidget(m_installLabel); m_optionLyt->addWidget(m_installLabel);
@ -235,92 +239,92 @@ void OptionView::setupSettingOptions() {
bool OptionView::eventFilter(QObject *watched, QEvent *event) { bool OptionView::eventFilter(QObject *watched, QEvent *event) {
if(m_openLabel && watched == m_openLabel) { if(m_openLabel && watched == m_openLabel) {
if(event->type() == QEvent::MouseButtonPress) { if(event->type() == QEvent::MouseButtonPress) {
m_openLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}"); m_openLabel->setForegroundRole(QPalette::Dark);
return true; return true;
} else if(event->type() == QEvent::MouseButtonRelease) { } else if(event->type() == QEvent::MouseButtonRelease) {
m_openLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_openLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::Open); Q_EMIT this->onOptionClicked(Options::Open);
return true; return true;
} else if(event->type() == QEvent::Enter) { } else if(event->type() == QEvent::Enter) {
m_openLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}"); m_openLabel->setForegroundRole(QPalette::Light);
return true; return true;
} else if(event->type() == QEvent::Leave) { } else if(event->type() == QEvent::Leave) {
m_openLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_openLabel->setForegroundRole(QPalette::WindowText);
return true; return true;
} }
} else if(m_shortcutLabel && watched == m_shortcutLabel) { } else if(m_shortcutLabel && watched == m_shortcutLabel) {
if(event->type() == QEvent::MouseButtonPress) { if(event->type() == QEvent::MouseButtonPress) {
m_shortcutLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}"); m_shortcutLabel->setForegroundRole(QPalette::Dark);
return true; return true;
} else if(event->type() == QEvent::MouseButtonRelease) { } else if(event->type() == QEvent::MouseButtonRelease) {
m_shortcutLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_shortcutLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::Shortcut); Q_EMIT this->onOptionClicked(Options::Shortcut);
return true; return true;
} else if(event->type() == QEvent::Enter) { } else if(event->type() == QEvent::Enter) {
m_shortcutLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}"); m_shortcutLabel->setForegroundRole(QPalette::Light);
return true; return true;
} else if(event->type() == QEvent::Leave) { } else if(event->type() == QEvent::Leave) {
m_shortcutLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_shortcutLabel->setForegroundRole(QPalette::WindowText);
return true; return true;
} }
} else if(m_panelLabel && watched == m_panelLabel) { } else if(m_panelLabel && watched == m_panelLabel) {
if(event->type() == QEvent::MouseButtonPress) { if(event->type() == QEvent::MouseButtonPress) {
m_panelLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}"); m_panelLabel->setForegroundRole(QPalette::Dark);
return true; return true;
} else if(event->type() == QEvent::MouseButtonRelease) { } else if(event->type() == QEvent::MouseButtonRelease) {
m_panelLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_panelLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::Panel); Q_EMIT this->onOptionClicked(Options::Panel);
return true; return true;
} else if(event->type() == QEvent::Enter) { } else if(event->type() == QEvent::Enter) {
m_panelLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}"); m_panelLabel->setForegroundRole(QPalette::Light);
return true; return true;
} else if(event->type() == QEvent::Leave) { } else if(event->type() == QEvent::Leave) {
m_panelLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_panelLabel->setForegroundRole(QPalette::WindowText);
return true; return true;
} }
} else if(m_openPathLabel && watched == m_openPathLabel) { } else if(m_openPathLabel && watched == m_openPathLabel) {
if(event->type() == QEvent::MouseButtonPress) { if(event->type() == QEvent::MouseButtonPress) {
m_openPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}"); m_openPathLabel->setForegroundRole(QPalette::Dark);
return true; return true;
} else if(event->type() == QEvent::MouseButtonRelease) { } else if(event->type() == QEvent::MouseButtonRelease) {
m_openPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_openPathLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::OpenPath); Q_EMIT this->onOptionClicked(Options::OpenPath);
return true; return true;
} else if(event->type() == QEvent::Enter) { } else if(event->type() == QEvent::Enter) {
m_openPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}"); m_openPathLabel->setForegroundRole(QPalette::Light);
return true; return true;
} else if(event->type() == QEvent::Leave) { } else if(event->type() == QEvent::Leave) {
m_openPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_openPathLabel->setForegroundRole(QPalette::WindowText);
return true; return true;
} }
} else if(m_copyPathLabel && watched == m_copyPathLabel) { } else if(m_copyPathLabel && watched == m_copyPathLabel) {
if(event->type() == QEvent::MouseButtonPress) { if(event->type() == QEvent::MouseButtonPress) {
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}"); m_copyPathLabel->setForegroundRole(QPalette::Dark);
return true; return true;
} else if(event->type() == QEvent::MouseButtonRelease) { } else if(event->type() == QEvent::MouseButtonRelease) {
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_copyPathLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::CopyPath); Q_EMIT this->onOptionClicked(Options::CopyPath);
return true; return true;
} else if(event->type() == QEvent::Enter) { } else if(event->type() == QEvent::Enter) {
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}"); m_copyPathLabel->setForegroundRole(QPalette::Light);
return true; return true;
} else if(event->type() == QEvent::Leave) { } else if(event->type() == QEvent::Leave) {
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_copyPathLabel->setForegroundRole(QPalette::WindowText);
return true; return true;
} }
} else if(m_installLabel && watched == m_installLabel) { } else if(m_installLabel && watched == m_installLabel) {
if(event->type() == QEvent::MouseButtonPress) { if(event->type() == QEvent::MouseButtonPress) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}"); m_installLabel->setForegroundRole(QPalette::Dark);
return true; return true;
} else if(event->type() == QEvent::MouseButtonRelease) { } else if(event->type() == QEvent::MouseButtonRelease) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_installLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::Install); Q_EMIT this->onOptionClicked(Options::Install);
return true; return true;
} else if(event->type() == QEvent::Enter) { } else if(event->type() == QEvent::Enter) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}"); m_installLabel->setForegroundRole(QPalette::Light);
return true; return true;
} else if(event->type() == QEvent::Leave) { } else if(event->type() == QEvent::Leave) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_installLabel->setForegroundRole(QPalette::WindowText);
return true; return true;
} }
} }

View File

@ -28,6 +28,10 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include "search-list-view.h" #include "search-list-view.h"
#define NORMAL_COLOR QColor(55, 144, 250, 255)
#define HOVER_COLOR QColor(64, 169, 251, 255)
#define PRESS_COLOR QColor(41, 108, 217, 255)
namespace Zeeker { namespace Zeeker {
class OptionView : public QWidget { class OptionView : public QWidget {
Q_OBJECT Q_OBJECT

View File

@ -217,7 +217,8 @@ void SearchDetailView::setAppWidget(const QString &appname, const QString &path,
QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
QString showname = fontMetrics.elidedText(m_name, Qt::ElideRight, 274); //当字体长度超过215时显示为省略号 QString showname = fontMetrics.elidedText(m_name, Qt::ElideRight, 274); //当字体长度超过215时显示为省略号
m_nameLabel->setText(showname); // m_nameLabel->setText(showname);
m_nameLabel->setText(QString("<h3 style=\"font-weight:normal;\">%1</h3>").arg(escapeHtml(showname)));
if(QString::compare(showname, m_name)) { if(QString::compare(showname, m_name)) {
m_nameLabel->setToolTip(m_name); m_nameLabel->setToolTip(m_name);
} }
@ -350,18 +351,19 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
QString wholeName = FileUtils::getFileName(path); QString wholeName = FileUtils::getFileName(path);
QString name = fontMetrics.elidedText(wholeName, Qt::ElideRight, 274); QString name = fontMetrics.elidedText(wholeName, Qt::ElideRight, 274);
m_nameLabel->setText(name); // m_nameLabel->setText(name);
m_nameLabel->setText(QString("<h3 style=\"font-weight:normal;\">%1</h3>").arg(escapeHtml(name)));
if(QString::compare(name, wholeName)) { if(QString::compare(name, wholeName)) {
m_nameLabel->setToolTip(wholeName); m_nameLabel->setToolTip(wholeName);
} }
m_nameLabel->setTextFormat(Qt::PlainText); //显示纯文本
m_typeLabel->setText(tr("Document")); m_typeLabel->setText(tr("Document"));
break; break;
} }
case SearchListView::ResType::Setting : { case SearchListView::ResType::Setting : {
setIcon(path); setIcon(path);
QString settingType = path.mid(path.indexOf("/") + 1, path.lastIndexOf("/") - path.indexOf("/") - 1); //配置项所属控制面板插件名 QString settingType = path.mid(path.indexOf("/") + 1, path.lastIndexOf("/") - path.indexOf("/") - 1); //配置项所属控制面板插件名
m_nameLabel->setText(settingType); // m_nameLabel->setText(settingType);
m_nameLabel->setText(QString("<h3 style=\"font-weight:normal;\">%1</h3>").arg(escapeHtml(settingType)));
m_typeLabel->setText(FileUtils::getSettingName(path)); m_typeLabel->setText(FileUtils::getSettingName(path));
break; break;
} }
@ -404,6 +406,7 @@ void SearchDetailView::execActions(const int& type, const int& option, const QSt
default: default:
break; break;
} }
Q_EMIT this->actionTriggerd();
} }
/** /**
@ -462,8 +465,6 @@ void SearchDetailView::initUI() {
m_layout = new QVBoxLayout(this); m_layout = new QVBoxLayout(this);
this->setLayout(m_layout); this->setLayout(m_layout);
m_layout->setContentsMargins(16, 60, 16, 24); m_layout->setContentsMargins(16, 60, 16, 24);
this->setObjectName("detailView");
this->setStyleSheet("QWidget#detailView{background:transparent;}");
this->setFixedWidth(378); this->setFixedWidth(378);
//没有网络的时候的提示信息 //没有网络的时候的提示信息
@ -491,8 +492,7 @@ void SearchDetailView::initUI() {
m_nameLayout = new QHBoxLayout(m_nameFrame); m_nameLayout = new QHBoxLayout(m_nameFrame);
m_nameLabel = new QLabel(m_nameFrame); m_nameLabel = new QLabel(m_nameFrame);
m_typeLabel = new QLabel(m_nameFrame); m_typeLabel = new QLabel(m_nameFrame);
m_nameLabel->setStyleSheet("QLabel{font-size: 18px;}"); m_typeLabel->setEnabled(false);
m_typeLabel->setStyleSheet("QLabel{font-size: 14px; color: palette(mid);}");
m_nameFrame->setFixedHeight(48); m_nameFrame->setFixedHeight(48);
m_nameLabel->setMaximumWidth(280); m_nameLabel->setMaximumWidth(280);
m_nameLayout->addWidget(m_nameLabel); m_nameLayout->addWidget(m_nameLabel);

View File

@ -105,6 +105,7 @@ private:
Q_SIGNALS: Q_SIGNALS:
void configFileChanged(); void configFileChanged();
void actionTriggerd();
private Q_SLOTS: private Q_SLOTS:
void execActions(const int&, const int&, const QString&); void execActions(const int&, const int&, const QString&);
void refreshIcon(); void refreshIcon();

View File

@ -21,12 +21,11 @@
#include "search-list-view.h" #include "search-list-view.h"
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include "custom-style.h"
using namespace Zeeker; using namespace Zeeker;
SearchListView::SearchListView(QWidget * parent, const QStringList& list, const int& type) : QTreeView(parent) { SearchListView::SearchListView(QWidget * parent, const QStringList& list, const int& type) : QTreeView(parent) {
// CustomStyle * style = new CustomStyle(GlobalSettings::getInstance()->getValue(STYLE_NAME_KEY).toString()); this->setFrameShape(QFrame::NoFrame);
this->setStyle(CustomStyle::getStyle()); this->viewport()->setAutoFillBackground(false);
setRootIsDecorated(false); setRootIsDecorated(false);
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -43,7 +42,6 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const
// this->setFixedHeight(list.count() * rowheight + 4); // this->setFixedHeight(list.count() * rowheight + 4);
this->setAttribute(Qt::WA_TranslucentBackground, true); this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setAutoFillBackground(false); this->setAutoFillBackground(false);
// this->setStyleSheet("QWidget{background:transparent;}");
m_styleDelegate = new HighlightItemDelegate(this); m_styleDelegate = new HighlightItemDelegate(this);
// m_styleDelegate->setSearchKeyword(keyword); // m_styleDelegate->setSearchKeyword(keyword);
this->setItemDelegate(m_styleDelegate); this->setItemDelegate(m_styleDelegate);
@ -130,13 +128,6 @@ void SearchListView::clear() {
*/ */
void SearchListView::refresh() void SearchListView::refresh()
{ {
QModelIndex index = this->currentIndex();
m_model->refresh();
if(index.row() >= 0 && index.row() < m_model->length() && m_isSelected) {
this->blockSignals(true);
this->setCurrentIndex(index);
this->blockSignals(false);
}
rowheight = this->rowHeight(this->model()->index(0, 0, QModelIndex())) + 1; rowheight = this->rowHeight(this->model()->index(0, 0, QModelIndex())) + 1;
this->setFixedHeight(m_item->getCurrentSize() * rowheight + 4); this->setFixedHeight(m_item->getCurrentSize() * rowheight + 4);
} }

View File

@ -47,6 +47,8 @@ bool ShowMoreLabel::getExpanded() {
} }
void ShowMoreLabel::initUi() { void ShowMoreLabel::initUi() {
QPalette pal = palette();
pal.setColor(QPalette::WindowText, QColor(55, 144, 250, 255));
m_layout = new QHBoxLayout(this); m_layout = new QHBoxLayout(this);
m_layout->setContentsMargins(0, 0, 0, 6); m_layout->setContentsMargins(0, 0, 0, 6);
m_textLabel = new QLabel(this); m_textLabel = new QLabel(this);
@ -58,7 +60,7 @@ void ShowMoreLabel::initUi() {
// m_loadingIconLabel->hide(); // m_loadingIconLabel->hide();
m_layout->setAlignment(Qt::AlignRight); m_layout->setAlignment(Qt::AlignRight);
m_layout->addWidget(m_textLabel); m_layout->addWidget(m_textLabel);
m_textLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}"); m_textLabel->setPalette(pal);
// m_layout->addWidget(m_loadingIconLabel); // m_layout->addWidget(m_loadingIconLabel);
} }

View File

@ -126,8 +126,6 @@ void CreateIndexAskDialog::initUi() {
* @brief CreateIndexAskDialog::paintEvent * @brief CreateIndexAskDialog::paintEvent
*/ */
void CreateIndexAskDialog::paintEvent(QPaintEvent *event) { void CreateIndexAskDialog::paintEvent(QPaintEvent *event) {
Q_UNUSED(event)
QPainter p(this); QPainter p(this);
p.setRenderHint(QPainter::Antialiasing); p.setRenderHint(QPainter::Antialiasing);
QPainterPath rectPath; QPainterPath rectPath;

View File

@ -1,49 +0,0 @@
/*
*
* 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: zhangjiaping <zhangjiaping@kylinos.cn>
*
*/
#include "custom-style.h"
using namespace Zeeker;
static CustomStyle *customstyle_global_instance = nullptr;
CustomStyle::CustomStyle(QStyle *style) {
}
CustomStyle *CustomStyle::getStyle()
{
if (!customstyle_global_instance)
customstyle_global_instance = new CustomStyle;
return customstyle_global_instance;
}
QSize CustomStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const {
switch(type) {
case CT_ItemViewItem: {
QSize size(0, GlobalSettings::getInstance()->getValue(FONT_SIZE_KEY).toDouble() * 2);
return size;
}
break;
default:
break;
}
return QProxyStyle::sizeFromContents(type, option, contentsSize, widget);
}

View File

@ -1,39 +0,0 @@
/*
*
* 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: zhangjiaping <zhangjiaping@kylinos.cn>
*
*/
#ifndef CUSTOMSTYLE_H
#define CUSTOMSTYLE_H
#include <QProxyStyle>
#include "global-settings.h"
namespace Zeeker {
class CustomStyle : public QProxyStyle {
Q_OBJECT
public:
static CustomStyle *getStyle();
virtual QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget = nullptr) const;
private:
explicit CustomStyle(QStyle *style = nullptr);
~CustomStyle() override {}
};
}
#endif // CUSTOMSTYLE_H

View File

@ -98,7 +98,6 @@ void SearchBarHLayout::initUI() {
m_queryWidget = new QWidget(m_queryLineEdit); m_queryWidget = new QWidget(m_queryLineEdit);
m_queryWidget->setFocusPolicy(Qt::NoFocus); m_queryWidget->setFocusPolicy(Qt::NoFocus);
m_queryWidget->setStyleSheet("border:0px;background:transparent");
QHBoxLayout* queryWidLayout = new QHBoxLayout; QHBoxLayout* queryWidLayout = new QHBoxLayout;
queryWidLayout->setContentsMargins(8, 4, 0, 0); queryWidLayout->setContentsMargins(8, 4, 0, 0);
@ -109,13 +108,12 @@ void SearchBarHLayout::initUI() {
QPixmap pixmap(QIcon::fromTheme("system-search-symbolic").pixmap(QSize(20, 20))); QPixmap pixmap(QIcon::fromTheme("system-search-symbolic").pixmap(QSize(20, 20)));
m_queryIcon = new QLabel; m_queryIcon = new QLabel;
m_queryIcon->setStyleSheet("background:transparent");
m_queryIcon->setFixedSize(pixmap.size()); m_queryIcon->setFixedSize(pixmap.size());
m_queryIcon->setPixmap(pixmap); m_queryIcon->setPixmap(pixmap);
m_queryText = new QLabel; m_queryText = new QLabel;
m_queryText->setText(tr("Search")); m_queryText->setText(tr("Search"));
m_queryText->setStyleSheet("background:transparent;color:#626c6e;"); m_queryText->setEnabled(false);
m_queryText->setContentsMargins(0, 0, 0, 4); m_queryText->setContentsMargins(0, 0, 0, 4);
m_queryText->adjustSize(); m_queryText->adjustSize();
@ -215,7 +213,6 @@ SearchLineEdit::SearchLineEdit() {
// popView->setProperty("customShadowMargins", QVector4D(20, 20, 20, 20)); // popView->setProperty("customShadowMargins", QVector4D(20, 20, 20, 20));
// popView->setAttribute(Qt::WA_TranslucentBackground); // popView->setAttribute(Qt::WA_TranslucentBackground);
// m_completer->setPopup(popView); // m_completer->setPopup(popView);
// m_completer->popup()->setStyle(CustomStyle::getStyle());
m_completer->setMaxVisibleItems(14); m_completer->setMaxVisibleItems(14);
setCompleter(m_completer); setCompleter(m_completer);

View File

@ -174,6 +174,13 @@ int main(int argc, char *argv[]) {
syslog(LOG_ERR, "Home is not exits!!\n"); syslog(LOG_ERR, "Home is not exits!!\n");
::sleep(1); ::sleep(1);
} }
while(!QDir("/media/用户保险箱").exists()) {
qWarning() << "集中管控目录未挂载!!";
printf("集中管控目录未挂载!!");
syslog(LOG_ERR, "集中管控目录未挂载!!\n");
::sleep(1);
}
// Output log to file // Output log to file
qInstallMessageHandler(messageOutput); qInstallMessageHandler(messageOutput);

View File

@ -263,7 +263,7 @@ void MainWindow::initUi() {
mainlayout->addWidget(m_titleFrame); mainlayout->addWidget(m_titleFrame);
mainlayout->addWidget(m_contentFrame); mainlayout->addWidget(m_contentFrame);
mainlayout->addWidget(m_searchWidget); mainlayout->addWidget(m_searchWidget);
connect(m_contentFrame, &ContentWidget::mousePressed, m_searchLayout, &SearchBarHLayout::effectiveSearchRecord); connect(m_contentFrame, &ContentWidget::effectiveSearch, m_searchLayout, &SearchBarHLayout::effectiveSearchRecord);
connect(QApplication::primaryScreen(), &QScreen::geometryChanged, connect(QApplication::primaryScreen(), &QScreen::geometryChanged,
this, &MainWindow::monitorResolutionChange); this, &MainWindow::monitorResolutionChange);
@ -287,7 +287,7 @@ void MainWindow::initUi() {
if(! m_search_result_thread->isRunning()) { if(! m_search_result_thread->isRunning()) {
m_search_result_thread->start(); m_search_result_thread->start();
} }
searchContent(text); startSearch(text);
// //允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索 // //允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索
// if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH) // if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH)
// m_askTimer->start(); // m_askTimer->start();
@ -389,10 +389,10 @@ void MainWindow::primaryScreenChangedSlot(QScreen *screen) {
} }
/** /**
* @brief searchContent * @brief startSearch
* @param searchcontent * @param keyword
*/ */
void MainWindow::searchContent(QString keyword) { void MainWindow::startSearch(QString keyword) {
m_contentFrame->setKeyword(keyword); m_contentFrame->setKeyword(keyword);
//设置搜索 //设置搜索

View File

@ -81,7 +81,7 @@ public:
*/ */
// The parameter:keyword is the word or sentence which users want to search. // The parameter:keyword is the word or sentence which users want to search.
void searchContent(QString keyword); void startSearch(QString keyword);
// The position which mainwindow shows follow the ukui-panel. // The position which mainwindow shows follow the ukui-panel.
void moveToPanel(); void moveToPanel();

View File

@ -182,12 +182,6 @@ void SearchItemModel::setBestAppIcon(const QString &str, const bool & is_install
} }
} }
void SearchItemModel::refresh()
{
this->beginResetModel();
this->endResetModel();
}
int SearchItemModel::length() int SearchItemModel::length()
{ {
return m_item->m_pathlist.length(); return m_item->m_pathlist.length();

View File

@ -59,7 +59,6 @@ public:
void removeItem(QString); void removeItem(QString);
void clear(); void clear();
void setBestAppIcon(const QString &, const bool &); void setBestAppIcon(const QString &, const bool &);
void refresh();
int length(); int length();
private : private :

View File

@ -57,6 +57,8 @@ SettingsWidget::~SettingsWidget() {
* @brief SettingsWidget::initUi UI * @brief SettingsWidget::initUi UI
*/ */
void SettingsWidget::initUi() { void SettingsWidget::initUi() {
QPalette pal = palette();
pal.setColor(QPalette::Window, QColor(0, 0, 0, 0));
// this->setFixedWidth(528); // this->setFixedWidth(528);
// this->setMinimumHeight(460); // this->setMinimumHeight(460);
// this->setMaximumHeight(680); // this->setMaximumHeight(680);
@ -81,8 +83,6 @@ void SettingsWidget::initUi() {
m_closeBtn = new QPushButton(m_titleFrame); m_closeBtn = new QPushButton(m_titleFrame);
m_closeBtn->setFixedSize(24, 24); m_closeBtn->setFixedSize(24, 24);
// m_closeBtn->setIcon(QIcon(":/res/icons/close.svg")); // m_closeBtn->setIcon(QIcon(":/res/icons/close.svg"));
// m_closeBtn->setStyleSheet("QPushButton{background: transparent;}"
// "QPushButton:hover:!pressed{background: transparent;}");
m_closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic")); m_closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
m_closeBtn->setProperty("isWindowButton", 0x02); m_closeBtn->setProperty("isWindowButton", 0x02);
m_closeBtn->setProperty("useIconHighlightEffect", 0x08); m_closeBtn->setProperty("useIconHighlightEffect", 0x08);
@ -139,9 +139,9 @@ void SettingsWidget::initUi() {
m_indexBtnLyt->addWidget(m_addDirBtn); m_indexBtnLyt->addWidget(m_addDirBtn);
m_indexBtnLyt->addStretch(); m_indexBtnLyt->addStretch();
m_dirListArea = new QScrollArea(m_contentFrame); m_dirListArea = new QScrollArea(m_contentFrame);
m_dirListArea->setStyleSheet("QScrollArea{background:transparent;}"); m_dirListArea->setPalette(pal);
m_dirListArea->setFrameShape(QFrame::Shape::NoFrame);
m_dirListWidget = new QWidget(m_contentFrame); m_dirListWidget = new QWidget(m_contentFrame);
m_dirListWidget->setStyleSheet("QWidget{background:transparent;}");
m_dirListLyt = new QVBoxLayout(m_dirListWidget); m_dirListLyt = new QVBoxLayout(m_dirListWidget);
m_dirListLyt->setContentsMargins(0, 0, 0, 0); m_dirListLyt->setContentsMargins(0, 0, 0, 0);
m_dirListLyt->setSpacing(0); m_dirListLyt->setSpacing(0);

View File

@ -28,7 +28,6 @@ include(singleapplication/qt-single-application.pri)
SOURCES += \ SOURCES += \
content-widget.cpp \ content-widget.cpp \
create-index-ask-dialog.cpp \ create-index-ask-dialog.cpp \
custom-style.cpp \
input-box.cpp \ input-box.cpp \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
@ -41,7 +40,6 @@ SOURCES += \
HEADERS += \ HEADERS += \
content-widget.h \ content-widget.h \
create-index-ask-dialog.h \ create-index-ask-dialog.h \
custom-style.h \
input-box.h \ input-box.h \
mainwindow.h \ mainwindow.h \
search-app-thread.h \ search-app-thread.h \