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 "UI/base/xatom-helper.h"
#include "ukuistylehelper/ukuistylehelper.h" #include "ukuistylehelper/ukuistylehelper.h"
#include "windowmanager/windowmanager.h" #include "windowmanager/windowmanager.h"
#include "kwindoweffects.h"
#include <KWindowEffects>
#include "UI/globalsignal.h" #include "UI/globalsignal.h"
#include "UIControl/global/global.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) 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.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS;
hintt.functions = MWM_FUNC_ALL; hintt.functions = MWM_FUNC_ALL;
hintt.decorations = MWM_DECOR_BORDER; hintt.decorations = MWM_DECOR_BORDER;
KWindowEffects::enableBlurBehind(this->winId(), true); //毛玻璃
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hintt); XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hintt);
MotifWmHints hints; MotifWmHints hints;
@ -773,14 +790,14 @@ void Widget::initGSettings()//初始化GSettings
if (QGSettings::isSchemaInstalled(FITCONTROLTRANS)) { if (QGSettings::isSchemaInstalled(FITCONTROLTRANS)) {
m_transparencyGSettings = new QGSettings(FITCONTROLTRANS); m_transparencyGSettings = new QGSettings(FITCONTROLTRANS);
} }
// if (m_transparencyGSettings != nullptr) { if (m_transparencyGSettings != nullptr) {
// connect(m_transparencyGSettings, &QGSettings::changed, this, [=](const QString &key) { connect(m_transparencyGSettings, &QGSettings::changed, this, [=](const QString &key) {
// if (key == "transparency") { if (key == "transparency") {
// transparencyChange(); transparencyChange();
// } }
// }); });
// transparencyChange(); transparencyChange();
// } }
if(QGSettings::isSchemaInstalled(FITTHEMEWINDOWS)) if(QGSettings::isSchemaInstalled(FITTHEMEWINDOWS))
@ -935,8 +952,8 @@ void Widget::paintEvent(QPaintEvent *event)
void Widget::transparencyChange() void Widget::transparencyChange()
{ {
// m_transparency = m_transparencyGSettings->get("transparency").toDouble() * 255; m_transparency = m_transparencyGSettings->get("transparency").toDouble() * 255;
// this->update(); this->update();
} }
//键盘F1响应唤出用户手册 //键盘F1响应唤出用户手册

View File

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

View File

@ -2,8 +2,10 @@
#include <QDebug> #include <QDebug>
#include <QGSettings> #include <QGSettings>
#include <QStyleOption> #include <QStyleOption>
#include <QPainterPath>
#include <QPainter> #include <QPainter>
#include "kwindoweffects.h"
#include "UI/base/widgetstyle.h"
#define PERSONALSIE_SCHEMA "org.ukui.control-center.personalise" #define PERSONALSIE_SCHEMA "org.ukui.control-center.personalise"
#define PERSONALSIE_TRAN_KEY "transparency" #define PERSONALSIE_TRAN_KEY "transparency"
#define CONTAIN_PERSONALSIE_TRAN_KEY "transparency" #define CONTAIN_PERSONALSIE_TRAN_KEY "transparency"
@ -11,6 +13,7 @@
LeftsiderbarWidget::LeftsiderbarWidget(QWidget *parent) LeftsiderbarWidget::LeftsiderbarWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
QGSettings *personalQgsettings = nullptr; QGSettings *personalQgsettings = nullptr;
if (QGSettings::isSchemaInstalled(PERSONALSIE_SCHEMA)) { if (QGSettings::isSchemaInstalled(PERSONALSIE_SCHEMA)) {
personalQgsettings = new QGSettings(PERSONALSIE_SCHEMA, QByteArray(), this); personalQgsettings = new QGSettings(PERSONALSIE_SCHEMA, QByteArray(), this);
@ -35,17 +38,35 @@ LeftsiderbarWidget::~LeftsiderbarWidget()
void LeftsiderbarWidget::paintEvent(QPaintEvent *event) void LeftsiderbarWidget::paintEvent(QPaintEvent *event)
{ {
QStyleOption opt;
opt.init(this);
QPainter p(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); p.setPen(Qt::NoPen);
QColor color = palette().color(QPalette::Window); QColor color = palette().color(QPalette::Window);
color.setAlpha(transparency); color.setAlpha(transparency);
QPalette pal(this->palette()); 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); 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); QBrush brush =QBrush(color);
p.setBrush(brush); p.setBrush(brush);
p.drawRoundedRect(opt.rect,0,0); p.drawRoundedRect(opt.rect,0,0);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
QWidget::paintEvent(event);
} }

View File

@ -44,7 +44,7 @@ void SideBarWidget::initAddButton()
void SideBarWidget::initWidget() void SideBarWidget::initWidget()
{ {
this->setProperty("useSystemStyleBlur", true); this->setProperty("useSystemStyleBlur", true);
this->setAttribute(Qt::WA_TranslucentBackground, true); // this->setAttribute(Qt::WA_TranslucentBackground, true);
//侧边栏界面样式 //侧边栏界面样式
QVBoxLayout *mainLayout = new QVBoxLayout(); 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 kylin-music (1.1.0.47-ok6~0730) yangtze; urgency=medium
* [BUG] * [BUG]