mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
feat(appItem):drop application to dock, drag appitem to undock
This commit is contained in:
parent
4692406d63
commit
66e33b9b39
@ -179,6 +179,11 @@ void DockItemManager::itemMoved(DockItem *const sourceItem, DockItem *const targ
|
|||||||
refreshFSTItemSpliterVisible();
|
refreshFSTItemSpliterVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockItemManager::itemAdded(const QString &appDesktop, int idx)
|
||||||
|
{
|
||||||
|
m_appInter->RequestDock(appDesktop, idx);
|
||||||
|
}
|
||||||
|
|
||||||
void DockItemManager::itemDroppedIntoContainer(DockItem *const item)
|
void DockItemManager::itemDroppedIntoContainer(DockItem *const item)
|
||||||
{
|
{
|
||||||
Q_ASSERT(item->itemType() == DockItem::Plugins || item->itemType() == DockItem::TrayPlugin);
|
Q_ASSERT(item->itemType() == DockItem::Plugins || item->itemType() == DockItem::TrayPlugin);
|
||||||
@ -235,8 +240,7 @@ void DockItemManager::refreshFSTItemSpliterVisible()
|
|||||||
|
|
||||||
void DockItemManager::appItemAdded(const QDBusObjectPath &path, const int index)
|
void DockItemManager::appItemAdded(const QDBusObjectPath &path, const int index)
|
||||||
{
|
{
|
||||||
// the first index is launcher item
|
int insertIndex = 0;
|
||||||
int insertIndex = 1;
|
|
||||||
|
|
||||||
// -1 for append to app list end
|
// -1 for append to app list end
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
|
@ -63,6 +63,7 @@ public slots:
|
|||||||
void sortPluginItems();
|
void sortPluginItems();
|
||||||
void updatePluginsItemOrderKey();
|
void updatePluginsItemOrderKey();
|
||||||
void itemMoved(DockItem *const sourceItem, DockItem *const targetItem);
|
void itemMoved(DockItem *const sourceItem, DockItem *const targetItem);
|
||||||
|
void itemAdded(const QString &appDesktop, int idx);
|
||||||
void itemDroppedIntoContainer(DockItem *const item);
|
void itemDroppedIntoContainer(DockItem *const item);
|
||||||
void itemDragOutFromContainer(DockItem *const item);
|
void itemDragOutFromContainer(DockItem *const item);
|
||||||
void refreshFSTItemSpliterVisible();
|
void refreshFSTItemSpliterVisible();
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
#include "mainpanelcontrol.h"
|
#include "mainpanelcontrol.h"
|
||||||
#include "../item/dockitem.h"
|
#include "../item/dockitem.h"
|
||||||
#include "util/docksettings.h"
|
#include "util/docksettings.h"
|
||||||
|
#include "../item/placeholderitem.h"
|
||||||
|
#include "../item/components/appdrag.h"
|
||||||
|
#include "../item/appitem.h"
|
||||||
|
|
||||||
#include <DAnchors>
|
#include <DAnchors>
|
||||||
|
|
||||||
@ -43,6 +46,8 @@ MainPanelControl::MainPanelControl(QWidget *parent)
|
|||||||
, m_appAreaSonWidget(new QWidget(this))
|
, m_appAreaSonWidget(new QWidget(this))
|
||||||
, m_appAreaSonLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
, m_appAreaSonLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||||
, m_position(Qt::TopEdge)
|
, m_position(Qt::TopEdge)
|
||||||
|
, m_placeholderItem(nullptr)
|
||||||
|
, m_appDragWidget(nullptr)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
updateMainPanelLayout();
|
updateMainPanelLayout();
|
||||||
@ -218,6 +223,7 @@ void MainPanelControl::insertItem(const int index, DockItem *item)
|
|||||||
addFixedAreaItem(index, item);
|
addFixedAreaItem(index, item);
|
||||||
break;
|
break;
|
||||||
case DockItem::App:
|
case DockItem::App:
|
||||||
|
case DockItem::Placeholder:
|
||||||
addAppAreaItem(index, item);
|
addAppAreaItem(index, item);
|
||||||
break;
|
break;
|
||||||
case DockItem::TrayPlugin:
|
case DockItem::TrayPlugin:
|
||||||
@ -230,6 +236,7 @@ void MainPanelControl::insertItem(const int index, DockItem *item)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateMainPanelLayout();
|
||||||
updateAppAreaSonWidgetSize();
|
updateAppAreaSonWidgetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +247,7 @@ void MainPanelControl::removeItem(DockItem *item)
|
|||||||
removeFixedAreaItem(item);
|
removeFixedAreaItem(item);
|
||||||
break;
|
break;
|
||||||
case DockItem::App:
|
case DockItem::App:
|
||||||
|
case DockItem::Placeholder:
|
||||||
removeAppAreaItem(item);
|
removeAppAreaItem(item);
|
||||||
break;
|
break;
|
||||||
case DockItem::TrayPlugin:
|
case DockItem::TrayPlugin:
|
||||||
@ -255,6 +263,16 @@ void MainPanelControl::removeItem(DockItem *item)
|
|||||||
updateAppAreaSonWidgetSize();
|
updateAppAreaSonWidgetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MainPanelDelegate *MainPanelControl::delegate() const
|
||||||
|
{
|
||||||
|
return m_delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainPanelControl::setDelegate(MainPanelDelegate *delegate)
|
||||||
|
{
|
||||||
|
m_delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
void MainPanelControl::moveItem(DockItem *sourceItem, DockItem *targetItem)
|
void MainPanelControl::moveItem(DockItem *sourceItem, DockItem *targetItem)
|
||||||
{
|
{
|
||||||
// get target index
|
// get target index
|
||||||
@ -275,18 +293,118 @@ void MainPanelControl::moveItem(DockItem *sourceItem, DockItem *targetItem)
|
|||||||
|
|
||||||
void MainPanelControl::dragEnterEvent(QDragEnterEvent *e)
|
void MainPanelControl::dragEnterEvent(QDragEnterEvent *e)
|
||||||
{
|
{
|
||||||
|
DockItem *sourceItem = qobject_cast<DockItem *>(e->source());
|
||||||
|
if (sourceItem) {
|
||||||
|
e->accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拖app到dock上
|
||||||
|
const char *RequestDockKey = "RequestDock";
|
||||||
|
const char *RequestDockKeyFallback = "text/plain";
|
||||||
|
const char *DesktopMimeType = "application/x-desktop";
|
||||||
|
|
||||||
|
m_draggingMimeKey = e->mimeData()->formats().contains(RequestDockKey) ? RequestDockKey : RequestDockKeyFallback;
|
||||||
|
|
||||||
|
// dragging item is NOT a desktop file
|
||||||
|
if (QMimeDatabase().mimeTypeForFile(e->mimeData()->data(m_draggingMimeKey)).name() != DesktopMimeType) {
|
||||||
|
m_draggingMimeKey.clear();
|
||||||
|
qDebug() << "dragging item is NOT a desktop file";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_delegate && m_delegate->appIsOnDock(e->mimeData()->data(m_draggingMimeKey)))
|
||||||
|
return;
|
||||||
|
|
||||||
e->accept();
|
e->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainPanelControl::dragMoveEvent(QDragMoveEvent *e)
|
void MainPanelControl::dragLeaveEvent(QDragLeaveEvent *e)
|
||||||
{
|
{
|
||||||
|
if (m_placeholderItem) {
|
||||||
|
const QRect r(static_cast<QWidget *>(parent())->pos(), size());
|
||||||
|
const QPoint p(QCursor::pos());
|
||||||
|
|
||||||
|
// remove margins to fix a touch screen bug:
|
||||||
|
// the mouse point position will stay on this rect's margins after
|
||||||
|
// drag move to the edge of screen
|
||||||
|
if (r.marginsRemoved(QMargins(1, 10, 1, 1)).contains(p))
|
||||||
|
return;
|
||||||
|
|
||||||
|
removeAppAreaItem(m_placeholderItem);
|
||||||
|
m_placeholderItem->deleteLater();
|
||||||
|
updateMainPanelLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainPanelControl::dropEvent(QDropEvent *e)
|
||||||
|
{
|
||||||
|
if (m_placeholderItem) {
|
||||||
|
|
||||||
|
emit itemAdded(e->mimeData()->data(m_draggingMimeKey), m_appAreaSonLayout->indexOf(m_placeholderItem));
|
||||||
|
|
||||||
|
removeAppAreaItem(m_placeholderItem);
|
||||||
|
m_placeholderItem->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainPanelControl::handleDragMove(QDragMoveEvent *e, bool isFilter)
|
||||||
|
{
|
||||||
|
if (!e->source()) {
|
||||||
|
// 应用程序拖到dock上
|
||||||
|
e->accept();
|
||||||
|
|
||||||
|
DockItem *insertPositionItem = dropTargetItem(nullptr, e->pos());
|
||||||
|
|
||||||
|
if (m_placeholderItem.isNull()) {
|
||||||
|
|
||||||
|
m_placeholderItem = new PlaceholderItem;
|
||||||
|
|
||||||
|
if (m_position == Qt::TopEdge || m_position == Qt::BottomEdge) {
|
||||||
|
if (m_appAreaSonWidget->mapFromParent(e->pos()).x() > m_appAreaSonWidget->rect().right()) {
|
||||||
|
// 插入到最右侧
|
||||||
|
insertPositionItem = nullptr;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (m_appAreaSonWidget->mapFromParent(e->pos()).y() > m_appAreaSonWidget->rect().bottom()) {
|
||||||
|
// 插入到最下测
|
||||||
|
insertPositionItem = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
insertItem(m_appAreaSonLayout->indexOf(insertPositionItem), m_placeholderItem);
|
||||||
|
|
||||||
|
} else if (insertPositionItem && m_placeholderItem != insertPositionItem) {
|
||||||
|
moveItem(m_placeholderItem, insertPositionItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DockItem *sourceItem = qobject_cast<DockItem *>(e->source());
|
DockItem *sourceItem = qobject_cast<DockItem *>(e->source());
|
||||||
|
|
||||||
if (!sourceItem) {
|
if (!sourceItem) {
|
||||||
e->ignore();
|
e->ignore();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DockItem *targetItem = dropTargetItem(sourceItem, e->pos());
|
DockItem *targetItem = nullptr;
|
||||||
|
|
||||||
|
if (isFilter) {
|
||||||
|
// appItem调整顺序或者移除驻留
|
||||||
|
targetItem = dropTargetItem(sourceItem, mapFromGlobal(m_appDragWidget->mapToGlobal(e->pos())));
|
||||||
|
|
||||||
|
if (targetItem) {
|
||||||
|
m_appDragWidget->setOriginPos((m_appAreaSonWidget->mapToGlobal(targetItem->pos())));
|
||||||
|
} else {
|
||||||
|
targetItem = sourceItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// other dockItem调整顺序
|
||||||
|
targetItem = dropTargetItem(sourceItem, e->pos());
|
||||||
|
}
|
||||||
|
|
||||||
if (!targetItem) {
|
if (!targetItem) {
|
||||||
e->ignore();
|
e->ignore();
|
||||||
return;
|
return;
|
||||||
@ -301,8 +419,27 @@ void MainPanelControl::dragMoveEvent(QDragMoveEvent *e)
|
|||||||
emit itemMoved(sourceItem, targetItem);
|
emit itemMoved(sourceItem, targetItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainPanelControl::dragMoveEvent(QDragMoveEvent *e)
|
||||||
|
{
|
||||||
|
handleDragMove(e, false);
|
||||||
|
}
|
||||||
|
|
||||||
bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
|
if (m_appDragWidget && watched == static_cast<QGraphicsView *>(m_appDragWidget)->viewport()) {
|
||||||
|
QDropEvent *e = static_cast<QDropEvent *>(event);
|
||||||
|
bool isContains = rect().contains(mapFromGlobal(m_appDragWidget->mapToGlobal(e->pos())));
|
||||||
|
if (isContains) {
|
||||||
|
if (event->type() == QEvent::DragMove) {
|
||||||
|
handleDragMove(static_cast<QDragMoveEvent *>(event), true);
|
||||||
|
} else if (event->type() == QEvent::Drop) {
|
||||||
|
m_appDragWidget->hide();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (event->type() != QEvent::MouseMove)
|
if (event->type() != QEvent::MouseMove)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -329,29 +466,59 @@ void MainPanelControl::startDrag(DockItem *item)
|
|||||||
item->setDraging(true);
|
item->setDraging(true);
|
||||||
item->update();
|
item->update();
|
||||||
|
|
||||||
QDrag *drag = new QDrag(item);
|
QDrag *drag = nullptr;
|
||||||
drag->setPixmap(pixmap);
|
if (item->itemType() == DockItem::App) {
|
||||||
|
AppDrag *appDrag = new AppDrag(item);
|
||||||
|
appDrag->setPixmap(pixmap);
|
||||||
|
m_appDragWidget = appDrag->appDragWidget();
|
||||||
|
|
||||||
|
connect(m_appDragWidget, &AppDragWidget::destroyed, this, [ = ] {
|
||||||
|
m_appDragWidget = nullptr;
|
||||||
|
});
|
||||||
|
|
||||||
|
m_appDragWidget->show();
|
||||||
|
|
||||||
|
Dock::Position position;
|
||||||
|
switch (m_position) {
|
||||||
|
case Qt::TopEdge: position = Dock::Top; break;
|
||||||
|
case Qt::BottomEdge: position = Dock::Bottom; break;
|
||||||
|
case Qt::LeftEdge: position = Dock::Left; break;
|
||||||
|
case Qt::RightEdge: position = Dock::Right; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
appDrag->appDragWidget()->setOriginPos((m_appAreaSonWidget->mapToGlobal(item->pos())));
|
||||||
|
appDrag->appDragWidget()->setDockInfo(position, QRect(mapToGlobal(pos()), size()));
|
||||||
|
static_cast<QGraphicsView *>(m_appDragWidget)->viewport()->installEventFilter(this);
|
||||||
|
|
||||||
|
drag = appDrag;
|
||||||
|
} else {
|
||||||
|
drag = new QDrag(item);
|
||||||
|
drag->setPixmap(pixmap);
|
||||||
|
}
|
||||||
drag->setHotSpot(pixmap.rect().center() / pixmap.devicePixelRatioF());
|
drag->setHotSpot(pixmap.rect().center() / pixmap.devicePixelRatioF());
|
||||||
drag->setMimeData(new QMimeData);
|
drag->setMimeData(new QMimeData);
|
||||||
drag->exec(Qt::MoveAction);
|
drag->exec(Qt::MoveAction);
|
||||||
|
|
||||||
|
m_appDragWidget = nullptr;
|
||||||
item->setDraging(false);
|
item->setDraging(false);
|
||||||
item->update();
|
item->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point)
|
DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point)
|
||||||
{
|
{
|
||||||
QWidget *parentWidget = nullptr;
|
QWidget *parentWidget = m_appAreaSonWidget;
|
||||||
|
|
||||||
switch (sourceItem->itemType()) {
|
if (sourceItem) {
|
||||||
case DockItem::App:
|
switch (sourceItem->itemType()) {
|
||||||
parentWidget = m_appAreaSonWidget;
|
case DockItem::App:
|
||||||
break;
|
parentWidget = m_appAreaSonWidget;
|
||||||
case DockItem::Plugins:
|
break;
|
||||||
parentWidget = m_pluginAreaWidget;
|
case DockItem::Plugins:
|
||||||
break;
|
parentWidget = m_pluginAreaWidget;
|
||||||
default:
|
break;
|
||||||
break;
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parentWidget)
|
if (!parentWidget)
|
||||||
@ -378,5 +545,31 @@ DockItem *MainPanelControl::dropTargetItem(DockItem *sourceItem, QPoint point)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!targetItem && parentWidget == m_appAreaSonWidget) {
|
||||||
|
// appitem调整顺序是,判断是否拖放在两边空白区域
|
||||||
|
|
||||||
|
if (!m_appAreaSonLayout->count())
|
||||||
|
return targetItem;
|
||||||
|
|
||||||
|
DockItem *first = qobject_cast<DockItem *>(m_appAreaSonLayout->itemAt(0)->widget());
|
||||||
|
DockItem *last = qobject_cast<DockItem *>(m_appAreaSonLayout->itemAt(m_appAreaSonLayout->count() - 1)->widget());
|
||||||
|
|
||||||
|
if (m_position == Qt::TopEdge || m_position == Qt::BottomEdge) {
|
||||||
|
|
||||||
|
if (point.x() < 0) {
|
||||||
|
targetItem = first;
|
||||||
|
} else {
|
||||||
|
targetItem = last;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (point.y() < 0) {
|
||||||
|
targetItem = first;
|
||||||
|
} else {
|
||||||
|
targetItem = last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return targetItem;
|
return targetItem;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,15 @@
|
|||||||
|
|
||||||
using namespace Dock;
|
using namespace Dock;
|
||||||
|
|
||||||
|
class MainPanelDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool appIsOnDock(const QString &appDesktop) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class DockItem;
|
class DockItem;
|
||||||
|
class PlaceholderItem;
|
||||||
|
class AppDragWidget;
|
||||||
class MainPanelControl : public QWidget
|
class MainPanelControl : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -48,8 +56,12 @@ public:
|
|||||||
void setPositonValue(const Qt::Edge val);
|
void setPositonValue(const Qt::Edge val);
|
||||||
void updateDisplayMode(DisplayMode m_displayMode);
|
void updateDisplayMode(DisplayMode m_displayMode);
|
||||||
|
|
||||||
|
MainPanelDelegate *delegate() const;
|
||||||
|
void setDelegate(MainPanelDelegate *delegate);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void itemMoved(DockItem *sourceItem, DockItem *targetItem);
|
void itemMoved(DockItem *sourceItem, DockItem *targetItem);
|
||||||
|
void itemAdded(const QString &appDesktop, int idx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
@ -60,11 +72,14 @@ private:
|
|||||||
|
|
||||||
void dragMoveEvent(QDragMoveEvent *e) override;
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
||||||
void dragEnterEvent(QDragEnterEvent *e) override;
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
||||||
|
void dragLeaveEvent(QDragLeaveEvent *e);
|
||||||
|
void dropEvent(QDropEvent *) override;
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
void startDrag(DockItem *);
|
void startDrag(DockItem *);
|
||||||
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
||||||
void moveItem(DockItem *sourceItem, DockItem *targetItem);
|
void moveItem(DockItem *sourceItem, DockItem *targetItem);
|
||||||
|
void handleDragMove(QDragMoveEvent *e, bool isFilter);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void insertItem(const int index, DockItem *item);
|
void insertItem(const int index, DockItem *item);
|
||||||
@ -82,6 +97,10 @@ private:
|
|||||||
QWidget *m_appAreaSonWidget;
|
QWidget *m_appAreaSonWidget;
|
||||||
QBoxLayout *m_appAreaSonLayout;
|
QBoxLayout *m_appAreaSonLayout;
|
||||||
Qt::Edge m_position;
|
Qt::Edge m_position;
|
||||||
|
QPointer<PlaceholderItem> m_placeholderItem;
|
||||||
|
MainPanelDelegate *m_delegate;
|
||||||
|
QString m_draggingMimeKey;
|
||||||
|
AppDragWidget *m_appDragWidget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINPANELCONTROL_H
|
#endif // MAINPANELCONTROL_H
|
||||||
|
@ -113,6 +113,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
|
|
||||||
resizeMainPanelWindow();
|
resizeMainPanelWindow();
|
||||||
|
|
||||||
|
m_mainPanel->setDelegate(this);
|
||||||
for (auto item : DockItemManager::instance()->itemList())
|
for (auto item : DockItemManager::instance()->itemList())
|
||||||
m_mainPanel->insertItem(-1, item);
|
m_mainPanel->insertItem(-1, item);
|
||||||
}
|
}
|
||||||
@ -417,6 +418,7 @@ void MainWindow::initConnections()
|
|||||||
connect(DockItemManager::instance(), &DockItemManager::requestRefershWindowVisible, this, &MainWindow::updatePanelVisible, Qt::QueuedConnection);
|
connect(DockItemManager::instance(), &DockItemManager::requestRefershWindowVisible, this, &MainWindow::updatePanelVisible, Qt::QueuedConnection);
|
||||||
connect(DockItemManager::instance(), &DockItemManager::requestWindowAutoHide, m_settings, &DockSettings::setAutoHide);
|
connect(DockItemManager::instance(), &DockItemManager::requestWindowAutoHide, m_settings, &DockSettings::setAutoHide);
|
||||||
connect(m_mainPanel, &MainPanelControl::itemMoved, DockItemManager::instance(), &DockItemManager::itemMoved, Qt::DirectConnection);
|
connect(m_mainPanel, &MainPanelControl::itemMoved, DockItemManager::instance(), &DockItemManager::itemMoved, Qt::DirectConnection);
|
||||||
|
connect(m_mainPanel, &MainPanelControl::itemAdded, DockItemManager::instance(), &DockItemManager::itemAdded, Qt::DirectConnection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,7 +501,15 @@ void MainWindow::updateGeometry()
|
|||||||
|
|
||||||
// DockDisplayMode and DockPosition MUST be set before invoke setFixedSize method of MainPanel
|
// DockDisplayMode and DockPosition MUST be set before invoke setFixedSize method of MainPanel
|
||||||
// m_mainPanel->updateDockDisplayMode(m_settings->displayMode());
|
// m_mainPanel->updateDockDisplayMode(m_settings->displayMode());
|
||||||
// m_mainPanel->updateDockPosition(position);
|
|
||||||
|
Qt::Edge panelPos;
|
||||||
|
switch (position) {
|
||||||
|
case Dock::Top: panelPos = Qt::TopEdge; break;
|
||||||
|
case Dock::Bottom: panelPos = Qt::BottomEdge; break;
|
||||||
|
case Dock::Left: panelPos = Qt::LeftEdge; break;
|
||||||
|
case Dock::Right: panelPos = Qt::RightEdge; break;
|
||||||
|
}
|
||||||
|
m_mainPanel->setPositonValue(panelPos);
|
||||||
// this->setFixedSize has been overridden for size animation
|
// this->setFixedSize has been overridden for size animation
|
||||||
resizeMainPanelWindow();
|
resizeMainPanelWindow();
|
||||||
|
|
||||||
@ -886,6 +896,11 @@ QRect MainWindow::getNoneResizeRegion()
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWindow::appIsOnDock(const QString &appDesktop)
|
||||||
|
{
|
||||||
|
return DockItemManager::instance()->appIsOnDock(appDesktop);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::resizeMainWindow()
|
void MainWindow::resizeMainWindow()
|
||||||
{
|
{
|
||||||
const Position position = m_settings->position();
|
const Position position = m_settings->position();
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "dbus/dbusdockadaptors.h"
|
#include "dbus/dbusdockadaptors.h"
|
||||||
#include "dbus/sni/statusnotifierwatcher_interface.h"
|
#include "dbus/sni/statusnotifierwatcher_interface.h"
|
||||||
#include "util/docksettings.h"
|
#include "util/docksettings.h"
|
||||||
|
#include "panel/mainpanelcontrol.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -41,7 +42,7 @@ DWIDGET_USE_NAMESPACE
|
|||||||
class MainPanel;
|
class MainPanel;
|
||||||
class MainPanelControl;
|
class MainPanelControl;
|
||||||
class DBusDockAdaptors;
|
class DBusDockAdaptors;
|
||||||
class MainWindow : public DBlurEffectWidget
|
class MainWindow : public DBlurEffectWidget, public MainPanelDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -81,6 +82,7 @@ private:
|
|||||||
void x11MoveWindow(const int x, const int y);
|
void x11MoveWindow(const int x, const int y);
|
||||||
void x11MoveResizeWindow(const int x, const int y, const int w, const int h);
|
void x11MoveResizeWindow(const int x, const int y, const int w, const int h);
|
||||||
QRect getNoneResizeRegion();
|
QRect getNoneResizeRegion();
|
||||||
|
bool appIsOnDock(const QString &appDesktop);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void panelGeometryChanged();
|
void panelGeometryChanged();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user