2021-05-22 21:29:43 +08:00
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* 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-section.h"
|
|
|
|
|
#include <QDebug>
|
2021-07-31 16:12:04 +08:00
|
|
|
|
#include <QScrollBar>
|
2021-12-14 14:43:35 +08:00
|
|
|
|
using namespace UkuiSearch;
|
2021-05-22 21:29:43 +08:00
|
|
|
|
|
|
|
|
|
#define RESULT_LAYOUT_MARGINS 0,0,0,0
|
|
|
|
|
#define RESULT_BACKGROUND_COLOR QColor(0, 0, 0, 0)
|
|
|
|
|
#define DETAIL_BACKGROUND_COLOR QColor(0, 0, 0, 0)
|
|
|
|
|
#define DETAIL_WIDGET_TRANSPARENT 0.04
|
2021-07-08 18:53:16 +08:00
|
|
|
|
#define DETAIL_WIDGET_MARGINS 8,0,8,0
|
|
|
|
|
#define DETAIL_FRAME_MARGINS 8,0,0,0
|
2021-05-22 21:29:43 +08:00
|
|
|
|
#define DETAIL_ICON_HEIGHT 120
|
|
|
|
|
#define NAME_LABEL_WIDTH 280
|
2021-07-08 18:53:16 +08:00
|
|
|
|
#define ICON_SIZE QSize(120, 120)
|
2021-05-22 21:29:43 +08:00
|
|
|
|
#define LINE_STYLE "QFrame{background: rgba(0,0,0,0.2);}"
|
2021-05-25 19:42:40 +08:00
|
|
|
|
#define ACTION_NORMAL_COLOR QColor(55, 144, 250, 255)
|
|
|
|
|
#define ACTION_HOVER_COLOR QColor(64, 169, 251, 255)
|
|
|
|
|
#define ACTION_PRESS_COLOR QColor(41, 108, 217, 255)
|
2021-08-24 17:10:28 +08:00
|
|
|
|
#define TITLE_HEIGHT 30
|
2021-10-20 16:30:20 +08:00
|
|
|
|
#define FRAME_HEIGHT 516
|
|
|
|
|
#define DETAIL_FRAME_WIDTH 376
|
2021-05-22 21:29:43 +08:00
|
|
|
|
|
|
|
|
|
ResultArea::ResultArea(QWidget *parent) : QScrollArea(parent)
|
|
|
|
|
{
|
|
|
|
|
qRegisterMetaType<SearchPluginIface::ResultInfo>("SearchPluginIface::ResultInfo");
|
2021-09-27 17:25:06 +08:00
|
|
|
|
this->viewport()->setAttribute(Qt::WA_AcceptTouchEvents);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
initUi();
|
2021-08-02 13:46:59 +08:00
|
|
|
|
initConnections();
|
2021-05-22 21:29:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResultArea::appendWidet(ResultWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
m_mainLyt->addWidget(widget);
|
|
|
|
|
setupConnectionsForWidget(widget);
|
2021-08-12 14:57:25 +08:00
|
|
|
|
widget->clearResult();
|
2021-05-27 10:25:15 +08:00
|
|
|
|
m_widget_list.append(widget);
|
|
|
|
|
int spacing_height = m_widget_list.length() > 1 ? m_mainLyt->spacing() : 0;
|
|
|
|
|
m_widget->setFixedHeight(m_widget->height() + widget->height() + spacing_height);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 10:17:36 +08:00
|
|
|
|
void ResultArea::insertWidget(ResultWidget *widget, int index)
|
|
|
|
|
{
|
|
|
|
|
m_mainLyt->insertWidget(index, widget);
|
|
|
|
|
setupConnectionsForWidget(widget);
|
|
|
|
|
widget->clearResult();
|
|
|
|
|
m_widget_list.insert(index, widget);
|
|
|
|
|
qDebug() << "========insert widget:" << widget->pluginId() << index;
|
|
|
|
|
int spacing_height = m_widget_list.length() > 1 ? m_mainLyt->spacing() : 0;
|
|
|
|
|
m_widget->setFixedHeight(m_widget->height() + widget->height() + spacing_height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ResultArea::removeWidget(const QString &pluginName)
|
|
|
|
|
{
|
|
|
|
|
int height = 0;
|
|
|
|
|
bool res(false);
|
|
|
|
|
for (ResultWidget *myWidget : m_widget_list) {
|
|
|
|
|
if (myWidget->pluginId() == pluginName) {
|
|
|
|
|
height = myWidget->height();
|
|
|
|
|
myWidget->disconnect();
|
|
|
|
|
myWidget->clearResult();
|
|
|
|
|
m_mainLyt->removeWidget(myWidget);
|
|
|
|
|
m_widget_list.removeAll(myWidget);
|
|
|
|
|
res = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (res) {
|
|
|
|
|
int spacing_height = m_widget_list.length() > 0 ? m_mainLyt->spacing() : 0;
|
|
|
|
|
m_widget->setFixedHeight(m_widget->height() - (height + spacing_height));
|
|
|
|
|
qDebug() << "Remove Widget " << pluginName;
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ResultArea::moveWidget(const QString& pluginName, int index)
|
|
|
|
|
{
|
|
|
|
|
for (ResultWidget *myWidget : m_widget_list) {
|
|
|
|
|
if (myWidget->pluginId() == pluginName) {
|
|
|
|
|
m_mainLyt->removeWidget(myWidget);
|
|
|
|
|
m_mainLyt->insertWidget(index, myWidget);//第一个插件固定为bestlist
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-22 21:29:43 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief ResultArea::setVisibleList 设置哪些插件可见,默认全部可见
|
|
|
|
|
* @param list
|
|
|
|
|
*/
|
|
|
|
|
void ResultArea::setVisibleList(const QStringList &list)
|
|
|
|
|
{
|
|
|
|
|
Q_FOREACH (auto widget, m_widget_list) {
|
|
|
|
|
if (list.contains(widget->pluginId())) {
|
|
|
|
|
widget->setEnabled(true);
|
|
|
|
|
} else {
|
|
|
|
|
widget->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-18 14:23:14 +08:00
|
|
|
|
void ResultArea::pressEnter()
|
|
|
|
|
{
|
|
|
|
|
if (false == m_is_selected) {//未选中时默认选取bestlist第一项
|
|
|
|
|
int resultNum = m_bestListWidget->getResultNum();
|
2021-09-24 15:35:47 +08:00
|
|
|
|
if (0 == resultNum) {//无搜索结果时默认选中websearch
|
2021-10-27 11:37:55 +08:00
|
|
|
|
for (ResultWidget * i : m_widget_list) {
|
|
|
|
|
if (m_selectedPluginID == m_widget_list.back()->pluginId()) {
|
|
|
|
|
QModelIndex index = i->getModlIndex(0, 0);
|
|
|
|
|
i->setResultSelection(index);
|
|
|
|
|
m_selectedPluginID = i->pluginId();
|
|
|
|
|
m_is_selected = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-18 14:23:14 +08:00
|
|
|
|
} else {//选取bestlist第一项
|
|
|
|
|
QModelIndex index = m_bestListWidget->getModlIndex(0, 0);
|
|
|
|
|
m_bestListWidget->setResultSelection(index);
|
|
|
|
|
m_selectedPluginID = m_bestListWidget->getWidgetName();
|
|
|
|
|
m_is_selected = true;
|
|
|
|
|
}
|
|
|
|
|
} else {//选中状态时默认启动action首项
|
2021-10-27 11:37:55 +08:00
|
|
|
|
//先判断详情页是否打开
|
|
|
|
|
if (m_detail_open_state) {
|
|
|
|
|
if (m_selectedPluginID == m_bestListWidget->getWidgetName()) {//最佳匹配
|
|
|
|
|
m_bestListWidget->activateIndex();
|
|
|
|
|
} else {
|
|
|
|
|
for (ResultWidget * i : m_widget_list) {
|
|
|
|
|
if (m_selectedPluginID == i->pluginId()) {
|
|
|
|
|
i->activateIndex();
|
|
|
|
|
break;
|
2021-08-18 14:23:14 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-27 11:37:55 +08:00
|
|
|
|
} else {//打开详情页
|
|
|
|
|
m_detail_open_state = true;
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
2021-08-18 14:23:14 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResultArea::pressDown()
|
|
|
|
|
{
|
2021-10-27 11:37:55 +08:00
|
|
|
|
if (m_selectedPluginID == m_widget_list.back()->pluginId()) {//当前为web search,暂不处理
|
2021-08-18 14:23:14 +08:00
|
|
|
|
return;
|
|
|
|
|
} else if (m_selectedPluginID == m_bestListWidget->getWidgetName()) {
|
|
|
|
|
QModelIndex index = m_bestListWidget->getCurrentSelection();
|
|
|
|
|
int maxNum = m_bestListWidget->getExpandState() ?
|
|
|
|
|
m_bestListWidget->getResultNum() : (m_bestListWidget->getResultNum() < NUM_LIMIT_SHOWN_DEFAULT ?
|
|
|
|
|
m_bestListWidget->getResultNum() : NUM_LIMIT_SHOWN_DEFAULT);
|
|
|
|
|
if (index.row() < maxNum - 1 and index.row() >= 0) {
|
|
|
|
|
int row = index.row();
|
|
|
|
|
QModelIndex setIndex = m_bestListWidget->getModlIndex(++row, 0);
|
|
|
|
|
m_bestListWidget->setResultSelection(setIndex);
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
2021-08-24 17:10:28 +08:00
|
|
|
|
} else if (index.row() >= maxNum - 1 or index.row() < 0) {//跳转下一个widget
|
2021-08-18 14:23:14 +08:00
|
|
|
|
m_bestListWidget->clearResultSelection();
|
|
|
|
|
for (ResultWidget * plugin : m_widget_list) {
|
|
|
|
|
if (plugin->getResultNum() != 0) {
|
|
|
|
|
QModelIndex resultIndex = plugin->getModlIndex(0, 0);
|
|
|
|
|
plugin->setResultSelection(resultIndex);
|
|
|
|
|
m_selectedPluginID = plugin->pluginId();
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
qWarning() << "QModelIndex error ! row:" << index.row() << "maxNum:" << maxNum;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (ResultWidget * plugin : m_widget_list) {
|
|
|
|
|
if (m_selectedPluginID == plugin->pluginId()) {
|
|
|
|
|
QModelIndex index = plugin->getCurrentSelection();
|
|
|
|
|
int maxNum = plugin->getExpandState() ?
|
|
|
|
|
plugin->getResultNum() : (plugin->getResultNum() < NUM_LIMIT_SHOWN_DEFAULT ?
|
|
|
|
|
plugin->getResultNum() : NUM_LIMIT_SHOWN_DEFAULT);
|
|
|
|
|
if (index.row() < maxNum - 1 and index.row() >= 0) {
|
|
|
|
|
int row = index.row();
|
|
|
|
|
QModelIndex setIndex = plugin->getModlIndex(++row, 0);
|
|
|
|
|
plugin->setResultSelection(setIndex);
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
2021-08-24 17:10:28 +08:00
|
|
|
|
} else if (index.row() >= maxNum - 1 or index.row() < 0) {//跳转下一个widget
|
2021-08-18 14:23:14 +08:00
|
|
|
|
plugin->clearResultSelection();
|
|
|
|
|
int indexNum = m_widget_list.indexOf(plugin);
|
|
|
|
|
bool findNextWidget = false;
|
|
|
|
|
while (++indexNum < m_widget_list.size()) {
|
|
|
|
|
plugin = m_widget_list[indexNum];
|
|
|
|
|
if (plugin->getResultNum() != 0) {
|
|
|
|
|
QModelIndex resultIndex = plugin->getModlIndex(0, 0);
|
|
|
|
|
plugin->setResultSelection(resultIndex);
|
|
|
|
|
m_selectedPluginID = plugin->pluginId();
|
|
|
|
|
findNextWidget = true;
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (findNextWidget){
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
qWarning() << "QModelIndex error ! row:" << index.row() << "maxNum:" << maxNum;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResultArea::pressUp()
|
|
|
|
|
{
|
|
|
|
|
if (!m_is_selected) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-10-27 11:37:55 +08:00
|
|
|
|
if (m_selectedPluginID == m_bestListWidget->getWidgetName()) {
|
2021-08-18 14:23:14 +08:00
|
|
|
|
QModelIndex index = m_bestListWidget->getCurrentSelection();
|
|
|
|
|
int maxNum = m_bestListWidget->getExpandState() ?
|
|
|
|
|
m_bestListWidget->getResultNum() : (m_bestListWidget->getResultNum() < NUM_LIMIT_SHOWN_DEFAULT ?
|
|
|
|
|
m_bestListWidget->getResultNum() : NUM_LIMIT_SHOWN_DEFAULT);
|
2021-08-24 17:10:28 +08:00
|
|
|
|
if (index.row() > 0 and index.row() < maxNum) {
|
2021-08-18 14:23:14 +08:00
|
|
|
|
int row = index.row();
|
|
|
|
|
QModelIndex setIndex = m_bestListWidget->getModlIndex(--row, 0);
|
|
|
|
|
m_bestListWidget->setResultSelection(setIndex);
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
|
|
|
|
} else if (index.row() == 0) {
|
|
|
|
|
//已到最上层,暂不处理
|
|
|
|
|
} else {
|
2021-08-24 17:10:28 +08:00
|
|
|
|
QModelIndex setIndex = m_bestListWidget->getModlIndex(--maxNum, 0);
|
|
|
|
|
m_bestListWidget->setResultSelection(setIndex);
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
2021-08-18 14:23:14 +08:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
for (ResultWidget * plugin : m_widget_list) {
|
|
|
|
|
if (m_selectedPluginID == plugin->pluginId()) {
|
2021-08-24 17:10:28 +08:00
|
|
|
|
int indexMaxNum = plugin->getExpandState() ?
|
|
|
|
|
plugin->getResultNum() : (plugin->getResultNum() < NUM_LIMIT_SHOWN_DEFAULT ?
|
|
|
|
|
plugin->getResultNum() : NUM_LIMIT_SHOWN_DEFAULT);
|
2021-08-18 14:23:14 +08:00
|
|
|
|
QModelIndex index = plugin->getCurrentSelection();
|
2021-08-24 17:10:28 +08:00
|
|
|
|
if (index.row() > 0 and index.row() < indexMaxNum) {
|
2021-08-18 14:23:14 +08:00
|
|
|
|
int row = index.row();
|
|
|
|
|
QModelIndex setIndex = plugin->getModlIndex(--row, 0);
|
|
|
|
|
plugin->setResultSelection(setIndex);
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
|
|
|
|
} else if (index.row() == 0) {//跳转下一个widget
|
|
|
|
|
plugin->clearResultSelection();
|
|
|
|
|
int indexNum = m_widget_list.indexOf(plugin);
|
|
|
|
|
bool findNextWidget = false;
|
|
|
|
|
while (--indexNum >= 0) {
|
|
|
|
|
plugin = m_widget_list[indexNum];
|
|
|
|
|
if (plugin->getResultNum() != 0) {
|
|
|
|
|
int maxNum = plugin->getExpandState() ?
|
|
|
|
|
plugin->getResultNum() : (plugin->getResultNum() < NUM_LIMIT_SHOWN_DEFAULT ?
|
|
|
|
|
plugin->getResultNum() : NUM_LIMIT_SHOWN_DEFAULT);
|
|
|
|
|
QModelIndex resultIndex = plugin->getModlIndex(maxNum - 1, 0);
|
|
|
|
|
plugin->setResultSelection(resultIndex);
|
|
|
|
|
m_selectedPluginID = plugin->pluginId();
|
|
|
|
|
findNextWidget = true;
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (indexNum < 0) {//下一项是best list
|
|
|
|
|
int bestListNum = m_bestListWidget->getExpandState() ?
|
|
|
|
|
m_bestListWidget->getResultNum() : (m_bestListWidget->getResultNum() < NUM_LIMIT_SHOWN_DEFAULT ?
|
|
|
|
|
m_bestListWidget->getResultNum() : NUM_LIMIT_SHOWN_DEFAULT);
|
|
|
|
|
QModelIndex setIndex = m_bestListWidget->getModlIndex(--bestListNum, 0);
|
|
|
|
|
m_bestListWidget->setResultSelection(setIndex);
|
|
|
|
|
m_selectedPluginID = m_bestListWidget->getWidgetName();
|
|
|
|
|
m_is_selected = true;
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
|
|
|
|
}
|
|
|
|
|
if (findNextWidget){
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2021-08-24 17:10:28 +08:00
|
|
|
|
QModelIndex setIndex = plugin->getModlIndex(indexMaxNum - 1, 0);
|
2021-08-18 14:23:14 +08:00
|
|
|
|
plugin->setResultSelection(setIndex);
|
|
|
|
|
sendKeyPressSignal(m_selectedPluginID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-13 11:22:30 +08:00
|
|
|
|
int ResultArea::getVScrollBarWidth()
|
|
|
|
|
{
|
|
|
|
|
if (verticalScrollBar()->isVisible()) {
|
|
|
|
|
return this->verticalScrollBar()->width();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-18 14:23:14 +08:00
|
|
|
|
bool ResultArea::getSelectedState()
|
|
|
|
|
{
|
|
|
|
|
return m_is_selected;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResultArea::sendKeyPressSignal(QString &pluginID)
|
|
|
|
|
{
|
2021-08-20 10:07:53 +08:00
|
|
|
|
int height(0);
|
2021-08-24 17:10:28 +08:00
|
|
|
|
int resultHeight = m_bestListWidget->getResultHeight();
|
2021-08-20 10:07:53 +08:00
|
|
|
|
if (pluginID == m_bestListWidget->getWidgetName()) {
|
|
|
|
|
QModelIndex index = m_bestListWidget->getCurrentSelection();
|
2021-08-24 17:10:28 +08:00
|
|
|
|
height = index.row() == 0 ? 0 : index.row() * resultHeight + TITLE_HEIGHT;
|
|
|
|
|
height = (height - resultHeight) < 0 ? 0 : height - resultHeight;
|
2021-08-20 10:07:53 +08:00
|
|
|
|
this->ensureVisible(0, height, 0, 0);
|
|
|
|
|
if (m_detail_open_state) {
|
2021-08-18 14:23:14 +08:00
|
|
|
|
Q_EMIT this->keyPressChanged(m_bestListWidget->getPluginInfo(index), m_bestListWidget->getIndexResultInfo(index));
|
2021-08-20 10:07:53 +08:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
height += m_bestListWidget->height();
|
|
|
|
|
for (ResultWidget *plugin : m_widget_list) {
|
|
|
|
|
if (pluginID == plugin->pluginId()) {
|
|
|
|
|
QModelIndex index = plugin->getCurrentSelection();
|
2023-01-21 19:52:40 +08:00
|
|
|
|
//todo 这里偶尔会导致崩溃@jxx,暂时规避。
|
|
|
|
|
if(!index.isValid()) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-08-24 17:10:28 +08:00
|
|
|
|
height += index.row() == 0 ? 0 : index.row() * resultHeight + TITLE_HEIGHT;
|
|
|
|
|
int moreHeight = index.row() == 0 ? (TITLE_HEIGHT + resultHeight * 2) : (resultHeight * 2);
|
2021-08-20 10:07:53 +08:00
|
|
|
|
this->ensureVisible(0, height + moreHeight, 0, 0);
|
2021-08-24 17:10:28 +08:00
|
|
|
|
height = (height - resultHeight) < 0 ? 0 : height - resultHeight;
|
2021-08-20 10:07:53 +08:00
|
|
|
|
this->ensureVisible(0, height, 0, 0);
|
|
|
|
|
if (m_detail_open_state) {
|
2021-08-18 14:23:14 +08:00
|
|
|
|
Q_EMIT this->keyPressChanged(m_selectedPluginID, plugin->getIndexResultInfo(index));
|
|
|
|
|
}
|
2021-08-20 10:07:53 +08:00
|
|
|
|
break;
|
|
|
|
|
} else {
|
|
|
|
|
height += plugin->height();
|
2021-08-18 14:23:14 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-27 10:25:15 +08:00
|
|
|
|
void ResultArea::onWidgetSizeChanged()
|
|
|
|
|
{
|
|
|
|
|
int whole_height = 0;
|
|
|
|
|
Q_FOREACH (ResultWidget *widget, m_widget_list) {
|
|
|
|
|
whole_height += widget->height();
|
|
|
|
|
}
|
2021-08-02 13:46:59 +08:00
|
|
|
|
whole_height += m_bestListWidget->height();
|
2021-08-12 14:57:25 +08:00
|
|
|
|
|
2021-05-27 10:25:15 +08:00
|
|
|
|
int spacing_height = m_widget_list.length() > 1 ? m_mainLyt->spacing() : 0;
|
|
|
|
|
m_widget->setFixedHeight(whole_height + spacing_height * (m_widget_list.length() - 1));
|
2021-08-02 13:46:59 +08:00
|
|
|
|
Q_EMIT this->resizeHeight(whole_height + spacing_height * (m_widget_list.length() - 1));
|
2021-05-27 10:25:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-18 14:23:14 +08:00
|
|
|
|
void ResultArea::setSelectionInfo(QString &pluginID)
|
|
|
|
|
{
|
|
|
|
|
m_detail_open_state = true;
|
|
|
|
|
m_is_selected = true;
|
|
|
|
|
m_selectedPluginID = pluginID;
|
|
|
|
|
if (m_selectedPluginID != m_bestListWidget->getWidgetName()) {
|
|
|
|
|
m_bestListWidget->clearResultSelection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-27 17:25:06 +08:00
|
|
|
|
void ResultArea::mousePressEvent(QMouseEvent *event)
|
|
|
|
|
{
|
|
|
|
|
// qDebug() << "mouse pressed" << event->source() << event->button();
|
|
|
|
|
// m_pressPoint = event->pos();
|
|
|
|
|
return QScrollArea::mousePressEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResultArea::mouseMoveEvent(QMouseEvent *event)
|
|
|
|
|
{
|
|
|
|
|
// if(m_pressPoint.isNull()) {
|
|
|
|
|
// return QScrollArea::mouseMoveEvent(event);
|
|
|
|
|
// }
|
|
|
|
|
// int delta = ((event->pos().y() - m_pressPoint.y()) / this->widget()->height()) * verticalScrollBar()->maximum();
|
|
|
|
|
// this->verticalScrollBar()->setValue(verticalScrollBar()->value() + delta);
|
|
|
|
|
// event->accept();
|
|
|
|
|
return QScrollArea::mouseMoveEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResultArea::mouseReleaseEvent(QMouseEvent *event)
|
|
|
|
|
{
|
|
|
|
|
return QScrollArea::mouseReleaseEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ResultArea::viewportEvent(QEvent *event)
|
|
|
|
|
{
|
2022-08-18 17:27:10 +08:00
|
|
|
|
if (event->type() == QEvent::MouseButtonPress) {
|
|
|
|
|
QMouseEvent *e = dynamic_cast<QMouseEvent *>(event);
|
|
|
|
|
if (e->source() == Qt::MouseEventSynthesizedByApplication) {
|
|
|
|
|
qDebug() << "MouseButtonPress MouseEventSynthesizedByApplication";
|
|
|
|
|
m_pressPoint = m_widget->mapFrom(this, e->pos());
|
2021-09-27 17:25:06 +08:00
|
|
|
|
event->accept();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-08-18 17:27:10 +08:00
|
|
|
|
} else if (event->type() == QEvent::MouseMove) {
|
|
|
|
|
QMouseEvent *e = dynamic_cast<QMouseEvent *>(event);
|
|
|
|
|
if (e->source() == Qt::MouseEventSynthesizedByApplication) {
|
|
|
|
|
qDebug() << "MouseMove MouseEventSynthesizedByApplication";
|
|
|
|
|
int delta = m_pressPoint.y() - m_widget->mapFrom(this, e->pos()).y();
|
|
|
|
|
// qDebug() << "last pos:" << m_pressPoint.y();
|
|
|
|
|
// qDebug() << "new pos:" << m_widget->mapFrom(this, e->touchPoints().at(0).pos().toPoint()).y();
|
|
|
|
|
// qDebug() << "delta" << delta;
|
|
|
|
|
// qDebug() << "value" << verticalScrollBar()->value() << "--" << verticalScrollBar()->value() + delta;
|
2021-09-27 17:25:06 +08:00
|
|
|
|
this->verticalScrollBar()->setValue(verticalScrollBar()->value() + delta);
|
2022-08-18 17:27:10 +08:00
|
|
|
|
m_pressPoint = m_widget->mapFrom(this,e->pos());
|
2021-09-27 17:25:06 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QScrollArea::viewportEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-22 21:29:43 +08:00
|
|
|
|
void ResultArea::initUi()
|
|
|
|
|
{
|
2022-12-13 11:22:30 +08:00
|
|
|
|
m_scrollBar = new ResultScrollBar(this);
|
|
|
|
|
this->setVerticalScrollBar(m_scrollBar);
|
2021-07-31 16:12:04 +08:00
|
|
|
|
// this->verticalScrollBar()->setProperty("drawScrollBarGroove", false);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
QPalette pal = palette();
|
2021-08-16 09:39:55 +08:00
|
|
|
|
QPalette scroll_bar_pal = this->verticalScrollBar()->palette();
|
|
|
|
|
// pal.setColor(QPalette::Base, RESULT_BACKGROUND_COLOR);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
pal.setColor(QPalette::Window, RESULT_BACKGROUND_COLOR);
|
2021-08-16 09:39:55 +08:00
|
|
|
|
scroll_bar_pal.setColor(QPalette::Base, RESULT_BACKGROUND_COLOR);
|
|
|
|
|
this->verticalScrollBar()->setPalette(scroll_bar_pal);
|
2022-06-06 14:52:59 +08:00
|
|
|
|
this->verticalScrollBar()->setProperty("drawScrollBarGroove", false);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
this->setFrameShape(QFrame::Shape::NoFrame);
|
|
|
|
|
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
|
|
|
this->setPalette(pal);
|
|
|
|
|
this->setWidgetResizable(true);
|
|
|
|
|
this->setFrameShape(QFrame::Shape::NoFrame);
|
|
|
|
|
m_widget = new QWidget(this);
|
|
|
|
|
this->setWidget(m_widget);
|
|
|
|
|
m_mainLyt = new QVBoxLayout(m_widget);
|
|
|
|
|
m_widget->setLayout(m_mainLyt);
|
2021-08-02 13:46:59 +08:00
|
|
|
|
m_bestListWidget = new BestListWidget(this);
|
2021-08-18 14:23:14 +08:00
|
|
|
|
m_bestListWidget->clearResult();
|
2021-08-02 13:46:59 +08:00
|
|
|
|
m_mainLyt->addWidget(m_bestListWidget);
|
2021-08-12 14:57:25 +08:00
|
|
|
|
|
2021-05-22 21:29:43 +08:00
|
|
|
|
m_mainLyt->setContentsMargins(RESULT_LAYOUT_MARGINS);
|
2021-08-12 14:57:25 +08:00
|
|
|
|
this->widget()->setContentsMargins(0,0,0,0);
|
|
|
|
|
m_mainLyt->setSpacing(0);
|
2021-10-20 16:30:20 +08:00
|
|
|
|
|
2022-04-15 15:52:15 +08:00
|
|
|
|
m_titleLabel = new TitleLabel(this);
|
|
|
|
|
m_titleLabel->hide();
|
2021-05-22 21:29:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-02 13:46:59 +08:00
|
|
|
|
void ResultArea::initConnections()
|
|
|
|
|
{
|
|
|
|
|
connect(this, &ResultArea::startSearch, m_bestListWidget, &BestListWidget::startSearch);
|
2021-08-18 14:23:14 +08:00
|
|
|
|
connect(this, &ResultArea::startSearch, this, [=] () {
|
|
|
|
|
m_detail_open_state = false;
|
|
|
|
|
m_is_selected = false;
|
2021-10-27 11:37:55 +08:00
|
|
|
|
m_selectedPluginID = "";
|
2021-08-18 14:23:14 +08:00
|
|
|
|
});
|
2021-08-02 13:46:59 +08:00
|
|
|
|
connect(m_bestListWidget, &BestListWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged);
|
2021-09-08 11:03:43 +08:00
|
|
|
|
connect(m_bestListWidget, &BestListWidget::sizeChanged, this, [=] () {
|
2021-10-27 11:37:55 +08:00
|
|
|
|
QModelIndex index = m_bestListWidget->getModlIndex(0, 0);
|
|
|
|
|
if (index.isValid()) {
|
2021-09-08 11:03:43 +08:00
|
|
|
|
m_bestListWidget->setResultSelection(index);
|
|
|
|
|
m_selectedPluginID = m_bestListWidget->getWidgetName();
|
|
|
|
|
m_is_selected = true;
|
2021-10-27 11:37:55 +08:00
|
|
|
|
|
|
|
|
|
for (ResultWidget * i : m_widget_list) {
|
|
|
|
|
if (i->pluginId() == m_widget_list.back()->pluginId()) {
|
|
|
|
|
i->clearResultSelection();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-08 11:03:43 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-02 13:46:59 +08:00
|
|
|
|
connect(m_bestListWidget, &BestListWidget::currentRowChanged, this, &ResultArea::currentRowChanged);
|
2021-08-18 14:23:14 +08:00
|
|
|
|
connect(m_bestListWidget, &BestListWidget::currentRowChanged, this, [=] () {
|
|
|
|
|
m_detail_open_state = true;
|
|
|
|
|
m_is_selected = true;
|
|
|
|
|
m_selectedPluginID = m_bestListWidget->getWidgetName();
|
|
|
|
|
});
|
2021-08-02 13:46:59 +08:00
|
|
|
|
connect(this, &ResultArea::clearSelectedRow, m_bestListWidget, &BestListWidget::clearSelectedRow);
|
2021-08-12 14:57:25 +08:00
|
|
|
|
connect(this, &ResultArea::resizeWidth, this, [=] (const int &size) {
|
|
|
|
|
m_bestListWidget->setFixedWidth(size);
|
|
|
|
|
});
|
|
|
|
|
connect(m_bestListWidget, &BestListWidget::rowClicked, this, &ResultArea::rowClicked);
|
2021-10-20 16:30:20 +08:00
|
|
|
|
connect(this->verticalScrollBar(), &QScrollBar::valueChanged, this, [=] (int value) {//判断显示和隐藏逻辑
|
|
|
|
|
Q_FOREACH(auto widget, m_widget_list) {
|
|
|
|
|
if (!widget->getExpandState()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (value < (widget->pos().ry() + TITLE_HEIGHT)
|
|
|
|
|
or value > (widget->pos().ry() + widget->height() - FRAME_HEIGHT + 2*TITLE_HEIGHT)) {//暂定下一项标题显示完全后悬浮标题隐藏
|
2022-04-15 15:52:15 +08:00
|
|
|
|
if (!m_titleLabel->isHidden()) {
|
|
|
|
|
m_titleLabel->hide();
|
2021-10-20 16:30:20 +08:00
|
|
|
|
this->setViewportMargins(0,0,0,0);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2022-04-15 15:52:15 +08:00
|
|
|
|
if (m_titleLabel->isHidden()) {
|
|
|
|
|
m_titleLabel->setText(widget->pluginName());
|
|
|
|
|
m_titleLabel->setShowMoreLableVisible();//防止多项展开后无法收回其他项
|
|
|
|
|
m_titleLabel->show();
|
2021-10-20 16:30:20 +08:00
|
|
|
|
this->setViewportMargins(0,TITLE_HEIGHT,0,0);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-04-15 15:52:15 +08:00
|
|
|
|
connect(this->m_titleLabel, &TitleLabel::retractClicked, this, [=] () {
|
2021-10-20 16:30:20 +08:00
|
|
|
|
Q_FOREACH(auto widget, m_widget_list) {
|
2022-04-15 15:52:15 +08:00
|
|
|
|
if (widget->pluginName() == m_titleLabel->text()) {
|
|
|
|
|
if (!m_titleLabel->isHidden()) {
|
|
|
|
|
m_titleLabel->hide();
|
2021-10-20 16:30:20 +08:00
|
|
|
|
this->setViewportMargins(0,0,0,0);
|
|
|
|
|
}
|
2022-06-23 21:20:49 +08:00
|
|
|
|
widget->reduceListSlot();
|
|
|
|
|
this->verticalScrollBar()->setValue(widget->pos().ry());
|
|
|
|
|
widget->resetTitleLabel();
|
2021-10-20 16:30:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
connect(this, &ResultArea::resizeWidth, this, [=] (int size) {
|
2022-04-15 15:52:15 +08:00
|
|
|
|
m_titleLabel->setFixedWidth(size);
|
2021-10-20 16:30:20 +08:00
|
|
|
|
});
|
2022-12-13 11:22:30 +08:00
|
|
|
|
connect(m_scrollBar, &ResultScrollBar::scrollBarAppeared, this, &ResultArea::scrollBarAppeared);
|
|
|
|
|
connect(m_scrollBar, &ResultScrollBar::scrollBarIsHideen, this, &ResultArea::scrollBarIsHideen);
|
2021-08-02 13:46:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-22 21:29:43 +08:00
|
|
|
|
void ResultArea::setupConnectionsForWidget(ResultWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
connect(this, &ResultArea::startSearch, widget, &ResultWidget::startSearch);
|
2021-10-20 16:30:20 +08:00
|
|
|
|
connect(this, &ResultArea::startSearch, this, [=] () {
|
2022-04-15 15:52:15 +08:00
|
|
|
|
if (!m_titleLabel->isHidden()) {
|
|
|
|
|
m_titleLabel->hide();
|
2021-10-20 16:30:20 +08:00
|
|
|
|
this->setViewportMargins(0,0,0,0);
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-05-22 21:29:43 +08:00
|
|
|
|
connect(this, &ResultArea::stopSearch, widget, &ResultWidget::stopSearch);
|
2021-05-27 10:25:15 +08:00
|
|
|
|
connect(widget, &ResultWidget::sizeChanged, this, &ResultArea::onWidgetSizeChanged);
|
2021-10-27 11:37:55 +08:00
|
|
|
|
connect(widget, &ResultWidget::sizeChanged, this, [=] () {
|
|
|
|
|
if (widget->pluginId() == m_widget_list.back()->pluginId() and m_selectedPluginID != m_bestListWidget->getWidgetName()) {//每次搜索默认选中websearch,由bestlist取消
|
|
|
|
|
QModelIndex index = widget->getModlIndex(0, 0);
|
|
|
|
|
if (index.isValid()) {
|
|
|
|
|
widget->setResultSelection(index);
|
|
|
|
|
m_is_selected = true;
|
|
|
|
|
m_selectedPluginID = widget->pluginId();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-10-20 16:30:20 +08:00
|
|
|
|
connect(widget, &ResultWidget::showMoreClicked, this, [=] () {//点击展开搜索结果后 显示悬浮窗
|
|
|
|
|
if (widget->height() > FRAME_HEIGHT) {//当前widget高度大于搜索结果界面高度则显示悬浮窗
|
2021-11-02 16:59:25 +08:00
|
|
|
|
this->verticalScrollBar()->setValue(widget->pos().ry() + TITLE_HEIGHT); //置顶当前类型搜索结果,不显示标题栏
|
2022-04-15 15:52:15 +08:00
|
|
|
|
viewport()->stackUnder(m_titleLabel);
|
|
|
|
|
m_titleLabel->setText(widget->pluginName());
|
|
|
|
|
m_titleLabel->setFixedSize(widget->width(), TITLE_HEIGHT);
|
|
|
|
|
m_titleLabel->setShowMoreLableVisible();
|
|
|
|
|
if (m_titleLabel->isHidden()) {
|
|
|
|
|
m_titleLabel->show();
|
2021-10-20 16:30:20 +08:00
|
|
|
|
this->setViewportMargins(0,TITLE_HEIGHT,0,0);
|
|
|
|
|
}
|
2021-11-02 16:59:25 +08:00
|
|
|
|
} else {
|
|
|
|
|
this->verticalScrollBar()->setValue(widget->pos().ry()); //置顶当前类型搜索结果,显示标题栏
|
2021-10-20 16:30:20 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
connect(widget, &ResultWidget::retractClicked, this, [=] () {//点击收起搜索结果后
|
2022-04-15 15:52:15 +08:00
|
|
|
|
if (!m_titleLabel->isHidden()) {
|
2021-10-20 16:30:20 +08:00
|
|
|
|
this->setViewportMargins(0,0,0,0);
|
2022-06-17 15:55:37 +08:00
|
|
|
|
m_titleLabel->hide();
|
2021-10-20 16:30:20 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2021-08-02 13:46:59 +08:00
|
|
|
|
connect(widget, &ResultWidget::sendBestListData, m_bestListWidget, &BestListWidget::sendBestListData);
|
2022-11-22 10:17:36 +08:00
|
|
|
|
|
|
|
|
|
connect(SearchPluginManager::getInstance(), &SearchPluginManager::unregistered, this, &ResultArea::removeWidget);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DetailArea::DetailArea(QWidget *parent) : QScrollArea(parent)
|
|
|
|
|
{
|
|
|
|
|
initUi();
|
2021-07-31 16:12:04 +08:00
|
|
|
|
connect(this, &DetailArea::setWidgetInfo, m_detailWidget, &DetailWidget::updateDetailPage);
|
|
|
|
|
connect(this, &DetailArea::setWidgetInfo, this, &DetailArea::show);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DetailArea::initUi()
|
|
|
|
|
{
|
|
|
|
|
QPalette pal = palette();
|
2021-08-16 09:39:55 +08:00
|
|
|
|
// pal.setColor(QPalette::Base, DETAIL_BACKGROUND_COLOR);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
pal.setColor(QPalette::Window, DETAIL_BACKGROUND_COLOR);
|
2021-09-23 19:56:54 +08:00
|
|
|
|
QPalette scroll_bar_pal = this->verticalScrollBar()->palette();
|
|
|
|
|
scroll_bar_pal.setColor(QPalette::Base, RESULT_BACKGROUND_COLOR);
|
|
|
|
|
this->verticalScrollBar()->setPalette(scroll_bar_pal);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
this->setPalette(pal);
|
|
|
|
|
this->setFrameShape(QFrame::Shape::NoFrame);
|
|
|
|
|
this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
|
|
|
this->setWidgetResizable(true);
|
2021-10-20 16:30:20 +08:00
|
|
|
|
this->setFixedSize(DETAIL_FRAME_WIDTH, FRAME_HEIGHT);
|
2021-08-16 19:34:40 +08:00
|
|
|
|
// this->setStyleSheet("QScrollArea{border:2px solid red;}");
|
|
|
|
|
this->setContentsMargins(0,0,0,0);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
m_detailWidget = new DetailWidget(this);
|
|
|
|
|
this->setWidget(m_detailWidget);
|
2021-07-23 16:10:30 +08:00
|
|
|
|
this->hide();
|
2021-05-22 21:29:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DetailWidget::DetailWidget(QWidget *parent) : QWidget(parent)
|
|
|
|
|
{
|
2023-11-22 09:08:30 +08:00
|
|
|
|
m_radius = qApp->style()->property("maxRadius").toInt();
|
|
|
|
|
connect(qApp, &QApplication::paletteChanged, this, [&]() {
|
|
|
|
|
m_radius = qApp->style()->property("maxRadius").toInt();
|
|
|
|
|
});
|
2021-07-31 16:12:04 +08:00
|
|
|
|
this->setFixedWidth(368);
|
|
|
|
|
m_mainLyt = new QVBoxLayout(this);
|
|
|
|
|
this->setLayout(m_mainLyt);
|
|
|
|
|
m_mainLyt->setContentsMargins(DETAIL_WIDGET_MARGINS);
|
|
|
|
|
m_mainLyt->setAlignment(Qt::AlignHCenter);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString escapeHtml(const QString & str) {
|
|
|
|
|
QString temp = str;
|
|
|
|
|
temp.replace("<", "<");
|
|
|
|
|
temp.replace(">", ">");
|
|
|
|
|
return temp;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-31 16:12:04 +08:00
|
|
|
|
|
|
|
|
|
void DetailWidget::updateDetailPage(const QString &plugin_name, const SearchPluginIface::ResultInfo &info)
|
|
|
|
|
{
|
|
|
|
|
if(m_detailPage) {
|
|
|
|
|
if(m_currentPluginId == plugin_name) {
|
|
|
|
|
SearchPluginManager::getInstance()->getPlugin(plugin_name)->detailPage(info);
|
|
|
|
|
} else {
|
|
|
|
|
m_mainLyt->removeWidget(m_detailPage);
|
|
|
|
|
m_detailPage->hide();
|
|
|
|
|
m_detailPage = SearchPluginManager::getInstance()->getPlugin(plugin_name)->detailPage(info);
|
|
|
|
|
m_detailPage->setParent(this);
|
|
|
|
|
m_mainLyt->addWidget(m_detailPage);
|
|
|
|
|
m_detailPage->show();
|
|
|
|
|
// m_mainLyt->insertWidget(0, m_detailPage, 0);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
}
|
2021-07-31 16:12:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
m_detailPage = SearchPluginManager::getInstance()->getPlugin(plugin_name)->detailPage(info);
|
|
|
|
|
m_detailPage->setParent(this);
|
|
|
|
|
m_mainLyt->addWidget(m_detailPage);
|
|
|
|
|
// m_mainLyt->insertWidget(0, m_detailPage, 0);
|
2021-07-05 14:27:14 +08:00
|
|
|
|
}
|
2021-10-27 11:37:55 +08:00
|
|
|
|
m_currentPluginId = plugin_name;
|
2021-05-22 21:29:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-31 16:12:04 +08:00
|
|
|
|
void DetailWidget::paintEvent(QPaintEvent *event)
|
2021-05-22 21:29:43 +08:00
|
|
|
|
{
|
|
|
|
|
QStyleOption opt;
|
|
|
|
|
opt.init(this);
|
|
|
|
|
QPainter p(this);
|
|
|
|
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
|
|
|
|
|
2021-08-16 19:34:40 +08:00
|
|
|
|
QRect rect = this->rect().adjusted(0, 0, 0, 0);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
|
|
|
|
|
p.setBrush(opt.palette.color(QPalette::Text));
|
|
|
|
|
p.setOpacity(DETAIL_WIDGET_TRANSPARENT);
|
|
|
|
|
p.setPen(Qt::NoPen);
|
2023-11-22 09:08:30 +08:00
|
|
|
|
p.drawRoundedRect(rect, m_radius, m_radius);
|
2021-05-22 21:29:43 +08:00
|
|
|
|
return QWidget::paintEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DetailWidget::clearLayout(QLayout *layout)
|
|
|
|
|
{
|
2021-07-05 14:27:14 +08:00
|
|
|
|
if(!layout) return;
|
2021-05-22 21:29:43 +08:00
|
|
|
|
QLayoutItem * child;
|
|
|
|
|
while((child = layout->takeAt(0)) != 0) {
|
|
|
|
|
if(child->widget()) {
|
|
|
|
|
child->widget()->setParent(NULL);
|
|
|
|
|
}
|
|
|
|
|
delete child;
|
|
|
|
|
}
|
|
|
|
|
child = NULL;
|
|
|
|
|
}
|
2021-05-25 19:42:40 +08:00
|
|
|
|
|
2022-12-13 11:22:30 +08:00
|
|
|
|
ResultScrollBar::ResultScrollBar(QWidget *parent) : QScrollBar(parent)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResultScrollBar::showEvent(QShowEvent *event)
|
|
|
|
|
{
|
|
|
|
|
Q_EMIT this->scrollBarAppeared();
|
|
|
|
|
return QScrollBar::showEvent(event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ResultScrollBar::hideEvent(QHideEvent *event)
|
|
|
|
|
{
|
|
|
|
|
Q_EMIT this->scrollBarIsHideen();
|
|
|
|
|
return QScrollBar::hideEvent(event);
|
|
|
|
|
}
|