From b6c9acded3704ae7822886a071d332c0be2f750d Mon Sep 17 00:00:00 2001 From: JunjieBai Date: Tue, 5 Jul 2022 12:47:16 +0800 Subject: [PATCH] Add a mainWindow switch dbus interface. --- frontend/mainwindow.cpp | 5 +++++ frontend/mainwindow.h | 1 + frontend/ukui-search-dbus-service.cpp | 9 +++++++++ frontend/ukui-search-dbus-service.h | 3 ++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/frontend/mainwindow.cpp b/frontend/mainwindow.cpp index 1d2ca2b..58fbb58 100644 --- a/frontend/mainwindow.cpp +++ b/frontend/mainwindow.cpp @@ -327,6 +327,11 @@ void MainWindow::resizeHeight(int height) this->setFixedHeight(height); } +void MainWindow::tryHide() +{ + this->tryHideMainwindow(); +} + /** * @brief monitorResolutionChange 监听屏幕改变 * @param rect diff --git a/frontend/mainwindow.h b/frontend/mainwindow.h index 2558654..124ca4d 100644 --- a/frontend/mainwindow.h +++ b/frontend/mainwindow.h @@ -110,6 +110,7 @@ public Q_SLOTS: void settingsBtnClickedSlot(); void searchKeywordSlot(const QString&); void resizeHeight(int height); + void tryHide(); private: diff --git a/frontend/ukui-search-dbus-service.cpp b/frontend/ukui-search-dbus-service.cpp index 7a29e83..58d7110 100644 --- a/frontend/ukui-search-dbus-service.cpp +++ b/frontend/ukui-search-dbus-service.cpp @@ -12,6 +12,15 @@ void UkuiSearchDbusServices::searchKeyword(QString keyword) m_mainWindow->setText(keyword); } +void UkuiSearchDbusServices::mainWindowSwitch() +{ + if (m_mainWindow->isActiveWindow()) { + m_mainWindow->tryHide(); + } else { + m_mainWindow->bootOptionsFilter("-s"); + } +} + UkuiSearchDbusServices::UkuiSearchDbusServices(MainWindow *m) { m_mainWindow = m; diff --git a/frontend/ukui-search-dbus-service.h b/frontend/ukui-search-dbus-service.h index d3d13be..58eb25d 100644 --- a/frontend/ukui-search-dbus-service.h +++ b/frontend/ukui-search-dbus-service.h @@ -20,9 +20,10 @@ public: public Q_SLOTS: void showWindow(); void searchKeyword(QString keyword); + void mainWindowSwitch(); private: - MainWindow *m_mainWindow; + MainWindow *m_mainWindow = nullptr; }; }