Update changelog ukui-search3.1-1.1.1+0917.
This commit is contained in:
parent
a1199bd322
commit
c4a39937b7
|
@ -1,3 +1,11 @@
|
|||
ukui-search (3.1-1.1.1+0917) v101; urgency=medium
|
||||
|
||||
* Bug 81068,78036,73611,73609,73602
|
||||
* 任务号:无
|
||||
* 其他改动:无
|
||||
|
||||
-- zhangpengfei <zhangpengfei@kylinos.cn> Fri, 17 Sep 2021 11:30:30 +0800
|
||||
|
||||
ukui-search (3.1-1.1.0+0909) v101; urgency=medium
|
||||
|
||||
* Bug 77633,77578,77341,77922,77865,77655,77422,77382,77963,73760,73626
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
include(stack-pages/stack-pages.pri)
|
||||
include(flow-layout/flow-layout.pri)
|
||||
include(list-labels/list-labels.pri)
|
||||
|
||||
INCLUDEPATH += $$PWD
|
||||
|
@ -8,10 +7,8 @@ HEADERS += \
|
|||
$$PWD/search-line-edit.h \
|
||||
$$PWD/settings-widget.h \
|
||||
$$PWD/create-index-ask-dialog.h \
|
||||
$$PWD/stacked-widget.h \
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/search-line-edit.cpp \
|
||||
$$PWD/settings-widget.cpp \
|
||||
$$PWD/create-index-ask-dialog.cpp \
|
||||
$$PWD/stacked-widget.cpp \
|
||||
|
|
|
@ -1,277 +0,0 @@
|
|||
#include "home-page-section.h"
|
||||
|
||||
#define SQUARE_WIDTH 116
|
||||
#define SQUARE_HEIGHT 116
|
||||
#define SQUARE_ICON_SIZE 48
|
||||
#define SQUARE_NAME_SIZE 108
|
||||
#define BAR_WIDTH 300
|
||||
#define BAR_HEIGHT 48
|
||||
#define BAR_ICON_SIZE 24
|
||||
#define BAR_NAME_SIZE 250
|
||||
#define TITLE_HEIGHT 24
|
||||
#define MAIN_LAYOUT_SPACING 6
|
||||
#define ITEM_LAYOUT_SPACING 8
|
||||
#define ITEM_RADIUS 4
|
||||
#define ITEM_TRANS_NORMAL 0.06
|
||||
#define ITEM_TRANS_HOVER 0.15
|
||||
#define ITEM_TRANS_PRESS 0.06
|
||||
#define ITEM_MARGINS 0,0,0,0
|
||||
#define FLOW_LAYOUT_MARGIN 0
|
||||
|
||||
using namespace Zeeker;
|
||||
|
||||
HomePageSection::HomePageSection(QString title, HomePageItemShape shape, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
m_title = title;
|
||||
m_shape = shape;
|
||||
initUi();
|
||||
}
|
||||
|
||||
HomePageSection::~HomePageSection()
|
||||
{
|
||||
if (m_itemsLyt) {
|
||||
delete m_itemsLyt;
|
||||
m_itemsLyt = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HomePageSection::setItems 设置所有的项
|
||||
* @param itemList 显示的Item列表
|
||||
*/
|
||||
void HomePageSection::setItems(QVector<HomePageItem> itemList)
|
||||
{
|
||||
clear();
|
||||
if (m_shape == HomePageItemShape::Square) {
|
||||
Q_FOREACH (HomePageItem item, itemList) {
|
||||
m_itemsLyt->addWidget(createSquareItem(item));
|
||||
}
|
||||
int line_num = ceil(double(itemList.length())/5);
|
||||
this->setFixedHeight(TITLE_HEIGHT + MAIN_LAYOUT_SPACING + ITEM_LAYOUT_SPACING*(line_num-1) + SQUARE_HEIGHT*line_num);
|
||||
} else {
|
||||
Q_FOREACH (HomePageItem item, itemList) {
|
||||
m_itemsLyt->addWidget(createBarItem(item));
|
||||
}
|
||||
int line_num = ceil(double(itemList.length())/2);
|
||||
this->setFixedHeight(TITLE_HEIGHT + MAIN_LAYOUT_SPACING + ITEM_LAYOUT_SPACING*(line_num-1) + BAR_HEIGHT*line_num);
|
||||
}
|
||||
m_length = itemList.length();
|
||||
}
|
||||
|
||||
int HomePageSection::length()
|
||||
{
|
||||
return m_length;
|
||||
}
|
||||
|
||||
///**
|
||||
// * @brief HomePageSection::appendItem 添加一项
|
||||
// * @param item 要添加的item
|
||||
// */
|
||||
//void HomePageSection::appendItem(HomePageItem item)
|
||||
//{
|
||||
// if (m_shape == HomePageItemShape::Square) {
|
||||
// m_itemsLyt->addWidget(createSquareItem(item));
|
||||
// } else {
|
||||
// m_itemsLyt->addWidget(createBarItem(item));
|
||||
// }
|
||||
// m_length++;
|
||||
//}
|
||||
|
||||
//NEW_TODO
|
||||
///**
|
||||
// * @brief HomePageSection::insertItem 插入一项
|
||||
// * @param index 插入位置
|
||||
// * @param item 要插入的item
|
||||
// */
|
||||
//void HomePageSection::insertItem(const int &index, const HomePageSection::HomePageItem &item)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
///**
|
||||
// * @brief HomePageSection::removeOne 删除一项
|
||||
// * @param key HomePageSection的key,用来寻找item
|
||||
// */
|
||||
//void HomePageSection::removeOne(const QString &key)
|
||||
//{
|
||||
// Q_FOREACH (ItemWidget * item, m_itemsLyt->findChildren<ItemWidget *>()) {
|
||||
// if (item->objectName() == key) {
|
||||
// delete item;
|
||||
// item = NULL;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
/**
|
||||
* @brief HomePageSection::clear 清空
|
||||
*/
|
||||
void HomePageSection::clear()
|
||||
{
|
||||
if(! m_itemsLyt) return;
|
||||
QLayoutItem * item;
|
||||
while((item = m_itemsLyt->takeAt(0)) != 0) {
|
||||
if(item->widget()) {
|
||||
item->widget()->setParent(NULL); //防止删除后窗口看上去没有消失
|
||||
}
|
||||
delete item;
|
||||
}
|
||||
item = NULL;
|
||||
this->setFixedHeight(0);
|
||||
m_length = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HomePageSection::initUi 初始化固有控件
|
||||
*/
|
||||
void HomePageSection::initUi()
|
||||
{
|
||||
m_mainLyt = new QVBoxLayout(this);
|
||||
m_mainLyt->setContentsMargins(ITEM_MARGINS);
|
||||
this->setLayout(m_mainLyt);
|
||||
m_titleLabel = new QLabel(this);
|
||||
m_titleLabel->setFixedHeight(TITLE_HEIGHT);
|
||||
m_titleLabel->setText(m_title);
|
||||
m_itemWidget = new QWidget(this);
|
||||
m_mainLyt->setSpacing(MAIN_LAYOUT_SPACING);
|
||||
m_itemsLyt = new FlowLayout(m_itemWidget, FLOW_LAYOUT_MARGIN, ITEM_LAYOUT_SPACING, ITEM_LAYOUT_SPACING);
|
||||
m_itemWidget->setLayout(m_itemsLyt);
|
||||
m_mainLyt->addWidget(m_titleLabel);
|
||||
m_mainLyt->addWidget(m_itemWidget);
|
||||
}
|
||||
|
||||
///**
|
||||
// * @brief HomePageSection::resize 重新计算此窗口size
|
||||
// */
|
||||
//void HomePageSection::resize()
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
/**
|
||||
* @brief HomePageSection::createSquareItem 创建一个方形小窗格
|
||||
* @param item 数据
|
||||
* @return
|
||||
*/
|
||||
ItemWidget *HomePageSection::createSquareItem(const HomePageItem &item)
|
||||
{
|
||||
ItemWidget * square_item = new ItemWidget(m_itemWidget, HomePageItemShape::Square, item);
|
||||
square_item->setObjectName(item.key);
|
||||
connect(square_item, &ItemWidget::clicked, this, &HomePageSection::requestAction);
|
||||
return square_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HomePageSection::createBarItem 创建一个条状小窗格
|
||||
* @param item 数据
|
||||
* @return
|
||||
*/
|
||||
ItemWidget *HomePageSection::createBarItem(const HomePageItem &item)
|
||||
{
|
||||
ItemWidget * bar_item = new ItemWidget(m_itemWidget, HomePageItemShape::Bar, item);
|
||||
bar_item->setObjectName(item.key);
|
||||
connect(bar_item, &ItemWidget::clicked, this, &HomePageSection::requestAction);
|
||||
return bar_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ItemWidget::ItemWidget 显示在flowlayout中的每个小窗格
|
||||
* @param parent 父窗口
|
||||
* @param shape 形状
|
||||
* @param item 数据
|
||||
*/
|
||||
ItemWidget::ItemWidget(QWidget *parent, const HomePageItemShape &shape, const HomePageItem &item) : QWidget(parent) {
|
||||
this->initUi(shape, item.name, item.icon);
|
||||
m_item = item;
|
||||
this->installEventFilter(this);
|
||||
this->setToolTip(item.name);
|
||||
m_transparency = ITEM_TRANS_NORMAL;
|
||||
connect(qApp, &QApplication::paletteChanged, this, [ = ]() {
|
||||
if(m_namelabel) {
|
||||
QString name = this->toolTip();
|
||||
if(shape == HomePageItemShape::Square) {
|
||||
m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, SQUARE_NAME_SIZE));
|
||||
} else {
|
||||
m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, BAR_NAME_SIZE));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HomePageItem::setupUi 根据不同的形状创建item
|
||||
* @param shape 形状
|
||||
* @param name 名称
|
||||
* @param icon 图标
|
||||
*/
|
||||
void ItemWidget::initUi(HomePageItemShape shape, const QString& name, const QIcon& icon) {
|
||||
m_iconlabel = new QLabel(this);
|
||||
m_namelabel = new QLabel(this);
|
||||
m_iconlabel->setAlignment(Qt::AlignCenter);
|
||||
m_namelabel->setAlignment(Qt::AlignCenter);
|
||||
if (shape == HomePageItemShape::Square) {
|
||||
m_vlayout = new QVBoxLayout(this);
|
||||
this->setLayout(m_vlayout);
|
||||
m_iconlabel->setPixmap(icon.pixmap(icon.actualSize(QSize(SQUARE_ICON_SIZE, SQUARE_ICON_SIZE))));
|
||||
m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, SQUARE_NAME_SIZE));
|
||||
m_vlayout->addWidget(m_iconlabel);
|
||||
m_vlayout->addWidget(m_namelabel);
|
||||
this->setFixedSize(SQUARE_WIDTH, SQUARE_HEIGHT);
|
||||
} else {
|
||||
m_hlayout = new QHBoxLayout(this);
|
||||
this->setLayout(m_hlayout);
|
||||
m_iconlabel->setPixmap(icon.pixmap(icon.actualSize(QSize(BAR_ICON_SIZE, BAR_ICON_SIZE))));
|
||||
m_namelabel->setText(m_namelabel->fontMetrics().elidedText(name, Qt::ElideRight, BAR_NAME_SIZE));
|
||||
m_hlayout->addWidget(m_iconlabel);
|
||||
m_hlayout->addWidget(m_namelabel);
|
||||
m_hlayout->addStretch();
|
||||
this->setFixedSize(BAR_WIDTH, BAR_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ItemWidget::eventFilter 处理悬停、离开、点击的窗格样式和点击时发出的信号
|
||||
* @param watched
|
||||
* @param event
|
||||
* @return
|
||||
*/
|
||||
bool ItemWidget::eventFilter(QObject *watched, QEvent *event) {
|
||||
if(watched == this) {
|
||||
if(event->type() == QEvent::MouseButtonPress) {
|
||||
m_transparency = ITEM_TRANS_PRESS;
|
||||
this->update();
|
||||
return true;
|
||||
} else if(event->type() == QEvent::MouseButtonRelease) {
|
||||
Q_EMIT this->clicked(m_item.key, m_item.action, m_item.pluginId);
|
||||
m_transparency = ITEM_TRANS_NORMAL;
|
||||
this->update();
|
||||
return true;
|
||||
} else if(event->type() == QEvent::Enter) {
|
||||
m_transparency = ITEM_TRANS_HOVER;
|
||||
this->update();
|
||||
return true;
|
||||
} else if(event->type() == QEvent::Leave) {
|
||||
m_transparency = ITEM_TRANS_NORMAL;
|
||||
this->update();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void ItemWidget::paintEvent(QPaintEvent *event) {
|
||||
Q_UNUSED(event)
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
QRect rect = this->rect();
|
||||
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
||||
p.setBrush(opt.palette.color(QPalette::Text));
|
||||
p.setOpacity(m_transparency);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.drawRoundedRect(rect, ITEM_RADIUS, ITEM_RADIUS);
|
||||
return QWidget::paintEvent(event);
|
||||
}
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
#ifndef HOMEPAGESECTION_H
|
||||
#define HOMEPAGESECTION_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include <QStyleOption>
|
||||
#include <math.h>
|
||||
#include "flow-layout/flow-layout.h"
|
||||
|
||||
namespace Zeeker {
|
||||
|
||||
enum class HomePageItemShape {
|
||||
Square = 0,
|
||||
Bar
|
||||
};
|
||||
struct HomePageItem
|
||||
{
|
||||
QIcon icon;
|
||||
QString name;
|
||||
QString key;
|
||||
QString action;
|
||||
QString pluginId;
|
||||
};
|
||||
|
||||
class ItemWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ItemWidget(QWidget *, const HomePageItemShape &, const HomePageItem &);
|
||||
~ItemWidget() = default;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
private:
|
||||
void initUi(HomePageItemShape, const QString&, const QIcon&);
|
||||
|
||||
QHBoxLayout * m_hlayout = nullptr;
|
||||
QVBoxLayout * m_vlayout = nullptr;
|
||||
QLabel * m_iconlabel = nullptr;
|
||||
QLabel * m_namelabel = nullptr;
|
||||
double m_transparency = 0;
|
||||
HomePageItem m_item;
|
||||
|
||||
Q_SIGNALS:
|
||||
void clicked(const QString &key, const QString &action, const QString &pluginId);
|
||||
};
|
||||
|
||||
class HomePageSection : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HomePageSection(QString title, HomePageItemShape shape = HomePageItemShape::Square, QWidget *parent = nullptr);
|
||||
~HomePageSection();
|
||||
|
||||
void setItems(QVector<HomePageItem> itemList);
|
||||
int length();
|
||||
// void appendItem(HomePageItem item);
|
||||
// void insertItem(const int &index, const HomePageItem &item);
|
||||
// void removeOne(const QString &key);
|
||||
void clear();
|
||||
|
||||
Q_SIGNALS:
|
||||
//emit on HomePageItem clicked
|
||||
void requestAction(const QString &key, const QString &action, const QString &pluginId);
|
||||
|
||||
private:
|
||||
QString m_title;
|
||||
QVector<HomePageItem> m_items;
|
||||
void initUi();
|
||||
// void resize();
|
||||
QVBoxLayout * m_mainLyt = nullptr;
|
||||
QLabel * m_titleLabel = nullptr;
|
||||
QWidget *m_itemWidget = nullptr;
|
||||
FlowLayout * m_itemsLyt = nullptr;
|
||||
HomePageItemShape m_shape;
|
||||
int m_length;
|
||||
|
||||
ItemWidget* createSquareItem(const HomePageItem &item);
|
||||
ItemWidget* createBarItem(const HomePageItem &item);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // HOMEPAGESECTION_H
|
|
@ -1,139 +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 "home-page.h"
|
||||
using namespace Zeeker;
|
||||
|
||||
#define BACKGROUND_COLOR QColor(0, 0, 0, 0)
|
||||
#define MAIN_SPACING 16
|
||||
#define MAIN_MARGINS 0,0,0,0
|
||||
|
||||
HomePage::HomePage(QWidget *parent) : QScrollArea(parent)
|
||||
{
|
||||
initUi();
|
||||
registerSections();
|
||||
}
|
||||
|
||||
void HomePage::initUi()
|
||||
{
|
||||
QPalette pal = palette();
|
||||
pal.setColor(QPalette::Base, BACKGROUND_COLOR);
|
||||
pal.setColor(QPalette::Window, BACKGROUND_COLOR); //使用此palette的窗口背景将为透明
|
||||
m_widget = new QWidget(this);
|
||||
this->setWidget(m_widget);
|
||||
m_mainLyt = new QVBoxLayout(m_widget);
|
||||
m_mainLyt->setSpacing(MAIN_SPACING);
|
||||
m_mainLyt->setContentsMargins(MAIN_MARGINS);
|
||||
m_widget->setLayout(m_mainLyt);
|
||||
m_widget->setFixedWidth(this->width());
|
||||
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
this->setPalette(pal);
|
||||
this->setFrameShape(QFrame::Shape::NoFrame);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HomePage::appendSection 向homepgae添加一个版块
|
||||
* @param section
|
||||
*/
|
||||
void HomePage::appendSection(HomePageSection *section)
|
||||
{
|
||||
section->setFixedWidth(this->width());
|
||||
m_mainLyt->addWidget(section);
|
||||
if (m_widget->height()) {
|
||||
m_widget->setFixedHeight(m_widget->height() + section->height() + MAIN_SPACING);
|
||||
} else {
|
||||
m_widget->setFixedHeight(m_widget->height() + section->height());
|
||||
}
|
||||
}
|
||||
|
||||
//以下为homepage各版块的信息获取的回调
|
||||
|
||||
//NEW_TODO
|
||||
//获取快速打开应用的列表
|
||||
QVector<HomePageItem> get_quickly_cb()
|
||||
{
|
||||
QVector<HomePageItem> quickly_list;
|
||||
QStringList quicklyOpenList;
|
||||
quicklyOpenList << "/usr/share/applications/ksc-defender.desktop"
|
||||
<< "/usr/share/applications/ukui-notebook.desktop"
|
||||
<< "/usr/share/applications/eom.desktop"
|
||||
<< "/usr/share/applications/pluma.desktop"
|
||||
<< "/usr/share/applications/claws-mail.desktop" ;
|
||||
Q_FOREACH (QString path, quicklyOpenList) {
|
||||
if (QString::compare(FileUtils::getAppName(path), "Unknown App") == 0)
|
||||
continue;
|
||||
HomePageItem item;
|
||||
item.icon = FileUtils::getAppIcon(path);
|
||||
item.name = FileUtils::getAppName(path);
|
||||
item.key = path;
|
||||
item.action = "open";
|
||||
item.pluginId = "applications";
|
||||
quickly_list.append(item);
|
||||
}
|
||||
return quickly_list;
|
||||
}
|
||||
|
||||
//NEW_TODO 需要读写配置文件
|
||||
//获取最近打开的列表
|
||||
QVector<HomePageItem> get_recently_cb()
|
||||
{
|
||||
// QVector<HomePageItem> recently_list;
|
||||
// return recently_list;
|
||||
return get_quickly_cb();
|
||||
}
|
||||
|
||||
//NEW_TODO 需要读写配置文件
|
||||
//获取常用应用的列表
|
||||
QVector<HomePageItem> get_commonly_cb()
|
||||
{
|
||||
// QVector<HomePageItem> commonly_list;
|
||||
// return commonly_list;
|
||||
return get_quickly_cb();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HomePage::registerSections 在此注册所有的版块
|
||||
*/
|
||||
void HomePage::registerSections()
|
||||
{
|
||||
//快速打开
|
||||
createSection(tr("Open Quickly"), HomePageItemShape::Square, get_quickly_cb());
|
||||
//最近打开
|
||||
createSection(tr("Recently Opened"), HomePageItemShape::Bar, get_recently_cb());
|
||||
//常用应用
|
||||
createSection(tr("Commonly Used"), HomePageItemShape::Square, get_commonly_cb());
|
||||
}
|
||||
|
||||
void HomePage::createSection(const QString §ion_name, const HomePageItemShape &shape, QVector<HomePageItem> items)
|
||||
{
|
||||
HomePageSection *section = new HomePageSection(section_name, shape, m_widget);
|
||||
section->setItems(items);
|
||||
if (section->length())
|
||||
this->appendSection(section);
|
||||
connect(section, &HomePageSection::requestAction, this, [ = ](const QString &key, const QString &action, const QString &pluginId) {
|
||||
SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(pluginId);
|
||||
// if (plugin) {
|
||||
// plugin->openAction(action, key);
|
||||
// } else {
|
||||
// qWarning()<<"Get plugin failed!";
|
||||
// }
|
||||
});
|
||||
}
|
|
@ -1,50 +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>
|
||||
*
|
||||
*/
|
||||
#ifndef HOMEPAGE_H
|
||||
#define HOMEPAGE_H
|
||||
|
||||
#include <QScrollArea>
|
||||
#include "home-page-section.h"
|
||||
#include "file-utils.h"
|
||||
#include "pluginmanage/search-plugin-manager.h"
|
||||
|
||||
namespace Zeeker {
|
||||
class HomePage : public QScrollArea
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HomePage(QWidget *parent = nullptr);
|
||||
~HomePage() = default;
|
||||
|
||||
private:
|
||||
void initUi();
|
||||
void appendSection(HomePageSection *);
|
||||
QWidget * m_widget = nullptr;
|
||||
QVBoxLayout * m_mainLyt = nullptr;
|
||||
|
||||
void registerSections();
|
||||
void createSection(const QString &, const HomePageItemShape &, QVector<HomePageItem>);
|
||||
Q_SIGNALS:
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // HOMEPAGE_H
|
|
@ -1,13 +1,9 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/home-page-section.h \
|
||||
$$PWD/home-page.h \
|
||||
$$PWD/search-page-section.h \
|
||||
$$PWD/search-result-page.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/home-page-section.cpp \
|
||||
$$PWD/home-page.cpp \
|
||||
$$PWD/search-page-section.cpp \
|
||||
$$PWD/search-result-page.cpp
|
||||
|
|
|
@ -1,92 +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 "stacked-widget.h"
|
||||
|
||||
using namespace Zeeker;
|
||||
Zeeker::StackedWidget::StackedWidget(QWidget *)
|
||||
{
|
||||
this->initWidgets();
|
||||
this->initConnections();
|
||||
}
|
||||
|
||||
Zeeker::StackedWidget::~StackedWidget()
|
||||
{
|
||||
if (m_homePage) {
|
||||
delete m_homePage;
|
||||
m_homePage = NULL;
|
||||
}
|
||||
// if (m_searchPage) {
|
||||
// delete m_searchPage;
|
||||
// m_searchPage = NULL;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief StackedWidget::setPage 设置StackedWidget所显示页面
|
||||
* @param type 页面类型
|
||||
*/
|
||||
void StackedWidget::setPage(const int & type)
|
||||
{
|
||||
this->setCurrentIndex(type);
|
||||
}
|
||||
|
||||
int StackedWidget::currentPage()
|
||||
{
|
||||
return this->currentIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief StackedWidget::setPlugins 设置所有插件
|
||||
*/
|
||||
void StackedWidget::setPlugins(const QStringList &plugins)
|
||||
{
|
||||
// m_searchPage->setPlugins(plugins);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief StackedWidget::addPlugin 添加一个插件
|
||||
*/
|
||||
void StackedWidget::appendPlugin(const QString &plugin)
|
||||
{
|
||||
// m_searchPage->appendPlugin(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief StackedWidget::initWidgets 初始化向stackedwidget添加窗口
|
||||
*/
|
||||
void StackedWidget::initWidgets()
|
||||
{
|
||||
//NEW_TODO
|
||||
// m_homePage = new HomePage;
|
||||
// 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
|
@ -1,63 +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>
|
||||
*
|
||||
*/
|
||||
#ifndef STACKEDWIDGET_H
|
||||
#define STACKEDWIDGET_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QStackedWidget>
|
||||
#include "search-line-edit.h"
|
||||
#include "home-page.h"
|
||||
#include "search-result-page.h"
|
||||
|
||||
namespace Zeeker {
|
||||
|
||||
enum class StackedPage {
|
||||
HomePage = 0,
|
||||
SearchPage
|
||||
};
|
||||
|
||||
class StackedWidget : public QStackedWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
StackedWidget(QWidget *);
|
||||
~StackedWidget();
|
||||
|
||||
void setPage(const int &);
|
||||
int currentPage();
|
||||
void setPlugins(const QStringList&);
|
||||
void appendPlugin(const QString&);
|
||||
|
||||
Q_SIGNALS:
|
||||
void startSearch(const QString &);
|
||||
void stopSearch();
|
||||
void effectiveSearch();
|
||||
|
||||
private: void initWidgets();
|
||||
void initConnections();
|
||||
|
||||
QString m_keyword;
|
||||
HomePage * m_homePage = nullptr;
|
||||
// SearchPage * m_searchPage = nullptr;
|
||||
// StackedPage m_current_page;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // STACKEDWIDGET_H
|
Loading…
Reference in New Issue