mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
feat:add mainpanelcontrol spliter and delete tray spliter
This commit is contained in:
parent
7dd3373438
commit
3cfbc502f0
@ -31,6 +31,10 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QString>
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
#define SPLITER_SIZE 2
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
MainPanelControl::MainPanelControl(QWidget *parent)
|
||||
@ -49,6 +53,9 @@ MainPanelControl::MainPanelControl(QWidget *parent)
|
||||
, m_placeholderItem(nullptr)
|
||||
, m_appDragWidget(nullptr)
|
||||
, m_dislayMode(Efficient)
|
||||
, m_fixedSpliter(new QLabel(this))
|
||||
, m_appSpliter(new QLabel(this))
|
||||
, m_traySpliter(new QLabel(this))
|
||||
{
|
||||
init();
|
||||
updateMainPanelLayout();
|
||||
@ -67,13 +74,19 @@ void MainPanelControl::init()
|
||||
{
|
||||
// 主窗口
|
||||
m_mainPanelLayout->addWidget(m_fixedAreaWidget);
|
||||
m_mainPanelLayout->addWidget(m_fixedSpliter);
|
||||
m_mainPanelLayout->addWidget(m_appAreaWidget);
|
||||
m_mainPanelLayout->addWidget(m_appSpliter);
|
||||
m_mainPanelLayout->addWidget(m_trayAreaWidget);
|
||||
m_mainPanelLayout->addWidget(m_traySpliter);
|
||||
m_mainPanelLayout->addWidget(m_pluginAreaWidget);
|
||||
|
||||
m_mainPanelLayout->setMargin(0);
|
||||
m_mainPanelLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_mainPanelLayout->setSpacing(0);
|
||||
m_mainPanelLayout->setAlignment(m_fixedSpliter, Qt::AlignCenter);
|
||||
m_mainPanelLayout->setAlignment(m_appSpliter, Qt::AlignCenter);
|
||||
m_mainPanelLayout->setAlignment(m_traySpliter, Qt::AlignCenter);
|
||||
|
||||
// 固定区域
|
||||
m_fixedAreaWidget->setLayout(m_fixedAreaLayout);
|
||||
@ -90,13 +103,13 @@ void MainPanelControl::init()
|
||||
// 托盘
|
||||
m_trayAreaWidget->setLayout(m_trayAreaLayout);
|
||||
m_trayAreaLayout->setMargin(0);
|
||||
m_trayAreaLayout->setContentsMargins(10, 10, 10, 10);
|
||||
m_trayAreaLayout->setContentsMargins(0, 10, 0, 10);
|
||||
m_trayAreaLayout->setSpacing(0);
|
||||
|
||||
// 插件
|
||||
m_pluginAreaWidget->setLayout(m_pluginLayout);
|
||||
m_pluginLayout->setMargin(0);
|
||||
m_pluginLayout->setContentsMargins(0, 10, 10, 10);
|
||||
m_pluginLayout->setContentsMargins(10, 10, 10, 10);
|
||||
m_pluginLayout->setSpacing(10);
|
||||
}
|
||||
|
||||
@ -122,7 +135,7 @@ void MainPanelControl::updateMainPanelLayout()
|
||||
m_pluginLayout->setDirection(QBoxLayout::LeftToRight);
|
||||
m_trayAreaLayout->setDirection(QBoxLayout::LeftToRight);
|
||||
m_appAreaSonLayout->setDirection(QBoxLayout::LeftToRight);
|
||||
m_pluginLayout->setContentsMargins(0, 10, 10, 10);
|
||||
m_trayAreaLayout->setContentsMargins(0, 10, 0, 10);
|
||||
break;
|
||||
case Position::Right:
|
||||
case Position::Left:
|
||||
@ -135,7 +148,7 @@ void MainPanelControl::updateMainPanelLayout()
|
||||
m_pluginLayout->setDirection(QBoxLayout::TopToBottom);
|
||||
m_trayAreaLayout->setDirection(QBoxLayout::TopToBottom);
|
||||
m_appAreaSonLayout->setDirection(QBoxLayout::TopToBottom);
|
||||
m_pluginLayout->setContentsMargins(10, 0, 10, 10);
|
||||
m_trayAreaLayout->setContentsMargins(10, 0, 10, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -218,6 +231,16 @@ void MainPanelControl::resizeEvent(QResizeEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_position == Dock::Position::Top || m_position == Dock::Position::Bottom) {
|
||||
m_fixedSpliter->setFixedSize(SPLITER_SIZE, height() * 0.6);
|
||||
m_appSpliter->setFixedSize(SPLITER_SIZE, height() * 0.6);
|
||||
m_traySpliter->setFixedSize(SPLITER_SIZE, height() * 0.5);
|
||||
} else {
|
||||
m_fixedSpliter->setFixedSize(width() * 0.6, SPLITER_SIZE);
|
||||
m_appSpliter->setFixedSize(width() * 0.6, SPLITER_SIZE);
|
||||
m_traySpliter->setFixedSize(width() * 0.5, SPLITER_SIZE);
|
||||
}
|
||||
|
||||
return QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
@ -675,3 +698,20 @@ void MainPanelControl::itemUpdated(DockItem *item)
|
||||
{
|
||||
item->parentWidget()->adjustSize();
|
||||
}
|
||||
|
||||
void MainPanelControl::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
QColor color;
|
||||
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
|
||||
color = Qt::black;
|
||||
painter.setOpacity(0.5);
|
||||
} else {
|
||||
color = Qt::white;
|
||||
painter.setOpacity(0.1);
|
||||
}
|
||||
|
||||
painter.fillRect(m_fixedSpliter->geometry(), color);
|
||||
painter.fillRect(m_appSpliter->geometry(), color);
|
||||
painter.fillRect(m_traySpliter->geometry(), color);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
using namespace Dock;
|
||||
|
||||
@ -82,6 +83,7 @@ private:
|
||||
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
||||
void moveItem(DockItem *sourceItem, DockItem *targetItem);
|
||||
void handleDragMove(QDragMoveEvent *e, bool isFilter);
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
|
||||
public slots:
|
||||
void insertItem(const int index, DockItem *item);
|
||||
@ -105,6 +107,9 @@ private:
|
||||
QString m_draggingMimeKey;
|
||||
AppDragWidget *m_appDragWidget;
|
||||
DisplayMode m_dislayMode;
|
||||
QLabel *m_fixedSpliter;
|
||||
QLabel *m_appSpliter;
|
||||
QLabel *m_traySpliter;
|
||||
};
|
||||
|
||||
#endif // MAINPANELCONTROL_H
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <QSvgRenderer>
|
||||
#include <QMouseEvent>
|
||||
#include <DFontSizeManager>
|
||||
#include <DGuiApplicationHelper>
|
||||
|
||||
#define PLUGIN_STATE_KEY "enable"
|
||||
#define SHOW_DATE_MIN_HEIGHT 45
|
||||
|
@ -135,17 +135,17 @@ QSize AbstractContainer::totalSize() const
|
||||
if (m_dockPosition == Dock::Position::Top || m_dockPosition == Dock::Position::Bottom) {
|
||||
|
||||
size.setWidth(
|
||||
m_wrapperList.size() * std::min(parentWidget()->height(), PLUGIN_BACKGROUND_MAX_SIZE) // 所有托盘图标
|
||||
+ m_wrapperList.size() * TraySpace // 所有托盘图标之间 + 一个尾部的 space
|
||||
+ TraySpace
|
||||
(expand() ? (m_wrapperList.size() * std::min(parentWidget()->height(), PLUGIN_BACKGROUND_MAX_SIZE) // 所有托盘图标
|
||||
+ m_wrapperList.size() * TraySpace) : 0 // 所有托盘图标之间 + 一个尾部的 space
|
||||
) + TraySpace
|
||||
);
|
||||
size.setHeight(height());
|
||||
} else {
|
||||
size.setWidth(width());
|
||||
size.setHeight(
|
||||
m_wrapperList.size() * std::min(parentWidget()->width(), PLUGIN_BACKGROUND_MAX_SIZE) // 所有托盘图标
|
||||
+ m_wrapperList.size() * TraySpace // 所有托盘图标之间 + 一个尾部的 space
|
||||
+ TraySpace
|
||||
(expand() ? (m_wrapperList.size() * std::min(parentWidget()->width(), PLUGIN_BACKGROUND_MAX_SIZE) // 所有托盘图标
|
||||
+ m_wrapperList.size() * TraySpace) : 0 // 所有托盘图标之间 + 一个尾部的 space
|
||||
) + TraySpace
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ void HoldContainer::refreshVisible()
|
||||
{
|
||||
AbstractContainer::refreshVisible();
|
||||
|
||||
setVisible(expand() || !isEmpty());
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
void HoldContainer::setDockPosition(const Dock::Position pos)
|
||||
|
@ -5,13 +5,8 @@ NormalContainer::NormalContainer(TrayPlugin *trayPlugin, QWidget *parent)
|
||||
: AbstractContainer(trayPlugin, parent)
|
||||
, m_sizeAnimation(new QVariantAnimation(this))
|
||||
{
|
||||
m_sizeAnimation->setDuration(200);
|
||||
m_sizeAnimation->setEasingCurve(QEasingCurve::InOutCubic);
|
||||
|
||||
connect(m_sizeAnimation, &QVariantAnimation::finished, [ = ]() {
|
||||
setVisible(expand());
|
||||
});
|
||||
|
||||
connect(m_sizeAnimation, &QVariantAnimation::valueChanged, [ = ](const QVariant & value) {
|
||||
|
||||
if (dockPosition() == Dock::Top || dockPosition() == Dock::Bottom) {
|
||||
@ -23,9 +18,24 @@ NormalContainer::NormalContainer(TrayPlugin *trayPlugin, QWidget *parent)
|
||||
}
|
||||
});
|
||||
|
||||
connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasCompositeChanged, [ = ]() {
|
||||
m_sizeAnimation->setDuration(DWindowManagerHelper::instance()->hasComposite() ? 200 : 0);
|
||||
connect(m_sizeAnimation, &QVariantAnimation::finished, [ = ]() {
|
||||
for (auto w : wrapperList()) {
|
||||
w->setFixedSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
}
|
||||
|
||||
this->setVisible(expand());
|
||||
});
|
||||
|
||||
connect(DWindowManagerHelper::instance(), &DWindowManagerHelper::hasCompositeChanged, this, &NormalContainer::compositeChanged, Qt::QueuedConnection);
|
||||
|
||||
QTimer::singleShot(1, this, &NormalContainer::compositeChanged);
|
||||
}
|
||||
|
||||
void NormalContainer::compositeChanged()
|
||||
{
|
||||
const int duration = DWindowManagerHelper::instance()->hasComposite() ? 300 : 0;
|
||||
|
||||
m_sizeAnimation->setDuration(duration);
|
||||
}
|
||||
|
||||
QSize NormalContainer::sizeHint() const
|
||||
@ -104,6 +114,15 @@ void NormalContainer::setExpand(const bool expand)
|
||||
for (auto w : wrapperList()) {
|
||||
// reset all tray item attention state
|
||||
w->setAttention(false);
|
||||
|
||||
int itemSize;
|
||||
|
||||
if (dockPosition() == Dock::Position::Top || dockPosition() == Dock::Position::Bottom)
|
||||
itemSize = std::min(parentWidget()->height(), PLUGIN_BACKGROUND_MAX_SIZE);
|
||||
else
|
||||
itemSize = std::min(parentWidget()->width(), PLUGIN_BACKGROUND_MAX_SIZE);
|
||||
|
||||
w->setFixedSize(itemSize, itemSize);
|
||||
}
|
||||
|
||||
AbstractContainer::setExpand(expand);
|
||||
|
@ -25,6 +25,7 @@ private:
|
||||
int whereToInsertByDefault(FashionTrayWidgetWrapper *wrapper) const;
|
||||
int whereToInsertAppTrayByDefault(FashionTrayWidgetWrapper *wrapper) const;
|
||||
int whereToInsertSystemTrayByDefault(FashionTrayWidgetWrapper *wrapper) const;
|
||||
void compositeChanged();
|
||||
|
||||
private:
|
||||
mutable QVariantAnimation *m_sizeAnimation;
|
||||
|
@ -34,8 +34,6 @@ int FashionTrayItem::TrayWidgetHeight = PLUGIN_BACKGROUND_MAX_SIZE;
|
||||
FashionTrayItem::FashionTrayItem(TrayPlugin *trayPlugin, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_mainBoxLayout(new QBoxLayout(QBoxLayout::Direction::LeftToRight)),
|
||||
m_leftSpliter(new QLabel),
|
||||
m_rightSpliter(new QLabel),
|
||||
m_attentionDelayTimer(new QTimer(this)),
|
||||
m_trayPlugin(trayPlugin),
|
||||
m_controlWidget(new FashionTrayControlWidget(trayPlugin->dockPosition())),
|
||||
@ -43,14 +41,10 @@ FashionTrayItem::FashionTrayItem(TrayPlugin *trayPlugin, QWidget *parent)
|
||||
m_normalContainer(new NormalContainer(m_trayPlugin)),
|
||||
m_attentionContainer(new AttentionContainer(m_trayPlugin)),
|
||||
m_holdContainer(new HoldContainer(m_trayPlugin))
|
||||
, m_leftSpace(new QWidget)
|
||||
, m_rightSpace(new QWidget)
|
||||
, m_leftSpace(new QWidget)
|
||||
{
|
||||
setAcceptDrops(true);
|
||||
|
||||
m_leftSpliter->setStyleSheet("background-color: rgba(255, 255, 255, 0.1);");
|
||||
m_rightSpliter->setStyleSheet("background-color: rgba(255, 255, 255, 0.1);");
|
||||
|
||||
m_normalContainer->setVisible(false);
|
||||
m_attentionContainer->setVisible(false);
|
||||
m_holdContainer->setVisible(false);
|
||||
@ -59,21 +53,15 @@ FashionTrayItem::FashionTrayItem(TrayPlugin *trayPlugin, QWidget *parent)
|
||||
m_mainBoxLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_mainBoxLayout->setSpacing(0);
|
||||
|
||||
m_leftSpace->setFixedSize(TraySpace, TraySpace);
|
||||
m_rightSpace->setFixedSize(TraySpace, TraySpace);
|
||||
m_leftSpace->setFixedSize(TraySpace, TraySpace);
|
||||
|
||||
m_mainBoxLayout->addWidget(m_leftSpliter);
|
||||
m_mainBoxLayout->addWidget(m_leftSpace);
|
||||
m_mainBoxLayout->addWidget(m_leftSpace);
|
||||
m_mainBoxLayout->addWidget(m_normalContainer);
|
||||
m_mainBoxLayout->addWidget(m_controlWidget);
|
||||
m_mainBoxLayout->addWidget(m_holdContainer);
|
||||
m_mainBoxLayout->addWidget(m_attentionContainer);
|
||||
m_mainBoxLayout->addWidget(m_rightSpace);
|
||||
m_mainBoxLayout->addWidget(m_rightSpliter);
|
||||
|
||||
m_mainBoxLayout->setAlignment(m_leftSpliter, Qt::AlignCenter);
|
||||
m_mainBoxLayout->setAlignment(m_controlWidget, Qt::AlignCenter);
|
||||
m_mainBoxLayout->setAlignment(m_rightSpliter, Qt::AlignCenter);
|
||||
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
setLayout(m_mainBoxLayout);
|
||||
@ -196,11 +184,6 @@ void FashionTrayItem::onExpandChanged(const bool expand)
|
||||
|
||||
void FashionTrayItem::setRightSplitVisible(const bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
m_rightSpliter->setStyleSheet("background-color: rgba(255, 255, 255, 0.1);");
|
||||
} else {
|
||||
m_rightSpliter->setStyleSheet("background-color: transparent;");
|
||||
}
|
||||
}
|
||||
|
||||
void FashionTrayItem::onPluginSettingsChanged()
|
||||
@ -224,17 +207,6 @@ void FashionTrayItem::hideEvent(QHideEvent *event)
|
||||
|
||||
void FashionTrayItem::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
const QSize &mSize = event->size();
|
||||
const Dock::Position dockPosition = m_trayPlugin->dockPosition();
|
||||
|
||||
if (dockPosition == Dock::Position::Top || dockPosition == Dock::Position::Bottom) {
|
||||
m_leftSpliter->setFixedSize(SpliterSize, mSize.height() * 0.8);
|
||||
m_rightSpliter->setFixedSize(SpliterSize, mSize.height() * 0.5);
|
||||
} else {
|
||||
m_leftSpliter->setFixedSize(mSize.width() * 0.8, SpliterSize);
|
||||
m_rightSpliter->setFixedSize(mSize.width() * 0.5, SpliterSize);
|
||||
}
|
||||
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
@ -365,10 +337,7 @@ void FashionTrayItem::requestResize()
|
||||
{
|
||||
// 此属性用来通知dock实现动画,目前已经失效,动画效果在托盘实现
|
||||
// setProperty("FashionTraySize", sizeHint());
|
||||
|
||||
m_leftSpace->setVisible(!m_controlWidget->expanded());
|
||||
|
||||
m_rightSpace->setVisible(!m_controlWidget->expanded() && m_holdContainer->isEmpty() && m_attentionContainer->isEmpty());
|
||||
m_leftSpace->setVisible(!m_controlWidget->expanded());
|
||||
}
|
||||
|
||||
void FashionTrayItem::refreshHoldContainerPosition()
|
||||
|
@ -82,8 +82,6 @@ private Q_SLOTS:
|
||||
|
||||
private:
|
||||
QBoxLayout *m_mainBoxLayout;
|
||||
QLabel *m_leftSpliter;
|
||||
QLabel *m_rightSpliter;
|
||||
QTimer *m_attentionDelayTimer;
|
||||
|
||||
TrayPlugin *m_trayPlugin;
|
||||
@ -96,9 +94,7 @@ private:
|
||||
|
||||
static int TrayWidgetWidth;
|
||||
static int TrayWidgetHeight;
|
||||
|
||||
QWidget *m_leftSpace;
|
||||
QWidget *m_rightSpace;
|
||||
QWidget *m_leftSpace;
|
||||
};
|
||||
|
||||
#endif // FASHIONTRAYITEM_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user