From f29b36b91c1012a2793671f77fc5426a551dc005 Mon Sep 17 00:00:00 2001 From: zhangjiaping Date: Thu, 3 Jun 2021 15:32:32 +0800 Subject: [PATCH] Feat: #33347 #33346 #33337 --- src/control/search-detail-view.cpp | 15 +++++++++++++-- src/control/search-detail-view.h | 1 + src/input-box.cpp | 11 +++++++++++ src/mainwindow.cpp | 5 ++++- src/res/icons/system-search.symbolic.png | Bin 0 -> 498 bytes src/resource.qrc | 1 + 6 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 src/res/icons/system-search.symbolic.png diff --git a/src/control/search-detail-view.cpp b/src/control/search-detail-view.cpp index 291547f..09bac26 100644 --- a/src/control/search-detail-view.cpp +++ b/src/control/search-detail-view.cpp @@ -502,7 +502,6 @@ void SearchDetailView::initUI() { m_hLine = new QFrame(this); m_hLine->setLineWidth(0); m_hLine->setFixedHeight(1); - m_hLine->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); m_layout->addWidget(m_iconLabel); m_layout->addWidget(m_nameFrame); m_layout->addWidget(m_hLine); @@ -543,7 +542,6 @@ void SearchDetailView::initUI() { m_hLine_2 = new QFrame(this); m_hLine_2->setLineWidth(0); m_hLine_2->setFixedHeight(1); - m_hLine_2->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); m_layout->addWidget(m_detailFrame); m_layout->addWidget(m_hLine_2); @@ -557,6 +555,8 @@ void SearchDetailView::initUI() { m_layout->addStretch(); this->clearLayout(); //初始化时隐藏所有控件 + resetLineColor(); + connect(qApp, &QApplication::paletteChanged, this, &SearchDetailView::resetLineColor); } /** @@ -566,6 +566,17 @@ void SearchDetailView::refreshIcon() { this->setIcon(m_iconPath); } +void SearchDetailView::resetLineColor() +{ + if (GlobalSettings::getInstance()->getValue(STYLE_NAME_KEY).toString() != "ukui-dark") { + m_hLine->setStyleSheet("QFrame{background: rgba(0,0,0,0.06);}"); + m_hLine_2->setStyleSheet("QFrame{background: rgba(0,0,0,0.06);}"); + } else { + m_hLine->setStyleSheet("QFrame{background: rgba(255,255,255,0.08);}"); + m_hLine_2->setStyleSheet("QFrame{background: rgba(255,255,255,0.08);}"); + } +} + /** * @brief SearchDetailView::setIcon 设置图标区域 * @param path 图标路径或图标名 diff --git a/src/control/search-detail-view.h b/src/control/search-detail-view.h index 0d5770a..320f042 100644 --- a/src/control/search-detail-view.h +++ b/src/control/search-detail-view.h @@ -109,6 +109,7 @@ Q_SIGNALS: private Q_SLOTS: void execActions(const int&, const int&, const QString&); void refreshIcon(); + void resetLineColor(); }; //此类用于url拦截 diff --git a/src/input-box.cpp b/src/input-box.cpp index 416c69a..9396de3 100644 --- a/src/input-box.cpp +++ b/src/input-box.cpp @@ -106,6 +106,17 @@ void SearchBarHLayout::initUI() { m_queryWidget->setLayout(queryWidLayout); + if (!QIcon::fromTheme("system-search-symbolic").isNull()) { + QPixmap pixmap(QIcon::fromTheme("system-search-symbolic").pixmap(QSize(20, 20))); + m_queryIcon = new QLabel; + m_queryIcon->setFixedSize(pixmap.size()); + m_queryIcon->setPixmap(pixmap); + } else { + QPixmap pixmap(QIcon(":/res/icons/system-search.symbolic.png").pixmap(QSize(20, 20))); + m_queryIcon = new QLabel; + m_queryIcon->setFixedSize(pixmap.size()); + m_queryIcon->setPixmap(pixmap); + } QPixmap pixmap(QIcon::fromTheme("system-search-symbolic").pixmap(QSize(20, 20))); m_queryIcon = new QLabel; m_queryIcon->setFixedSize(pixmap.size()); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index be9f307..2863b07 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -110,7 +110,10 @@ MainWindow::MainWindow(QWidget *parent) : }); m_sys_tray_icon = new QSystemTrayIcon(this); - m_sys_tray_icon->setIcon(QIcon::fromTheme("system-search-symbolic")); + if (!QIcon::fromTheme("system-search-symbolic").isNull()) + m_sys_tray_icon->setIcon(QIcon::fromTheme("system-search-symbolic")); + else + m_sys_tray_icon->setIcon(QIcon(":/res/icons/system-search.symbolic.png")); m_sys_tray_icon->setToolTip(tr("Global Search")); m_sys_tray_icon->show(); connect(m_sys_tray_icon, &QSystemTrayIcon::activated, this, [ = ](QSystemTrayIcon::ActivationReason reason) { diff --git a/src/res/icons/system-search.symbolic.png b/src/res/icons/system-search.symbolic.png new file mode 100644 index 0000000000000000000000000000000000000000..170e2a2a05297dedb13f5ffb07a5c53f07251503 GIT binary patch literal 498 zcmV=FZ%C=REh%IfoIe zHh^amEi|wnU-1qb*r@`@Fpm@1Q}BHY4{;AahXL%vHO!^euHY#?;ydbSVis+D!cDyD zx0BA`i+F;o7%%a+u#8ol90YJZ1wTKCIq3kF@CeiWjG4bHA68R%j9dLoi@2}+SbFKA zSYXyUnP1vH##SBz*ri47R-R! z)^&$D;7b}0Rs_`XtqAZojm?UHCN_%z8=|+&RtTPndU#d@*b$AZEi!6Y)o?}huC-pK zG0_>9Mfne-OQOh5ml=res/icons/close.svg res/qt-translations/qt_zh_CN.qm res/icons/net-disconnected.svg + res/icons/system-search.symbolic.png