put all context menus in a separate window, resolving cutting and z-order issues
BUG:207956 svn path=/trunk/KDE/kdelibs/; revision=1067048
This commit is contained in:
parent
eaa5b602be
commit
06341cfb73
@ -25,6 +25,7 @@
|
||||
#include <QDir>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QMenu>
|
||||
|
||||
#include <kmimetype.h>
|
||||
#include <kglobalsettings.h>
|
||||
@ -113,6 +114,7 @@ Label::Label(QGraphicsWidget *parent)
|
||||
d(new LabelPrivate(this))
|
||||
{
|
||||
QLabel *native = new QLabel;
|
||||
native->setWindowFlags(native->windowFlags()|Qt::BypassGraphicsProxyWidget);
|
||||
d->textSelectable = false;
|
||||
connect(native, SIGNAL(linkActivated(QString)), this, SIGNAL(linkActivated(QString)));
|
||||
connect(native, SIGNAL(linkHovered(QString)), this, SIGNAL(linkHovered(QString)));
|
||||
@ -234,6 +236,13 @@ void Label::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Dat
|
||||
setText(texts.join(" "));
|
||||
}
|
||||
|
||||
void Label::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
QContextMenuEvent contextMenuEvent(QContextMenuEvent::Reason(event->reason()),
|
||||
event->pos().toPoint(), event->screenPos(), event->modifiers());
|
||||
QApplication::sendEvent(nativeWidget(), &contextMenuEvent);
|
||||
}
|
||||
|
||||
void Label::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
d->setPixmap();
|
||||
|
@ -152,6 +152,7 @@ protected:
|
||||
QWidget *widget);
|
||||
void changeEvent(QEvent *event);
|
||||
bool event(QEvent *event);
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||
|
||||
private:
|
||||
Q_PRIVATE_SLOT(d, void setPalette())
|
||||
|
@ -20,6 +20,10 @@
|
||||
|
||||
#include "scrollbar.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QGraphicsSceneContextMenuEvent>
|
||||
|
||||
#include <plasma/private/style_p.h>
|
||||
|
||||
namespace Plasma
|
||||
@ -36,6 +40,7 @@ ScrollBar::ScrollBar(QGraphicsWidget *parent)
|
||||
d(new ScrollBarPrivate)
|
||||
{
|
||||
QScrollBar *scrollbar = new QScrollBar();
|
||||
scrollbar->setWindowFlags(scrollbar->windowFlags()|Qt::BypassGraphicsProxyWidget);
|
||||
scrollbar->setAttribute(Qt::WA_NoSystemBackground);
|
||||
setWidget(scrollbar);
|
||||
d->style = Plasma::Style::sharedStyle();
|
||||
@ -118,6 +123,13 @@ void ScrollBar::setOrientation(Qt::Orientation orientation)
|
||||
resize(native->sizeHint());
|
||||
}
|
||||
|
||||
void ScrollBar::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
QContextMenuEvent contextMenuEvent(QContextMenuEvent::Reason(event->reason()),
|
||||
event->pos().toPoint(), event->screenPos(), event->modifiers());
|
||||
QApplication::sendEvent(nativeWidget(), &contextMenuEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include <scrollbar.moc>
|
||||
|
@ -118,6 +118,9 @@ public:
|
||||
*/
|
||||
QScrollBar *nativeWidget() const;
|
||||
|
||||
protected:
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Sets the current value for the ScrollBar
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
#include <QGraphicsSceneWheelEvent>
|
||||
#include <QMenu>
|
||||
|
||||
#include <kmimetype.h>
|
||||
#include <ktextbrowser.h>
|
||||
@ -101,6 +102,7 @@ TextBrowser::TextBrowser(QGraphicsWidget *parent)
|
||||
d(new TextBrowserPrivate(this))
|
||||
{
|
||||
KTextBrowser *native = new KTextBrowser;
|
||||
native->setWindowFlags(native->windowFlags()|Qt::BypassGraphicsProxyWidget);
|
||||
connect(native, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
|
||||
connect(native, SIGNAL(textChanged()), this, SLOT(setFixedHeight()));
|
||||
setWidget(native);
|
||||
@ -171,6 +173,13 @@ void TextBrowser::dataUpdated(const QString &sourceName, const Plasma::DataEngin
|
||||
}
|
||||
}
|
||||
|
||||
void TextBrowser::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
QMenu *popup = nativeWidget()->createStandardContextMenu(event->screenPos());
|
||||
popup->exec(event->screenPos());
|
||||
delete popup;
|
||||
}
|
||||
|
||||
void TextBrowser::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
d->setFixedHeight();
|
||||
|
@ -101,6 +101,7 @@ protected:
|
||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
void wheelEvent(QGraphicsSceneWheelEvent *event);
|
||||
void changeEvent(QEvent *event);
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||
|
||||
private:
|
||||
TextBrowserPrivate * const d;
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
#include <QMenu>
|
||||
#include <QGraphicsSceneContextMenuEvent>
|
||||
|
||||
#include <kmimetype.h>
|
||||
#include <ktextedit.h>
|
||||
@ -75,7 +77,9 @@ TextEdit::TextEdit(QGraphicsWidget *parent)
|
||||
{
|
||||
d->style = Plasma::Style::sharedStyle();
|
||||
|
||||
setNativeWidget(new KTextEdit);
|
||||
KTextEdit *nativeWidget = new KTextEdit;
|
||||
nativeWidget->setWindowFlags(nativeWidget->windowFlags()|Qt::BypassGraphicsProxyWidget);
|
||||
setNativeWidget(nativeWidget);
|
||||
connect(Theme::defaultTheme(), SIGNAL(themeChanged()),
|
||||
this, SLOT(setPalette()));
|
||||
}
|
||||
@ -153,6 +157,13 @@ void TextEdit::dataUpdated(const QString &sourceName, const Plasma::DataEngine::
|
||||
}
|
||||
}
|
||||
|
||||
void TextEdit::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
{
|
||||
QMenu *popup = nativeWidget()->mousePopupMenu();
|
||||
popup->exec(event->screenPos());
|
||||
delete popup;
|
||||
}
|
||||
|
||||
void TextEdit::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
{
|
||||
QGraphicsProxyWidget::resizeEvent(event);
|
||||
|
@ -109,6 +109,7 @@ Q_SIGNALS:
|
||||
protected:
|
||||
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
||||
void changeEvent(QEvent *event);
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
||||
|
||||
private:
|
||||
TextEditPrivate * const d;
|
||||
|
Loading…
Reference in New Issue
Block a user