mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
add fashion mode
Change-Id: I9fb88a4356d049f18ce82cf91d756bc05c12ca4f
This commit is contained in:
parent
b727862b8e
commit
28f2745de3
@ -44,10 +44,11 @@ void DockItemController::itemMove(DockItem * const moveItem, DockItem * const re
|
|||||||
m_itemList.indexOf(replaceItem);
|
m_itemList.indexOf(replaceItem);
|
||||||
|
|
||||||
m_itemList.removeAt(moveIndex);
|
m_itemList.removeAt(moveIndex);
|
||||||
emit itemRemoved(moveItem);
|
// emit itemRemoved(moveItem);
|
||||||
|
|
||||||
m_itemList.insert(replaceIndex, moveItem);
|
m_itemList.insert(replaceIndex, moveItem);
|
||||||
emit itemInserted(replaceIndex, moveItem);
|
// emit itemInserted(replaceIndex, moveItem);
|
||||||
|
emit itemMoved(moveItem, replaceIndex);
|
||||||
|
|
||||||
// for app move, index 0 is launcher item, need to pass it.
|
// for app move, index 0 is launcher item, need to pass it.
|
||||||
if (moveItem->itemType() == DockItem::App)
|
if (moveItem->itemType() == DockItem::App)
|
||||||
|
@ -19,8 +19,9 @@ public:
|
|||||||
const QList<DockItem *> itemList() const;
|
const QList<DockItem *> itemList() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void itemInserted(const int index, DockItem *item);
|
void itemInserted(const int index, DockItem *item) const;
|
||||||
void itemRemoved(DockItem *item);
|
void itemRemoved(DockItem *item) const;
|
||||||
|
void itemMoved(DockItem *item, const int index) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void itemMove(DockItem * const moveItem, DockItem * const replaceItem);
|
void itemMove(DockItem * const moveItem, DockItem * const replaceItem);
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
int AppItem::IconBaseSize;
|
int AppItem::IconBaseSize;
|
||||||
QPoint AppItem::MousePressPos;
|
QPoint AppItem::MousePressPos;
|
||||||
DBusClientManager *AppItem::ClientInter = nullptr;
|
DBusClientManager *AppItem::ClientInter = nullptr;
|
||||||
//uint AppItem::ActiveWindowId = 0;
|
|
||||||
|
|
||||||
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||||
: DockItem(App, parent),
|
: DockItem(App, parent),
|
||||||
@ -175,9 +174,6 @@ void AppItem::initClientManager()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ClientInter = new DBusClientManager(this);
|
ClientInter = new DBusClientManager(this);
|
||||||
// connect(ClientInter, &DBusClientManager::ActiveWindowChanged, [&] (const uint wid) {
|
|
||||||
// ActiveWindowId = wid;
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::updateTitle()
|
void AppItem::updateTitle()
|
||||||
|
@ -47,7 +47,6 @@ private:
|
|||||||
static int IconBaseSize;
|
static int IconBaseSize;
|
||||||
static QPoint MousePressPos;
|
static QPoint MousePressPos;
|
||||||
static DBusClientManager *ClientInter;
|
static DBusClientManager *ClientInter;
|
||||||
// static uint ActiveWindowId;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPITEM_H
|
#endif // APPITEM_H
|
||||||
|
@ -26,6 +26,7 @@ MainPanel::MainPanel(QWidget *parent)
|
|||||||
|
|
||||||
connect(m_itemController, &DockItemController::itemInserted, this, &MainPanel::itemInserted);
|
connect(m_itemController, &DockItemController::itemInserted, this, &MainPanel::itemInserted);
|
||||||
connect(m_itemController, &DockItemController::itemRemoved, this, &MainPanel::itemRemoved);
|
connect(m_itemController, &DockItemController::itemRemoved, this, &MainPanel::itemRemoved);
|
||||||
|
connect(m_itemController, &DockItemController::itemMoved, this, &MainPanel::itemMoved);
|
||||||
|
|
||||||
const QList<DockItem *> itemList = m_itemController->itemList();
|
const QList<DockItem *> itemList = m_itemController->itemList();
|
||||||
for (auto item : itemList)
|
for (auto item : itemList)
|
||||||
@ -158,6 +159,14 @@ void MainPanel::itemRemoved(DockItem *item)
|
|||||||
m_itemLayout->removeWidget(item);
|
m_itemLayout->removeWidget(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainPanel::itemMoved(DockItem *item, const int index)
|
||||||
|
{
|
||||||
|
// remove old item
|
||||||
|
m_itemLayout->removeWidget(item);
|
||||||
|
// insert new position
|
||||||
|
m_itemLayout->insertWidget(index, item);
|
||||||
|
}
|
||||||
|
|
||||||
void MainPanel::itemDragStarted()
|
void MainPanel::itemDragStarted()
|
||||||
{
|
{
|
||||||
DragingItem = qobject_cast<DockItem *>(sender());
|
DragingItem = qobject_cast<DockItem *>(sender());
|
||||||
|
@ -30,6 +30,7 @@ private slots:
|
|||||||
void adjustItemSize();
|
void adjustItemSize();
|
||||||
void itemInserted(const int index, DockItem *item);
|
void itemInserted(const int index, DockItem *item);
|
||||||
void itemRemoved(DockItem *item);
|
void itemRemoved(DockItem *item);
|
||||||
|
void itemMoved(DockItem *item, const int index);
|
||||||
void itemDragStarted();
|
void itemDragStarted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -82,6 +82,10 @@ DockSettings::DockSettings(QObject *parent)
|
|||||||
connect(&m_settingsMenu, &DMenu::triggered, this, &DockSettings::menuActionClicked);
|
connect(&m_settingsMenu, &DMenu::triggered, this, &DockSettings::menuActionClicked);
|
||||||
connect(m_dockInter, &DBusDock::PositionChanged, this, &DockSettings::positionChanged);
|
connect(m_dockInter, &DBusDock::PositionChanged, this, &DockSettings::positionChanged);
|
||||||
connect(m_dockInter, &DBusDock::IconSizeChanged, this, &DockSettings::iconSizeChanged);
|
connect(m_dockInter, &DBusDock::IconSizeChanged, this, &DockSettings::iconSizeChanged);
|
||||||
|
connect(m_dockInter, &DBusDock::DisplayModeChanged, this, &DockSettings::displayModeChanged);
|
||||||
|
|
||||||
|
connect(m_itemController, &DockItemController::itemInserted, this, &DockSettings::dockItemCountChanged, Qt::QueuedConnection);
|
||||||
|
connect(m_itemController, &DockItemController::itemRemoved, this, &DockSettings::dockItemCountChanged, Qt::QueuedConnection);
|
||||||
|
|
||||||
calculateWindowConfig();
|
calculateWindowConfig();
|
||||||
}
|
}
|
||||||
@ -172,27 +176,87 @@ void DockSettings::iconSizeChanged()
|
|||||||
emit dataChanged();
|
emit dataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DockSettings::displayModeChanged()
|
||||||
|
{
|
||||||
|
m_displayMode = Dock::DisplayMode(m_dockInter->displayMode());
|
||||||
|
|
||||||
|
calculateWindowConfig();
|
||||||
|
|
||||||
|
emit dataChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockSettings::dockItemCountChanged()
|
||||||
|
{
|
||||||
|
if (m_displayMode == Dock::Efficient)
|
||||||
|
return;
|
||||||
|
|
||||||
|
calculateWindowConfig();
|
||||||
|
|
||||||
|
emit windowGeometryChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void DockSettings::calculateWindowConfig()
|
void DockSettings::calculateWindowConfig()
|
||||||
{
|
{
|
||||||
const QRect primaryRect = m_displayInter->primaryRect();
|
const QRect primaryRect = m_displayInter->primaryRect();
|
||||||
const int defaultHeight = AppItem::itemBaseHeight();
|
const int defaultHeight = AppItem::itemBaseHeight();
|
||||||
const int defaultWidth = AppItem::itemBaseWidth();
|
const int defaultWidth = AppItem::itemBaseWidth();
|
||||||
|
|
||||||
switch (m_position)
|
if (m_displayMode == Dock::Efficient)
|
||||||
{
|
{
|
||||||
case Top:
|
switch (m_position)
|
||||||
case Bottom:
|
{
|
||||||
m_mainWindowSize.setHeight(defaultHeight);
|
case Top:
|
||||||
m_mainWindowSize.setWidth(primaryRect.width());
|
case Bottom:
|
||||||
break;
|
m_mainWindowSize.setHeight(defaultHeight);
|
||||||
|
m_mainWindowSize.setWidth(primaryRect.width());
|
||||||
|
break;
|
||||||
|
|
||||||
case Left:
|
case Left:
|
||||||
case Right:
|
case Right:
|
||||||
m_mainWindowSize.setHeight(primaryRect.height());
|
m_mainWindowSize.setHeight(primaryRect.height());
|
||||||
m_mainWindowSize.setWidth(defaultWidth);
|
m_mainWindowSize.setWidth(defaultWidth);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Q_ASSERT(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_displayMode == Dock::Fashion)
|
||||||
|
{
|
||||||
|
int appItemCount = 0;
|
||||||
|
int pluginItemCount = 0;
|
||||||
|
const QList<DockItem *> itemList = m_itemController->itemList();
|
||||||
|
for (auto item : itemList)
|
||||||
|
{
|
||||||
|
switch (item->itemType())
|
||||||
|
{
|
||||||
|
case DockItem::Launcher:
|
||||||
|
case DockItem::App: ++appItemCount; break;
|
||||||
|
case DockItem::Plugins: ++pluginItemCount; break;
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int perfectWidth = qMin(primaryRect.width(), defaultWidth * (appItemCount + pluginItemCount));
|
||||||
|
const int perfectHeight = qMin(primaryRect.height(), defaultHeight * (appItemCount + pluginItemCount));
|
||||||
|
switch (m_position)
|
||||||
|
{
|
||||||
|
case Top:
|
||||||
|
case Bottom:
|
||||||
|
m_mainWindowSize.setHeight(defaultHeight);
|
||||||
|
m_mainWindowSize.setWidth(perfectWidth);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Left:
|
||||||
|
case Right:
|
||||||
|
m_mainWindowSize.setHeight(perfectHeight);
|
||||||
|
m_mainWindowSize.setWidth(defaultWidth);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Q_ASSERT(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataChanged() const;
|
void dataChanged() const;
|
||||||
|
void windowGeometryChanged() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateGeometry();
|
void updateGeometry();
|
||||||
@ -39,6 +40,9 @@ private slots:
|
|||||||
void menuActionClicked(DAction *action);
|
void menuActionClicked(DAction *action);
|
||||||
void positionChanged();
|
void positionChanged();
|
||||||
void iconSizeChanged();
|
void iconSizeChanged();
|
||||||
|
void displayModeChanged();
|
||||||
|
|
||||||
|
void dockItemCountChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void calculateWindowConfig();
|
void calculateWindowConfig();
|
||||||
|
@ -68,33 +68,42 @@ void MainWindow::initConnections()
|
|||||||
{
|
{
|
||||||
connect(m_displayInter, &DBusDisplay::PrimaryRectChanged, m_positionUpdateTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
connect(m_displayInter, &DBusDisplay::PrimaryRectChanged, m_positionUpdateTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||||
connect(m_settings, &DockSettings::dataChanged, m_positionUpdateTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
connect(m_settings, &DockSettings::dataChanged, m_positionUpdateTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||||
|
connect(m_settings, &DockSettings::windowGeometryChanged, this, &MainWindow::updateGeometry);
|
||||||
|
|
||||||
connect(m_positionUpdateTimer, &QTimer::timeout, this, &MainWindow::updatePosition);
|
connect(m_positionUpdateTimer, &QTimer::timeout, this, &MainWindow::updatePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updatePosition()
|
void MainWindow::updatePosition()
|
||||||
{
|
{
|
||||||
|
// all update operation need pass by timer
|
||||||
Q_ASSERT(sender() == m_positionUpdateTimer);
|
Q_ASSERT(sender() == m_positionUpdateTimer);
|
||||||
|
|
||||||
clearStrutPartial();
|
clearStrutPartial();
|
||||||
|
updateGeometry();
|
||||||
|
setStrutPartial();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateGeometry()
|
||||||
|
{
|
||||||
setFixedSize(m_settings->windowSize());
|
setFixedSize(m_settings->windowSize());
|
||||||
m_mainPanel->updateDockPosition(m_settings->position());
|
m_mainPanel->updateDockPosition(m_settings->position());
|
||||||
|
|
||||||
const QRect primaryRect = m_displayInter->primaryRect();
|
const QRect primaryRect = m_displayInter->primaryRect();
|
||||||
|
const int offsetX = (primaryRect.width() - width()) / 2;
|
||||||
|
const int offsetY = (primaryRect.height() - height()) / 2;
|
||||||
switch (m_settings->position())
|
switch (m_settings->position())
|
||||||
{
|
{
|
||||||
case Top:
|
case Top:
|
||||||
|
move(primaryRect.topLeft().x() + offsetX, 0); break;
|
||||||
case Left:
|
case Left:
|
||||||
move(primaryRect.topLeft()); break;
|
move(primaryRect.topLeft().x(), offsetY); break;
|
||||||
case Right:
|
case Right:
|
||||||
move(primaryRect.right() - width(), 0); break;
|
move(primaryRect.right() - width(), offsetY); break;
|
||||||
case Bottom:
|
case Bottom:
|
||||||
move(0, primaryRect.bottom() - height() + 1); break;
|
move(offsetX, primaryRect.bottom() - height() + 1); break;
|
||||||
default:
|
default:
|
||||||
Q_ASSERT(false);
|
Q_ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
setStrutPartial();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::clearStrutPartial()
|
void MainWindow::clearStrutPartial()
|
||||||
@ -121,7 +130,7 @@ void MainWindow::setStrutPartial()
|
|||||||
{
|
{
|
||||||
case Position::Top:
|
case Position::Top:
|
||||||
orientation = XcbMisc::OrientationTop;
|
orientation = XcbMisc::OrientationTop;
|
||||||
strut = r.bottom();
|
strut = r.bottom() + 1;
|
||||||
strutStart = r.left();
|
strutStart = r.left();
|
||||||
strutEnd = r.right();
|
strutEnd = r.right();
|
||||||
break;
|
break;
|
||||||
|
@ -26,6 +26,7 @@ private:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatePosition();
|
void updatePosition();
|
||||||
|
void updateGeometry();
|
||||||
void clearStrutPartial();
|
void clearStrutPartial();
|
||||||
void setStrutPartial();
|
void setStrutPartial();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user