Update UI.
This commit is contained in:
parent
fa20094e04
commit
323fc1bdab
|
@ -91,9 +91,10 @@ void SearchLineEdit::paintEvent(QPaintEvent *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
SeachBarWidget::SeachBarWidget(QWidget *parent): QWidget(parent) {
|
SeachBarWidget::SeachBarWidget(QWidget *parent): QWidget(parent) {
|
||||||
this->setFixedSize(700, 70);
|
|
||||||
m_ly = new QHBoxLayout(this);
|
m_ly = new QHBoxLayout(this);
|
||||||
m_searchLineEdit = new SearchLineEdit(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);
|
m_ly->addWidget(m_searchLineEdit);
|
||||||
connect(m_searchLineEdit, &SearchLineEdit::requestSearchKeyword, this, &SeachBarWidget::requestSearchKeyword);
|
connect(m_searchLineEdit, &SearchLineEdit::requestSearchKeyword, this, &SeachBarWidget::requestSearchKeyword);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,7 @@ void SeachBarWidget::paintEvent(QPaintEvent *e)
|
||||||
pixmap.fill(Qt::transparent);
|
pixmap.fill(Qt::transparent);
|
||||||
QPainter pixmapPainter(&pixmap);
|
QPainter pixmapPainter(&pixmap);
|
||||||
pixmapPainter.setRenderHint(QPainter::Antialiasing);
|
pixmapPainter.setRenderHint(QPainter::Antialiasing);
|
||||||
// pixmapPainter.setCompositionMode(QPainter::CompositionMode_Difference);
|
// pixmapPainter.setCompositionMode(QPainter::CompositionMode_Difference);
|
||||||
pixmapPainter.setPen(Qt::transparent);
|
pixmapPainter.setPen(Qt::transparent);
|
||||||
pixmapPainter.setBrush(Qt::black);
|
pixmapPainter.setBrush(Qt::black);
|
||||||
pixmapPainter.setOpacity(0.65);
|
pixmapPainter.setOpacity(0.65);
|
||||||
|
|
|
@ -99,6 +99,9 @@ void ResultArea::initUi()
|
||||||
void ResultArea::setupConnectionsForWidget(ResultWidget *widget)
|
void ResultArea::setupConnectionsForWidget(ResultWidget *widget)
|
||||||
{
|
{
|
||||||
connect(this, &ResultArea::startSearch, widget, &ResultWidget::startSearch);
|
connect(this, &ResultArea::startSearch, widget, &ResultWidget::startSearch);
|
||||||
|
connect(this, &ResultArea::startSearch, [=](){
|
||||||
|
});
|
||||||
|
|
||||||
connect(this, &ResultArea::stopSearch, widget, &ResultWidget::stopSearch);
|
connect(this, &ResultArea::stopSearch, widget, &ResultWidget::stopSearch);
|
||||||
connect(widget, &ResultWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged);
|
connect(widget, &ResultWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged);
|
||||||
}
|
}
|
||||||
|
@ -121,6 +124,7 @@ void DetailArea::initUi()
|
||||||
this->setWidgetResizable(true);
|
this->setWidgetResizable(true);
|
||||||
m_detailWidget = new DetailWidget(this);
|
m_detailWidget = new DetailWidget(this);
|
||||||
this->setWidget(m_detailWidget);
|
this->setWidget(m_detailWidget);
|
||||||
|
this->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
DetailWidget::DetailWidget(QWidget *parent) : QWidget(parent)
|
DetailWidget::DetailWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
@ -192,6 +196,7 @@ void DetailWidget::clear()
|
||||||
|
|
||||||
void DetailWidget::initUi()
|
void DetailWidget::initUi()
|
||||||
{
|
{
|
||||||
|
this->setFixedSize(368, 516);
|
||||||
m_mainLyt = new QVBoxLayout(this);
|
m_mainLyt = new QVBoxLayout(this);
|
||||||
this->setLayout(m_mainLyt);
|
this->setLayout(m_mainLyt);
|
||||||
m_mainLyt->setContentsMargins(DETAIL_WIDGET_MARGINS);
|
m_mainLyt->setContentsMargins(DETAIL_WIDGET_MARGINS);
|
||||||
|
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* Authors: zhangjiaping <zhangjiaping@kylinos.cn>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#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<int> size_list;
|
|
||||||
size_list<<RESULT_WIDTH<<DETAIL_WIDTH;
|
|
||||||
m_splitter->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);
|
|
||||||
}
|
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* Authors: zhangjiaping <zhangjiaping@kylinos.cn>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#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<int> 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);
|
||||||
|
}
|
|
@ -18,28 +18,31 @@
|
||||||
* Authors: zhangjiaping <zhangjiaping@kylinos.cn>
|
* Authors: zhangjiaping <zhangjiaping@kylinos.cn>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef SEARCHPAGE_H
|
#ifndef SEARCHRESULTPAGE_H
|
||||||
#define SEARCHPAGE_H
|
#define SEARCHRESULTPAGE_H
|
||||||
|
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include "search-page-section.h"
|
#include "search-page-section.h"
|
||||||
|
|
||||||
namespace Zeeker {
|
namespace Zeeker {
|
||||||
class SearchPage : public QWidget
|
class SearchResultPage : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SearchPage(QWidget *parent = nullptr);
|
explicit SearchResultPage(QWidget *parent = nullptr);
|
||||||
~SearchPage() = default;
|
~SearchResultPage() = default;
|
||||||
void setSize(const int&, const int&);
|
void setSize(const int&, const int&);
|
||||||
void setPlugins(const QStringList &plugins_id);
|
void setInternalPlugins();
|
||||||
void appendPlugin(const QString &plugin_id);
|
void appendPlugin(const QString &plugin_id);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
private:
|
private:
|
||||||
void initUi();
|
void initUi();
|
||||||
void initConnections();
|
void initConnections();
|
||||||
void setupConnectionsForWidget(ResultWidget *);
|
void setupConnectionsForWidget(ResultWidget *);
|
||||||
QSplitter * m_splitter = nullptr;
|
QSplitter * m_splitter = nullptr;
|
||||||
|
QHBoxLayout *m_hlayout = nullptr;
|
||||||
ResultArea * m_resultArea = nullptr;
|
ResultArea * m_resultArea = nullptr;
|
||||||
DetailArea * m_detailArea = nullptr;
|
DetailArea * m_detailArea = nullptr;
|
||||||
|
|
||||||
|
@ -51,4 +54,4 @@ Q_SIGNALS:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SEARCHPAGE_H
|
#endif // SEARCHRESULTPAGE_H
|
|
@ -4,10 +4,10 @@ HEADERS += \
|
||||||
$$PWD/home-page-section.h \
|
$$PWD/home-page-section.h \
|
||||||
$$PWD/home-page.h \
|
$$PWD/home-page.h \
|
||||||
$$PWD/search-page-section.h \
|
$$PWD/search-page-section.h \
|
||||||
$$PWD/search-page.h \
|
$$PWD/search-result-page.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/home-page-section.cpp \
|
$$PWD/home-page-section.cpp \
|
||||||
$$PWD/home-page.cpp \
|
$$PWD/home-page.cpp \
|
||||||
$$PWD/search-page-section.cpp \
|
$$PWD/search-page-section.cpp \
|
||||||
$$PWD/search-page.cpp \
|
$$PWD/search-result-page.cpp
|
||||||
|
|
|
@ -33,10 +33,10 @@ Zeeker::StackedWidget::~StackedWidget()
|
||||||
delete m_homePage;
|
delete m_homePage;
|
||||||
m_homePage = NULL;
|
m_homePage = NULL;
|
||||||
}
|
}
|
||||||
if (m_searchPage) {
|
// if (m_searchPage) {
|
||||||
delete m_searchPage;
|
// delete m_searchPage;
|
||||||
m_searchPage = NULL;
|
// m_searchPage = NULL;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +58,7 @@ int StackedWidget::currentPage()
|
||||||
*/
|
*/
|
||||||
void StackedWidget::setPlugins(const QStringList &plugins)
|
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)
|
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->insertWidget(int(StackedPage::HomePage), m_homePage);
|
||||||
// this->setPage(int(StackedPage::HomePage));
|
// this->setPage(int(StackedPage::HomePage));
|
||||||
|
|
||||||
m_searchPage = new SearchPage;
|
// m_searchPage = new SearchPage;
|
||||||
m_searchPage->setSize(this->width(), this->height());
|
// m_searchPage->setSize(this->width(), this->height());
|
||||||
this->insertWidget(int(StackedPage::SearchPage), m_searchPage);
|
// this->insertWidget(int(StackedPage::SearchPage), m_searchPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StackedWidget::initConnections()
|
void StackedWidget::initConnections()
|
||||||
{
|
{
|
||||||
connect(this, &StackedWidget::startSearch, m_searchPage, &SearchPage::startSearch);
|
// connect(this, &StackedWidget::startSearch, m_searchPage, &SearchPage::startSearch);
|
||||||
connect(this, &StackedWidget::stopSearch, m_searchPage, &SearchPage::stopSearch);
|
// connect(this, &StackedWidget::stopSearch, m_searchPage, &SearchPage::stopSearch);
|
||||||
connect(m_searchPage, &SearchPage::effectiveSearch, this, &StackedWidget::effectiveSearch);
|
// connect(m_searchPage, &SearchPage::effectiveSearch, this, &StackedWidget::effectiveSearch);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include "search-line-edit.h"
|
#include "search-line-edit.h"
|
||||||
#include "home-page.h"
|
#include "home-page.h"
|
||||||
#include "search-page.h"
|
#include "search-result-page.h"
|
||||||
|
|
||||||
namespace Zeeker {
|
namespace Zeeker {
|
||||||
|
|
||||||
|
@ -50,12 +50,12 @@ Q_SIGNALS:
|
||||||
void stopSearch();
|
void stopSearch();
|
||||||
void effectiveSearch();
|
void effectiveSearch();
|
||||||
|
|
||||||
private:
|
private: void initWidgets();
|
||||||
void initWidgets();
|
|
||||||
void initConnections();
|
void initConnections();
|
||||||
|
|
||||||
QString m_keyword;
|
QString m_keyword;
|
||||||
HomePage * m_homePage = nullptr;
|
HomePage * m_homePage = nullptr;
|
||||||
SearchPage * m_searchPage = nullptr;
|
// SearchPage * m_searchPage = nullptr;
|
||||||
// StackedPage m_current_page;
|
// StackedPage m_current_page;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
//NEW_TODO, register plugins
|
//NEW_TODO, register plugins
|
||||||
// SearchPluginManager::getInstance()->registerPlugin(\\);
|
// SearchPluginManager::getInstance()->registerPlugin(\\);
|
||||||
// m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds());
|
// m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds());
|
||||||
m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds());
|
// m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
|
@ -111,23 +111,29 @@ MainWindow::~MainWindow() {
|
||||||
void MainWindow::initUi() {
|
void MainWindow::initUi() {
|
||||||
this->setFixedSize(WINDOW_WIDTH, WINDOW_HEIGHT);
|
this->setFixedSize(WINDOW_WIDTH, WINDOW_HEIGHT);
|
||||||
|
|
||||||
m_frame = new QFrame(this);
|
m_widget = new QWidget(this);
|
||||||
|
|
||||||
this->setCentralWidget(m_frame);
|
this->setCentralWidget(m_widget);
|
||||||
QVBoxLayout * mainlayout = new QVBoxLayout(m_frame);
|
m_widget->setFixedSize(this->size());
|
||||||
mainlayout->setContentsMargins(MAIN_MARGINS);
|
// QVBoxLayout * mainlayout = new QVBoxLayout(m_frame);
|
||||||
m_frame->setLayout(mainlayout);
|
// mainlayout->setContentsMargins(MAIN_MARGINS);
|
||||||
|
// m_frame->setLayout(mainlayout);
|
||||||
|
|
||||||
m_stackedWidget = new StackedWidget(m_frame);//内容栏
|
// m_stackedWidget = new StackedWidget(m_frame);//内容栏
|
||||||
m_seachBarWidget = new SeachBarWidget(this);
|
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_searchWidget = new SeachBarWidget(this);
|
||||||
// m_searchLayout = new SearchBarHLayout(this);
|
// m_searchLayout = new SearchBarHLayout(this);
|
||||||
// m_searchWidget->setLayout(m_searchLayout);
|
// m_searchWidget->setLayout(m_searchLayout);
|
||||||
// m_searchWidget->setFixedHeight(SEARCH_BAR_SIZE);
|
// m_searchWidget->setFixedHeight(SEARCH_BAR_SIZE);
|
||||||
|
|
||||||
// mainlayout->addWidget(m_titleFrame);
|
// mainlayout->addWidget(m_titleFrame);
|
||||||
mainlayout->addWidget(m_seachBarWidget);
|
// mainlayout->addWidget(m_seachBarWidget);
|
||||||
mainlayout->addWidget(m_stackedWidget);
|
// mainlayout->addSpacing(8);
|
||||||
|
// mainlayout->addWidget(m_searchResultPage);
|
||||||
|
|
||||||
//创建索引询问弹窗
|
//创建索引询问弹窗
|
||||||
m_askDialog = new CreateIndexAskDialog(this);
|
m_askDialog = new CreateIndexAskDialog(this);
|
||||||
|
@ -159,7 +165,7 @@ void MainWindow::initConnections()
|
||||||
// connect(qApp, &QApplication::paletteChanged, this, [ = ]() {
|
// connect(qApp, &QApplication::paletteChanged, this, [ = ]() {
|
||||||
// m_iconLabel->setPixmap(QIcon::fromTheme("kylin-search").pixmap(QSize(WINDOW_ICON_SIZE, WINDOW_ICON_SIZE)));
|
// 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);
|
// connect(m_stackedWidget, &StackedWidget::effectiveSearch, m_searchLayout, &SearchBarHLayout::effectiveSearchRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +188,7 @@ void MainWindow::bootOptionsFilter(QString opt) {
|
||||||
* @brief clearSearchResult 清空搜索结果
|
* @brief clearSearchResult 清空搜索结果
|
||||||
*/
|
*/
|
||||||
void MainWindow::clearSearchResult() {
|
void MainWindow::clearSearchResult() {
|
||||||
m_seachBarWidget->clear();
|
m_searchBarWidget->clear();
|
||||||
// m_searchLineEdit->clearFocus();
|
// m_searchLineEdit->clearFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,16 +287,16 @@ void MainWindow::searchKeywordSlot(const QString &keyword)
|
||||||
{
|
{
|
||||||
//NEW_TODO
|
//NEW_TODO
|
||||||
if(keyword == "") {
|
if(keyword == "") {
|
||||||
m_stackedWidget->setPage(int(StackedPage::HomePage));
|
// m_stackedWidget->setPage(int(StackedPage::HomePage));
|
||||||
m_askTimer->stop();
|
m_askTimer->stop();
|
||||||
Q_EMIT m_stackedWidget->stopSearch();
|
Q_EMIT m_searchResultPage->stopSearch();
|
||||||
} else {
|
} else {
|
||||||
m_stackedWidget->setPage(int(StackedPage::SearchPage));
|
// m_stackedWidget->setPage(int(StackedPage::SearchPage));
|
||||||
QTimer::singleShot(10, this, [ = ]() {
|
QTimer::singleShot(10, this, [ = ]() {
|
||||||
//允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索
|
//允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索
|
||||||
if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH)
|
if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH)
|
||||||
m_askTimer->start();
|
m_askTimer->start();
|
||||||
Q_EMIT m_stackedWidget->startSearch(keyword);
|
Q_EMIT m_searchResultPage->startSearch(keyword);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
m_researchTimer->stop(); //如果搜索内容发生改变,则停止建索引后重新搜索的倒计时
|
m_researchTimer->stop(); //如果搜索内容发生改变,则停止建索引后重新搜索的倒计时
|
||||||
|
@ -463,7 +469,7 @@ bool MainWindow::tryHideMainwindow()
|
||||||
this->hide();
|
this->hide();
|
||||||
m_askTimer->stop();
|
m_askTimer->stop();
|
||||||
m_researchTimer->stop();
|
m_researchTimer->stop();
|
||||||
Q_EMIT m_stackedWidget->stopSearch();
|
Q_EMIT m_searchResultPage->stopSearch();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
//有上层弹窗未关闭,不允许隐藏主界面
|
//有上层弹窗未关闭,不允许隐藏主界面
|
||||||
|
@ -514,7 +520,9 @@ void MainWindow::paintEvent(QPaintEvent *event) {
|
||||||
|
|
||||||
QPainterPath path;
|
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()));
|
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,16 +108,17 @@ public Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QFrame * m_frame = nullptr; // Main frame
|
QWidget *m_widget = nullptr; // central widget
|
||||||
QFrame * m_titleFrame = nullptr; // Title bar frame
|
QFrame * m_titleFrame = nullptr; // Title bar frame
|
||||||
QHBoxLayout * m_titleLyt = nullptr; // Title layout
|
QHBoxLayout * m_titleLyt = nullptr; // Title layout
|
||||||
QLabel * m_iconLabel = nullptr; // Icon lable
|
QLabel * m_iconLabel = nullptr; // Icon lable
|
||||||
QLabel * m_titleLabel = nullptr; // Title lable
|
QLabel * m_titleLabel = nullptr; // Title lable
|
||||||
QPushButton * m_settingsBtn = nullptr; // Menu button
|
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
|
// SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout
|
||||||
// SeachBarWidget * m_searchWidget = nullptr; // Search bar
|
// SeachBarWidget * m_searchWidget = nullptr; // Search bar
|
||||||
SeachBarWidget *m_seachBarWidget;
|
SeachBarWidget *m_searchBarWidget;
|
||||||
|
SearchResultPage *m_searchResultPage;
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
|
||||||
SettingsWidget * m_settingsWidget = nullptr; // Settings Widget
|
SettingsWidget * m_settingsWidget = nullptr; // Settings Widget
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,59 +40,6 @@ void SearchResultManager::startSearch(const QString &keyword)
|
||||||
m_result_queue->clear();
|
m_result_queue->clear();
|
||||||
SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_plugin_id);
|
SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_plugin_id);
|
||||||
plugin->KeywordSearch(keyword, m_result_queue);
|
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<SearchPluginIface::DescriptionInfo> 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<SearchPluginIface::DescriptionInfo> 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);
|
|
||||||
// }
|
|
||||||
/********************测试用数据********************/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -80,6 +80,7 @@ void ResultWidget::initConnections()
|
||||||
{
|
{
|
||||||
connect(this, &ResultWidget::startSearch, m_resultView, &ResultView::startSearch);
|
connect(this, &ResultWidget::startSearch, m_resultView, &ResultView::startSearch);
|
||||||
connect(this, &ResultWidget::startSearch, this, [ = ]() {
|
connect(this, &ResultWidget::startSearch, this, [ = ]() {
|
||||||
|
qDebug() << "==========start search!";
|
||||||
m_showMoreLabel->resetLabel();
|
m_showMoreLabel->resetLabel();
|
||||||
});
|
});
|
||||||
connect(this, &ResultWidget::stopSearch, m_resultView, &ResultView::stopSearch);
|
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, m_model, &SearchResultModel::startSearch);
|
||||||
connect(this, &ResultView::startSearch, [ = ](const QString &keyword) {
|
connect(this, &ResultView::startSearch, [ = ](const QString &keyword) {
|
||||||
|
qDebug() << "==========start search!";
|
||||||
m_style_delegate->setSearchKeyword(keyword);
|
m_style_delegate->setSearchKeyword(keyword);
|
||||||
m_model->startSearch(keyword);
|
m_model->startSearch(keyword);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue