close-cd: #I7DCAO 【设计走查】侧边栏UI问题

This commit is contained in:
liujiayang 2023-08-30 09:48:04 +08:00
parent e47b2c6df3
commit 929f52a42e
5 changed files with 64 additions and 16 deletions

View File

@ -4,6 +4,8 @@
#include "UI/base/xatom-helper.h"
#include "ukuistylehelper/ukuistylehelper.h"
#include "windowmanager/windowmanager.h"
#include "kwindoweffects.h"
#include <KWindowEffects>
#include "UI/globalsignal.h"
#include "UIControl/global/global.h"
@ -270,6 +272,20 @@ void Widget::slotPrepareForSwitchuser()
}
}
void Widget::changeEvent(QEvent *event)
{
QWidget::changeEvent(event);
// 主窗口需要先获取焦点,否则按键事件(键盘按下、松开)会捕捉不到
if (historyListTable && historyListTable->isHidden()) {
this->setFocus();
}
if (sideBarWid) {
// fix #160022, 在音乐软件打开进行打开文件等操作,软件侧边栏显示异常
sideBarWid->sidecolor();
}
}
int Widget::kylin_music_play_request(QString cmd1, QString cmd2, QString cmd3)
{
//无参数,单例触发
@ -640,6 +656,7 @@ void Widget::initAllComponent()
hintt.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS;
hintt.functions = MWM_FUNC_ALL;
hintt.decorations = MWM_DECOR_BORDER;
KWindowEffects::enableBlurBehind(this->winId(), true); //毛玻璃
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hintt);
MotifWmHints hints;
@ -773,14 +790,14 @@ void Widget::initGSettings()//初始化GSettings
if (QGSettings::isSchemaInstalled(FITCONTROLTRANS)) {
m_transparencyGSettings = new QGSettings(FITCONTROLTRANS);
}
// if (m_transparencyGSettings != nullptr) {
// connect(m_transparencyGSettings, &QGSettings::changed, this, [=](const QString &key) {
// if (key == "transparency") {
// transparencyChange();
// }
// });
// transparencyChange();
// }
if (m_transparencyGSettings != nullptr) {
connect(m_transparencyGSettings, &QGSettings::changed, this, [=](const QString &key) {
if (key == "transparency") {
transparencyChange();
}
});
transparencyChange();
}
if(QGSettings::isSchemaInstalled(FITTHEMEWINDOWS))
@ -935,8 +952,8 @@ void Widget::paintEvent(QPaintEvent *event)
void Widget::transparencyChange()
{
// m_transparency = m_transparencyGSettings->get("transparency").toDouble() * 255;
// this->update();
m_transparency = m_transparencyGSettings->get("transparency").toDouble() * 255;
this->update();
}
//键盘F1响应唤出用户手册

View File

@ -131,6 +131,7 @@ private Q_SLOTS:
void inputDevice_get(QString str);
void slotPrepareForSwitchuser();
protected:
void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;

View File

@ -2,8 +2,10 @@
#include <QDebug>
#include <QGSettings>
#include <QStyleOption>
#include <QPainterPath>
#include <QPainter>
#include "kwindoweffects.h"
#include "UI/base/widgetstyle.h"
#define PERSONALSIE_SCHEMA "org.ukui.control-center.personalise"
#define PERSONALSIE_TRAN_KEY "transparency"
#define CONTAIN_PERSONALSIE_TRAN_KEY "transparency"
@ -11,6 +13,7 @@
LeftsiderbarWidget::LeftsiderbarWidget(QWidget *parent)
: QWidget(parent)
{
QGSettings *personalQgsettings = nullptr;
if (QGSettings::isSchemaInstalled(PERSONALSIE_SCHEMA)) {
personalQgsettings = new QGSettings(PERSONALSIE_SCHEMA, QByteArray(), this);
@ -35,17 +38,35 @@ LeftsiderbarWidget::~LeftsiderbarWidget()
void LeftsiderbarWidget::paintEvent(QPaintEvent *event)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿
QPainterPath rectPath;
rectPath.addRoundedRect(this->rect(), 0, 0);
/* 开启背景模糊效果毛玻璃可以使用主题的QMe */
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(rectPath.toFillPolygon().toPolygon()));
p.setPen(Qt::NoPen);
QColor color = palette().color(QPalette::Window);
color.setAlpha(transparency);
QPalette pal(this->palette());
pal.setColor(QPalette::Window,QColor(color));
if(WidgetStyle::themeColor == 1 ){
pal.setColor(QPalette::Window,QColor(38, 38, 38, 0));
this->setPalette(pal);
}else if(WidgetStyle::themeColor == 0){
pal.setColor(QPalette::Window,QColor(255, 255, 255, 0));
this->setPalette(pal);
}
QStyleOption opt;
opt.init(this);
QBrush brush =QBrush(color);
p.setBrush(brush);
p.drawRoundedRect(opt.rect,0,0);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(event);
}

View File

@ -44,7 +44,7 @@ void SideBarWidget::initAddButton()
void SideBarWidget::initWidget()
{
this->setProperty("useSystemStyleBlur", true);
this->setAttribute(Qt::WA_TranslucentBackground, true);
// this->setAttribute(Qt::WA_TranslucentBackground, true);
//侧边栏界面样式
QVBoxLayout *mainLayout = new QVBoxLayout();

9
debian/changelog vendored
View File

@ -1,3 +1,12 @@
kylin-music (1.1.0.47-ok6~0731) yangtze; urgency=medium
* [BUG]
- close-cd: #I7DCAO 【设计走查】侧边栏UI问题
* 其他: 无
-- liujiayang <liujiayang@kylinos.cn> Mon, 30 Wed 2023 09:22:17 +0800
kylin-music (1.1.0.47-ok6~0730) yangtze; urgency=medium
* [BUG]