diff --git a/frame/panel/mainpanelcontrol.cpp b/frame/panel/mainpanelcontrol.cpp index c292d183e..195b4717c 100644 --- a/frame/panel/mainpanelcontrol.cpp +++ b/frame/panel/mainpanelcontrol.cpp @@ -20,6 +20,7 @@ */ #include "mainpanelcontrol.h" +#include "../item/dockitem.h" #include @@ -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 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(); +} + diff --git a/frame/panel/mainpanelcontrol.h b/frame/panel/mainpanelcontrol.h index 7c37708fa..bfa4f1994 100644 --- a/frame/panel/mainpanelcontrol.h +++ b/frame/panel/mainpanelcontrol.h @@ -25,6 +25,7 @@ #include #include +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;