use dbus interface to show the ukui-search window

This commit is contained in:
baijunjie@kylinos.cn 2021-08-11 13:57:54 +08:00
parent 2f3f072bb4
commit cdc03035c2
4 changed files with 54 additions and 0 deletions

View File

@ -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();

View File

@ -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.

View File

@ -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(){
}

View File

@ -0,0 +1,28 @@
#ifndef UKUISEARCHDBUSSERVICE_H
#define UKUISEARCHDBUSSERVICE_H
#include <QDBusConnection>
#include <QObject>
#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