mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat(mainpanel): delect mainpanel's object
This commit is contained in:
parent
854d8a68a4
commit
1f7d63dae4
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include "mainpanelcontrol.h"
|
||||
#include "../item/dockitem.h"
|
||||
|
||||
#include <DAnchors>
|
||||
|
||||
@ -56,7 +57,6 @@ void MainPanelControl::init()
|
||||
m_fixedAreaLayout->setMargin(0);
|
||||
m_fixedAreaLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_pluginLayout->setMargin(0);
|
||||
m_pluginLayout->setSpacing(0);
|
||||
m_pluginLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_trayAreaLayout->setMargin(0);
|
||||
m_trayAreaLayout->setContentsMargins(0, 0, 0, 0);
|
||||
@ -70,6 +70,10 @@ void MainPanelControl::init()
|
||||
m_mainPanelLayout->addWidget(m_pluginAreaWidget);
|
||||
m_pluginAreaWidget->setLayout(m_pluginLayout);
|
||||
m_appAreaSonWidget->setLayout(m_appAreaSonLayout);
|
||||
m_fixedAreaLayout->setSpacing(0);
|
||||
m_appAreaSonLayout->setSpacing(0);
|
||||
m_trayAreaLayout->setSpacing(0);
|
||||
m_pluginLayout->setSpacing(0);
|
||||
|
||||
DAnchors<QWidget> anchors(m_appAreaSonWidget);
|
||||
anchors.setAnchor(Qt::AnchorHorizontalCenter, this, Qt::AnchorHorizontalCenter);
|
||||
@ -130,6 +134,26 @@ void MainPanelControl::addPluginAreaItem(QWidget *wdg)
|
||||
m_pluginLayout->addWidget(wdg, 0, Qt::AlignCenter);
|
||||
}
|
||||
|
||||
void MainPanelControl::removeFixedAreaItem(QWidget *wdg)
|
||||
{
|
||||
m_fixedAreaLayout->removeWidget(wdg);
|
||||
}
|
||||
|
||||
void MainPanelControl::removeAppAreaItem(QWidget *wdg)
|
||||
{
|
||||
m_appAreaSonLayout->removeWidget(wdg);
|
||||
}
|
||||
|
||||
void MainPanelControl::removeTrayAreaItem(QWidget *wdg)
|
||||
{
|
||||
m_trayAreaLayout->removeWidget(wdg);
|
||||
}
|
||||
|
||||
void MainPanelControl::removePluginAreaItem(QWidget *wdg)
|
||||
{
|
||||
m_pluginLayout->removeWidget(wdg);
|
||||
}
|
||||
|
||||
void MainPanelControl::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
updateAppAreaSonWidgetSize();
|
||||
@ -154,3 +178,48 @@ void MainPanelControl::setPositonValue(const Qt::Edge val)
|
||||
{
|
||||
m_position = val;
|
||||
}
|
||||
|
||||
void MainPanelControl::itemInserted(const int index, DockItem *item)
|
||||
{
|
||||
switch (item->itemType()) {
|
||||
case DockItem::Launcher:
|
||||
addFixedAreaItem(item);
|
||||
break;
|
||||
case DockItem::App:
|
||||
addAppAreaItem(item);
|
||||
break;
|
||||
case DockItem::TrayPlugin:
|
||||
addTrayAreaItem(item);
|
||||
break;
|
||||
case DockItem::Plugins:
|
||||
addPluginAreaItem(item);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
updateAppAreaSonWidgetSize();
|
||||
}
|
||||
|
||||
void MainPanelControl::itemRemoved(DockItem *item)
|
||||
{
|
||||
switch (item->itemType()) {
|
||||
case DockItem::Launcher:
|
||||
removeFixedAreaItem(item);
|
||||
break;
|
||||
case DockItem::App:
|
||||
removeAppAreaItem(item);
|
||||
break;
|
||||
case DockItem::TrayPlugin:
|
||||
removeTrayAreaItem(item);
|
||||
break;
|
||||
case DockItem::Plugins:
|
||||
removePluginAreaItem(item);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
updateAppAreaSonWidgetSize();
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <QWidget>
|
||||
#include <QBoxLayout>
|
||||
|
||||
class DockItem;
|
||||
class MainPanelControl : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -36,6 +37,10 @@ public:
|
||||
void addAppAreaItem(QWidget *wdg);
|
||||
void addTrayAreaItem(QWidget *wdg);
|
||||
void addPluginAreaItem(QWidget *wdg);
|
||||
void removeFixedAreaItem(QWidget *wdg);
|
||||
void removeAppAreaItem(QWidget *wdg);
|
||||
void removeTrayAreaItem(QWidget *wdg);
|
||||
void removePluginAreaItem(QWidget *wdg);
|
||||
void setPositonValue(const Qt::Edge val);
|
||||
|
||||
private:
|
||||
@ -45,6 +50,10 @@ private:
|
||||
void updateAppAreaSonWidgetSize();
|
||||
void updateMainPanelLayout();
|
||||
|
||||
private slots:
|
||||
void itemInserted(const int index, DockItem *item);
|
||||
void itemRemoved(DockItem *item);
|
||||
|
||||
private:
|
||||
QBoxLayout *m_mainPanelLayout;
|
||||
QWidget *m_fixedAreaWidget;
|
||||
|
Loading…
x
Reference in New Issue
Block a user