diff --git a/frame/frame.pro b/frame/frame.pro index abcf59ee9..4c0230c6e 100644 --- a/frame/frame.pro +++ b/frame/frame.pro @@ -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 diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index 353eb7a48..b3baed502 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -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), diff --git a/frame/item/appitem.h b/frame/item/appitem.h index a002d5be0..5f817bfd2 100644 --- a/frame/item/appitem.h +++ b/frame/item/appitem.h @@ -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); diff --git a/frame/item/containeritem.cpp b/frame/item/containeritem.cpp new file mode 100644 index 000000000..3a95bc111 --- /dev/null +++ b/frame/item/containeritem.cpp @@ -0,0 +1,7 @@ +#include "containeritem.h" + +ContainerItem::ContainerItem(QWidget *parent) + : DockItem(parent) +{ + +} diff --git a/frame/item/containeritem.h b/frame/item/containeritem.h new file mode 100644 index 000000000..3c138f36f --- /dev/null +++ b/frame/item/containeritem.h @@ -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 diff --git a/frame/item/dockitem.cpp b/frame/item/dockitem.cpp index ebcc64668..7321bd9ef 100644 --- a/frame/item/dockitem.cpp +++ b/frame/item/dockitem.cpp @@ -10,9 +10,8 @@ Position DockItem::DockPosition = Position::Top; DisplayMode DockItem::DockDisplayMode = DisplayMode::Efficient; std::unique_ptr 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()) diff --git a/frame/item/dockitem.h b/frame/item/dockitem.h index fcd28df3b..c6d2e9306 100644 --- a/frame/item/dockitem.h +++ b/frame/item/dockitem.h @@ -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; diff --git a/frame/item/launcheritem.cpp b/frame/item/launcheritem.cpp index 3d4d39495..55bae2246 100644 --- a/frame/item/launcheritem.cpp +++ b/frame/item/launcheritem.cpp @@ -7,7 +7,7 @@ #include LauncherItem::LauncherItem(QWidget *parent) - : DockItem(DockItem::Launcher, parent), + : DockItem(parent), m_tips(new QLabel(this)) { diff --git a/frame/item/launcheritem.h b/frame/item/launcheritem.h index a6b4e639d..8ed4d78b6 100644 --- a/frame/item/launcheritem.h +++ b/frame/item/launcheritem.h @@ -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); diff --git a/frame/item/placeholderitem.cpp b/frame/item/placeholderitem.cpp index 6579d9f22..8d35598d2 100644 --- a/frame/item/placeholderitem.cpp +++ b/frame/item/placeholderitem.cpp @@ -1,6 +1,6 @@ #include "placeholderitem.h" PlaceholderItem::PlaceholderItem(QWidget *parent) - : DockItem(App, parent) + : DockItem(parent) { } diff --git a/frame/item/placeholderitem.h b/frame/item/placeholderitem.h index ada516ceb..d90354bb0 100644 --- a/frame/item/placeholderitem.h +++ b/frame/item/placeholderitem.h @@ -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 diff --git a/frame/item/pluginsitem.cpp b/frame/item/pluginsitem.cpp index 16c7ecca9..e90838097 100644 --- a/frame/item/pluginsitem.cpp +++ b/frame/item/pluginsitem.cpp @@ -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), diff --git a/frame/item/pluginsitem.h b/frame/item/pluginsitem.h index 85233ac8a..30f754af7 100644 --- a/frame/item/pluginsitem.h +++ b/frame/item/pluginsitem.h @@ -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); diff --git a/frame/item/stretchitem.cpp b/frame/item/stretchitem.cpp index e902d60c7..e79a681a6 100644 --- a/frame/item/stretchitem.cpp +++ b/frame/item/stretchitem.cpp @@ -3,7 +3,7 @@ #include StretchItem::StretchItem(QWidget *parent) - : DockItem(Stretch, parent) + : DockItem(parent) { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } diff --git a/frame/item/stretchitem.h b/frame/item/stretchitem.h index 788570be7..04d15b122 100644 --- a/frame/item/stretchitem.h +++ b/frame/item/stretchitem.h @@ -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); };