mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
appitem inherited showMenu function
Change-Id: I627ca0cfe6ae9ff0de1aa9f16bc1bda753cc77f1
This commit is contained in:
parent
e64474b8d7
commit
f10f9cac6a
Notes:
Deepin Code Review
2016-06-14 07:19:47 +00:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: <mr.asianwang@gmail.com> Submitted-by: <mr.asianwang@gmail.com> Submitted-at: Tue, 08 Sep 2015 15:24:41 +0800 Reviewed-on: https://cr.deepin.io/6838 Project: dde/dde-dock Branch: refs/heads/master
@ -68,7 +68,7 @@ void PluginItemWrapper::leaveEvent(QEvent *)
|
||||
|
||||
void PluginItemWrapper::mousePressEvent(QMouseEvent * event)
|
||||
{
|
||||
hidePreview();
|
||||
hidePreview(0);
|
||||
|
||||
if (event->button() == Qt::RightButton) {
|
||||
this->showMenu();
|
||||
|
@ -178,6 +178,8 @@ void AbstractDockItem::showMenu()
|
||||
{
|
||||
if (getMenuContent().isEmpty()) return;
|
||||
|
||||
hidePreview(0);
|
||||
|
||||
if (m_dbusMenuManager == NULL) {
|
||||
m_dbusMenuManager = new DBusMenuManager(this);
|
||||
}
|
||||
|
@ -73,7 +73,6 @@ signals:
|
||||
void moveAnimationFinished();
|
||||
|
||||
protected:
|
||||
|
||||
bool m_moveable = true;
|
||||
bool m_isActived = false;
|
||||
PreviewArrowRectangle *m_previewAR = NULL;
|
||||
|
@ -15,7 +15,6 @@ AppItem::AppItem(QWidget *parent) :
|
||||
initClientManager();
|
||||
connect(m_dockModeData, &DockModeData::dockModeChanged,this, &AppItem::onDockModeChanged);
|
||||
|
||||
initMenu();
|
||||
initPreview();
|
||||
}
|
||||
|
||||
@ -201,11 +200,6 @@ void AppItem::initTitle()
|
||||
m_appTitle->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
||||
}
|
||||
|
||||
void AppItem::initMenu()
|
||||
{
|
||||
m_menuManager = new DBusMenuManager(this);
|
||||
}
|
||||
|
||||
void AppItem::initData()
|
||||
{
|
||||
StringMap dataMap = m_entryProxyer->data();
|
||||
@ -287,12 +281,6 @@ void AppItem::onDockModeChanged(Dock::DockMode, Dock::DockMode)
|
||||
resizeResources();
|
||||
}
|
||||
|
||||
void AppItem::onMenuItemInvoked(QString id, bool)
|
||||
{
|
||||
m_entryProxyer->HandleMenuItem(id);
|
||||
m_menuManager->UnregisterMenu(m_menuInterfacePath);
|
||||
}
|
||||
|
||||
void AppItem::onMousePress(QMouseEvent *event)
|
||||
{
|
||||
//qWarning() << "mouse press...";
|
||||
@ -385,26 +373,14 @@ void AppItem::setActived(bool value)
|
||||
m_appBackground->setIsActived(value);
|
||||
}
|
||||
|
||||
void AppItem::showMenu()
|
||||
void AppItem::invokeMenuItem(QString id, bool)
|
||||
{
|
||||
if (m_menuManager->isValid()){
|
||||
QDBusPendingReply<QDBusObjectPath> pr = m_menuManager->RegisterMenu();
|
||||
if (pr.count() == 1){
|
||||
QDBusObjectPath op = pr.argumentAt(0).value<QDBusObjectPath>();
|
||||
m_menuInterfacePath = op.path();
|
||||
DBusMenu *m_menu = new DBusMenu(m_menuInterfacePath,this);
|
||||
connect(m_menu, &DBusMenu::MenuUnregistered, m_menu, &DBusMenu::deleteLater);
|
||||
connect(m_menu, &DBusMenu::ItemInvoked, this, &AppItem::onMenuItemInvoked);
|
||||
m_entryProxyer->HandleMenuItem(id);
|
||||
}
|
||||
|
||||
QJsonObject targetObj;
|
||||
targetObj.insert("x",QJsonValue(globalX() + width() / 2));
|
||||
targetObj.insert("y",QJsonValue(globalY() - 5));
|
||||
targetObj.insert("isDockMenu",QJsonValue(true));
|
||||
targetObj.insert("menuJsonContent",QJsonValue(m_itemData.menuJsonString));
|
||||
|
||||
m_menu->ShowMenu(QString(QJsonDocument(targetObj).toJson()));
|
||||
}
|
||||
}
|
||||
QString AppItem::getMenuContent()
|
||||
{
|
||||
return m_itemData.menuJsonString;
|
||||
}
|
||||
|
||||
AppItem::~AppItem()
|
||||
|
@ -19,8 +19,6 @@
|
||||
#include "apppreviews.h"
|
||||
#include "appbackground.h"
|
||||
#include "abstractdockitem.h"
|
||||
#include "dbus/dbusmenu.h"
|
||||
#include "dbus/dbusmenumanager.h"
|
||||
#include "dbus/dbusentryproxyer.h"
|
||||
#include "dbus/dbusclientmanager.h"
|
||||
#include "controller/dockmodedata.h"
|
||||
@ -68,7 +66,6 @@ private:
|
||||
void initPreview();
|
||||
void initAppIcon();
|
||||
void initTitle();
|
||||
void initMenu();
|
||||
void initData();
|
||||
|
||||
void updateIcon();
|
||||
@ -79,7 +76,6 @@ private:
|
||||
|
||||
void onDbusDataChanged(const QString &, const QString &);
|
||||
void onDockModeChanged(Dock::DockMode, Dock::DockMode);
|
||||
void onMenuItemInvoked(QString id,bool);
|
||||
void onMousePress(QMouseEvent *event);
|
||||
void onMouseRelease(QMouseEvent *event);
|
||||
void onMouseEnter();
|
||||
@ -90,15 +86,14 @@ private:
|
||||
void reanchorIcon();
|
||||
void setCurrentOpened(uint);
|
||||
void setActived(bool value);
|
||||
void showMenu();
|
||||
void invokeMenuItem(QString id,bool);
|
||||
QString getMenuContent();
|
||||
|
||||
private:
|
||||
QString m_menuInterfacePath = "";
|
||||
AppItemData m_itemData;
|
||||
DockModeData *m_dockModeData = DockModeData::instance();
|
||||
DBusClientManager *m_clientmanager = NULL;
|
||||
DBusEntryProxyer *m_entryProxyer = NULL;
|
||||
DBusMenuManager *m_menuManager = NULL;
|
||||
AppBackground * m_appBackground = NULL;
|
||||
AppPreviews *m_preview = NULL;
|
||||
AppIcon * m_appIcon = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user