!22 默认窗口增加阴影

Merge pull request !22 from lixueman/openkylin/yangtze
This commit is contained in:
lixueman 2022-10-20 01:21:06 +00:00 committed by Gitee
commit 4b5fd60f62
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
5 changed files with 56 additions and 32 deletions

12
debian/changelog vendored
View File

@ -1,3 +1,15 @@
ukui-menu (3.1.1-ok4~1020) yangtze; urgency=medium
* close-cd #129225【开始菜单】【PC】在列表顶部或底部继续触摸拖动概率性出现图标缺失情况再次滑动显示正常1/10)
-- lixueman <lixueman@kylinos.cn> Thu, 20 Oct 2022 09:11:06 +0800
ukui-menu (3.1.1-ok4~1012) yangtze; urgency=medium
* close-cd #116176 【设计】【开始菜单】【浅色模式】底板缺少描边及阴影
-- lixueman <lixueman@kylinos.cn> Wed, 12 Oct 2022 11:14:50 +0800
ukui-menu (3.1.1-ok4~0920) yangtze; urgency=medium
* 任务:开始菜单工具提示内容优化(收藏&最近 区域),增加路径提示

View File

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

View File

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

View File

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

View File

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