mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Separate DockItem as base class for AppItem and AppletItem
This commit is contained in:
parent
6a1866d0dd
commit
880b38ea00
@ -1,7 +1,7 @@
|
|||||||
#include "appitem.h"
|
#include "appitem.h"
|
||||||
|
|
||||||
AppItem::AppItem(QWidget *parent) :
|
AppItem::AppItem(QWidget *parent) :
|
||||||
QFrame(parent)
|
DockItem(parent)
|
||||||
{
|
{
|
||||||
setParent(parent);
|
setParent(parent);
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ AppItem::AppItem(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppItem::AppItem(QString title, QWidget *parent):
|
AppItem::AppItem(QString title, QWidget *parent):
|
||||||
QFrame(parent)
|
DockItem(parent)
|
||||||
{
|
{
|
||||||
this->setParent(parent);
|
this->setParent(parent);
|
||||||
this->itemTitle = title;
|
this->itemTitle = title;
|
||||||
@ -19,7 +19,7 @@ AppItem::AppItem(QString title, QWidget *parent):
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppItem::AppItem(QString title, QString iconPath, QWidget *parent) :
|
AppItem::AppItem(QString title, QString iconPath, QWidget *parent) :
|
||||||
QFrame(parent)
|
DockItem(parent)
|
||||||
{
|
{
|
||||||
this->setParent(parent);
|
this->setParent(parent);
|
||||||
this->itemTitle = title;
|
this->itemTitle = title;
|
||||||
@ -29,18 +29,6 @@ AppItem::AppItem(QString title, QString iconPath, QWidget *parent) :
|
|||||||
this->setIcon(itemIconPath);
|
this->setIcon(itemIconPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::setTitle(const QString &title)
|
|
||||||
{
|
|
||||||
this->itemTitle = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppItem::setIcon(const QString &iconPath, int size)
|
|
||||||
{
|
|
||||||
appIcon = new AppIcon(iconPath,this);
|
|
||||||
appIcon->resize(size,size);
|
|
||||||
appIcon->move(this->width() / 2, this->height() / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppItem::resize(const QSize &size)
|
void AppItem::resize(const QSize &size)
|
||||||
{
|
{
|
||||||
QFrame::resize(size);
|
QFrame::resize(size);
|
||||||
@ -53,26 +41,6 @@ void AppItem::resize(int width, int height)
|
|||||||
resizeResources();
|
resizeResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::setMoveable(bool value)
|
|
||||||
{
|
|
||||||
this->itemMoveable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AppItem::getMoveable()
|
|
||||||
{
|
|
||||||
return this->itemMoveable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppItem::setIndex(int value)
|
|
||||||
{
|
|
||||||
this->itemIndex = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
int AppItem::getIndex()
|
|
||||||
{
|
|
||||||
return this->itemIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPoint AppItem::getNextPos()
|
QPoint AppItem::getNextPos()
|
||||||
{
|
{
|
||||||
return this->nextPos;
|
return this->nextPos;
|
||||||
|
@ -10,14 +10,13 @@
|
|||||||
#include <QDrag>
|
#include <QDrag>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "dockitem.h"
|
||||||
#include "dockconstants.h"
|
#include "dockconstants.h"
|
||||||
#include "appicon.h"
|
#include "appicon.h"
|
||||||
#include "appbackground.h"
|
#include "appbackground.h"
|
||||||
#include "QDebug"
|
|
||||||
|
|
||||||
class QDragEnterEvent;
|
class AppItem : public DockItem
|
||||||
class QDropEvent;
|
|
||||||
class AppItem : public QFrame
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QPoint pos READ pos WRITE move)
|
Q_PROPERTY(QPoint pos READ pos WRITE move)
|
||||||
@ -27,14 +26,8 @@ public:
|
|||||||
AppItem(QString title, QString iconPath, QWidget *parent = 0);
|
AppItem(QString title, QString iconPath, QWidget *parent = 0);
|
||||||
~AppItem();
|
~AppItem();
|
||||||
|
|
||||||
void setTitle(const QString &title);
|
|
||||||
void setIcon(const QString &iconPath, int size = 42);
|
|
||||||
void resize(const QSize &size);
|
void resize(const QSize &size);
|
||||||
void resize(int width, int height);
|
void resize(int width, int height);
|
||||||
void setMoveable(bool value);
|
|
||||||
bool getMoveable();
|
|
||||||
void setIndex(int value);
|
|
||||||
int getIndex();
|
|
||||||
QPoint getNextPos();
|
QPoint getNextPos();
|
||||||
void setNextPos(const QPoint &value);
|
void setNextPos(const QPoint &value);
|
||||||
void setNextPos(int x, int y);
|
void setNextPos(int x, int y);
|
||||||
@ -67,17 +60,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
AppBackground * appBackground = NULL;
|
AppBackground * appBackground = NULL;
|
||||||
AppIcon * appIcon = NULL;
|
|
||||||
QPoint nextPos;
|
QPoint nextPos;
|
||||||
int itemIndex;
|
|
||||||
|
|
||||||
bool itemMoveable = true;
|
|
||||||
bool itemHover = false;
|
|
||||||
bool itemActived = false;
|
|
||||||
bool itemDraged = false;
|
|
||||||
|
|
||||||
QString itemTitle = "";
|
|
||||||
QString itemIconPath = "";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPITEM_H
|
#endif // APPITEM_H
|
||||||
|
53
dde-dock/Widgets/dockitem.cpp
Normal file
53
dde-dock/Widgets/dockitem.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#include "dockitem.h"
|
||||||
|
|
||||||
|
DockItem::DockItem(QWidget *parent) :
|
||||||
|
QFrame(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget * DockItem::getContents()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockItem::setTitle(const QString &title)
|
||||||
|
{
|
||||||
|
this->itemTitle = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockItem::setIcon(const QString &iconPath, int size)
|
||||||
|
{
|
||||||
|
appIcon = new AppIcon(iconPath,this);
|
||||||
|
appIcon->resize(size,size);
|
||||||
|
appIcon->move(this->width() / 2, this->height() / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockItem::setActived(bool value)
|
||||||
|
{
|
||||||
|
this->itemActived = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DockItem::actived()
|
||||||
|
{
|
||||||
|
return this->itemActived;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockItem::setMoveable(bool value)
|
||||||
|
{
|
||||||
|
this->itemMoveable = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DockItem::moveable()
|
||||||
|
{
|
||||||
|
return this->itemMoveable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DockItem::setIndex(int value)
|
||||||
|
{
|
||||||
|
this->itemIndex = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DockItem::index()
|
||||||
|
{
|
||||||
|
return this->itemIndex;
|
||||||
|
}
|
42
dde-dock/Widgets/dockitem.h
Normal file
42
dde-dock/Widgets/dockitem.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#ifndef DOCKITEM_H
|
||||||
|
#define DOCKITEM_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QRectF>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "dockconstants.h"
|
||||||
|
#include "appicon.h"
|
||||||
|
|
||||||
|
class DockItem : public QFrame
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit DockItem(QWidget *parent = 0);
|
||||||
|
virtual ~DockItem(){}
|
||||||
|
|
||||||
|
virtual QWidget * getContents();
|
||||||
|
|
||||||
|
virtual void setTitle(const QString &title);
|
||||||
|
virtual void setIcon(const QString &iconPath, int size = 42);
|
||||||
|
virtual void setMoveable(bool value);
|
||||||
|
virtual bool moveable();
|
||||||
|
virtual void setActived(bool value);
|
||||||
|
virtual bool actived();
|
||||||
|
virtual void setIndex(int value);
|
||||||
|
virtual int index();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
AppIcon * appIcon = NULL;
|
||||||
|
|
||||||
|
bool itemMoveable = true;
|
||||||
|
bool itemActived = false;
|
||||||
|
|
||||||
|
QString itemTitle = "";
|
||||||
|
QString itemIconPath = "";
|
||||||
|
int itemIndex = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DOCKITEM_H
|
@ -23,7 +23,8 @@ SOURCES += main.cpp\
|
|||||||
Widgets/dockitemdelegate.cpp \
|
Widgets/dockitemdelegate.cpp \
|
||||||
Widgets/appitem.cpp \
|
Widgets/appitem.cpp \
|
||||||
Widgets/docklayout.cpp \
|
Widgets/docklayout.cpp \
|
||||||
Widgets/windowpreview.cpp
|
Widgets/windowpreview.cpp \
|
||||||
|
Widgets/dockitem.cpp
|
||||||
|
|
||||||
HEADERS += mainwidget.h \
|
HEADERS += mainwidget.h \
|
||||||
Panel/panel.h \
|
Panel/panel.h \
|
||||||
@ -35,7 +36,8 @@ HEADERS += mainwidget.h \
|
|||||||
Widgets/dockitemdelegate.h \
|
Widgets/dockitemdelegate.h \
|
||||||
Widgets/appitem.h \
|
Widgets/appitem.h \
|
||||||
Widgets/docklayout.h \
|
Widgets/docklayout.h \
|
||||||
Widgets/windowpreview.h
|
Widgets/windowpreview.h \
|
||||||
|
Widgets/dockitem.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
images.qrc
|
images.qrc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user