From 323fc1bdab933f62779d8541bbea61582d7a4f21 Mon Sep 17 00:00:00 2001 From: iaom <18504285112@163.com> Date: Fri, 23 Jul 2021 16:10:30 +0800 Subject: [PATCH] Update UI. --- frontend/control/search-line-edit.cpp | 59 ++++---- .../stack-pages/search-page-section.cpp | 5 + frontend/control/stack-pages/search-page.cpp | 81 ---------- .../stack-pages/search-result-page.cpp | 140 ++++++++++++++++++ .../{search-page.h => search-result-page.h} | 17 ++- frontend/control/stack-pages/stack-pages.pri | 4 +- frontend/control/stacked-widget.cpp | 24 +-- frontend/control/stacked-widget.h | 8 +- frontend/mainwindow.cpp | 44 +++--- frontend/mainwindow.h | 7 +- frontend/model/search-result-manager.cpp | 53 ------- frontend/view/result-view.cpp | 2 + 12 files changed, 235 insertions(+), 209 deletions(-) delete mode 100644 frontend/control/stack-pages/search-page.cpp create mode 100644 frontend/control/stack-pages/search-result-page.cpp rename frontend/control/stack-pages/{search-page.h => search-result-page.h} (80%) diff --git a/frontend/control/search-line-edit.cpp b/frontend/control/search-line-edit.cpp index f5289f1..d81901a 100644 --- a/frontend/control/search-line-edit.cpp +++ b/frontend/control/search-line-edit.cpp @@ -91,9 +91,10 @@ void SearchLineEdit::paintEvent(QPaintEvent *e) } SeachBarWidget::SeachBarWidget(QWidget *parent): QWidget(parent) { - this->setFixedSize(700, 70); m_ly = new QHBoxLayout(this); m_searchLineEdit = new SearchLineEdit(this); + this->setFixedSize(m_searchLineEdit->width()+20, m_searchLineEdit->height()+20); + m_ly->setContentsMargins(0,0,0,0); m_ly->addWidget(m_searchLineEdit); connect(m_searchLineEdit, &SearchLineEdit::requestSearchKeyword, this, &SeachBarWidget::requestSearchKeyword); } @@ -110,42 +111,42 @@ void SeachBarWidget::paintEvent(QPaintEvent *e) { Q_UNUSED(e) - QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); - QPainterPath rectPath; - rectPath.addRoundedRect(this->rect().adjusted(10, 10, -10, -10), 6, 6); + QPainter p(this); + p.setRenderHint(QPainter::Antialiasing); + QPainterPath rectPath; + rectPath.addRoundedRect(this->rect().adjusted(10, 10, -10, -10), 6, 6); - // 画一个黑底 - QPixmap pixmap(this->rect().size()); - pixmap.fill(Qt::transparent); - QPainter pixmapPainter(&pixmap); - pixmapPainter.setRenderHint(QPainter::Antialiasing); -// pixmapPainter.setCompositionMode(QPainter::CompositionMode_Difference); - pixmapPainter.setPen(Qt::transparent); - pixmapPainter.setBrush(Qt::black); - pixmapPainter.setOpacity(0.65); - pixmapPainter.drawPath(rectPath); - pixmapPainter.end(); + // 画一个黑底 + QPixmap pixmap(this->rect().size()); + pixmap.fill(Qt::transparent); + QPainter pixmapPainter(&pixmap); + pixmapPainter.setRenderHint(QPainter::Antialiasing); + // pixmapPainter.setCompositionMode(QPainter::CompositionMode_Difference); + pixmapPainter.setPen(Qt::transparent); + pixmapPainter.setBrush(Qt::black); + pixmapPainter.setOpacity(0.65); + pixmapPainter.drawPath(rectPath); + pixmapPainter.end(); - // 模糊这个黑底 - QImage img = pixmap.toImage(); - qt_blurImage(img, 10, false, false); + // 模糊这个黑底 + QImage img = pixmap.toImage(); + qt_blurImage(img, 10, false, false); - // 挖掉中心 - pixmap = QPixmap::fromImage(img); - QPainter pixmapPainter2(&pixmap); - pixmapPainter2.setRenderHint(QPainter::Antialiasing); - pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear); - pixmapPainter2.setPen(Qt::transparent); - pixmapPainter2.setBrush(Qt::transparent); - pixmapPainter2.drawPath(rectPath); + // 挖掉中心 + pixmap = QPixmap::fromImage(img); + QPainter pixmapPainter2(&pixmap); + pixmapPainter2.setRenderHint(QPainter::Antialiasing); + pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear); + pixmapPainter2.setPen(Qt::transparent); + pixmapPainter2.setBrush(Qt::transparent); + pixmapPainter2.drawPath(rectPath); - // 绘制阴影 - p.drawPixmap(this->rect(), pixmap, pixmap.rect()); + // 绘制阴影 + p.drawPixmap(this->rect(), pixmap, pixmap.rect()); } void LineEditStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const diff --git a/frontend/control/stack-pages/search-page-section.cpp b/frontend/control/stack-pages/search-page-section.cpp index 07ad05f..7fcfc3a 100644 --- a/frontend/control/stack-pages/search-page-section.cpp +++ b/frontend/control/stack-pages/search-page-section.cpp @@ -99,6 +99,9 @@ void ResultArea::initUi() void ResultArea::setupConnectionsForWidget(ResultWidget *widget) { connect(this, &ResultArea::startSearch, widget, &ResultWidget::startSearch); + connect(this, &ResultArea::startSearch, [=](){ + }); + connect(this, &ResultArea::stopSearch, widget, &ResultWidget::stopSearch); connect(widget, &ResultWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged); } @@ -121,6 +124,7 @@ void DetailArea::initUi() this->setWidgetResizable(true); m_detailWidget = new DetailWidget(this); this->setWidget(m_detailWidget); + this->hide(); } DetailWidget::DetailWidget(QWidget *parent) : QWidget(parent) @@ -192,6 +196,7 @@ void DetailWidget::clear() void DetailWidget::initUi() { + this->setFixedSize(368, 516); m_mainLyt = new QVBoxLayout(this); this->setLayout(m_mainLyt); m_mainLyt->setContentsMargins(DETAIL_WIDGET_MARGINS); diff --git a/frontend/control/stack-pages/search-page.cpp b/frontend/control/stack-pages/search-page.cpp deleted file mode 100644 index 110ee38..0000000 --- a/frontend/control/stack-pages/search-page.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * Copyright (C) 2020, KylinSoft Co., Ltd. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Authors: zhangjiaping - * - */ -#include "search-page.h" -using namespace Zeeker; - -#define RESULT_WIDTH 266 -#define DETAIL_WIDTH 374 - -SearchPage::SearchPage(QWidget *parent) : QWidget(parent) -{ - initUi(); - initConnections(); -} - -void SearchPage::setSize(const int&width, const int&height) -{ - m_splitter->setFixedSize(width, height); -} - -void SearchPage::setPlugins(const QStringList &plugins_id) -{ - Q_FOREACH (QString plugin_id, plugins_id) { - ResultWidget * widget = new ResultWidget(plugin_id, m_resultArea); - m_resultArea->appendWidet(widget); - setupConnectionsForWidget(widget); - } -} - -void SearchPage::appendPlugin(const QString &plugin_id) -{ - ResultWidget * widget = new ResultWidget(plugin_id, m_resultArea); - m_resultArea->appendWidet(widget); - setupConnectionsForWidget(widget); -} - -void SearchPage::initUi() -{ - m_splitter = new QSplitter(this); - m_splitter->setContentsMargins(0, 0, 0, 0); - m_resultArea = new ResultArea(m_splitter); - m_detailArea = new DetailArea(m_splitter); - m_splitter->addWidget(m_resultArea); - m_splitter->addWidget(m_detailArea); - m_splitter->setOpaqueResize(false); - QList size_list; - size_list<setSizes(size_list); - m_splitter->handle(1)->setEnabled(false); //暂时禁止拖动分隔条 -} - -void SearchPage::initConnections() -{ - connect(this, &SearchPage::startSearch, m_resultArea, &ResultArea::startSearch); - connect(this, &SearchPage::stopSearch, m_resultArea, &ResultArea::stopSearch); -} - -void SearchPage::setupConnectionsForWidget(ResultWidget *widget) -{ - connect(widget, &ResultWidget::currentRowChanged, m_detailArea, &DetailArea::setWidgetInfo); - connect(widget, &ResultWidget::currentRowChanged, this, &SearchPage::currentRowChanged); - connect(this, &SearchPage::currentRowChanged, widget, &ResultWidget::clearSelectedRow); - connect(widget, &ResultWidget::rowClicked, this, &SearchPage::effectiveSearch); -} diff --git a/frontend/control/stack-pages/search-result-page.cpp b/frontend/control/stack-pages/search-result-page.cpp new file mode 100644 index 0000000..a09ce68 --- /dev/null +++ b/frontend/control/stack-pages/search-result-page.cpp @@ -0,0 +1,140 @@ +/* + * + * Copyright (C) 2020, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: zhangjiaping + * + */ +#include "search-result-page.h" +QT_BEGIN_NAMESPACE +extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); +QT_END_NAMESPACE +using namespace Zeeker; + +#define RESULT_WIDTH 266 +#define DETAIL_WIDTH 374 + +SearchResultPage::SearchResultPage(QWidget *parent) : QWidget(parent) +{ + initUi(); + initConnections(); + setInternalPlugins(); +} + +void SearchResultPage::setSize(const int&width, const int&height) +{ +// m_splitter->setFixedSize(width, height); +} + +void SearchResultPage::setInternalPlugins() +{ + Q_FOREACH (QString plugin_id, SearchPluginManager::getInstance()->getPluginIds()) { + ResultWidget * widget = new ResultWidget(plugin_id, m_resultArea); + m_resultArea->appendWidet(widget); + setupConnectionsForWidget(widget); + } +} + +void SearchResultPage::appendPlugin(const QString &plugin_id) +{ + ResultWidget * widget = new ResultWidget(plugin_id, m_resultArea); + m_resultArea->appendWidet(widget); + setupConnectionsForWidget(widget); +} + +void SearchResultPage::paintEvent(QPaintEvent *event) +{ + QPainter p(this); + p.setRenderHint(QPainter::Antialiasing); + p.setBrush(palette().base()); + p.setOpacity(GlobalSettings::getInstance()->getValue(TRANSPARENCY_KEY).toDouble()); + p.setPen(Qt::NoPen); + p.drawRoundedRect(this->rect().adjusted(10,10,-10,-10), 6, 6); + + QPainterPath rectPath; + rectPath.addRoundedRect(this->rect().adjusted(10, 10, -10, -10), 6, 6); + + + // 画一个黑底 + QPixmap pixmap(this->rect().size()); + pixmap.fill(Qt::transparent); + QPainter pixmapPainter(&pixmap); + pixmapPainter.setRenderHint(QPainter::Antialiasing); +// pixmapPainter.setCompositionMode(QPainter::CompositionMode_Difference); + pixmapPainter.setPen(Qt::transparent); + pixmapPainter.setBrush(Qt::black); + pixmapPainter.setOpacity(0.65); + pixmapPainter.drawPath(rectPath); + pixmapPainter.end(); + + + // 模糊这个黑底 + QImage img = pixmap.toImage(); + qt_blurImage(img, 10, false, false); + + + // 挖掉中心 + pixmap = QPixmap::fromImage(img); + QPainter pixmapPainter2(&pixmap); + pixmapPainter2.setRenderHint(QPainter::Antialiasing); + pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear); + pixmapPainter2.setPen(Qt::transparent); + pixmapPainter2.setBrush(Qt::transparent); + pixmapPainter2.drawPath(rectPath); + + + // 绘制阴影 + p.drawPixmap(this->rect(), pixmap, pixmap.rect()); +} + +void SearchResultPage::initUi() +{ + this->setFixedSize(700,552); + m_hlayout = new QHBoxLayout(this); + m_hlayout->setContentsMargins(18 ,18, 10, 18); + +// m_splitter = new QSplitter(this); +// m_splitter->setContentsMargins(0, 0, 0, 0); +// m_splitter->setFixedSize(664, 516); +// m_splitter->move(this->rect().topLeft().x() + 18, this->rect().topLeft().y() + 18); + m_resultArea = new ResultArea(this); + m_detailArea = new DetailArea(this); + + m_hlayout->addWidget(m_resultArea); + m_hlayout->addWidget(m_detailArea); + this->setLayout(m_hlayout); +// m_splitter->addWidget(m_resultArea); +// m_splitter->addWidget(m_detailArea); +// m_splitter->setOpaqueResize(false); +// QList size_list; +// size_list<<664<<0; +// m_splitter->setSizes(size_list); +// m_splitter->handle(1)->setVisible(false); //暂时禁止拖动分隔条 +} + +void SearchResultPage::initConnections() +{ + connect(this, &SearchResultPage::startSearch, m_resultArea, &ResultArea::startSearch); + connect(this, &SearchResultPage::stopSearch, m_resultArea, &ResultArea::stopSearch); +} + +void SearchResultPage::setupConnectionsForWidget(ResultWidget *widget) +{ + connect(widget, &ResultWidget::currentRowChanged, m_detailArea, &DetailArea::setWidgetInfo); + connect(widget, &ResultWidget::currentRowChanged, this, &SearchResultPage::currentRowChanged); + connect(this, &SearchResultPage::currentRowChanged, widget, &ResultWidget::clearSelectedRow); +// connect(widget, &ResultWidget::rowClicked, this, &SearchResultPage::effectiveSearch); +} diff --git a/frontend/control/stack-pages/search-page.h b/frontend/control/stack-pages/search-result-page.h similarity index 80% rename from frontend/control/stack-pages/search-page.h rename to frontend/control/stack-pages/search-result-page.h index 3c81d1a..057edcf 100644 --- a/frontend/control/stack-pages/search-page.h +++ b/frontend/control/stack-pages/search-result-page.h @@ -18,28 +18,31 @@ * Authors: zhangjiaping * */ -#ifndef SEARCHPAGE_H -#define SEARCHPAGE_H +#ifndef SEARCHRESULTPAGE_H +#define SEARCHRESULTPAGE_H #include #include "search-page-section.h" namespace Zeeker { -class SearchPage : public QWidget +class SearchResultPage : public QWidget { Q_OBJECT public: - explicit SearchPage(QWidget *parent = nullptr); - ~SearchPage() = default; + explicit SearchResultPage(QWidget *parent = nullptr); + ~SearchResultPage() = default; void setSize(const int&, const int&); - void setPlugins(const QStringList &plugins_id); + void setInternalPlugins(); void appendPlugin(const QString &plugin_id); +protected: + void paintEvent(QPaintEvent *event); private: void initUi(); void initConnections(); void setupConnectionsForWidget(ResultWidget *); QSplitter * m_splitter = nullptr; + QHBoxLayout *m_hlayout = nullptr; ResultArea * m_resultArea = nullptr; DetailArea * m_detailArea = nullptr; @@ -51,4 +54,4 @@ Q_SIGNALS: }; } -#endif // SEARCHPAGE_H +#endif // SEARCHRESULTPAGE_H diff --git a/frontend/control/stack-pages/stack-pages.pri b/frontend/control/stack-pages/stack-pages.pri index 924e1a9..9cef87c 100644 --- a/frontend/control/stack-pages/stack-pages.pri +++ b/frontend/control/stack-pages/stack-pages.pri @@ -4,10 +4,10 @@ HEADERS += \ $$PWD/home-page-section.h \ $$PWD/home-page.h \ $$PWD/search-page-section.h \ - $$PWD/search-page.h \ + $$PWD/search-result-page.h SOURCES += \ $$PWD/home-page-section.cpp \ $$PWD/home-page.cpp \ $$PWD/search-page-section.cpp \ - $$PWD/search-page.cpp \ + $$PWD/search-result-page.cpp diff --git a/frontend/control/stacked-widget.cpp b/frontend/control/stacked-widget.cpp index 32c5550..18eafab 100644 --- a/frontend/control/stacked-widget.cpp +++ b/frontend/control/stacked-widget.cpp @@ -33,10 +33,10 @@ Zeeker::StackedWidget::~StackedWidget() delete m_homePage; m_homePage = NULL; } - if (m_searchPage) { - delete m_searchPage; - m_searchPage = NULL; - } +// if (m_searchPage) { +// delete m_searchPage; +// m_searchPage = NULL; +// } } /** @@ -58,7 +58,7 @@ int StackedWidget::currentPage() */ void StackedWidget::setPlugins(const QStringList &plugins) { - m_searchPage->setPlugins(plugins); +// m_searchPage->setPlugins(plugins); } /** @@ -66,7 +66,7 @@ void StackedWidget::setPlugins(const QStringList &plugins) */ void StackedWidget::appendPlugin(const QString &plugin) { - m_searchPage->appendPlugin(plugin); +// m_searchPage->appendPlugin(plugin); } /** @@ -79,14 +79,14 @@ void StackedWidget::initWidgets() // this->insertWidget(int(StackedPage::HomePage), m_homePage); // this->setPage(int(StackedPage::HomePage)); - m_searchPage = new SearchPage; - m_searchPage->setSize(this->width(), this->height()); - this->insertWidget(int(StackedPage::SearchPage), m_searchPage); +// m_searchPage = new SearchPage; +// m_searchPage->setSize(this->width(), this->height()); +// this->insertWidget(int(StackedPage::SearchPage), m_searchPage); } void StackedWidget::initConnections() { - connect(this, &StackedWidget::startSearch, m_searchPage, &SearchPage::startSearch); - connect(this, &StackedWidget::stopSearch, m_searchPage, &SearchPage::stopSearch); - connect(m_searchPage, &SearchPage::effectiveSearch, this, &StackedWidget::effectiveSearch); +// connect(this, &StackedWidget::startSearch, m_searchPage, &SearchPage::startSearch); +// connect(this, &StackedWidget::stopSearch, m_searchPage, &SearchPage::stopSearch); +// connect(m_searchPage, &SearchPage::effectiveSearch, this, &StackedWidget::effectiveSearch); } diff --git a/frontend/control/stacked-widget.h b/frontend/control/stacked-widget.h index 4c92e84..5405092 100644 --- a/frontend/control/stacked-widget.h +++ b/frontend/control/stacked-widget.h @@ -25,7 +25,7 @@ #include #include "search-line-edit.h" #include "home-page.h" -#include "search-page.h" +#include "search-result-page.h" namespace Zeeker { @@ -50,12 +50,12 @@ Q_SIGNALS: void stopSearch(); void effectiveSearch(); -private: - void initWidgets(); +private: void initWidgets(); void initConnections(); + QString m_keyword; HomePage * m_homePage = nullptr; - SearchPage * m_searchPage = nullptr; +// SearchPage * m_searchPage = nullptr; // StackedPage m_current_page; }; } diff --git a/frontend/mainwindow.cpp b/frontend/mainwindow.cpp index e6ec422..c3620bf 100644 --- a/frontend/mainwindow.cpp +++ b/frontend/mainwindow.cpp @@ -81,7 +81,7 @@ MainWindow::MainWindow(QWidget *parent) : //NEW_TODO, register plugins // SearchPluginManager::getInstance()->registerPlugin(\\); // m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds()); - m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds()); +// m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds()); } MainWindow::~MainWindow() { @@ -111,23 +111,29 @@ MainWindow::~MainWindow() { void MainWindow::initUi() { this->setFixedSize(WINDOW_WIDTH, WINDOW_HEIGHT); - m_frame = new QFrame(this); + m_widget = new QWidget(this); - this->setCentralWidget(m_frame); - QVBoxLayout * mainlayout = new QVBoxLayout(m_frame); - mainlayout->setContentsMargins(MAIN_MARGINS); - m_frame->setLayout(mainlayout); + this->setCentralWidget(m_widget); + m_widget->setFixedSize(this->size()); +// QVBoxLayout * mainlayout = new QVBoxLayout(m_frame); +// mainlayout->setContentsMargins(MAIN_MARGINS); +// m_frame->setLayout(mainlayout); - m_stackedWidget = new StackedWidget(m_frame);//内容栏 - m_seachBarWidget = new SeachBarWidget(this); +// m_stackedWidget = new StackedWidget(m_frame);//内容栏 + m_searchBarWidget = new SeachBarWidget(m_widget); + m_searchBarWidget->move(m_widget->rect().topLeft()); + m_searchBarWidget->show(); + m_searchResultPage = new SearchResultPage(m_widget); + m_searchResultPage->move(0, 58); // m_searchWidget = new SeachBarWidget(this); // m_searchLayout = new SearchBarHLayout(this); // m_searchWidget->setLayout(m_searchLayout); // m_searchWidget->setFixedHeight(SEARCH_BAR_SIZE); // mainlayout->addWidget(m_titleFrame); - mainlayout->addWidget(m_seachBarWidget); - mainlayout->addWidget(m_stackedWidget); +// mainlayout->addWidget(m_seachBarWidget); +// mainlayout->addSpacing(8); +// mainlayout->addWidget(m_searchResultPage); //创建索引询问弹窗 m_askDialog = new CreateIndexAskDialog(this); @@ -159,7 +165,7 @@ void MainWindow::initConnections() // connect(qApp, &QApplication::paletteChanged, this, [ = ]() { // m_iconLabel->setPixmap(QIcon::fromTheme("kylin-search").pixmap(QSize(WINDOW_ICON_SIZE, WINDOW_ICON_SIZE))); // }); - connect(m_seachBarWidget, &SeachBarWidget::requestSearchKeyword, this, &MainWindow::searchKeywordSlot); + connect(m_searchBarWidget, &SeachBarWidget::requestSearchKeyword, this, &MainWindow::searchKeywordSlot); // connect(m_stackedWidget, &StackedWidget::effectiveSearch, m_searchLayout, &SearchBarHLayout::effectiveSearchRecord); } @@ -182,7 +188,7 @@ void MainWindow::bootOptionsFilter(QString opt) { * @brief clearSearchResult 清空搜索结果 */ void MainWindow::clearSearchResult() { - m_seachBarWidget->clear(); + m_searchBarWidget->clear(); // m_searchLineEdit->clearFocus(); } @@ -281,16 +287,16 @@ void MainWindow::searchKeywordSlot(const QString &keyword) { //NEW_TODO if(keyword == "") { - m_stackedWidget->setPage(int(StackedPage::HomePage)); +// m_stackedWidget->setPage(int(StackedPage::HomePage)); m_askTimer->stop(); - Q_EMIT m_stackedWidget->stopSearch(); + Q_EMIT m_searchResultPage->stopSearch(); } else { - m_stackedWidget->setPage(int(StackedPage::SearchPage)); +// m_stackedWidget->setPage(int(StackedPage::SearchPage)); QTimer::singleShot(10, this, [ = ]() { //允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索 if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH) m_askTimer->start(); - Q_EMIT m_stackedWidget->startSearch(keyword); + Q_EMIT m_searchResultPage->startSearch(keyword); }); } m_researchTimer->stop(); //如果搜索内容发生改变,则停止建索引后重新搜索的倒计时 @@ -463,7 +469,7 @@ bool MainWindow::tryHideMainwindow() this->hide(); m_askTimer->stop(); m_researchTimer->stop(); - Q_EMIT m_stackedWidget->stopSearch(); + Q_EMIT m_searchResultPage->stopSearch(); return true; } else { //有上层弹窗未关闭,不允许隐藏主界面 @@ -514,7 +520,9 @@ void MainWindow::paintEvent(QPaintEvent *event) { QPainterPath path; - path.addRoundedRect(m_seachBarWidget->x()+10, m_seachBarWidget->y()+10, m_seachBarWidget->width()-20, m_seachBarWidget->height()-20, 6, 6); + path.addRoundedRect(m_searchBarWidget->x()+10, m_searchBarWidget->y()+10, m_searchBarWidget->width()-20, m_searchBarWidget->height()-20, 6, 6); + path.addRoundedRect(m_searchResultPage->x()+10, m_searchResultPage->y()+10, m_searchResultPage->width()-20, m_searchResultPage->height()-20, 6, 6); + KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); } diff --git a/frontend/mainwindow.h b/frontend/mainwindow.h index 4456240..ed31877 100644 --- a/frontend/mainwindow.h +++ b/frontend/mainwindow.h @@ -108,16 +108,17 @@ public Q_SLOTS: private: - QFrame * m_frame = nullptr; // Main frame + QWidget *m_widget = nullptr; // central widget QFrame * m_titleFrame = nullptr; // Title bar frame QHBoxLayout * m_titleLyt = nullptr; // Title layout QLabel * m_iconLabel = nullptr; // Icon lable QLabel * m_titleLabel = nullptr; // Title lable QPushButton * m_settingsBtn = nullptr; // Menu button - StackedWidget * m_stackedWidget = nullptr; // Stacked widget +// StackedWidget * m_stackedWidget = nullptr; // Stacked widget // SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout // SeachBarWidget * m_searchWidget = nullptr; // Search bar - SeachBarWidget *m_seachBarWidget; + SeachBarWidget *m_searchBarWidget; + SearchResultPage *m_searchResultPage; #if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) SettingsWidget * m_settingsWidget = nullptr; // Settings Widget #endif diff --git a/frontend/model/search-result-manager.cpp b/frontend/model/search-result-manager.cpp index b00c7c0..d868b04 100644 --- a/frontend/model/search-result-manager.cpp +++ b/frontend/model/search-result-manager.cpp @@ -40,59 +40,6 @@ void SearchResultManager::startSearch(const QString &keyword) m_result_queue->clear(); SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_plugin_id); plugin->KeywordSearch(keyword, m_result_queue); - /*********************测试用数据*********************/ -// SearchPluginIface::ResultInfo test_info; -// if (m_plugin_id == "File") { -// test_info.icon = QIcon::fromTheme("ukui-control-center"); -// test_info.name = "搜索"; -// QVector desc; -// SearchPluginIface::DescriptionInfo desc_1; -// desc_1.key = "描述"; -// desc_1.value = "控制面板搜索插件"; -// desc.append(desc_1); -// QStringList actions; -// actions.append("打开"); -// test_info.description = desc; -// test_info.actionList = actions; -// m_result_queue->append(test_info); -// } else { -// test_info.icon = QIcon::fromTheme("unknown"); -// test_info.name = "文件12345abcde.txt"; -// QVector desc; -// SearchPluginIface::DescriptionInfo desc_1; -// SearchPluginIface::DescriptionInfo desc_2; -// desc_1.key = "描述"; -// desc_1.value = "一个文件"; -// desc_2.key = "路径"; -// desc_2.value = "一个路径/a/b/c/d/e/fffffff/文件12345abcde.txt"; -// desc.append(desc_1); -// desc.append(desc_2); -// QStringList actions; -// actions.append("打开"); -// actions.append("复制路径"); -// test_info.description = desc; -// test_info.actionList = actions; -// SearchPluginIface::ResultInfo test_info_1 = test_info; -// test_info_1.name = "文件1"; -// SearchPluginIface::ResultInfo test_info_2 = test_info; -// test_info_2.name = "文件2"; -// SearchPluginIface::ResultInfo test_info_3 = test_info; -// test_info_3.name = "文件3"; -// SearchPluginIface::ResultInfo test_info_4 = test_info; -// test_info_4.name = "文件4"; -// SearchPluginIface::ResultInfo test_info_5 = test_info; -// test_info_5.name = "文件5"; -// SearchPluginIface::ResultInfo test_info_6 = test_info; -// test_info_6.name = "文件6"; -// m_result_queue->append(test_info); -// m_result_queue->append(test_info_1); -// m_result_queue->append(test_info_2); -// m_result_queue->append(test_info_3); -// m_result_queue->append(test_info_4); -// m_result_queue->append(test_info_5); -// m_result_queue->append(test_info_6); -// } - /********************测试用数据********************/ } /** diff --git a/frontend/view/result-view.cpp b/frontend/view/result-view.cpp index 0625a3c..c883331 100644 --- a/frontend/view/result-view.cpp +++ b/frontend/view/result-view.cpp @@ -80,6 +80,7 @@ void ResultWidget::initConnections() { connect(this, &ResultWidget::startSearch, m_resultView, &ResultView::startSearch); connect(this, &ResultWidget::startSearch, this, [ = ]() { + qDebug() << "==========start search!"; m_showMoreLabel->resetLabel(); }); connect(this, &ResultWidget::stopSearch, m_resultView, &ResultView::stopSearch); @@ -240,6 +241,7 @@ void ResultView::initConnections() { // connect(this, &ResultView::startSearch, m_model, &SearchResultModel::startSearch); connect(this, &ResultView::startSearch, [ = ](const QString &keyword) { + qDebug() << "==========start search!"; m_style_delegate->setSearchKeyword(keyword); m_model->startSearch(keyword); });