add container item

Change-Id: I4a33a2286b5a5bea98aa08fa7729e00ab7cc936e
This commit is contained in:
石博文 2016-08-08 09:52:05 +08:00
parent ac74a279bd
commit 66f9aff697
Notes: Deepin Code Review 2016-08-08 01:57:45 +00:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: 石博文 <sbw@sbw.so>
Submitted-by: 石博文 <sbw@sbw.so>
Submitted-at: Mon, 08 Aug 2016 01:57:45 +0000
Reviewed-on: https://cr.deepin.io/14960
Project: dde/dde-dock
Branch: refs/heads/master
15 changed files with 47 additions and 17 deletions

View File

@ -33,7 +33,8 @@ SOURCES += main.cpp \
dbus/dbusxmousearea.cpp \
item/stretchitem.cpp \
item/placeholderitem.cpp \
controller/dockpluginloader.cpp
controller/dockpluginloader.cpp \
item/containeritem.cpp
HEADERS += \
window/mainwindow.h \
@ -58,7 +59,8 @@ HEADERS += \
dbus/dbusxmousearea.h \
item/stretchitem.h \
item/placeholderitem.h \
controller/dockpluginloader.h
controller/dockpluginloader.h \
item/containeritem.h
dbus_service.files += com.deepin.dde.dock.service
dbus_service.path = /usr/share/dbus-1/services

View File

@ -14,7 +14,7 @@ int AppItem::IconBaseSize;
QPoint AppItem::MousePressPos;
AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
: DockItem(App, parent),
: DockItem(parent),
m_appNameTips(new QLabel(this)),
m_itemEntry(new DBusDockEntry(entry.path(), this)),
m_draging(false),

View File

@ -19,6 +19,8 @@ public:
static int itemBaseHeight();
static int itemBaseWidth();
inline ItemType itemType() const {return App;}
private:
void paintEvent(QPaintEvent *e);
void mouseReleaseEvent(QMouseEvent *e);

View File

@ -0,0 +1,7 @@
#include "containeritem.h"
ContainerItem::ContainerItem(QWidget *parent)
: DockItem(parent)
{
}

View File

@ -0,0 +1,16 @@
#ifndef CONTAINERITEM_H
#define CONTAINERITEM_H
#include "dockitem.h"
class ContainerItem : public DockItem
{
Q_OBJECT
public:
explicit ContainerItem(QWidget *parent = 0);
inline ItemType itemType() const {return Container;}
};
#endif // CONTAINERITEM_H

View File

@ -10,9 +10,8 @@ Position DockItem::DockPosition = Position::Top;
DisplayMode DockItem::DockDisplayMode = DisplayMode::Efficient;
std::unique_ptr<DockPopupWindow> DockItem::PopupWindow(nullptr);
DockItem::DockItem(const ItemType type, QWidget *parent)
DockItem::DockItem(QWidget *parent)
: QWidget(parent),
m_type(type),
m_hover(false),
m_popupShown(false),
@ -49,11 +48,6 @@ void DockItem::setDockDisplayMode(const DisplayMode mode)
DockDisplayMode = mode;
}
DockItem::ItemType DockItem::itemType() const
{
return m_type;
}
void DockItem::updatePopupPosition()
{
if (!m_popupShown || !PopupWindow->isVisible())

View File

@ -21,16 +21,17 @@ public:
App,
Stretch,
Plugins,
Container,
};
public:
explicit DockItem(const ItemType type, QWidget *parent = nullptr);
explicit DockItem(QWidget *parent = nullptr);
~DockItem();
static void setDockPosition(const Position side);
static void setDockDisplayMode(const DisplayMode mode);
ItemType itemType() const;
inline virtual ItemType itemType() const = 0;
signals:
void dragStarted() const;
@ -61,7 +62,6 @@ private:
void showPopupWindow(QWidget * const content, const bool model = false);
protected:
ItemType m_type;
bool m_hover;
bool m_popupShown;

View File

@ -7,7 +7,7 @@
#include <QMouseEvent>
LauncherItem::LauncherItem(QWidget *parent)
: DockItem(DockItem::Launcher, parent),
: DockItem(parent),
m_tips(new QLabel(this))
{

View File

@ -10,6 +10,8 @@ class LauncherItem : public DockItem
public:
explicit LauncherItem(QWidget *parent = 0);
inline ItemType itemType() const {return Launcher;}
private:
void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e);

View File

@ -1,6 +1,6 @@
#include "placeholderitem.h"
PlaceholderItem::PlaceholderItem(QWidget *parent)
: DockItem(App, parent)
: DockItem(parent)
{
}

View File

@ -9,6 +9,9 @@ class PlaceholderItem : public DockItem
public:
explicit PlaceholderItem(QWidget *parent = 0);
// fake as app item
inline ItemType itemType() const {return App;}
};
#endif // PLACEHOLDERITEM_H

View File

@ -14,7 +14,7 @@
QPoint PluginsItem::MousePressPoint = QPoint();
PluginsItem::PluginsItem(PluginsItemInterface* const pluginInter, const QString &itemKey, QWidget *parent)
: DockItem(Plugins, parent),
: DockItem(parent),
m_pluginInter(pluginInter),
m_centeralWidget(m_pluginInter->itemWidget(itemKey)),
m_itemKey(itemKey),

View File

@ -15,6 +15,8 @@ public:
int itemSortKey() const;
void detachPluginWidget();
inline ItemType itemType() const {return Plugins;}
private:
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);

View File

@ -3,7 +3,7 @@
#include <QPaintEvent>
StretchItem::StretchItem(QWidget *parent)
: DockItem(Stretch, parent)
: DockItem(parent)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}

View File

@ -10,6 +10,8 @@ class StretchItem : public DockItem
public:
explicit StretchItem(QWidget *parent = 0);
inline ItemType itemType() const {return Stretch;}
private:
void mousePressEvent(QMouseEvent *e);
};