ukui-menu/0015-22.patch
peijiankang 3eb98cb553 add patch from openkylin
(cherry picked from commit 49080eb14485c039ea6bdf00f09cff10c0c98c9f)
2023-05-25 10:20:45 +08:00

190 lines
7.7 KiB
Diff

From: lixueman <lixueman@kylinos.cn>
Date: Thu, 20 Oct 2022 01:21:06 +0000
Subject: =?utf-8?b?ITIyIOm7mOiupOeql+WPo+WinuWKoOmYtOW9sSBNZXJnZSBwdWxsIHJl?=
=?utf-8?b?cXVlc3QgITIyIGZyb20gbGl4dWVtYW4vb3Blbmt5bGluL3lhbmd0emU=?=
---
src/UserInterface/ListView/listview.cpp | 26 +++++++++++++++++++---
src/UserInterface/ListView/listview.h | 3 ++-
src/UserInterface/Widget/main_view_widget.cpp | 15 ++-----------
src/UserInterface/mainwindow.cpp | 32 ++++++++++++++-------------
4 files changed, 44 insertions(+), 32 deletions(-)
diff --git a/src/UserInterface/ListView/listview.cpp b/src/UserInterface/ListView/listview.cpp
index f781921..89be87b 100755
--- a/src/UserInterface/ListView/listview.cpp
+++ b/src/UserInterface/ListView/listview.cpp
@@ -29,6 +29,7 @@ ListView::ListView(QWidget *parent/*, int width, int height, int module*/):
this->h = 540;
this->module = 1;
initWidget();
+ setAttribute(Qt::WA_AcceptTouchEvents);
m_listmodel = new QStandardItemModel(this);
this->setModel(m_listmodel);
m_ukuiMenuInterface = new UkuiMenuInterface;
@@ -95,6 +96,21 @@ void ListView::updateData(QVector<QStringList> data)
}
}
+bool ListView::event(QEvent *e)
+{
+ switch (e->type()) {
+ case QEvent::TouchBegin:
+ m_scrollbarState = false;
+ break;
+ case QEvent::ChildRemoved:
+ m_scrollbarState = true;
+ break;
+ default:
+ break;
+ }
+ return QListView::event(e);
+}
+
void ListView::onClicked(QModelIndex index)
{
QVariant var = m_listmodel->data(index, Qt::DisplayRole);
@@ -119,14 +135,18 @@ void ListView::onClicked(QModelIndex index)
void ListView::enterEvent(QEvent *e)
{
Q_UNUSED(e);
- this->selectionModel()->clear();
- this->verticalScrollBar()->setVisible(true);
+ if (m_scrollbarState) {
+ this->selectionModel()->clear();
+ verticalScrollBar()->setVisible(true);
+ }
}
void ListView::leaveEvent(QEvent *e)
{
Q_UNUSED(e);
- this->verticalScrollBar()->setVisible(false);
+ if (m_scrollbarState) {
+ verticalScrollBar()->setVisible(false);
+ }
}
void ListView::paintEvent(QPaintEvent *e)
diff --git a/src/UserInterface/ListView/listview.h b/src/UserInterface/ListView/listview.h
index ff39d9b..f9125e8 100755
--- a/src/UserInterface/ListView/listview.h
+++ b/src/UserInterface/ListView/listview.h
@@ -49,11 +49,12 @@ protected:
void leaveEvent(QEvent *e) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent *e) override;
void keyPressEvent(QKeyEvent *e);
-
+ bool event(QEvent *e);
private:
int w = 0;
int h = 0;
int m_preRowCount;
+ bool m_scrollbarState = true;
private Q_SLOTS:
diff --git a/src/UserInterface/Widget/main_view_widget.cpp b/src/UserInterface/Widget/main_view_widget.cpp
index c459745..c53fc53 100755
--- a/src/UserInterface/Widget/main_view_widget.cpp
+++ b/src/UserInterface/Widget/main_view_widget.cpp
@@ -54,23 +54,12 @@ void MainViewWidget::styleChangeSlot(const QString &style)
void MainViewWidget::paintEvent(QPaintEvent *event)
{
-// double transparency = getTransparency();
- QRect rect = this->rect();
+ QRect rect = this->rect().adjusted(5, 5, 0, -5);
QPainterPath path;
QPainter painter(this);
+ path.addRoundedRect(rect, 10, 10);
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
painter.setPen(Qt::transparent);
- qreal radius = 10;
- path.moveTo(rect.topRight() - QPointF(radius, 0));
- path.lineTo(rect.topLeft() + QPointF(radius, 0));
- path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius));
- path.lineTo(rect.bottomLeft() + QPointF(0, -radius));
- path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0));
- path.lineTo(rect.bottomRight() - QPointF(radius, 0));
- path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius));
- path.lineTo(rect.topRight() + QPointF(0, radius));
- path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0));
- painter.setPen(Qt::transparent);
painter.setOpacity(0.58);
painter.fillPath(path, m_backColor);
QWidget::paintEvent(event);
diff --git a/src/UserInterface/mainwindow.cpp b/src/UserInterface/mainwindow.cpp
index 53451fd..0c07b15 100755
--- a/src/UserInterface/mainwindow.cpp
+++ b/src/UserInterface/mainwindow.cpp
@@ -674,27 +674,29 @@ void MainWindow::paintEvent(QPaintEvent *event)
if ( transparency == 1) {
curColor.setAlpha(255);
}
- QRect rect = this->rect();
+ QRect rect = this->rect().adjusted(5, 5, -5, -5);
QPainterPath path;
- // rect.setTopLeft(QPoint(rect.x()+320,rect.y()));
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
+ painter.save();
painter.setPen(Qt::transparent);
- qreal radius = 10;
- path.moveTo(rect.topRight() - QPointF(radius, 0));
- path.lineTo(rect.topLeft() + QPointF(radius, 0));
- path.quadTo(rect.topLeft(), rect.topLeft() + QPointF(0, radius));
- path.lineTo(rect.bottomLeft() + QPointF(0, -radius));
- path.quadTo(rect.bottomLeft(), rect.bottomLeft() + QPointF(radius, 0));
- path.lineTo(rect.bottomRight() - QPointF(radius, 0));
- path.quadTo(rect.bottomRight(), rect.bottomRight() + QPointF(0, -radius));
- path.lineTo(rect.topRight() + QPointF(0, radius));
- path.quadTo(rect.topRight(), rect.topRight() + QPointF(-radius, -0));
+ path.addRoundedRect(rect, 10, 10);
painter.setBrush(curColor);
painter.setPen(Qt::transparent);
painter.setOpacity(transparency);
painter.drawPath(path);
+ painter.restore();
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
+ QColor color = Qt::black;
+ painter.save();
+ for (int i = 0; i < 7; i++) {
+ rect = this->rect().adjusted(i, i, - i, - i);
+ color.setAlpha(i * 6);
+ painter.setBrush(Qt::NoBrush);
+ painter.setPen(QPen(color, 1));
+ painter.drawRoundedRect(rect, 10, 10);
+ }
+ painter.restore();
QMainWindow::paintEvent(event);
}
/**
@@ -1276,7 +1278,7 @@ void MainWindow::on_minMaxChangeButton_clicked()
m_maxAnimation->setDuration(1);
} else {
m_animationPage->show();
- m_animationPage->setGeometry(this->x(), this->y(), Style::m_minw, Style::m_minh);
+ m_animationPage->setGeometry(this->x() + 5, this->y() + 5, Style::m_minw - 10, Style::m_minh - 10);
m_animationPage->raise();
m_animationPage->repaint();
m_maxAnimation->setDuration(260);
@@ -1287,7 +1289,7 @@ void MainWindow::on_minMaxChangeButton_clicked()
loop.exec();
m_maxAnimation->setEasingCurve(QEasingCurve::OutExpo);
// m_maxAnimation->setStartValue(QRect(Style::m_primaryScreenX, Style::m_primaryScreenY + Style::m_availableScreenHeight - Style::minh, Style::minw, Style::minh));
- m_maxAnimation->setStartValue(QRect(this->x(), this->y(), Style::m_minw, Style::m_minh));
+ m_maxAnimation->setStartValue(QRect(this->x() + 5, this->y() + 5, Style::m_minw - 10, Style::m_minh - 10));
m_maxAnimation->setEndValue(QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight));
m_maxAnimation->start(QAbstractAnimation::DeleteWhenStopped);
@@ -1410,7 +1412,7 @@ void MainWindow::showNormalWindowSlot()
m_isFullScreen = false;
m_minAnimation->setEasingCurve(QEasingCurve::OutExpo);
m_minAnimation->setStartValue(QRect(0, 0, Style::m_availableScreenWidth, Style::m_availableScreenHeight));
- m_minAnimation->setEndValue(QRect(this->x(), this->y(), Style::m_minw, Style::m_minh));
+ m_minAnimation->setEndValue(QRect(this->x() + 5, this->y() + 5, Style::m_minw - 10, Style::m_minh - 10));
m_minAnimation->start(QAbstractAnimation::DeleteWhenStopped);
m_fullWindow->hide();