Optimize code & adapt to theme.

This commit is contained in:
zhangjiaping 2021-05-14 21:19:51 +08:00
parent cc9b5dde11
commit 45f097e75f
18 changed files with 72 additions and 180 deletions

View File

@ -52,6 +52,9 @@ ContentWidget::~ContentWidget() {
* @brief initUI homepage和resultpage
*/
void ContentWidget::initUI() {
QPalette pal = palette();
pal.setColor(QPalette::Base, QColor(0, 0, 0, 0));
pal.setColor(QPalette::Window, QColor(0, 0, 0, 0)); //使用此palette的窗口背景将为透明
m_homePage = new QWidget(this);
m_homePageLyt = new QVBoxLayout(m_homePage);
m_homePageLyt->setSpacing(0);
@ -79,7 +82,6 @@ void ContentWidget::initUI() {
m_detailLyt = new QVBoxLayout(m_resultDetail);
m_resultList->setFixedWidth(236);
m_resultList->setFixedHeight(0);
m_resultList->setStyleSheet("QWidget{background:transparent;}");
m_listLyt->setContentsMargins(0, 0, 12, 0);
m_listLyt->setSpacing(0);
m_resultListArea->setWidget(m_resultList);
@ -91,8 +93,10 @@ void ContentWidget::initUI() {
});
m_resultDetailArea->setWidget(m_detailView);
m_resultDetailArea->setWidgetResizable(true);
m_resultListArea->setStyleSheet("QScrollArea{background: transparent;}");
m_resultDetailArea->setStyleSheet("QScrollArea{background: transparent; border-radius: 4px;}");
m_resultListArea->setFrameShape(QFrame::NoFrame);
m_resultDetailArea->setFrameShape(QFrame::NoFrame);
m_resultListArea->setPalette(pal);
m_resultDetailArea->setPalette(pal);
this->addWidget(m_homePage);
this->addWidget(m_resultPage);
@ -226,7 +230,7 @@ void ContentWidget::initListView() {
this->resetListHeight();
});
connect(qApp, &QApplication::paletteChanged, this, [ = ](const QPalette &pal) {
connect(qApp, &QApplication::paletteChanged, this, [ = ]() {
m_fileListView->refresh();
m_dirListView->refresh();
m_contentListView->refresh();

View File

@ -53,8 +53,9 @@ void FolderListItem::initUi() {
m_iconLabel->setPixmap(QIcon::fromTheme("inode-directory").pixmap(QSize(16, 16)));
m_pathLabel->setText(m_path);
m_delLabel->setText(tr("Delete the folder out of blacklist"));
m_pathLabel->setStyleSheet("QLabel{color: palette(text); background: transparent;}");
m_delLabel->setStyleSheet("QLabel{color: #3790FA; background: transparent;}");
QPalette pal = palette();
pal.setColor(QPalette::WindowText, QColor(55, 144, 250, 255));
m_delLabel->setPalette(pal);
m_delLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_delLabel->installEventFilter(this);
m_delLabel->hide();

View File

@ -56,7 +56,6 @@ void HomePageItem::setupUi(const int& type, const QString& path) {
m_type = type;
m_widget = new QWidget(this);
m_widget->setObjectName("MainWidget");
// m_widget->setStyleSheet("QWidget#MainWidget{background: rgba(0, 0, 0, 0.05); border-radius: 4px;}");
m_widget->installEventFilter(this);
m_iconlabel = new QLabel(m_widget);
m_namelabel = new QLabel(m_widget);

View File

@ -91,48 +91,52 @@ void OptionView::setupOptions(const int& type, bool is_appInstalled) {
void OptionView::initUI() {
QPalette pal = palette();
pal.setColor(QPalette::WindowText, NORMAL_COLOR);
pal.setColor(QPalette::Light, HOVER_COLOR);
pal.setColor(QPalette::Dark, PRESS_COLOR);
m_optionFrame = new QFrame(this);
m_optionLyt = new QVBoxLayout(m_optionFrame);
m_optionLyt->setContentsMargins(8, 0, 0, 0);
m_openLabel = new QLabel(m_optionFrame);
m_openLabel->setText(tr("Open")); //打开
m_openLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_openLabel->setPalette(pal);
m_openLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_openLabel->installEventFilter(this);
m_optionLyt->addWidget(m_openLabel);
m_shortcutLabel = new QLabel(m_optionFrame);
m_shortcutLabel->setText(tr("Add Shortcut to Desktop")); //添加到桌面快捷方式
m_shortcutLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_shortcutLabel->setPalette(pal);
m_shortcutLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_shortcutLabel->installEventFilter(this);
m_optionLyt->addWidget(m_shortcutLabel);
m_panelLabel = new QLabel(m_optionFrame);
m_panelLabel->setText(tr("Add Shortcut to Panel")); //添加到任务栏快捷方式
m_panelLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_panelLabel->setPalette(pal);
m_panelLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_panelLabel->installEventFilter(this);
m_optionLyt->addWidget(m_panelLabel);
m_openPathLabel = new QLabel(m_optionFrame);
m_openPathLabel->setText(tr("Open path")); //打开所在路径
m_openPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_openPathLabel->setPalette(pal);
m_openPathLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_openPathLabel->installEventFilter(this);
m_optionLyt->addWidget(m_openPathLabel);
m_copyPathLabel = new QLabel(m_optionFrame);
m_copyPathLabel->setText(tr("Copy path")); //复制所在路径
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_copyPathLabel->setPalette(pal);
m_copyPathLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_copyPathLabel->installEventFilter(this);
m_optionLyt->addWidget(m_copyPathLabel);
m_installLabel = new QLabel(m_optionFrame);
m_installLabel->setText(tr("Install")); //复制所在路径
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_installLabel->setPalette(pal);
m_installLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_installLabel->installEventFilter(this);
m_optionLyt->addWidget(m_installLabel);
@ -235,92 +239,92 @@ void OptionView::setupSettingOptions() {
bool OptionView::eventFilter(QObject *watched, QEvent *event) {
if(m_openLabel && watched == m_openLabel) {
if(event->type() == QEvent::MouseButtonPress) {
m_openLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}");
m_openLabel->setForegroundRole(QPalette::Dark);
return true;
} else if(event->type() == QEvent::MouseButtonRelease) {
m_openLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_openLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::Open);
return true;
} else if(event->type() == QEvent::Enter) {
m_openLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}");
m_openLabel->setForegroundRole(QPalette::Light);
return true;
} else if(event->type() == QEvent::Leave) {
m_openLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_openLabel->setForegroundRole(QPalette::WindowText);
return true;
}
} else if(m_shortcutLabel && watched == m_shortcutLabel) {
if(event->type() == QEvent::MouseButtonPress) {
m_shortcutLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}");
m_shortcutLabel->setForegroundRole(QPalette::Dark);
return true;
} else if(event->type() == QEvent::MouseButtonRelease) {
m_shortcutLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_shortcutLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::Shortcut);
return true;
} else if(event->type() == QEvent::Enter) {
m_shortcutLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}");
m_shortcutLabel->setForegroundRole(QPalette::Light);
return true;
} else if(event->type() == QEvent::Leave) {
m_shortcutLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_shortcutLabel->setForegroundRole(QPalette::WindowText);
return true;
}
} else if(m_panelLabel && watched == m_panelLabel) {
if(event->type() == QEvent::MouseButtonPress) {
m_panelLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}");
m_panelLabel->setForegroundRole(QPalette::Dark);
return true;
} else if(event->type() == QEvent::MouseButtonRelease) {
m_panelLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_panelLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::Panel);
return true;
} else if(event->type() == QEvent::Enter) {
m_panelLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}");
m_panelLabel->setForegroundRole(QPalette::Light);
return true;
} else if(event->type() == QEvent::Leave) {
m_panelLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_panelLabel->setForegroundRole(QPalette::WindowText);
return true;
}
} else if(m_openPathLabel && watched == m_openPathLabel) {
if(event->type() == QEvent::MouseButtonPress) {
m_openPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}");
m_openPathLabel->setForegroundRole(QPalette::Dark);
return true;
} else if(event->type() == QEvent::MouseButtonRelease) {
m_openPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_openPathLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::OpenPath);
return true;
} else if(event->type() == QEvent::Enter) {
m_openPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}");
m_openPathLabel->setForegroundRole(QPalette::Light);
return true;
} else if(event->type() == QEvent::Leave) {
m_openPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_openPathLabel->setForegroundRole(QPalette::WindowText);
return true;
}
} else if(m_copyPathLabel && watched == m_copyPathLabel) {
if(event->type() == QEvent::MouseButtonPress) {
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}");
m_copyPathLabel->setForegroundRole(QPalette::Dark);
return true;
} else if(event->type() == QEvent::MouseButtonRelease) {
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_copyPathLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::CopyPath);
return true;
} else if(event->type() == QEvent::Enter) {
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}");
m_copyPathLabel->setForegroundRole(QPalette::Light);
return true;
} else if(event->type() == QEvent::Leave) {
m_copyPathLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_copyPathLabel->setForegroundRole(QPalette::WindowText);
return true;
}
} else if(m_installLabel && watched == m_installLabel) {
if(event->type() == QEvent::MouseButtonPress) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #296CD9;}");
m_installLabel->setForegroundRole(QPalette::Dark);
return true;
} else if(event->type() == QEvent::MouseButtonRelease) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_installLabel->setForegroundRole(QPalette::WindowText);
Q_EMIT this->onOptionClicked(Options::Install);
return true;
} else if(event->type() == QEvent::Enter) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #40A9FB;}");
m_installLabel->setForegroundRole(QPalette::Light);
return true;
} else if(event->type() == QEvent::Leave) {
m_installLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_installLabel->setForegroundRole(QPalette::WindowText);
return true;
}
}

