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; }; }