mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
Add Launcher item
This commit is contained in:
parent
65d7df422f
commit
59c4199434
@ -43,7 +43,8 @@ SOURCES += \
|
||||
src/Widgets/apppreviews.cpp \
|
||||
src/Widgets/closebutton.cpp \
|
||||
src/DBus/dbushidestatemanager.cpp \
|
||||
../libs/xcb_misc.cpp
|
||||
../libs/xcb_misc.cpp \
|
||||
src/Widgets/launcheritem.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/abstractdockitem.h \
|
||||
@ -76,7 +77,8 @@ HEADERS += \
|
||||
src/Widgets/apppreviews.h \
|
||||
src/Widgets/closebutton.h \
|
||||
src/DBus/dbushidestatemanager.h \
|
||||
../libs/xcb_misc.h
|
||||
../libs/xcb_misc.h \
|
||||
src/Widgets/launcheritem.h
|
||||
|
||||
RESOURCES += \
|
||||
images.qrc \
|
||||
|
@ -9,6 +9,10 @@ AppManager::AppManager(QObject *parent) : QObject(parent)
|
||||
|
||||
void AppManager::updateEntries()
|
||||
{
|
||||
|
||||
LauncherItem * lItem = new LauncherItem();
|
||||
emit entryAdded(lItem);
|
||||
|
||||
QList<QDBusObjectPath> entryList = m_entryManager->entries();
|
||||
for (int i = 0; i < entryList.count(); i ++)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "DBus/dbusentrymanager.h"
|
||||
#include "DBus/dbusentryproxyer.h"
|
||||
#include "Widgets/appitem.h"
|
||||
#include "Widgets/launcheritem.h"
|
||||
|
||||
class AppManager : public QObject
|
||||
{
|
||||
@ -15,7 +16,7 @@ public:
|
||||
void updateEntries();
|
||||
|
||||
signals:
|
||||
void entryAdded(AppItem *item);
|
||||
void entryAdded(AbstractDockItem *item);
|
||||
void entryRemoved(const QString &id);
|
||||
|
||||
private slots:
|
||||
|
@ -86,6 +86,7 @@ void Panel::slotDragStarted()
|
||||
void Panel::slotItemDropped()
|
||||
{
|
||||
hideScreenMask();
|
||||
leftLayout->clearTmpItem();
|
||||
leftLayout->relayout();
|
||||
}
|
||||
|
||||
@ -96,7 +97,7 @@ void Panel::slotEnteredMask()
|
||||
|
||||
void Panel::slotExitedMask()
|
||||
{
|
||||
// leftLayout->relayout();
|
||||
leftLayout->relayout();
|
||||
}
|
||||
|
||||
void Panel::changeDockMode(Dock::DockMode newMode, Dock::DockMode oldMode)
|
||||
@ -116,7 +117,7 @@ void Panel::slotLayoutContentsWidthChanged()
|
||||
reanchorsLayout(dockCons->getDockMode());
|
||||
}
|
||||
|
||||
void Panel::slotAddAppItem(AppItem *item)
|
||||
void Panel::slotAddAppItem(AbstractDockItem *item)
|
||||
{
|
||||
leftLayout->addItem(item);
|
||||
}
|
||||
@ -127,7 +128,7 @@ void Panel::slotRemoveAppItem(const QString &id)
|
||||
for (int i = 0; i < tmpList.count(); i ++)
|
||||
{
|
||||
AppItem *tmpItem = qobject_cast<AppItem *>(tmpList.at(i));
|
||||
if (tmpItem->itemId() == id)
|
||||
if (tmpItem && tmpItem->itemId() == id)
|
||||
{
|
||||
leftLayout->removeItem(i);
|
||||
return;
|
||||
@ -195,7 +196,7 @@ void Panel::updateBackground()
|
||||
void Panel::initAppManager()
|
||||
{
|
||||
m_appManager = new AppManager(this);
|
||||
connect(m_appManager,SIGNAL(entryAdded(AppItem*)),this, SLOT(slotAddAppItem(AppItem*)));
|
||||
connect(m_appManager,SIGNAL(entryAdded(AbstractDockItem*)),this, SLOT(slotAddAppItem(AbstractDockItem*)));
|
||||
connect(m_appManager, SIGNAL(entryRemoved(QString)),this, SLOT(slotRemoveAppItem(QString)));
|
||||
m_appManager->updateEntries();
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ signals:
|
||||
private slots:
|
||||
void slotLayoutContentsWidthChanged();
|
||||
|
||||
void slotAddAppItem(AppItem *item);
|
||||
void slotAddAppItem(AbstractDockItem *item);
|
||||
void slotRemoveAppItem(const QString &id);
|
||||
|
||||
protected:
|
||||
|
@ -257,6 +257,16 @@ void DockLayout::relayout()
|
||||
emit contentsWidthChange();
|
||||
}
|
||||
|
||||
void DockLayout::clearTmpItem()
|
||||
{
|
||||
if (tmpAppMap.count() > 0)
|
||||
{
|
||||
AbstractDockItem * tmpItem = tmpAppMap.firstKey();
|
||||
tmpAppMap.clear();
|
||||
tmpItem->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void DockLayout::addSpacingItem()
|
||||
{
|
||||
int spacingValue = 0;
|
||||
@ -327,7 +337,6 @@ void DockLayout::dragEnterEvent(QDragEnterEvent *event)
|
||||
|
||||
void DockLayout::dropEvent(QDropEvent *event)
|
||||
{
|
||||
//("text/plain", "COMPOUND_TEXT", "text/plain;charset=utf-8", "_DEEPIN_DND", "text/uri-list")
|
||||
AbstractDockItem *sourceItem = NULL;
|
||||
sourceItem = dynamic_cast<AbstractDockItem *>(event->source());
|
||||
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void relayout();
|
||||
void clearTmpItem();
|
||||
|
||||
signals:
|
||||
void dragStarted();
|
||||
|
53
dde-dock/src/Widgets/launcheritem.cpp
Normal file
53
dde-dock/src/Widgets/launcheritem.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "launcheritem.h"
|
||||
|
||||
LauncherItem::LauncherItem(QWidget *parent) : AbstractDockItem(parent)
|
||||
{
|
||||
resize(m_dmd->getNormalItemWidth(), m_dmd->getItemHeight());
|
||||
connect(m_dmd, &DockModeData::dockModeChanged, this, &LauncherItem::changeDockMode);
|
||||
|
||||
m_appIcon = new AppIcon(this);
|
||||
m_appIcon->resize(height(), height());
|
||||
|
||||
m_launcherProcess = new QProcess();
|
||||
|
||||
//TODO icon not show on init
|
||||
QTimer::singleShot(20, this, &LauncherItem::updateIcon);
|
||||
}
|
||||
|
||||
void LauncherItem::mousePressEvent(QMouseEvent *)
|
||||
{
|
||||
hidePreview();
|
||||
}
|
||||
|
||||
void LauncherItem::mouseReleaseEvent(QMouseEvent *)
|
||||
{
|
||||
m_launcherProcess->start("dde-launcher",QStringList());
|
||||
}
|
||||
|
||||
void LauncherItem::enterEvent(QEvent *)
|
||||
{
|
||||
showPreview();
|
||||
}
|
||||
|
||||
void LauncherItem::leaveEvent(QEvent *)
|
||||
{
|
||||
hidePreview();
|
||||
}
|
||||
|
||||
void LauncherItem::changeDockMode(Dock::DockMode, Dock::DockMode)
|
||||
{
|
||||
resize(m_dmd->getNormalItemWidth(), m_dmd->getItemHeight());
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
void LauncherItem::updateIcon()
|
||||
{
|
||||
m_appIcon->setIcon("deepin-launcher");
|
||||
m_appIcon->move((width() - m_appIcon->width()) / 2, (height() - m_appIcon->height()) / 2);
|
||||
}
|
||||
|
||||
LauncherItem::~LauncherItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
43
dde-dock/src/Widgets/launcheritem.h
Normal file
43
dde-dock/src/Widgets/launcheritem.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef LAUNCHERITEM_H
|
||||
#define LAUNCHERITEM_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
#include "Controller/dockmodedata.h"
|
||||
#include "abstractdockitem.h"
|
||||
#include "appicon.h"
|
||||
#include "arrowrectangle.h"
|
||||
#include "../dockconstants.h"
|
||||
|
||||
class LauncherItem : public AbstractDockItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LauncherItem(QWidget *parent = 0);
|
||||
~LauncherItem();
|
||||
|
||||
QString getTitle(){return "Launcher";}
|
||||
QWidget * getApplet(){return NULL;}
|
||||
bool moveable(){return false;}
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void mouseReleaseEvent(QMouseEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
|
||||
private:
|
||||
void changeDockMode(Dock::DockMode newMode, Dock::DockMode oldMode);
|
||||
void updateIcon();
|
||||
|
||||
private:
|
||||
DockModeData * m_dmd = DockModeData::instance();
|
||||
AppIcon * m_appIcon = NULL;
|
||||
QProcess * m_launcherProcess = NULL;
|
||||
QString m_menuInterfacePath = "";
|
||||
};
|
||||
|
||||
#endif // LAUNCHERITEM_H
|
Loading…
x
Reference in New Issue
Block a user