Skip to content

Commit

Permalink
chore: adjust dock ui
Browse files Browse the repository at this point in the history
1.

log: as title
  • Loading branch information
tsic404 committed Jan 31, 2024
1 parent 48cced0 commit ac1632d
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 19 deletions.
2 changes: 1 addition & 1 deletion frame/util/multiscreenworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <QObject>
#include <QFlag>

#define WINDOWMARGIN ((m_displayMode == Dock::Efficient) ? 0 : 10)
#define WINDOWMARGIN ((m_displayMode == Dock::Efficient) ? 0 : 5)
#define ANIMATIONTIME 300
#define FREE_POINT(p) if (p) {\
delete p;\
Expand Down
9 changes: 4 additions & 5 deletions frame/window/traymanagerwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,8 @@ void TrayManagerWindow::resetChildWidgetSize()
int dateTimeHeight = m_appPluginDatetimeWidget->height() - - m.top() - m.bottom() - trayHeight;
m_dateTimeWidget->setFixedSize(dateTimeWidth, dateTimeHeight);
m_systemPluginWidget->setFixedSize(m_systemPluginWidget->suitableSize());
int contentSpace = qMin(MAXDIFF, qMax(((Utils::isDraging() ? height() : (int)m_windowFashionSize) - MINHIGHT), 0)) + MINSPACE;
m_mainLayout->setContentsMargins(contentSpace, contentSpace, contentSpace, contentSpace);
m_mainLayout->setSpacing(contentSpace);
m_mainLayout->setContentsMargins(SINGLEROWSPACE, SINGLEROWSPACE, SINGLEROWSPACE, SINGLEROWSPACE);
m_mainLayout->setSpacing(SINGLEROWSPACE);

// 调整插件和日期窗体的位置显示,这里没有用到布局,是因为在调整任务栏位置的时候,
// 随着布局方向的改变,显示有很大的问题
Expand Down Expand Up @@ -537,8 +536,8 @@ void TrayManagerWindow::paintEvent(QPaintEvent *event)
painter.save();
painter.setRenderHint(QPainter::Antialiasing);
painter.setClipPath(path);
painter.fillRect(rect().adjusted(1, 1, -1, -1), maskColor(102));
painter.setPen(maskColor(110));
painter.fillRect(rect().adjusted(1, 1, -1, -1), maskColor(255 * 0.1));
painter.setPen(maskColor(255 * 0.15));
painter.drawPath(path);
painter.restore();

Expand Down
2 changes: 1 addition & 1 deletion frame/window/windowmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ void WindowManager::onRequestNotifyWindowManager()
}

XcbMisc::instance()->set_strut_partial(static_cast<xcb_window_t>(mainWindow->winId()), orientation,
static_cast<uint>(strut + WINDOWMARGIN * ratio), // 设置窗口与屏幕边缘距离,需要乘缩放
static_cast<uint>(strut - WINDOWMARGIN * ratio), // 设置窗口与屏幕边缘距离,需要乘缩放
static_cast<uint>(strutStart), // 设置任务栏起点坐标(上下为x,左右为y)
static_cast<uint>(strutEnd)); // 设置任务栏终点坐标(上下为x,左右为y)
}
Expand Down
22 changes: 18 additions & 4 deletions plugins/pluginmanager/quicksettingitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include <QFontMetrics>
#include <QPainter>
#include <QStringLiteral>
#include <dguiapplicationhelper.h>
#include <qcolor.h>
#include <qnamespace.h>
#include <qpainterpath.h>

#define ICONWIDTH 24
#define ICONHEIGHT 24
Expand Down Expand Up @@ -93,12 +97,22 @@ void QuickSettingItem::paintEvent(QPaintEvent *e)
painter.setClipPath(path);
// 绘制背景色
QColor backColor(Qt::white);
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::DarkType) {
backColor = Qt::black;
}
backColor.setAlphaF(0.5);
backColor.setAlphaF(0.1);

DPalette dpa = DPaletteHelper::instance()->palette(this);
painter.fillRect(rect(), backColor);

QColor borderColor(Qt::black);
borderColor.setAlphaF(0.2);
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) {
borderColor = QColor(Qt::white);
borderColor.setAlphaF(0.15);
}

painter.save();
painter.setPen(borderColor);
painter.drawRoundedRect(rect(), RADIUS, RADIUS);
painter.restore();
}

