修复菜单按钮hover样式异常

This commit is contained in:
peijiankang 2022-06-29 10:57:08 +08:00
parent 7d51c4fdd2
commit 693d7f4ade
2 changed files with 87 additions and 1 deletions

View File

@ -0,0 +1,81 @@
From dc3c07f95c6e8c87f184afb5ac45ec52b38579a8 Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Wed, 29 Jun 2022 10:43:03 +0800
Subject: [PATCH] Repair menu button hover style exception
---
src/leftupsearchbox.cpp | 9 +++------
src/menumodule.cpp | 10 +++++++++-
src/menumodule.h | 1 +
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/leftupsearchbox.cpp b/src/leftupsearchbox.cpp
index 5412056..6e2a95e 100644
--- a/src/leftupsearchbox.cpp
+++ b/src/leftupsearchbox.cpp
@@ -87,18 +87,15 @@ bool LeftUpSearchBox::event(QEvent *e){
switch(k->key()){
case Qt::Key_Up:{
emit lineEditKeyEvent("up");
-// return true;
- break;
+ break;
}
case Qt::Key_Down:{
emit lineEditKeyEvent("down");
- // return true;
- break;
+ break;
}
case Qt::Key_Return:{
emit lineEditKeyEvent("enter");
- // return true;
- break;
+ break;
}
}
}
diff --git a/src/menumodule.cpp b/src/menumodule.cpp
index 39d8a8d..3e83462 100644
--- a/src/menumodule.cpp
+++ b/src/menumodule.cpp
@@ -14,7 +14,9 @@ void menuModule::initAction(){
iconSize = QSize(30,30);
menuButton = new QPushButton;
menuButton->setIcon(QIcon::fromTheme("application-menu"));
+ menuButton->setFlat(true);
menuButton->setFixedSize(iconSize);
+
m_menu = new QMenu();
addCityAction = new AddCityAction(m_menu);
QList<QAction *> actions ;
@@ -249,7 +251,13 @@ QVBoxLayout* menuModule::initBody(){
}
void menuModule::setStyle(){
- menuButton->setStyleSheet("QPushButton::menu-indicator{image:None;}");
+ //menuButton->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;}"
+ // "QPushButton:Hover{border:0px;border-radius:4px;background:transparent;background-color:rgba(0,0,0,0.1);}"
+ // "QPushButton:Pressed{border:0px;border-radius:4px;background:transparent;background-color:rgba(0,0,0,0.15);}");
+ menuButton->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;}"
+ "QPushButton:Hover{border:0px;border-radius:4px;background:transparent;background-color:rgba(0,0,0,0.1);}"
+ "QPushButton:Pressed{border:0px;border-radius:4px;background:transparent;background-color:rgba(0,0,0,0.15);}"
+ "QPushButton::menu-indicator{image:None;}");
}
void menuModule::initGsetting(){
diff --git a/src/menumodule.h b/src/menumodule.h
index 480443b..d3a8717 100644
--- a/src/menumodule.h
+++ b/src/menumodule.h
@@ -9,6 +9,7 @@
#include <QWidget>
#include <QMenu>
#include <QPushButton>
+#include <QToolButton>
#include <QDebug>
#include <QString>
#include <QLabel>
--
2.33.0

View File

@ -1,7 +1,7 @@
%define debug_package %{nil}
Name: indicator-china-weather
Version: 3.1.0
Release: 13
Release: 14
Summary: The weather data are from the heweather API s6 version.
License: GPL-3.0+
URL: https://github.com/UbuntuKylin/indicator-china-weather
@ -28,6 +28,7 @@ patch3: 0003-add-X-UKUI-AutoRestart-filed-in-desktop.patch
patch4: 0004-update-translation-file.patch
patch5: 0005-Increase-the-drag-bar-of-forecast-part.patch
patch6: 0006-Hide-tray-icon-in-case-of-network-exception.patch
patch7: 0007-Repair-menu-button-hover-style-exception.patch
%description
Indicator that displays China weather information
@ -44,6 +45,7 @@ patch6: 0006-Hide-tray-icon-in-case-of-network-exception.patch
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build
%{qmake_qt5} %{_qt5_qmake_flags} CONFIG+=enable-by-default indicator-china-weather.pro
@ -75,6 +77,9 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/man/man1/indicator-china-weather.1.gz
%changelog
* Wed Jun 29 2022 peijiankang <peijiankang@kylinos.cn> - 3.1.0-14
- 修复菜单按钮hover样式异常
* Wed Jun 29 2022 peijiankang <peijiankang@kylinos.cn> - 3.1.0-13
- 网络异常情况下隐藏托盘icon