allow popup applets to define the alignment of their popup

svn path=/trunk/KDE/kdelibs/; revision=1174612
This commit is contained in:
Aaron J. Seigo 2010-09-12 23:54:30 +00:00
parent 43b5b80b47
commit 2f9828b966
3 changed files with 30 additions and 3 deletions

View File

@ -609,6 +609,16 @@ Plasma::PopupPlacement PopupApplet::popupPlacement() const
return d->popupPlacement;
}
void PopupApplet::setPopupAlignment(Qt::AlignmentFlag alignment)
{
d->popupAlignment = alignment;
}
Qt::AlignmentFlag PopupApplet::popupAlignment() const
{
return d->popupAlignment;
}
void PopupApplet::popupEvent(bool popped)
{
if (Applet::d->script) {
@ -637,6 +647,7 @@ PopupAppletPrivate::PopupAppletPrivate(PopupApplet *applet)
widget(0),
graphicsWidget(0),
popupPlacement(Plasma::FloatingPopup),
popupAlignment(Qt::AlignLeft),
savedAspectRatio(Plasma::InvalidAspectRatioMode),
timer(0),
popupLostFocus(false),
@ -824,9 +835,9 @@ void PopupAppletPrivate::updateDialogPosition()
QPoint pos = view->mapFromScene(q->scenePos());
if (!q->containment() || view == q->containment()->view()) {
pos = corona->popupPosition(q, s);
pos = corona->popupPosition(q, s, popupAlignment);
} else {
pos = corona->popupPosition(q->parentItem(), s);
pos = corona->popupPosition(q->parentItem(), s, popupAlignment);
}
bool reverse = false;

View File

@ -52,6 +52,8 @@ class PopupAppletPrivate;
class PLASMA_EXPORT PopupApplet : public Plasma::Applet
{
Q_OBJECT
Q_PROPERTY(Qt::AlignmentFlag popupAlignment READ popupAlignment WRITE setPopupAlignment)
public:
PopupApplet(QObject *parent, const QVariantList &args);
~PopupApplet();
@ -99,10 +101,23 @@ public:
void setGraphicsWidget(QGraphicsWidget * widget);
/**
* @return the placement of the popup relating to the icon
* @return the placement of the popup relating to the applet
*/
Plasma::PopupPlacement popupPlacement() const;
/**
* Sets the default alignment of the popup relative to the applet
* @arg alignment the alignment to use; Qt::AlignLeft or Qt::AlignRight
* @since 4.6
*/
void setPopupAlignment(Qt::AlignmentFlag alignment);
/**
* @return the default alignment of the popup relative to the applet
* @since 4.6
*/
Qt::AlignmentFlag popupAlignment() const;
/**
* Sets whether or not the dialog popup that gets created should be a "passive" popup
* that does not steal focus from other windows or not.

View File

@ -53,6 +53,7 @@ public:
QWidget *widget;
QGraphicsWidget *graphicsWidget;
Plasma::PopupPlacement popupPlacement;
Qt::AlignmentFlag popupAlignment;
Plasma::AspectRatioMode savedAspectRatio;
QTimer *timer;
QPoint clicked;