mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 修复托盘和快捷设置区域行数变化的时候边框显示问题
1.在单行和多行的时候分别获取圆角区域并显示 2.在任务栏调整大小的时候,圆角大小根据实际情况动态计算生成 Log: 优化界面显示 Influence: 任务栏拖动改变大小,查看单行和多行的显示效果 Task: https://pms.uniontech.com/task-view-112073.html Change-Id: I2f595bb8304c23e95672d953bd53d6d74072ed7b
This commit is contained in:
parent
73ad24a682
commit
b1143e91ce
@ -59,6 +59,12 @@
|
|||||||
#define PLUGIN_MAX_SIZE 40
|
#define PLUGIN_MAX_SIZE 40
|
||||||
#define PLUGIN_MIN_SIZE 20
|
#define PLUGIN_MIN_SIZE 20
|
||||||
#define DESKTOP_SIZE 10
|
#define DESKTOP_SIZE 10
|
||||||
|
// 任务栏圆角最小的时候,任务栏的高度值
|
||||||
|
#define MINRADIUSSIZE 46
|
||||||
|
// 任务栏圆角最小值和最大值的差值
|
||||||
|
#define MAXDIFFVALUE 6
|
||||||
|
// 最小圆角值
|
||||||
|
#define MINRADIUS 12
|
||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
@ -352,6 +358,14 @@ void MainPanelControl::resizeEvent(QResizeEvent *event)
|
|||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
resizeDesktopWidget();
|
resizeDesktopWidget();
|
||||||
resizeDockIcon();
|
resizeDockIcon();
|
||||||
|
resetRadius();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainPanelControl::resetRadius()
|
||||||
|
{
|
||||||
|
int size = ((m_position == Dock::Position::Top || m_position == Dock::Position::Bottom) ? height() : width());
|
||||||
|
int radius = qMin(MAXDIFFVALUE, qMax(size - MINRADIUSSIZE, 0)) + MINRADIUS;
|
||||||
|
qApp->setProperty("EffectBorderRadius", radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**根据任务栏所在位置, 设置应用区域控件的大小
|
/**根据任务栏所在位置, 设置应用区域控件的大小
|
||||||
@ -975,11 +989,19 @@ QPainterPath MainPanelControl::areaPath()
|
|||||||
if (m_dislayMode == DisplayMode::Efficient)
|
if (m_dislayMode == DisplayMode::Efficient)
|
||||||
return QPainterPath();
|
return QPainterPath();
|
||||||
|
|
||||||
|
int radius = qApp->property("EffectBorderRadius").toInt();
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
int leftWidth = m_fixedAreaWidget->width() + m_fixedSpliter->width() + m_appAreaWidget->width();
|
if (m_position == Dock::Position::Top || m_position == Dock::Position::Bottom) {
|
||||||
int roundHeight = height();
|
int leftWidth = m_fixedAreaWidget->width() + m_fixedSpliter->width() + m_appAreaWidget->width();
|
||||||
path.addRoundedRect(QRect(0, 0, leftWidth, roundHeight), 18, 18);
|
int roundHeight = height();
|
||||||
path.addRoundedRect(QRect(m_trayManagerWidget->x(), 0, m_trayManagerWidget->width(), roundHeight), 18, 18);
|
path.addRoundedRect(QRect(0, 0, leftWidth, roundHeight), radius, radius);
|
||||||
|
path.addRoundedRect(QRect(m_trayManagerWidget->x(), 0, m_trayManagerWidget->width(), roundHeight), radius, radius);
|
||||||
|
} else {
|
||||||
|
int roundWidth = width();
|
||||||
|
int topHeight = m_fixedAreaWidget->height() + m_fixedSpliter->height() + m_appAreaWidget->height();
|
||||||
|
path.addRoundedRect(QRect(0, 0, roundWidth, topHeight), radius, radius);
|
||||||
|
path.addRoundedRect(QRect(0, m_trayManagerWidget->y(), roundWidth, m_trayManagerWidget->height()), radius, radius);
|
||||||
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,8 @@ private:
|
|||||||
void resizeDesktopWidget();
|
void resizeDesktopWidget();
|
||||||
bool checkNeedShowDesktop();
|
bool checkNeedShowDesktop();
|
||||||
bool appIsOnDock(const QString &appDesktop);
|
bool appIsOnDock(const QString &appDesktop);
|
||||||
|
void resetRadius();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void dragMoveEvent(QDragMoveEvent *e) override;
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||||
void dragEnterEvent(QDragEnterEvent *e) override;
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
||||||
|
@ -253,6 +253,7 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
|||||||
// 任务栏大小、位置、模式改变都会触发resize,发射大小改变信号,供依赖项目更新位置
|
// 任务栏大小、位置、模式改变都会触发resize,发射大小改变信号,供依赖项目更新位置
|
||||||
Q_EMIT panelGeometryChanged();
|
Q_EMIT panelGeometryChanged();
|
||||||
|
|
||||||
|
setMaskPath(m_mainPanel->areaPath());
|
||||||
m_mainPanel->updatePluginsLayout();
|
m_mainPanel->updatePluginsLayout();
|
||||||
m_shadowMaskOptimizeTimer->start();
|
m_shadowMaskOptimizeTimer->start();
|
||||||
|
|
||||||
@ -380,7 +381,11 @@ void MainWindow::adjustShadowMask()
|
|||||||
DPlatformTheme *theme = DGuiApplicationHelper::instance()->systemTheme();
|
DPlatformTheme *theme = DGuiApplicationHelper::instance()->systemTheme();
|
||||||
radius = theme->windowRadius(radius);
|
radius = theme->windowRadius(radius);
|
||||||
} else {
|
} else {
|
||||||
radius = dstyle.pixelMetric(DStyle::PM_TopLevelWindowRadius);
|
QVariant vRadius = qApp->property("EffectBorderRadius");
|
||||||
|
if (vRadius.isNull())
|
||||||
|
radius = dstyle.pixelMetric(DStyle::PM_TopLevelWindowRadius);
|
||||||
|
else
|
||||||
|
radius = vRadius.toInt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define ICONMARGIN 8
|
#define ICONMARGIN 8
|
||||||
|
|
||||||
SystemPluginWindow::SystemPluginWindow(QWidget *parent)
|
SystemPluginWindow::SystemPluginWindow(QWidget *parent)
|
||||||
: DBlurEffectWidget(parent)
|
: QWidget(parent)
|
||||||
, m_pluginController(new FixedPluginController(this))
|
, m_pluginController(new FixedPluginController(this))
|
||||||
, m_listView(new DListView(this))
|
, m_listView(new DListView(this))
|
||||||
, m_position(Dock::Position::Bottom)
|
, m_position(Dock::Position::Bottom)
|
||||||
@ -110,7 +110,7 @@ QSize SystemPluginWindow::suitableSize()
|
|||||||
|
|
||||||
void SystemPluginWindow::resizeEvent(QResizeEvent *event)
|
void SystemPluginWindow::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
DBlurEffectWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
Q_EMIT pluginSizeChanged();
|
Q_EMIT pluginSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "dockpluginscontroller.h"
|
#include "dockpluginscontroller.h"
|
||||||
|
|
||||||
#include <DBlurEffectWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class DockPluginsController;
|
class DockPluginsController;
|
||||||
class PluginsItem;
|
class PluginsItem;
|
||||||
@ -34,7 +34,7 @@ namespace Dtk { namespace Widget { class DListView; } }
|
|||||||
|
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
class SystemPluginWindow : public DBlurEffectWidget
|
class SystemPluginWindow : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -37,13 +37,21 @@
|
|||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QPainterPath>
|
||||||
|
|
||||||
#define MAXFIXEDSIZE 999999
|
#define MAXFIXEDSIZE 999999
|
||||||
#define CRITLCALHEIGHT 56
|
#define CRITLCALHEIGHT 42
|
||||||
|
#define CONTENTSPACE 7
|
||||||
|
// 高度小于等于这个值的时候,间距最小值
|
||||||
|
#define MINHIGHT 46
|
||||||
|
// 最小值与最大值的差值
|
||||||
|
#define MINSPACE 4
|
||||||
|
// 当前高度与最小高度差值大于这个值的时候,间距使用最大值
|
||||||
|
#define MAXDIFF 3
|
||||||
|
|
||||||
TrayManagerWindow::TrayManagerWindow(QWidget *parent)
|
TrayManagerWindow::TrayManagerWindow(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_appPluginDatetimeWidget(new DBlurEffectWidget(this))
|
, m_appPluginDatetimeWidget(new QWidget(this))
|
||||||
, m_systemPluginWidget(new SystemPluginWindow(this))
|
, m_systemPluginWidget(new SystemPluginWindow(this))
|
||||||
, m_appPluginWidget(new QWidget(m_appPluginDatetimeWidget))
|
, m_appPluginWidget(new QWidget(m_appPluginDatetimeWidget))
|
||||||
, m_quickIconWidget(new QuickPluginWindow(m_appPluginWidget))
|
, m_quickIconWidget(new QuickPluginWindow(m_appPluginWidget))
|
||||||
@ -90,8 +98,6 @@ void TrayManagerWindow::setPositon(Dock::Position position)
|
|||||||
m_quickIconWidget->setPositon(position);
|
m_quickIconWidget->setPositon(position);
|
||||||
m_dateTimeWidget->setPositon(position);
|
m_dateTimeWidget->setPositon(position);
|
||||||
m_systemPluginWidget->setPositon(position);
|
m_systemPluginWidget->setPositon(position);
|
||||||
|
|
||||||
QMetaObject::invokeMethod(this, &TrayManagerWindow::resetDirection, Qt::QueuedConnection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TrayManagerWindow::appDatetimeSize()
|
int TrayManagerWindow::appDatetimeSize()
|
||||||
@ -100,10 +106,10 @@ int TrayManagerWindow::appDatetimeSize()
|
|||||||
// 如果是一行
|
// 如果是一行
|
||||||
if (m_appDatetimeLayout->direction() == QBoxLayout::Direction::LeftToRight) {
|
if (m_appDatetimeLayout->direction() == QBoxLayout::Direction::LeftToRight) {
|
||||||
return m_trayView->suitableSize().width() + m_quickIconWidget->suitableSize().width()
|
return m_trayView->suitableSize().width() + m_quickIconWidget->suitableSize().width()
|
||||||
+ m_dateTimeWidget->suitableSize().width();
|
+ m_dateTimeWidget->suitableSize().width() + m_appDatetimeLayout->spacing();
|
||||||
}
|
}
|
||||||
//如果是两行
|
//如果是两行
|
||||||
int topWidth = m_trayView->suitableSize().width() + m_quickIconWidget->width();
|
int topWidth = m_trayView->suitableSize().width() + m_appDatetimeLayout->spacing() + m_quickIconWidget->width();
|
||||||
int bottomWidth = m_dateTimeWidget->suitableSize().width();
|
int bottomWidth = m_dateTimeWidget->suitableSize().width();
|
||||||
return qMax(topWidth, bottomWidth);
|
return qMax(topWidth, bottomWidth);
|
||||||
}
|
}
|
||||||
@ -131,6 +137,37 @@ QSize TrayManagerWindow::suitableSize()
|
|||||||
m.top() + m.bottom());
|
m.top() + m.bottom());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 用于返回需要绘制的圆形区域
|
||||||
|
QPainterPath TrayManagerWindow::roundedPaths()
|
||||||
|
{
|
||||||
|
int topLevelRadius = qApp->property("EffectBorderRadius").toInt();
|
||||||
|
QMargins mainMargin = m_mainLayout->contentsMargins();
|
||||||
|
int radius = topLevelRadius - mainMargin.top();
|
||||||
|
QPainterPath path;
|
||||||
|
if ((m_postion == Dock::Position::Top || m_postion == Dock::Position::Bottom)
|
||||||
|
&& (m_appDatetimeLayout->direction() == QBoxLayout::Direction::LeftToRight)) {
|
||||||
|
// 如果是上下方向,且只有一行
|
||||||
|
// 计算托盘和快捷插件区域
|
||||||
|
QPoint pointPlugin(mainMargin.left(), mainMargin.top());
|
||||||
|
QRect rctPlugin(QPoint(mainMargin.left(), mainMargin.top()), m_appPluginWidget->size());
|
||||||
|
path.addRoundedRect(rctPlugin, radius, radius);
|
||||||
|
|
||||||
|
// 计算日期时间区域
|
||||||
|
QPoint pointDateTime = m_dateTimeWidget->pos();
|
||||||
|
pointDateTime = m_dateTimeWidget->parentWidget()->mapTo(this, pointDateTime);
|
||||||
|
QRect rctDatetime(pointDateTime, m_dateTimeWidget->size());
|
||||||
|
path.addRoundedRect(rctDatetime, radius, radius);
|
||||||
|
// 计算系统插件区域
|
||||||
|
path.addRoundedRect(m_systemPluginWidget->geometry(), radius, radius);
|
||||||
|
} else {
|
||||||
|
// 添加系统插件区域的位置信息
|
||||||
|
path.addRoundedRect(m_appPluginDatetimeWidget->geometry(), radius, radius);
|
||||||
|
path.addRoundedRect(m_systemPluginWidget->geometry(), radius, radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
void TrayManagerWindow::resizeEvent(QResizeEvent *event)
|
void TrayManagerWindow::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
@ -147,7 +184,7 @@ void TrayManagerWindow::initUi()
|
|||||||
m_splitLine->setFixedHeight(1);
|
m_splitLine->setFixedHeight(1);
|
||||||
QPalette pal;
|
QPalette pal;
|
||||||
QColor lineColor(Qt::black);
|
QColor lineColor(Qt::black);
|
||||||
lineColor.setAlpha(static_cast<int>(255 * 0.2));
|
lineColor.setAlpha(static_cast<int>(255 * 0.1));
|
||||||
pal.setColor(QPalette::Background, lineColor);
|
pal.setColor(QPalette::Background, lineColor);
|
||||||
m_splitLine->setAutoFillBackground(true);
|
m_splitLine->setAutoFillBackground(true);
|
||||||
m_splitLine->setPalette(pal);
|
m_splitLine->setPalette(pal);
|
||||||
@ -158,11 +195,6 @@ void TrayManagerWindow::initUi()
|
|||||||
m_trayView->openPersistentEditor(m_model->index(0, 0));
|
m_trayView->openPersistentEditor(m_model->index(0, 0));
|
||||||
|
|
||||||
// 左侧的区域,包括应用托盘插件和下方的日期时间区域
|
// 左侧的区域,包括应用托盘插件和下方的日期时间区域
|
||||||
m_appPluginDatetimeWidget->setBlurRectXRadius(10);
|
|
||||||
m_appPluginDatetimeWidget->setBlurRectYRadius(10);
|
|
||||||
m_appPluginDatetimeWidget->setMaskAlpha(uint8_t(0.1 * 255));
|
|
||||||
m_appPluginDatetimeWidget->installEventFilter(this);
|
|
||||||
|
|
||||||
m_appPluginLayout->setContentsMargins(0, 0, 0, 0);
|
m_appPluginLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
m_appPluginLayout->setSpacing(0);
|
m_appPluginLayout->setSpacing(0);
|
||||||
m_appPluginWidget->setLayout(m_appPluginLayout);
|
m_appPluginWidget->setLayout(m_appPluginLayout);
|
||||||
@ -176,14 +208,10 @@ void TrayManagerWindow::initUi()
|
|||||||
m_appDatetimeLayout->addWidget(m_splitLine);
|
m_appDatetimeLayout->addWidget(m_splitLine);
|
||||||
m_appDatetimeLayout->addWidget(m_dateTimeWidget);
|
m_appDatetimeLayout->addWidget(m_dateTimeWidget);
|
||||||
|
|
||||||
m_systemPluginWidget->setBlurRectXRadius(10);
|
|
||||||
m_systemPluginWidget->setBlurRectYRadius(10);
|
|
||||||
m_systemPluginWidget->installEventFilter(this);
|
|
||||||
m_systemPluginWidget->setMaskAlpha(uint8_t(0.1 * 255));
|
|
||||||
|
|
||||||
setLayout(m_mainLayout);
|
setLayout(m_mainLayout);
|
||||||
m_mainLayout->setContentsMargins(8, 8, 8, 8);
|
// 通用情况下,设置边距和间距都为7
|
||||||
m_mainLayout->setSpacing(7);
|
m_mainLayout->setContentsMargins(CONTENTSPACE, CONTENTSPACE, CONTENTSPACE, CONTENTSPACE);
|
||||||
|
m_mainLayout->setSpacing(CONTENTSPACE);
|
||||||
m_mainLayout->addWidget(m_appPluginDatetimeWidget);
|
m_mainLayout->addWidget(m_appPluginDatetimeWidget);
|
||||||
m_mainLayout->addWidget(m_systemPluginWidget);
|
m_mainLayout->addWidget(m_systemPluginWidget);
|
||||||
}
|
}
|
||||||
@ -252,7 +280,7 @@ void TrayManagerWindow::initConnection()
|
|||||||
m_trayView->installEventFilter(this);
|
m_trayView->installEventFilter(this);
|
||||||
m_quickIconWidget->installEventFilter(this);
|
m_quickIconWidget->installEventFilter(this);
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
QMetaObject::invokeMethod(this, &TrayManagerWindow::resetChildWidgetSize, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, &TrayManagerWindow::resetDirection, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayManagerWindow::resetDirection()
|
void TrayManagerWindow::resetDirection()
|
||||||
@ -265,12 +293,13 @@ void TrayManagerWindow::resetDirection()
|
|||||||
resetChildWidgetSize();
|
resetChildWidgetSize();
|
||||||
// 当尺寸发生变化的时候,通知托盘区域刷新尺寸,让托盘图标始终保持居中显示
|
// 当尺寸发生变化的时候,通知托盘区域刷新尺寸,让托盘图标始终保持居中显示
|
||||||
Q_EMIT m_delegate->sizeHintChanged(m_model->index(0, 0));
|
Q_EMIT m_delegate->sizeHintChanged(m_model->index(0, 0));
|
||||||
|
Q_EMIT sizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrayManagerWindow::showSingleRow()
|
bool TrayManagerWindow::showSingleRow()
|
||||||
{
|
{
|
||||||
if (m_postion == Dock::Position::Top || m_postion == Dock::Position::Bottom)
|
if (m_postion == Dock::Position::Top || m_postion == Dock::Position::Bottom)
|
||||||
return height() < CRITLCALHEIGHT;
|
return topLevelWidget()->height() <= CRITLCALHEIGHT;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -296,14 +325,22 @@ void TrayManagerWindow::resetChildWidgetSize()
|
|||||||
m_quickIconWidget->setFixedSize(m_quickIconWidget->suitableSize().width(), trayHeight);
|
m_quickIconWidget->setFixedSize(m_quickIconWidget->suitableSize().width(), trayHeight);
|
||||||
m_appPluginWidget->setFixedSize(trayWidth + m_quickIconWidget->suitableSize().width(), trayHeight);
|
m_appPluginWidget->setFixedSize(trayWidth + m_quickIconWidget->suitableSize().width(), trayHeight);
|
||||||
m_dateTimeWidget->setFixedSize(m_dateTimeWidget->suitableSize().width(), trayHeight);
|
m_dateTimeWidget->setFixedSize(m_dateTimeWidget->suitableSize().width(), trayHeight);
|
||||||
|
m_mainLayout->setContentsMargins(4, 4, 4 ,4);
|
||||||
|
m_mainLayout->setSpacing(4);
|
||||||
|
m_appDatetimeLayout->setSpacing(4);
|
||||||
} else {
|
} else {
|
||||||
// 多行显示
|
// 多行显示
|
||||||
m_trayView->setFixedSize(trayWidth, QWIDGETSIZE_MAX);
|
m_trayView->setFixedSize(trayWidth, QWIDGETSIZE_MAX);
|
||||||
m_quickIconWidget->setFixedSize(m_quickIconWidget->suitableSize().width(), QWIDGETSIZE_MAX);
|
m_quickIconWidget->setFixedSize(m_quickIconWidget->suitableSize().width(), QWIDGETSIZE_MAX);
|
||||||
m_appPluginWidget->setFixedSize(trayWidth + m_quickIconWidget->suitableSize().width(), QWIDGETSIZE_MAX);
|
m_appPluginWidget->setFixedSize(trayWidth + m_quickIconWidget->suitableSize().width(), m_appPluginDatetimeWidget->height() / 2 + 4);
|
||||||
// 因为是两行,所以对于时间控件的尺寸,只能设置最小值
|
// 因为是两行,所以对于时间控件的尺寸,只能设置最小值
|
||||||
int dateTimeWidth = qMax(m_appPluginWidget->width(), m_dateTimeWidget->suitableSize().width());
|
int dateTimeWidth = qMax(m_appPluginWidget->width(), m_dateTimeWidget->suitableSize().width());
|
||||||
m_dateTimeWidget->setMinimumSize(dateTimeWidth, m_appPluginDatetimeWidget->height() / 2);
|
m_dateTimeWidget->setMinimumSize(dateTimeWidth, QWIDGETSIZE_MAX);
|
||||||
|
|
||||||
|
int contentSpace = qMin(MAXDIFF, qMax(height() - MINHIGHT, 0)) + MINSPACE;
|
||||||
|
m_mainLayout->setContentsMargins(contentSpace, contentSpace, contentSpace, contentSpace);
|
||||||
|
m_appDatetimeLayout->setSpacing(0);
|
||||||
|
m_mainLayout->setSpacing(contentSpace);
|
||||||
}
|
}
|
||||||
m_appPluginDatetimeWidget->setFixedWidth(appDatetimeSize());
|
m_appPluginDatetimeWidget->setFixedWidth(appDatetimeSize());
|
||||||
break;
|
break;
|
||||||
@ -322,6 +359,11 @@ void TrayManagerWindow::resetChildWidgetSize()
|
|||||||
m_dateTimeWidget->setFixedSize(sizeWidth, datetimeHeight);
|
m_dateTimeWidget->setFixedSize(sizeWidth, datetimeHeight);
|
||||||
m_appPluginWidget->setFixedSize(sizeWidth, trayHeight + quickAreaHeight);
|
m_appPluginWidget->setFixedSize(sizeWidth, trayHeight + quickAreaHeight);
|
||||||
m_appPluginDatetimeWidget->setFixedHeight(appDatetimeSize());
|
m_appPluginDatetimeWidget->setFixedHeight(appDatetimeSize());
|
||||||
|
|
||||||
|
int contentSpace = qMin(MAXDIFF, qMax(width() - MINHIGHT, 0)) + MINSPACE;
|
||||||
|
m_mainLayout->setContentsMargins(contentSpace, contentSpace, contentSpace, contentSpace);
|
||||||
|
m_appDatetimeLayout->setSpacing(0);
|
||||||
|
m_mainLayout->setSpacing(contentSpace);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,24 +376,28 @@ void TrayManagerWindow::resetSingleDirection()
|
|||||||
case Dock::Position::Bottom: {
|
case Dock::Position::Bottom: {
|
||||||
m_appPluginLayout->setDirection(QBoxLayout::Direction::LeftToRight);
|
m_appPluginLayout->setDirection(QBoxLayout::Direction::LeftToRight);
|
||||||
// 应用和时间在一行显示
|
// 应用和时间在一行显示
|
||||||
|
m_appDatetimeLayout->setSpacing(10);
|
||||||
m_appDatetimeLayout->setDirection(QBoxLayout::Direction::LeftToRight);
|
m_appDatetimeLayout->setDirection(QBoxLayout::Direction::LeftToRight);
|
||||||
m_mainLayout->setDirection(QBoxLayout::Direction::LeftToRight);
|
m_mainLayout->setDirection(QBoxLayout::Direction::LeftToRight);
|
||||||
|
m_splitLine->hide();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Dock::Position::Left:
|
case Dock::Position::Left:
|
||||||
case Dock::Position::Right:{
|
case Dock::Position::Right:{
|
||||||
|
m_appDatetimeLayout->setSpacing(0);
|
||||||
m_appPluginLayout->setDirection(QBoxLayout::Direction::TopToBottom);
|
m_appPluginLayout->setDirection(QBoxLayout::Direction::TopToBottom);
|
||||||
m_appDatetimeLayout->setDirection(QBoxLayout::Direction::TopToBottom);
|
m_appDatetimeLayout->setDirection(QBoxLayout::Direction::TopToBottom);
|
||||||
m_mainLayout->setDirection(QBoxLayout::Direction::TopToBottom);
|
m_mainLayout->setDirection(QBoxLayout::Direction::TopToBottom);
|
||||||
|
m_splitLine->show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_splitLine->hide();
|
|
||||||
m_dateTimeWidget->setOneRow(true);
|
m_dateTimeWidget->setOneRow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrayManagerWindow::resetMultiDirection()
|
void TrayManagerWindow::resetMultiDirection()
|
||||||
{
|
{
|
||||||
|
m_appDatetimeLayout->setSpacing(0);
|
||||||
switch (m_postion) {
|
switch (m_postion) {
|
||||||
case Dock::Position::Top: {
|
case Dock::Position::Top: {
|
||||||
m_appPluginLayout->setDirection(QBoxLayout::Direction::LeftToRight);
|
m_appPluginLayout->setDirection(QBoxLayout::Direction::LeftToRight);
|
||||||
@ -411,3 +457,24 @@ void TrayManagerWindow::dragLeaveEvent(QDragLeaveEvent *event)
|
|||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrayManagerWindow::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
QPainterPath path = roundedPaths();
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.save();
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.setClipPath(path);
|
||||||
|
painter.fillRect(rect().adjusted(1, 1, -1, -1), maskColor(102));
|
||||||
|
painter.setPen(maskColor(110));
|
||||||
|
painter.drawPath(path);
|
||||||
|
painter.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor TrayManagerWindow::maskColor(uint8_t alpha) const
|
||||||
|
{
|
||||||
|
QColor color = DGuiApplicationHelper::standardPalette(DGuiApplicationHelper::instance()->themeType()).window().color();
|
||||||
|
color.setAlpha(alpha);
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
@ -48,21 +48,22 @@ class TrayManagerWindow : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void sizeChanged();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TrayManagerWindow(QWidget *parent = nullptr);
|
explicit TrayManagerWindow(QWidget *parent = nullptr);
|
||||||
~TrayManagerWindow() override;
|
~TrayManagerWindow() override;
|
||||||
void setPositon(Dock::Position position);
|
void setPositon(Dock::Position position);
|
||||||
QSize suitableSize();
|
QSize suitableSize();
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void sizeChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
void dragEnterEvent(QDragEnterEvent *e) override;
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
||||||
void dragMoveEvent(QDragMoveEvent *e) override;
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||||
void dropEvent(QDropEvent *e) override;
|
void dropEvent(QDropEvent *e) override;
|
||||||
void dragLeaveEvent(QDragLeaveEvent *event) override;
|
void dragLeaveEvent(QDragLeaveEvent *event) override;
|
||||||
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initUi();
|
void initUi();
|
||||||
@ -72,12 +73,14 @@ private:
|
|||||||
void resetChildWidgetSize();
|
void resetChildWidgetSize();
|
||||||
void resetMultiDirection();
|
void resetMultiDirection();
|
||||||
void resetSingleDirection();
|
void resetSingleDirection();
|
||||||
|
QColor maskColor(uint8_t alpha) const;
|
||||||
|
|
||||||
bool showSingleRow();
|
bool showSingleRow();
|
||||||
int appDatetimeSize();
|
int appDatetimeSize();
|
||||||
|
QPainterPath roundedPaths();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DBlurEffectWidget *m_appPluginDatetimeWidget;
|
QWidget *m_appPluginDatetimeWidget;
|
||||||
SystemPluginWindow *m_systemPluginWidget;
|
SystemPluginWindow *m_systemPluginWidget;
|
||||||
QWidget *m_appPluginWidget;
|
QWidget *m_appPluginWidget;
|
||||||
QuickPluginWindow *m_quickIconWidget;
|
QuickPluginWindow *m_quickIconWidget;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user