mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Add placeholder item
Change-Id: I803667d290cf7a29e5fb536b778c8d2bd69cd3d5
This commit is contained in:
parent
525f24a712
commit
3e39f5f7c8
@ -1,6 +1,7 @@
|
||||
#include "dockitemcontroller.h"
|
||||
#include "dbus/dbusdockentry.h"
|
||||
#include "item/appitem.h"
|
||||
#include "item/placeholderitem.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@ -30,4 +31,5 @@ DockItemController::DockItemController(QObject *parent)
|
||||
{
|
||||
for (auto entry : m_entryManager->entries())
|
||||
m_itemList.append(new AppItem(entry));
|
||||
m_itemList.append(new PlaceholderItem);
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ SOURCES += main.cpp \
|
||||
dbus/dbusdockentry.cpp \
|
||||
dbus/dbusdisplay.cpp \
|
||||
item/appitem.cpp \
|
||||
util/docksettings.cpp
|
||||
util/docksettings.cpp \
|
||||
item/placeholderitem.cpp
|
||||
|
||||
HEADERS += \
|
||||
window/mainwindow.h \
|
||||
@ -28,4 +29,5 @@ HEADERS += \
|
||||
dbus/dbusdockentry.h \
|
||||
dbus/dbusdisplay.h \
|
||||
item/appitem.h \
|
||||
util/docksettings.h
|
||||
util/docksettings.h \
|
||||
item/placeholderitem.h
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <QPainter>
|
||||
|
||||
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||
: DockItem(parent),
|
||||
: DockItem(App, parent),
|
||||
m_itemEntry(new DBusDockEntry(entry.path(), this))
|
||||
{
|
||||
qDebug() << m_itemEntry->data();
|
||||
|
@ -1,11 +1,25 @@
|
||||
#include "dockitem.h"
|
||||
|
||||
DockItem::DockItem(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
DockItem::DockItem(const ItemType type, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_side(DockSettings::Top),
|
||||
m_type(type)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DockItem::setDockSide(const DockSettings::DockSide side)
|
||||
{
|
||||
m_side = side;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
DockItem::ItemType DockItem::itemType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
void DockItem::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
QWidget::paintEvent(e);
|
||||
|
@ -3,21 +3,32 @@
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
#include "util/docksettings.h"
|
||||
|
||||
class DockItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ItemType {
|
||||
Launcher,
|
||||
App,
|
||||
Placeholder,
|
||||
Plugins,
|
||||
};
|
||||
|
||||
public:
|
||||
explicit DockItem(QWidget *parent = nullptr);
|
||||
explicit DockItem(const ItemType type, QWidget *parent = nullptr);
|
||||
void setDockSide(const DockSettings::DockSide side);
|
||||
|
||||
ItemType itemType() const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
protected:
|
||||
DockSettings::DockSide m_side;
|
||||
ItemType m_type;
|
||||
};
|
||||
|
||||
#endif // DOCKITEM_H
|
||||
|
7
item/placeholderitem.cpp
Normal file
7
item/placeholderitem.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "placeholderitem.h"
|
||||
|
||||
PlaceholderItem::PlaceholderItem(QWidget *parent)
|
||||
: DockItem(Placeholder, parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
}
|
14
item/placeholderitem.h
Normal file
14
item/placeholderitem.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef PLACEHOLDERITEM_H
|
||||
#define PLACEHOLDERITEM_H
|
||||
|
||||
#include "dockitem.h"
|
||||
|
||||
class PlaceholderItem : public DockItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlaceholderItem(QWidget *parent = 0);
|
||||
};
|
||||
|
||||
#endif // PLACEHOLDERITEM_H
|
@ -32,3 +32,23 @@ void MainPanel::updateDockSide(const DockSettings::DockSide dockSide)
|
||||
case DockSettings::Right: m_itemLayout->setDirection(QBoxLayout::TopToBottom); break;
|
||||
}
|
||||
}
|
||||
|
||||
void MainPanel::resizeEvent(QResizeEvent *e)
|
||||
{
|
||||
QWidget::resizeEvent(e);
|
||||
|
||||
adjustItemSize();
|
||||
}
|
||||
|
||||
void MainPanel::adjustItemSize()
|
||||
{
|
||||
const QList<DockItem *> itemList = m_itemController->itemList();
|
||||
for (auto item : itemList)
|
||||
{
|
||||
switch (item->itemType())
|
||||
{
|
||||
case DockItem::App: item->setFixedWidth(80); break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,10 @@ public:
|
||||
|
||||
void updateDockSide(const DockSettings::DockSide dockSide);
|
||||
|
||||
private:
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void adjustItemSize();
|
||||
|
||||
private:
|
||||
QBoxLayout *m_itemLayout;
|
||||
|
||||
|
@ -57,5 +57,5 @@ void MainWindow::updatePosition()
|
||||
setFixedWidth(rect.width());
|
||||
setFixedHeight(80);
|
||||
|
||||
move(0, 0);
|
||||
move(0, 950);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user