QColor QuickSettingItem::foregroundColor() const
Expand Down
3 changes: 2 additions & 1 deletion plugins/pluginmanager/standardquickitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ QWidget *StandardQuickItem::iconWidget(QWidget *parent)
layout->setAlignment(Qt::AlignVCenter);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addSpacing(6);
QLabel *imageLabel = new QLabel(widget);
imageLabel->setObjectName("imageLabel");
imageLabel->setFixedHeight(ICONHEIGHT);
Expand All @@ -113,7 +114,7 @@ QWidget *StandardQuickItem::iconWidget(QWidget *parent)
labelText->setFixedWidth(70);
updatePluginName(labelText);
layout->addWidget(imageLabel);
layout->addSpacing(7);
layout->addSpacing(4);
layout->addWidget(labelText);
}

Expand Down
41 changes: 34 additions & 7 deletions widgets/slidercontainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <QMouseEvent>
#include <QGridLayout>
#include <QLabel>
#include <dguiapplicationhelper.h>

DWIDGET_USE_NAMESPACE

Expand All @@ -24,6 +25,7 @@ class SliderIconWidget : public QWidget
: QWidget(parent)
, m_iconSize(QSize(24, 24))
, m_shadowSize(QSize())
, m_isEnter(false)
{}

void updateData(const QIcon &icon, const QSize &iconSize, const QSize &shadowSize)
Expand All @@ -40,13 +42,28 @@ class SliderIconWidget : public QWidget
update();
}

void enterEvent(QEvent *event) override
{
m_isEnter = true;
QWidget::enterEvent(event);
update();
}

void leaveEvent(QEvent *event) override
{
m_isEnter = false;
QWidget::leaveEvent(event);
update();
}

protected:
void paintEvent(QPaintEvent *e) override;

private:
QIcon m_icon;
QSize m_iconSize;
QSize m_shadowSize;
bool m_isEnter;
};

void SliderIconWidget::paintEvent(QPaintEvent *e)
Expand All @@ -60,8 +77,12 @@ void SliderIconWidget::paintEvent(QPaintEvent *e)
// 绘制圆形背景
painter.setPen(Qt::NoPen);
// 获取阴影部分背景颜色
DPalette dpa = DPaletteHelper::instance()->palette(this);
painter.setBrush(dpa.brush(DPalette::ColorRole::Midlight));
QColor backColor = (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType ? Qt::black : Qt::white);
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType)
backColor.setAlphaF(m_isEnter ? 0.2 : 0.1);
else
backColor.setAlphaF(m_isEnter ? 0.1 : 0.2);
painter.setBrush(backColor);
int x = (rect().width() - m_shadowSize.width() ) / 2;
int y = (rect().height() - m_shadowSize.height() ) / 2;
painter.drawEllipse(QRect(x, y, m_shadowSize.width(), m_shadowSize.height()));
Expand Down Expand Up @@ -270,23 +291,29 @@ void SliderProxyStyle::drawRoundSlider(QPainter *painter, QRect rectGroove, QRec
QColor color = wigdet->isEnabled() ? (DGuiApplicationHelper::DarkType == DGuiApplicationHelper::instance()->themeType() ? Qt::white : Qt::black) : Qt::gray;
// 此处中绘制圆形滑动条,需要绘制圆角,圆角大小为其高度的一半
int radius = rectGroove.height() / 2;

// 此处绘制滑条的全长
QBrush allBrush(QColor(190,190,190));
QColor allBrush = (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::LightType ? Qt::black : Qt::white);
allBrush.setAlphaF( 0.15);

QPainterPath allPathGroove;
allPathGroove.addRoundedRect(rectGroove, radius, radius);
painter->fillPath(allPathGroove, allBrush);

// 已经滑动过的区域
QBrush brush(color);
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::ColorType::DarkType) {
color.setAlphaF(0.6);
}

QPainterPath pathGroove;
int handleSize = qMin(rectHandle.width(), rectHandle.height());
rectGroove.setWidth(rectHandle.x() + (rectHandle.width() - handleSize) / 2);
pathGroove.addRoundedRect(rectGroove, radius, radius);
painter->fillPath(pathGroove, brush);
painter->fillPath(pathGroove, color);

// 绘制滑块,因为滑块是正圆形,而它本来的区域是一个长方形区域,因此,需要计算当前
// 区域的正中心区域,将其作为一个正方形区域来绘制圆形滑块
color.setAlphaF(1.0);
int x = rectHandle.x() + (rectHandle.width() - handleSize) / 2;
int y = rectHandle.y() + (rectHandle.height() - handleSize) / 2;
rectHandle.setX(x);
Expand All @@ -296,5 +323,5 @@ void SliderProxyStyle::drawRoundSlider(QPainter *painter, QRect rectGroove, QRec

QPainterPath pathHandle;
pathHandle.addEllipse(rectHandle);
painter->fillPath(pathHandle, brush);
painter->fillPath(pathHandle, color);
}

0 comments on commit ac1632d

Please sign in to comment.