diff --git a/.gitignore b/.gitignore index 6e844ee..43a43f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,72 +1,53 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc +# C++ objects and libs +*.slo +*.lo *.o -*.obj -*.orig -*.rej +*.a +*.la +*.lai *.so *.so.* -*_pch.h.cpp -*_resource.rc -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res *.rc +*.dll +*.dylib + +# Qt-es +object_script.*.Release +object_script.*.Debug +*_plugin_import.cpp /.qmake.cache /.qmake.stash +*.pro.user +*.pro.user.* +*.qbs.user +*.qbs.user.* +*.moc +moc_*.cpp +moc_*.h +qrc_*.cpp +ui_*.h +*.qmlc +*.jsc +Makefile* +*build-* +*.qm +*.prl -# qtcreator generated files -*.pro.user* +# Qt unit tests +target_wrapper.* -# xemacs temporary files -*.flc +# QtCreator +*.autosave -# Vim temporary files -.*.swp +# QtCreator Qml +*.qmlproject.user +*.qmlproject.user.* -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* +# QtCreator CMake +CMakeLists.txt.user* -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe +# QtCreator 4.8< compilation database +compile_commands.json +# QtCreator local machine specific files for imported projects +*creator.user* diff --git a/data/ukui-search-menu.desktop b/data/ukui-search-menu.desktop index 085b75c..d9dc4b1 100644 --- a/data/ukui-search-menu.desktop +++ b/data/ukui-search-menu.desktop @@ -1,10 +1,13 @@ [Desktop Entry] Name=Search Name[zh_CN]=搜索 +Name[bo_CN]=བཤེར་འཚོལ། GenericName=UKUI Global Search GenericName[zh_CN]=全局搜索 +GenericName[bo_CN]=བཤེར་འཚོལ། Comment=ukui-search Comment[zh_CN]=全局搜索 +Comment[bo_CN]=ཁྱོན་ཡོངས་བཤེར་འཚོལ། Exec=/usr/bin/ukui-search -s Type=Application Icon=kylin-search diff --git a/libsearch/index/first-index.cpp b/libsearch/index/first-index.cpp index 15f6429..59a44b1 100644 --- a/libsearch/index/first-index.cpp +++ b/libsearch/index/first-index.cpp @@ -95,9 +95,7 @@ void FirstIndex::DoSomething(const QFileInfo& fileInfo) { void FirstIndex::run() { QTime t1 = QTime::currentTime(); - // Create a fifo at ~/.config/org.ukui/ukui-search, the fifo is used to control the order of child processes' running. - QString indexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(INDEX_DATABASE_STATE).toString(); QString contentIndexDataBaseStatus = IndexStatusRecorder::getInstance()->getStatus(CONTENT_INDEX_DATABASE_STATE).toString(); QString inotifyIndexStatus = IndexStatusRecorder::getInstance()->getStatus(INOTIFY_NORMAL_EXIT).toString(); @@ -106,7 +104,6 @@ void FirstIndex::run() { qDebug() << "contentIndexDataBaseStatus: " << contentIndexDataBaseStatus; qDebug() << "inotifyIndexStatus: " << inotifyIndexStatus; - /* || contentIndexDataBaseStatus == ""*/ if(indexDataBaseStatus == "") { this->bool_dataBaseExist = false; } else { @@ -119,9 +116,6 @@ void FirstIndex::run() { } this->q_index = new QQueue>(); - //this->q_content_index = new QQueue(); - //NEW_QUEUE(this->q_content_index); -// this->mlm = new MessageListManager(); this->q_content_index = new QQueue>(); int fifo_fd; @@ -135,11 +129,6 @@ void FirstIndex::run() { assert(false); } -// this->q_content_index->enqueue(QString("/home/zhangzihao/Desktop/qwerty/四库全书.txt")); - -// this->p_indexGenerator->creatAllIndex(this->q_content_index); - - ++FileUtils::_index_status; pid_t pid; pid = fork(); @@ -157,7 +146,6 @@ void FirstIndex::run() { } else { // p_indexGenerator = IndexGenerator::getInstance(false,this); p_indexGenerator = IndexGenerator::getInstance(true, this); - } //TODO Fix these weird code. QSemaphore sem(5); @@ -166,7 +154,6 @@ void FirstIndex::run() { mutex2.lock(); mutex3.lock(); sem.acquire(4); -// QtConcurrent::run([&](){ sem.acquire(1); mutex1.unlock(); this->setPath(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)); @@ -174,7 +161,6 @@ void FirstIndex::run() { FileUtils::_max_index_count = this->q_index->length(); qDebug() << "max_index_count:" << FileUtils::_max_index_count; sem.release(5); -// }); QtConcurrent::run(&m_pool, [&]() { sem.acquire(2); mutex2.unlock(); @@ -197,7 +183,6 @@ void FirstIndex::run() { QQueue* tmp2 = new QQueue(); qDebug() << "q_content_index:" << q_content_index->size(); while(!this->q_content_index->empty()) { - // for (size_t i = 0; (i < this->u_send_length) && (!this->q_content_index->empty()); ++i){ qint64 fileSize = 0; //修改一次处理的数据量,从30个文件改为文件总大小为50M以下,50M为暂定值--jxx20210519 for(size_t i = 0;/* (i < 30) && (fileSize < 52428800) && */(!this->q_content_index->empty()); ++i) { @@ -230,6 +215,8 @@ void FirstIndex::run() { mutex2.unlock(); mutex3.unlock(); + + if(this->q_index) delete this->q_index; this->q_index = nullptr; diff --git a/libsearch/index/first-index.h b/libsearch/index/first-index.h index ab1d23e..9275260 100644 --- a/libsearch/index/first-index.h +++ b/libsearch/index/first-index.h @@ -35,11 +35,9 @@ #include #include #include -//#include #include "traverse_bfs.h" #include "index-status-recorder.h" #include "index-generator.h" -#include "inotify-index.h" #include "file-utils.h" #include "common.h" namespace Zeeker { @@ -58,31 +56,11 @@ private: IndexGenerator* p_indexGenerator = nullptr; QThreadPool m_pool; - //here should be refact -// MessageListManager* mlm; - - //test QQueue>* q_index; // QQueue* q_content_index; //修改QQueue存储数据为QPair,增加存储文件大小数据便于处理时统计--jxx20210519 QQueue>* q_content_index; - const QMap targetFileTypeMap = { - std::map::value_type("doc", true), - std::map::value_type("docx", true), - std::map::value_type("ppt", true), - std::map::value_type("pptx", true), - std::map::value_type("xls", true), - std::map::value_type("xlsx", true), - std::map::value_type("txt", true), - std::map::value_type("dot", true), - std::map::value_type("wps", true), - std::map::value_type("pps", true), - std::map::value_type("dps", true), - std::map::value_type("et", true), - std::map::value_type("pdf", true) - }; - //xapian will auto commit per 10,000 changes, donnot change it!!! const size_t u_send_length = 8192; }; diff --git a/libsearch/index/pinyinWithoutTone.txt b/libsearch/index/pinyinWithoutTone.txt index 5477369..5c1af9c 100644 --- a/libsearch/index/pinyinWithoutTone.txt +++ b/libsearch/index/pinyinWithoutTone.txt @@ -7280,7 +7280,7 @@ jiao 叫 shao,zhao 召 ba,pa 叭 ding 叮 -ke,ge 可 +ke 可 tai,yi,si 台 chi,hua,e 叱 shi 史 @@ -8647,7 +8647,7 @@ di,ti 奃 yan 奄 pao 奅 juan 奆 -ji,ai,yi,qi 奇 +ji,qi 奇 nai 奈 feng 奉 pi,xi,lie,xie 奊 diff --git a/libsearch/index/search-manager.cpp b/libsearch/index/search-manager.cpp index 052e877..acccf8f 100644 --- a/libsearch/index/search-manager.cpp +++ b/libsearch/index/search-manager.cpp @@ -345,7 +345,7 @@ int FileContentSearch::getResult(Xapian::MSet &result, std::string &keyWord) { // qWarning()<addAction(searchAction,QLineEdit::LeadingPosition); /*发送输入框文字改变的dbus*/ - QDBusConnection::sessionBus().unregisterService("org.ukui.search.service"); - QDBusConnection::sessionBus().registerService("org.ukui.search.service"); - QDBusConnection::sessionBus().registerObject("/lineEdit/textChanged", this, QDBusConnection :: ExportAllSlots | QDBusConnection :: ExportAllSignals); +// QDBusConnection::sessionBus().unregisterService("org.ukui.search.service"); +// QDBusConnection::sessionBus().registerService("org.ukui.search.service"); +// QDBusConnection::sessionBus().registerObject("/lineEdit/textChanged", this, QDBusConnection :: ExportAllSlots | QDBusConnection :: ExportAllSignals); connect(this, &QLineEdit::textChanged, this, &SearchLineEdit::lineEditTextChanged); connect(this, &QLineEdit::textChanged, this, [ = ]() { diff --git a/src/input-box.h b/src/input-box.h index d17db8c..61e4973 100644 --- a/src/input-box.h +++ b/src/input-box.h @@ -94,11 +94,11 @@ private: class SearchLineEdit : public QLineEdit { Q_OBJECT - /* - * 负责与ukui桌面环境应用通信的dbus - * 搜索框文本改变的时候发送信号 -    */ - Q_CLASSINFO("D-Bus Interface", "org.ukui.search.inputbox") +// /* +// * 负责与ukui桌面环境应用通信的dbus +// * 搜索框文本改变的时候发送信号 +//    */ +// Q_CLASSINFO("D-Bus Interface", "org.ukui.search.inputbox") public: SearchLineEdit(QWidget *parent = nullptr); void record(); diff --git a/src/main.cpp b/src/main.cpp index 37674a2..04bdb83 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,6 +39,7 @@ //#include "inotify-manager.h" #include "libsearch.h" #include "global-settings.h" +#include "ukui-search-dbus-service.h" using namespace Zeeker; //void handler(int){ @@ -279,6 +280,7 @@ int main(int argc, char *argv[]) { //set main window to the center of screen MainWindow *w = new MainWindow; + UkuiSearchDbusServices dbusService(w); qApp->setWindowIcon(QIcon::fromTheme("kylin-search")); // centerToScreen(w); // w->moveToPanel(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e83f741..a80601e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -472,16 +472,16 @@ void MainWindow::centerToScreen(QWidget* widget) { int desk_y = desk_rect.height(); int x = widget->width(); int y = widget->height(); - QDBusInterface primaryScreenInterface("org.ukui.SettingsDaemon", - "/org/ukui/SettingsDaemon/wayland", - "org.ukui.SettingsDaemon.wayland", - QDBusConnection::sessionBus()); - if(QDBusReply(primaryScreenInterface.call("x")).isValid()) { - QDBusReply width = primaryScreenInterface.call("width"); - QDBusReply height = primaryScreenInterface.call("height"); - desk_x = width; - desk_y = height; - } +// QDBusInterface primaryScreenInterface("org.ukui.SettingsDaemon", +// "/org/ukui/SettingsDaemon/wayland", +// "org.ukui.SettingsDaemon.wayland", +// QDBusConnection::sessionBus()); +// if(QDBusReply(primaryScreenInterface.call("x")).isValid()) { +// QDBusReply width = primaryScreenInterface.call("width"); +// QDBusReply height = primaryScreenInterface.call("height"); +// desk_x = width; +// desk_y = height; +// } widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top()); } diff --git a/src/src.pro b/src/src.pro index 0a52d82..f8cf992 100644 --- a/src/src.pro +++ b/src/src.pro @@ -35,6 +35,7 @@ SOURCES += \ search-app-thread.cpp \ search-result.cpp \ settings-widget.cpp \ + ukui-search-dbus-service.cpp \ xatom-helper.cpp @@ -46,6 +47,7 @@ HEADERS += \ search-app-thread.h \ search-result.h \ settings-widget.h \ + ukui-search-dbus-service.h \ xatom-helper.h # Default rules for deployment. diff --git a/src/ukui-search-dbus-service.cpp b/src/ukui-search-dbus-service.cpp new file mode 100644 index 0000000..c0955af --- /dev/null +++ b/src/ukui-search-dbus-service.cpp @@ -0,0 +1,23 @@ +#include "ukui-search-dbus-service.h" + +using namespace Zeeker; +void UkuiSearchDbusServices::showWindow(){ + m_mainWindow->bootOptionsFilter("-s"); +} + +UkuiSearchDbusServices::UkuiSearchDbusServices(MainWindow *m) +{ + m_mainWindow = m; + //注册服务 + QDBusConnection sessionBus = QDBusConnection::sessionBus(); + QDBusConnection::sessionBus().unregisterService("com.ukui.search.service"); + if(!sessionBus.registerService("com.ukui.search.service")){ + qWarning() << "ukui-search dbus register service failed reason:" << sessionBus.lastError(); + } + + if(!sessionBus.registerObject("/", this, QDBusConnection::ExportAllSlots)){ + qWarning() << "ukui-search dbus register object failed reason:" << sessionBus.lastError(); + } +} +UkuiSearchDbusServices::~UkuiSearchDbusServices(){ +} diff --git a/src/ukui-search-dbus-service.h b/src/ukui-search-dbus-service.h new file mode 100644 index 0000000..d02ba87 --- /dev/null +++ b/src/ukui-search-dbus-service.h @@ -0,0 +1,28 @@ +#ifndef UKUISEARCHDBUSSERVICE_H +#define UKUISEARCHDBUSSERVICE_H + +#include +#include + +#include "mainwindow.h" + +namespace Zeeker { + +class UkuiSearchDbusServices: public QObject{ + Q_OBJECT + + Q_CLASSINFO("D-Bus Interface","org.ukui.search.service") + +public: + explicit UkuiSearchDbusServices(MainWindow *m); + ~UkuiSearchDbusServices(); + +public Q_SLOTS: + void showWindow(); + +private: + MainWindow *m_mainWindow; +}; +} + +#endif // UKUISEARCHDBUSSERVICE_H diff --git a/ukuisearch-systemdbus/ukuisearch-systemdbus.pro b/ukuisearch-systemdbus/ukuisearch-systemdbus.pro index 8ceb141..623a8b5 100644 --- a/ukuisearch-systemdbus/ukuisearch-systemdbus.pro +++ b/ukuisearch-systemdbus/ukuisearch-systemdbus.pro @@ -22,7 +22,7 @@ target.path = /usr/bin INSTALLS += \ target \ inst1 \ - inst2 \ + inst2 HEADERS += \ sysdbusregister.h