View File

@ -28,6 +28,10 @@
#include <QHBoxLayout>
#include "search-list-view.h"
#define NORMAL_COLOR QColor(55, 144, 250, 255)
#define HOVER_COLOR QColor(64, 169, 251, 255)
#define PRESS_COLOR QColor(41, 108, 217, 255)
namespace Zeeker {
class OptionView : public QWidget {
Q_OBJECT

View File

@ -217,7 +217,8 @@ void SearchDetailView::setAppWidget(const QString &appname, const QString &path,
QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
QString showname = fontMetrics.elidedText(m_name, Qt::ElideRight, 274); //当字体长度超过215时显示为省略号
m_nameLabel->setText(showname);
// m_nameLabel->setText(showname);
m_nameLabel->setText(QString("<h3 style=\"font-weight:normal;\">%1</h3>").arg(escapeHtml(showname)));
if(QString::compare(showname, m_name)) {
m_nameLabel->setToolTip(m_name);
}
@ -350,18 +351,19 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) {
QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
QString wholeName = FileUtils::getFileName(path);
QString name = fontMetrics.elidedText(wholeName, Qt::ElideRight, 274);
m_nameLabel->setText(name);
// m_nameLabel->setText(name);
m_nameLabel->setText(QString("<h3 style=\"font-weight:normal;\">%1</h3>").arg(escapeHtml(name)));
if(QString::compare(name, wholeName)) {
m_nameLabel->setToolTip(wholeName);
}
m_nameLabel->setTextFormat(Qt::PlainText); //显示纯文本
m_typeLabel->setText(tr("Document"));
break;
}
case SearchListView::ResType::Setting : {
setIcon(path);
QString settingType = path.mid(path.indexOf("/") + 1, path.lastIndexOf("/") - path.indexOf("/") - 1); //配置项所属控制面板插件名
m_nameLabel->setText(settingType);
// m_nameLabel->setText(settingType);
m_nameLabel->setText(QString("<h3 style=\"font-weight:normal;\">%1</h3>").arg(escapeHtml(settingType)));
m_typeLabel->setText(FileUtils::getSettingName(path));
break;
}
@ -462,8 +464,6 @@ void SearchDetailView::initUI() {
m_layout = new QVBoxLayout(this);
this->setLayout(m_layout);
m_layout->setContentsMargins(16, 60, 16, 24);
this->setObjectName("detailView");
this->setStyleSheet("QWidget#detailView{background:transparent;}");
this->setFixedWidth(378);
//没有网络的时候的提示信息
@ -491,8 +491,7 @@ void SearchDetailView::initUI() {
m_nameLayout = new QHBoxLayout(m_nameFrame);
m_nameLabel = new QLabel(m_nameFrame);
m_typeLabel = new QLabel(m_nameFrame);
m_nameLabel->setStyleSheet("QLabel{font-size: 18px;}");
m_typeLabel->setStyleSheet("QLabel{font-size: 14px; color: palette(mid);}");
m_typeLabel->setEnabled(false);
m_nameFrame->setFixedHeight(48);
m_nameLabel->setMaximumWidth(280);
m_nameLayout->addWidget(m_nameLabel);

View File

@ -21,12 +21,11 @@
#include "search-list-view.h"
#include <QDebug>
#include <QFileInfo>
#include "custom-style.h"
using namespace Zeeker;
SearchListView::SearchListView(QWidget * parent, const QStringList& list, const int& type) : QTreeView(parent) {
// CustomStyle * style = new CustomStyle(GlobalSettings::getInstance()->getValue(STYLE_NAME_KEY).toString());
this->setStyle(CustomStyle::getStyle());
this->setFrameShape(QFrame::NoFrame);
this->viewport()->setAutoFillBackground(false);
setRootIsDecorated(false);
this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@ -43,7 +42,6 @@ SearchListView::SearchListView(QWidget * parent, const QStringList& list, const
// this->setFixedHeight(list.count() * rowheight + 4);
this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setAutoFillBackground(false);
// this->setStyleSheet("QWidget{background:transparent;}");
m_styleDelegate = new HighlightItemDelegate(this);
// m_styleDelegate->setSearchKeyword(keyword);
this->setItemDelegate(m_styleDelegate);
@ -128,13 +126,6 @@ void SearchListView::clear() {
*/
void SearchListView::refresh()
{
QModelIndex index = this->currentIndex();
m_model->refresh();
if(index.row() >= 0 && index.row() < m_model->length() && m_isSelected) {
this->blockSignals(true);
this->setCurrentIndex(index);
this->blockSignals(false);
}
rowheight = this->rowHeight(this->model()->index(0, 0, QModelIndex())) + 1;
this->setFixedHeight(m_item->getCurrentSize() * rowheight + 4);
}

View File

@ -47,6 +47,8 @@ bool ShowMoreLabel::getExpanded() {
}
void ShowMoreLabel::initUi() {
QPalette pal = palette();
pal.setColor(QPalette::WindowText, QColor(55, 144, 250, 255));
m_layout = new QHBoxLayout(this);
m_layout->setContentsMargins(0, 0, 0, 6);
m_textLabel = new QLabel(this);
@ -58,7 +60,7 @@ void ShowMoreLabel::initUi() {
// m_loadingIconLabel->hide();
m_layout->setAlignment(Qt::AlignRight);
m_layout->addWidget(m_textLabel);
m_textLabel->setStyleSheet("QLabel{font-size: 14px; color: #3790FA}");
m_textLabel->setPalette(pal);
// m_layout->addWidget(m_loadingIconLabel);
}

View File

@ -126,8 +126,6 @@ void CreateIndexAskDialog::initUi() {
* @brief CreateIndexAskDialog::paintEvent
*/
void CreateIndexAskDialog::paintEvent(QPaintEvent *event) {
Q_UNUSED(event)
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
QPainterPath rectPath;

View File

@ -1,49 +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 "custom-style.h"
using namespace Zeeker;
static CustomStyle *customstyle_global_instance = nullptr;
CustomStyle::CustomStyle(QStyle *style) {
}
CustomStyle *CustomStyle::getStyle()
{
if (!customstyle_global_instance)
customstyle_global_instance = new CustomStyle;
return customstyle_global_instance;
}
QSize CustomStyle::sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const {
switch(type) {
case CT_ItemViewItem: {
QSize size(0, GlobalSettings::getInstance()->getValue(FONT_SIZE_KEY).toDouble() * 2);
return size;
}
break;
default:
break;
}
return QProxyStyle::sizeFromContents(type, option, contentsSize, widget);
}

View File

@ -1,39 +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 CUSTOMSTYLE_H
#define CUSTOMSTYLE_H
#include <QProxyStyle>
#include "global-settings.h"
namespace Zeeker {
class CustomStyle : public QProxyStyle {
Q_OBJECT
public:
static CustomStyle *getStyle();
virtual QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget = nullptr) const;
private:
explicit CustomStyle(QStyle *style = nullptr);
~CustomStyle() override {}
};
}
#endif // CUSTOMSTYLE_H

View File

@ -98,7 +98,6 @@ void SearchBarHLayout::initUI() {
m_queryWidget = new QWidget(m_queryLineEdit);
m_queryWidget->setFocusPolicy(Qt::NoFocus);
m_queryWidget->setStyleSheet("border:0px;background:transparent");
QHBoxLayout* queryWidLayout = new QHBoxLayout;
queryWidLayout->setContentsMargins(8, 4, 0, 0);
@ -109,13 +108,12 @@ void SearchBarHLayout::initUI() {
QPixmap pixmap(QIcon::fromTheme("system-search-symbolic").pixmap(QSize(20, 20)));
m_queryIcon = new QLabel;
m_queryIcon->setStyleSheet("background:transparent");
m_queryIcon->setFixedSize(pixmap.size());
m_queryIcon->setPixmap(pixmap);
m_queryText = new QLabel;
m_queryText->setText(tr("Search"));
m_queryText->setStyleSheet("background:transparent;color:#626c6e;");
m_queryText->setEnabled(false);
m_queryText->setContentsMargins(0, 0, 0, 4);
m_queryText->adjustSize();
@ -215,7 +213,6 @@ SearchLineEdit::SearchLineEdit() {
// popView->setProperty("customShadowMargins", QVector4D(20, 20, 20, 20));
// popView->setAttribute(Qt::WA_TranslucentBackground);
// m_completer->setPopup(popView);
// m_completer->popup()->setStyle(CustomStyle::getStyle());
m_completer->setMaxVisibleItems(14);
setCompleter(m_completer);

View File

@ -85,16 +85,6 @@ MainWindow::MainWindow(QWidget *parent) :
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
#endif
connect(qApp, &QApplication::paletteChanged, this, [ = ](const QPalette & pal) {
this->setPalette(pal);
this->update();
Q_FOREACH(QWidget *widget, this->findChildren<QWidget *>()) {
if(widget) {
widget->update();
}
}
});
m_search_result_file = new QQueue<QString>;
m_search_result_dir = new QQueue<QString>;
m_search_result_content = new QQueue<QPair<QString, QStringList>>;
@ -287,7 +277,7 @@ void MainWindow::initUi() {
if(! m_search_result_thread->isRunning()) {
m_search_result_thread->start();
}
searchContent(text);
startSearch(text);
//允许弹窗且当前次搜索(为关闭主界面,算一次搜索过程)未询问且当前为暴力搜索
if(GlobalSettings::getInstance()->getValue(ENABLE_CREATE_INDEX_ASK_DIALOG).toString() != "false" && !m_currentSearchAsked && FileUtils::searchMethod == FileUtils::SearchMethod::DIRECTSEARCH)
m_askTimer->start();
@ -389,10 +379,10 @@ void MainWindow::primaryScreenChangedSlot(QScreen *screen) {
}
/**
* @brief searchContent
* @param searchcontent
* @brief startSearch
* @param keyword
*/
void MainWindow::searchContent(QString keyword) {
void MainWindow::startSearch(QString keyword) {
m_contentFrame->setKeyword(keyword);
//设置搜索
@ -533,7 +523,7 @@ void MainWindow::initTimer() {
m_researchTimer->setInterval(10 * 1000);
connect(m_researchTimer, &QTimer::timeout, this, [ = ]() {
if(this->isVisible()) {
searchContent(m_searchLayout->text());
startSearch(m_searchLayout->text());
}
m_researchTimer->stop();
});

View File

@ -77,7 +77,7 @@ public:
*/
// The parameter:keyword is the word or sentence which users want to search.
void searchContent(QString keyword);
void startSearch(QString keyword);
// The position which mainwindow shows follow the ukui-panel.
void moveToPanel();

View File

@ -181,12 +181,6 @@ void SearchItemModel::setBestAppIcon(const QString &str, const bool & is_install
}
}
void SearchItemModel::refresh()
{
this->beginResetModel();
this->endResetModel();
}
int SearchItemModel::length()
{
return m_item->m_pathlist.length();

View File

@ -59,7 +59,6 @@ public:
void removeItem(QString);
void clear();
void setBestAppIcon(const QString &, const bool &);
void refresh();
int length();
private :

View File

@ -57,6 +57,8 @@ SettingsWidget::~SettingsWidget() {
* @brief SettingsWidget::initUi UI
*/
void SettingsWidget::initUi() {
QPalette pal = palette();
pal.setColor(QPalette::Window, QColor(0, 0, 0, 0));
// this->setFixedWidth(528);
// this->setMinimumHeight(460);
// this->setMaximumHeight(680);
@ -81,8 +83,6 @@ void SettingsWidget::initUi() {
m_closeBtn = new QPushButton(m_titleFrame);
m_closeBtn->setFixedSize(24, 24);
// m_closeBtn->setIcon(QIcon(":/res/icons/close.svg"));
// m_closeBtn->setStyleSheet("QPushButton{background: transparent;}"
// "QPushButton:hover:!pressed{background: transparent;}");
m_closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
m_closeBtn->setProperty("isWindowButton", 0x02);
m_closeBtn->setProperty("useIconHighlightEffect", 0x08);
@ -139,9 +139,9 @@ void SettingsWidget::initUi() {
m_indexBtnLyt->addWidget(m_addDirBtn);
m_indexBtnLyt->addStretch();
m_dirListArea = new QScrollArea(m_contentFrame);
m_dirListArea->setStyleSheet("QScrollArea{background:transparent;}");
m_dirListArea->setPalette(pal);
m_dirListArea->setFrameShape(QFrame::Shape::NoFrame);
m_dirListWidget = new QWidget(m_contentFrame);
m_dirListWidget->setStyleSheet("QWidget{background:transparent;}");
m_dirListLyt = new QVBoxLayout(m_dirListWidget);
m_dirListLyt->setContentsMargins(0, 0, 0, 0);
m_dirListLyt->setSpacing(0);

View File

@ -28,7 +28,6 @@ include(singleapplication/qt-single-application.pri)
SOURCES += \
content-widget.cpp \
create-index-ask-dialog.cpp \
custom-style.cpp \
input-box.cpp \
main.cpp \
mainwindow.cpp \
@ -41,7 +40,6 @@ SOURCES += \
HEADERS += \
content-widget.h \
create-index-ask-dialog.h \
custom-style.h \
input-box.h \
mainwindow.h \
search-app-thread.h \