mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
bugfix: the position of plugin's menu incorrect
Change-Id: I18888caf8677c902f0e2671971e05844b3e0b257
This commit is contained in:
parent
939c4acd93
commit
8df96a4945
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, 20 Oct 2015 17:52:57 +0800 Reviewed-on: https://cr.deepin.io/7911 Project: dde/dde-dock Branch: refs/heads/master
@ -76,7 +76,8 @@ void PluginItemWrapper::mousePressEvent(QMouseEvent * event)
|
||||
hidePreview(true);
|
||||
|
||||
if (event->button() == Qt::RightButton) {
|
||||
this->showMenu();
|
||||
QRect rec = QApplication::desktop()->screenGeometry();
|
||||
this->showMenu(QPoint(globalX() + width() / 2, rec.height() - DockModeData::instance()->getDockHeight()));
|
||||
} else if (event->button() == Qt::LeftButton) {
|
||||
QString command = m_plugin->getCommand(m_id);
|
||||
if (!command.isEmpty()) QProcess::startDetached(command);
|
||||
|
@ -149,8 +149,8 @@ void AbstractDockItem::showPreview(const QPoint &previewPos)
|
||||
|
||||
m_titlePreview->setArrowX(-1); //reset position
|
||||
m_titlePreview->setContent(m_titleLabel);
|
||||
m_titlePreview->showPreview(globalX() + width() / 2,
|
||||
globalY() -
|
||||
m_titlePreview->showPreview(pos.x(),
|
||||
pos.y() + 5 -
|
||||
m_titlePreview->shadowYOffset() +
|
||||
m_titlePreview->shadowBlurRadius() +
|
||||
m_titlePreview->shadowDistance(),
|
||||
@ -174,7 +174,7 @@ void AbstractDockItem::hidePreview(bool immediately)
|
||||
emit needPreviewHide();
|
||||
}
|
||||
|
||||
void AbstractDockItem::showMenu()
|
||||
void AbstractDockItem::showMenu(const QPoint &menuPos)
|
||||
{
|
||||
if (getMenuContent().isEmpty()) return;
|
||||
|
||||
@ -201,9 +201,10 @@ void AbstractDockItem::showMenu()
|
||||
setHoverable(true);
|
||||
});
|
||||
|
||||
QPoint pos = menuPos.isNull() ? QPoint(globalX() + width() / 2, globalY()) : menuPos;
|
||||
QJsonObject targetObj;
|
||||
targetObj.insert("x", QJsonValue(globalX() + width() / 2));
|
||||
targetObj.insert("y", QJsonValue(globalY() - 5));
|
||||
targetObj.insert("x", QJsonValue(pos.x()));
|
||||
targetObj.insert("y", QJsonValue(pos.y()));
|
||||
targetObj.insert("isDockMenu", QJsonValue(true));
|
||||
targetObj.insert("menuJsonContent", QJsonValue(getMenuContent()));
|
||||
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
void move(const QPoint &value);
|
||||
void resize(const QSize &size);
|
||||
void resize(int width,int height);
|
||||
void showMenu();
|
||||
void showMenu(const QPoint &menuPos = QPoint(0, 0));
|
||||
void showPreview(const QPoint &previewPos = QPoint(0, 0));
|
||||
void hidePreview(bool immediately = false);
|
||||
void setParent(QWidget * parent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user