mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feal(mainpanel): add moveitem function and add a new function variable
This commit is contained in:
parent
01500100b9
commit
e6bcc1e45a
@ -114,24 +114,24 @@ void MainPanelControl::updateMainPanelLayout()
|
|||||||
QTimer::singleShot(0, this, &MainPanelControl::updateAppAreaSonWidgetSize);
|
QTimer::singleShot(0, this, &MainPanelControl::updateAppAreaSonWidgetSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::addFixedAreaItem(QWidget *wdg)
|
void MainPanelControl::addFixedAreaItem(const int index, QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_fixedAreaLayout->addWidget(wdg, 0, Qt::AlignCenter);
|
m_fixedAreaLayout->insertWidget(index, wdg, 0, Qt::AlignCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::addAppAreaItem(QWidget *wdg)
|
void MainPanelControl::addAppAreaItem(const int index, QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_appAreaSonLayout->addWidget(wdg, 0, Qt::AlignCenter);
|
m_appAreaSonLayout->insertWidget(index, wdg, 0, Qt::AlignCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::addTrayAreaItem(QWidget *wdg)
|
void MainPanelControl::addTrayAreaItem(const int index, QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_trayAreaLayout->addWidget(wdg, 0, Qt::AlignCenter);
|
m_trayAreaLayout->insertWidget(index, wdg, 0, Qt::AlignCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::addPluginAreaItem(QWidget *wdg)
|
void MainPanelControl::addPluginAreaItem(const int index, QWidget *wdg)
|
||||||
{
|
{
|
||||||
m_pluginLayout->addWidget(wdg, 0, Qt::AlignCenter);
|
m_pluginLayout->insertWidget(index, wdg, 0, Qt::AlignCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::removeFixedAreaItem(QWidget *wdg)
|
void MainPanelControl::removeFixedAreaItem(QWidget *wdg)
|
||||||
@ -179,20 +179,20 @@ void MainPanelControl::setPositonValue(const Qt::Edge val)
|
|||||||
m_position = val;
|
m_position = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::itemInserted(const int index, DockItem *item)
|
void MainPanelControl::insertItem(const int index, DockItem *item)
|
||||||
{
|
{
|
||||||
switch (item->itemType()) {
|
switch (item->itemType()) {
|
||||||
case DockItem::Launcher:
|
case DockItem::Launcher:
|
||||||
addFixedAreaItem(item);
|
addFixedAreaItem(index, item);
|
||||||
break;
|
break;
|
||||||
case DockItem::App:
|
case DockItem::App:
|
||||||
addAppAreaItem(item);
|
addAppAreaItem(index, item);
|
||||||
break;
|
break;
|
||||||
case DockItem::TrayPlugin:
|
case DockItem::TrayPlugin:
|
||||||
addTrayAreaItem(item);
|
addTrayAreaItem(index, item);
|
||||||
break;
|
break;
|
||||||
case DockItem::Plugins:
|
case DockItem::Plugins:
|
||||||
addPluginAreaItem(item);
|
addPluginAreaItem(index, item);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -201,7 +201,7 @@ void MainPanelControl::itemInserted(const int index, DockItem *item)
|
|||||||
updateAppAreaSonWidgetSize();
|
updateAppAreaSonWidgetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::itemRemoved(DockItem *item)
|
void MainPanelControl::removeItem(DockItem *item)
|
||||||
{
|
{
|
||||||
switch (item->itemType()) {
|
switch (item->itemType()) {
|
||||||
case DockItem::Launcher:
|
case DockItem::Launcher:
|
||||||
@ -223,3 +223,11 @@ void MainPanelControl::itemRemoved(DockItem *item)
|
|||||||
updateAppAreaSonWidgetSize();
|
updateAppAreaSonWidgetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainPanelControl::movedItem(const int index, DockItem *item)
|
||||||
|
{
|
||||||
|
// remove old item
|
||||||
|
removeItem(item);
|
||||||
|
// insert new position
|
||||||
|
insertItem(index, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@ public:
|
|||||||
MainPanelControl(QWidget *parent = 0);
|
MainPanelControl(QWidget *parent = 0);
|
||||||
~MainPanelControl();
|
~MainPanelControl();
|
||||||
|
|
||||||
void addFixedAreaItem(QWidget *wdg);
|
void addFixedAreaItem(const int index, QWidget *wdg);
|
||||||
void addAppAreaItem(QWidget *wdg);
|
void addAppAreaItem(const int index, QWidget *wdg);
|
||||||
void addTrayAreaItem(QWidget *wdg);
|
void addTrayAreaItem(const int index, QWidget *wdg);
|
||||||
void addPluginAreaItem(QWidget *wdg);
|
void addPluginAreaItem(const int index, QWidget *wdg);
|
||||||
void removeFixedAreaItem(QWidget *wdg);
|
void removeFixedAreaItem(QWidget *wdg);
|
||||||
void removeAppAreaItem(QWidget *wdg);
|
void removeAppAreaItem(QWidget *wdg);
|
||||||
void removeTrayAreaItem(QWidget *wdg);
|
void removeTrayAreaItem(QWidget *wdg);
|
||||||
@ -51,8 +51,9 @@ private:
|
|||||||
void updateMainPanelLayout();
|
void updateMainPanelLayout();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void itemInserted(const int index, DockItem *item);
|
void insertItem(const int index, DockItem *item);
|
||||||
void itemRemoved(DockItem *item);
|
void removeItem(DockItem *item);
|
||||||
|
void movedItem(const int index, DockItem *item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QBoxLayout *m_mainPanelLayout;
|
QBoxLayout *m_mainPanelLayout;
|
||||||
|
@ -110,7 +110,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
m_mainPanel->setFixedSize(m_settings->panelSize());
|
m_mainPanel->setFixedSize(m_settings->panelSize());
|
||||||
|
|
||||||
for (auto item : DockItemManager::instance()->itemList())
|
for (auto item : DockItemManager::instance()->itemList())
|
||||||
m_mainPanel->itemInserted(-1, item);
|
m_mainPanel->insertItem(-1, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -403,8 +403,8 @@ void MainWindow::initConnections()
|
|||||||
|
|
||||||
connect(m_dbusDaemonInterface, &QDBusConnectionInterface::serviceOwnerChanged, this, &MainWindow::onDbusNameOwnerChanged);
|
connect(m_dbusDaemonInterface, &QDBusConnectionInterface::serviceOwnerChanged, this, &MainWindow::onDbusNameOwnerChanged);
|
||||||
|
|
||||||
connect(DockItemManager::instance(), &DockItemManager::itemInserted, m_mainPanel, &MainPanelControl::itemInserted, Qt::DirectConnection);
|
connect(DockItemManager::instance(), &DockItemManager::itemInserted, m_mainPanel, &MainPanelControl::insertItem, Qt::DirectConnection);
|
||||||
connect(DockItemManager::instance(), &DockItemManager::itemRemoved, m_mainPanel, &MainPanelControl::itemRemoved, Qt::DirectConnection);
|
connect(DockItemManager::instance(), &DockItemManager::itemRemoved, m_mainPanel, &MainPanelControl::removeItem, Qt::DirectConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPoint MainWindow::x11GetWindowPos()
|
const QPoint MainWindow::x11GetWindowPos()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user