From 8ab2857b1b9ff31c3da468794ac5d72896494092 Mon Sep 17 00:00:00 2001 From: "baijunjie@kylinos.cn" Date: Mon, 9 Aug 2021 21:00:15 +0800 Subject: [PATCH 1/3] use DBus Interface to show ukui-search window --- frontend/frontend.pro | 6 ++++-- frontend/main.cpp | 2 ++ frontend/ukui-search-dbus-service.h | 28 +++++++++++++++++++++++++++ frontend/ukui-search-dubs-service.cpp | 24 +++++++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 frontend/ukui-search-dbus-service.h create mode 100644 frontend/ukui-search-dubs-service.cpp diff --git a/frontend/frontend.pro b/frontend/frontend.pro index 93281f8..e8f85c3 100644 --- a/frontend/frontend.pro +++ b/frontend/frontend.pro @@ -30,11 +30,13 @@ include(view/view.pri) SOURCES += \ main.cpp \ - mainwindow.cpp + mainwindow.cpp \ + ukui-search-dubs-service.cpp HEADERS += \ - mainwindow.h \ + mainwindow.h \ \ + ukui-search-dbus-service.h # Default rules for deployment. diff --git a/frontend/main.cpp b/frontend/main.cpp index b666afe..578d28a 100644 --- a/frontend/main.cpp +++ b/frontend/main.cpp @@ -38,6 +38,7 @@ #include "qt-local-peer.h" #include "libsearch.h" #include "global-settings.h" +#include "ukui-search-dbus-service.h" using namespace Zeeker; @@ -263,6 +264,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); diff --git a/frontend/ukui-search-dbus-service.h b/frontend/ukui-search-dbus-service.h new file mode 100644 index 0000000..d02ba87 --- /dev/null +++ b/frontend/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/frontend/ukui-search-dubs-service.cpp b/frontend/ukui-search-dubs-service.cpp new file mode 100644 index 0000000..8be6564 --- /dev/null +++ b/frontend/ukui-search-dubs-service.cpp @@ -0,0 +1,24 @@ +#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(); + if(!sessionBus.registerService("org.ukui.search.service")){ + qCritical() << "QDbus register service failed reason:" << sessionBus.lastError(); + exit(1); + } + + if(!sessionBus.registerObject("/", this, QDBusConnection::ExportAllSlots)){ + qCritical() << "QDbus register object failed reason:" << sessionBus.lastError(); + exit(2); + } +} + +UkuiSearchDbusServices::~UkuiSearchDbusServices(){ +} From c6626ec3695523b97c675da63cc35459f27c0055 Mon Sep 17 00:00:00 2001 From: "baijunjie@kylinos.cn" Date: Wed, 11 Aug 2021 17:50:00 +0800 Subject: [PATCH 2/3] use dbus interface to search keyword --- frontend/control/search-line-edit.cpp | 5 +++++ frontend/control/search-line-edit.h | 3 +++ frontend/frontend.pro | 2 +- frontend/mainwindow.cpp | 1 + frontend/mainwindow.h | 1 + ...ubs-service.cpp => ukui-search-dbus-service.cpp} | 13 +++++++++---- frontend/ukui-search-dbus-service.h | 1 + 7 files changed, 21 insertions(+), 5 deletions(-) rename frontend/{ukui-search-dubs-service.cpp => ukui-search-dbus-service.cpp} (62%) diff --git a/frontend/control/search-line-edit.cpp b/frontend/control/search-line-edit.cpp index 6b4032e..8811bd3 100644 --- a/frontend/control/search-line-edit.cpp +++ b/frontend/control/search-line-edit.cpp @@ -113,6 +113,11 @@ void SeachBarWidget::reSearch() Q_EMIT this->m_searchLineEdit->requestSearchKeyword(m_searchLineEdit->text()); } +void SeachBarWidget::setText(QString keyword) +{ + m_searchLineEdit->setText(keyword); +} + void SeachBarWidget::paintEvent(QPaintEvent *e) { Q_UNUSED(e) diff --git a/frontend/control/search-line-edit.h b/frontend/control/search-line-edit.h index 85b99f6..bfe2d73 100644 --- a/frontend/control/search-line-edit.h +++ b/frontend/control/search-line-edit.h @@ -69,6 +69,9 @@ protected: Q_SIGNALS: void requestSearchKeyword(QString text); +public Q_SLOTS: + void setText(QString keyword); + private: SearchLineEdit *m_searchLineEdit; QHBoxLayout *m_ly; diff --git a/frontend/frontend.pro b/frontend/frontend.pro index e8f85c3..3668333 100644 --- a/frontend/frontend.pro +++ b/frontend/frontend.pro @@ -31,7 +31,7 @@ include(view/view.pri) SOURCES += \ main.cpp \ mainwindow.cpp \ - ukui-search-dubs-service.cpp + ukui-search-dbus-service.cpp HEADERS += \ diff --git a/frontend/mainwindow.cpp b/frontend/mainwindow.cpp index 7e5e04d..a6d0b7f 100644 --- a/frontend/mainwindow.cpp +++ b/frontend/mainwindow.cpp @@ -171,6 +171,7 @@ void MainWindow::initConnections() connect(m_searchBarWidget, &SeachBarWidget::requestSearchKeyword, this, &MainWindow::searchKeywordSlot); // connect(m_stackedWidget, &StackedWidget::effectiveSearch, m_searchLayout, &SearchBarHLayout::effectiveSearchRecord); //connect(m_searchResultPage, &SearchResultPage::resizeHeight, this, &MainWindow::resizeHeight); + connect(this,&MainWindow::setText,m_searchBarWidget,&SeachBarWidget::setText); } /** diff --git a/frontend/mainwindow.h b/frontend/mainwindow.h index 644cc42..5b05a27 100644 --- a/frontend/mainwindow.h +++ b/frontend/mainwindow.h @@ -87,6 +87,7 @@ protected: Q_SIGNALS: void searchMethodChanged(FileUtils::SearchMethod); void webEngineChanged(); + void setText(QString keyword); public Q_SLOTS: /** diff --git a/frontend/ukui-search-dubs-service.cpp b/frontend/ukui-search-dbus-service.cpp similarity index 62% rename from frontend/ukui-search-dubs-service.cpp rename to frontend/ukui-search-dbus-service.cpp index 8be6564..f214b2c 100644 --- a/frontend/ukui-search-dubs-service.cpp +++ b/frontend/ukui-search-dbus-service.cpp @@ -1,22 +1,27 @@ #include "ukui-search-dbus-service.h" + using namespace Zeeker; void UkuiSearchDbusServices::showWindow(){ m_mainWindow->bootOptionsFilter("-s"); } +void UkuiSearchDbusServices::searchKeyword(QString keyword) +{ + showWindow(); + m_mainWindow->setText(keyword); +} + UkuiSearchDbusServices::UkuiSearchDbusServices(MainWindow *m) { m_mainWindow = m; //注册服务 QDBusConnection sessionBus = QDBusConnection::sessionBus(); if(!sessionBus.registerService("org.ukui.search.service")){ - qCritical() << "QDbus register service failed reason:" << sessionBus.lastError(); - exit(1); + qWarning() << "ukui-search dbus register service failed reason:" << sessionBus.lastError(); } if(!sessionBus.registerObject("/", this, QDBusConnection::ExportAllSlots)){ - qCritical() << "QDbus register object failed reason:" << sessionBus.lastError(); - exit(2); + qWarning() << "ukui-search dbus register object failed reason:" << sessionBus.lastError(); } } diff --git a/frontend/ukui-search-dbus-service.h b/frontend/ukui-search-dbus-service.h index d02ba87..4adda09 100644 --- a/frontend/ukui-search-dbus-service.h +++ b/frontend/ukui-search-dbus-service.h @@ -19,6 +19,7 @@ public: public Q_SLOTS: void showWindow(); + void searchKeyword(QString keyword); private: MainWindow *m_mainWindow; From ea8382f56e65fc25f3963f764832390727345f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BF=8A=E6=9D=B0=20=E7=99=BD?= Date: Thu, 12 Aug 2021 06:53:17 +0000 Subject: [PATCH 3/3] Update frontend/frontend.pro --- frontend/frontend.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/frontend.pro b/frontend/frontend.pro index 3668333..dff18f4 100644 --- a/frontend/frontend.pro +++ b/frontend/frontend.pro @@ -35,7 +35,7 @@ SOURCES += \ HEADERS += \ - mainwindow.h \ \ + mainwindow.h \ ukui-search-dbus-service.h # Default rules for deployment.