[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/trash
From: Marco Martin <notmart () gmail ! com>
Date: 2007-12-11 13:36:42
Message-ID: 1197380202.048868.8492.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 747255 by mart:
Adapt to the change in Plasma::icon that doesn't have pressed(bool, \
QGraphicsSceneMouseEvent*) anymore but only pressed(bool) and the popup positioning \
behaves more like Kickoff
M +19 -11 trash.cpp
M +1 -1 trash.h
--- trunk/playground/base/plasma/applets/trash/trash.cpp #747254:747255
@@ -19,8 +19,12 @@
#include "trash.h"
+//QT
#include <QGraphicsSceneDragDropEvent>
+#include <QDesktopWidget>
+#include <QApplication>
+//KDE
#include <KDebug>
#include <KLocale>
#include <KIconLoader>
@@ -53,8 +57,8 @@
createMenu();
- connect(m_icon, SIGNAL(pressed(bool, QGraphicsSceneMouseEvent*)),
- this, SLOT(popup(bool,QGraphicsSceneMouseEvent*)));
+ connect(m_icon, SIGNAL(pressed(bool)),
+ this, SLOT(popup(bool)));
setMinimumSize(QSize(84,84));
setMaximumSize(QSize(400,400));
@@ -92,7 +96,7 @@
m_menu.addAction(empty);
}
-void Trash::popup(bool pressed, QGraphicsSceneMouseEvent *event)
+void Trash::popup(bool pressed)
{
if (!pressed || m_menu.isVisible()) {
m_menu.hide();
@@ -100,17 +104,21 @@
}
QPointF scenePos = mapToScene(boundingRect().topLeft());
- QWidget *viewWidget = event->widget() ? event->widget()->parentWidget() : 0;
- QGraphicsView *view = qobject_cast<QGraphicsView*>(viewWidget);
- if (view) {
- QPoint viewPos = view->mapFromScene(scenePos);
- QPoint globalPos = view->mapToGlobal(viewPos);
- int popupY = globalPos.ry() - m_menu.sizeHint().height();
+ QGraphicsView *viewWidget = view();
+ QDesktopWidget *desktop = QApplication::desktop();
+ if (viewWidget) {
+ QPoint viewPos = viewWidget->mapFromScene(scenePos);
+ QPoint globalPos = viewWidget->mapToGlobal(viewPos);
+ QRect desktopRect = desktop->availableGeometry(viewWidget);
+ QRect size = mapToView(viewWidget, contentRect());
- if (popupY < 0 && globalPos.ry() < view->height()/2){
+ const int menuHeight = m_menu.sizeHint().height();
+
+ if (globalPos.y() + size.height() + menuHeight
+ < desktopRect.bottom()) {
globalPos.ry() += contentSize().height();
}else{
- globalPos.ry() = popupY;
+ globalPos.ry() -= menuHeight;
}
m_menu.popup(globalPos);
}
--- trunk/playground/base/plasma/applets/trash/trash.h #747254:747255
@@ -60,7 +60,7 @@
void setIcon();
protected slots:
- void popup(bool pressed, QGraphicsSceneMouseEvent *event);
+ void popup(bool pressed);
void slotClear();
void slotCompleted();
void slotDeleteItem(KFileItem *);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic