From cbc58b02df1646db3bd501400a10270938531a48 Mon Sep 17 00:00:00 2001 From: baijunjie Date: Mon, 29 Nov 2021 15:02:45 +0800 Subject: [PATCH] Fixed that the add button has no hovering effect. --- search-ukcc-plugin/search.cpp | 12 +++++------- search-ukcc-plugin/search.h | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/search-ukcc-plugin/search.cpp b/search-ukcc-plugin/search.cpp index c0a0ada..6934579 100644 --- a/search-ukcc-plugin/search.cpp +++ b/search-ukcc-plugin/search.cpp @@ -200,17 +200,13 @@ void Search::initUi() m_blockDirsLyt->setContentsMargins(0, 0, 0, 0); m_blockDirsLyt->setSpacing(2); - QFrame * m_addBlockDirFrame = new QFrame(m_blockDirsFrame); m_addBlockDirFrame->setFrameShape(QFrame::Shape::NoFrame); m_addBlockDirFrame->setFixedHeight(60); - - - m_addBlockDirWidget = new HoverWidget("", m_addBlockDirFrame); + m_addBlockDirWidget = new QPushButton(m_addBlockDirFrame); m_addBlockDirWidget->setFixedHeight(60); - // m_addBlockDirWidget->setObjectName("addBlockDirWidget"); // QPalette pal; // QBrush brush = pal.highlight(); //获取window的色值 @@ -225,6 +221,8 @@ void Search::initUi() // HoverWidget:hover:!pressed#addBlockDirWidget{background: %1; \ // border-radius: 4px;}").arg(stringColor)); + m_addBlockDirWidget->setProperty("useButtonPalette", true); + m_addBlockDirWidget->setStyleSheet("QPushButton:!checked{background: palette(base);}"); m_addBlockDirIcon = new QLabel(m_addBlockDirWidget); m_addBlockDirIcon->setPixmap(QIcon("/usr/share/ukui-search/search-ukcc-plugin/image/add.svg").pixmap(12, 12)); @@ -248,7 +246,7 @@ void Search::initUi() m_mainLyt->addWidget(m_blockDirDescLabel); m_mainLyt->addWidget(m_blockDirsFrame); m_mainLyt->addStretch(); - m_mainLyt->setContentsMargins(0, 0, 40, 0); + m_mainLyt->setContentsMargins(0, 0, 0, 0); } /** @@ -390,7 +388,7 @@ void Search::removeBlockDirFromList(const QString &path) void Search::setupConnection() { - connect(m_addBlockDirWidget, &HoverWidget::widgetClicked, this, &Search::onBtnAddFolderClicked); + connect(m_addBlockDirWidget, &QPushButton::clicked, this, &Search::onBtnAddFolderClicked); } void Search::onBtnAddFolderClicked() diff --git a/search-ukcc-plugin/search.h b/search-ukcc-plugin/search.h index 6792a09..7efdd0a 100644 --- a/search-ukcc-plugin/search.h +++ b/search-ukcc-plugin/search.h @@ -86,7 +86,7 @@ private: QLabel * m_blockDirDescLabel = nullptr; QFrame * m_blockDirsFrame = nullptr; QVBoxLayout * m_blockDirsLyt = nullptr; - HoverWidget * m_addBlockDirWidget = nullptr; + QPushButton * m_addBlockDirWidget = nullptr; QLabel * m_addBlockDirIcon = nullptr; QLabel * m_addBlockDirLabel = nullptr; QHBoxLayout * m_addBlockDirLyt = nullptr;