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/src.pro b/src/src.pro index f61b5a7..fd8f22c 100644 --- a/src/src.pro +++ b/src/src.pro @@ -34,6 +34,7 @@ SOURCES += \ search-app-thread.cpp \ search-result.cpp \ settings-widget.cpp \ + ukui-search-dbus-service.cpp \ xatom-helper.cpp @@ -45,6 +46,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..5ca1981 --- /dev/null +++ b/src/ukui-search-dbus-service.cpp @@ -0,0 +1,22 @@ +#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")){ + 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