From 8e445406a01785cc59344bcc9e92789a11857062 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Tue, 27 Apr 2021 13:56:43 +0800 Subject: [PATCH] Start ukui-control-center on settings button clicked. --- src/mainwindow.cpp | 71 ++++++++++++++++++++++++---------------------- src/mainwindow.h | 4 +-- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 55497cd..baebad0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -35,7 +35,7 @@ #include "qt-single-application.h" //#include "inotify-manager.h" -#include "settings-widget.h" +//#include "settings-widget.h" #include "global-settings.h" @@ -153,10 +153,10 @@ MainWindow::~MainWindow() { delete m_searchLayout; m_searchLayout = NULL; } - if(m_settingsWidget) { - delete m_settingsWidget; - m_settingsWidget = NULL; - } +// if(m_settingsWidget) { +// delete m_settingsWidget; +// m_settingsWidget = NULL; +// } if(m_askDialog) { delete m_askDialog; m_askDialog = NULL; @@ -202,35 +202,38 @@ void MainWindow::initUi() { m_menuBtn->setProperty("isWindowButton", 0x01); m_menuBtn->setFlat(true); connect(m_menuBtn, &QPushButton::clicked, this, [ = ]() { - if(m_settingsWidget) { //当此窗口已存在时,仅需置顶 - if(!m_settingsWidget->isVisible()) { - centerToScreen(m_settingsWidget); - } - m_settingsWidget->showWidget(); - return; - } - m_settingsWidget = new SettingsWidget(); - connect(this, &MainWindow::webEngineChanged, m_settingsWidget, [ = ]() { - m_settingsWidget->resetWebEngine(); - }); - connect(m_settingsWidget, &SettingsWidget::webEngineChanged, this, [ = ](const QString & engine) { - if(m_search_gsettings && m_search_gsettings->keys().contains(WEB_ENGINE_KEY)) { - m_search_gsettings->set(WEB_ENGINE_KEY, engine); - } else { - GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine); - } - }); - centerToScreen(m_settingsWidget); - m_settingsWidget->show(); - connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() { - QTimer::singleShot(100, this, [ = ] { -// clearSearchResult(); //现暂定从设置页返回主页面不清空搜索结果 - this->setWindowState(this->windowState() & ~Qt::WindowMinimized); - this->raise(); - this->showNormal(); - this->activateWindow(); - }); - }); +// if(m_settingsWidget) { //当此窗口已存在时,仅需置顶 +// if(!m_settingsWidget->isVisible()) { +// centerToScreen(m_settingsWidget); +// } +// m_settingsWidget->showWidget(); +// return; +// } +// m_settingsWidget = new SettingsWidget(); +// connect(this, &MainWindow::webEngineChanged, m_settingsWidget, [ = ]() { +// m_settingsWidget->resetWebEngine(); +// }); +// connect(m_settingsWidget, &SettingsWidget::webEngineChanged, this, [ = ](const QString & engine) { +// if(m_search_gsettings && m_search_gsettings->keys().contains(WEB_ENGINE_KEY)) { +// m_search_gsettings->set(WEB_ENGINE_KEY, engine); +// } else { +// GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine); +// } +// }); +// centerToScreen(m_settingsWidget); +// m_settingsWidget->show(); +// connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() { +// QTimer::singleShot(100, this, [ = ] { +//// clearSearchResult(); //现暂定从设置页返回主页面不清空搜索结果 +// this->setWindowState(this->windowState() & ~Qt::WindowMinimized); +// this->raise(); +// this->showNormal(); +// this->activateWindow(); +// }); +// }); + //打开控制面板的设置页 + QProcess process; + process.startDetached("ukui-control-center --search"); }); m_titleLyt->addWidget(m_iconLabel); m_titleLyt->addWidget(m_titleLabel); diff --git a/src/mainwindow.h b/src/mainwindow.h index a6f0082..8b4440a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -48,7 +48,7 @@ #include "content-widget.h" #include "input-box.h" #include "index/index-generator.h" -#include "settings-widget.h" +//#include "settings-widget.h" #include "libsearch.h" #include "search-app-thread.h" #include "xatom-helper.h" @@ -93,7 +93,7 @@ private: QLabel * m_iconLabel = nullptr; // Icon lable QLabel * m_titleLabel = nullptr; // Title lable QPushButton * m_menuBtn = nullptr; // Menu button - SettingsWidget * m_settingsWidget = nullptr; // Settings Widget +// SettingsWidget * m_settingsWidget = nullptr; // Settings Widget ContentWidget * m_contentFrame = nullptr; // Content frame SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout SeachBarWidget * m_searchWidget = nullptr; // Search bar