Fixed that the add button has no hovering effect.

This commit is contained in:
baijunjie 2021-11-29 15:02:45 +08:00 committed by iaom
parent 9692ba6ca6
commit cbc58b02df
2 changed files with 6 additions and 8 deletions

View File

@ -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()

View File

@ -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;