get rid of context menu and wheel events
This commit is contained in:
parent
ff0cab8fa6
commit
38145bedba
@ -380,66 +380,6 @@ void Containment::showDropZone(const QPoint pos)
|
|||||||
//Base implementation does nothing, don't put code here
|
//Base implementation does nothing, don't put code here
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::showContextMenu(const QPointF &containmentPos, const QPoint &screenPos)
|
|
||||||
{
|
|
||||||
//kDebug() << containmentPos << screenPos;
|
|
||||||
QContextMenuEvent gvevent(QContextMenuEvent::Mouse, screenPos);
|
|
||||||
|
|
||||||
//FIXME: do we need views here?
|
|
||||||
//gvevent.setWidget(view());
|
|
||||||
contextMenuEvent(&gvevent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::contextMenuEvent(QContextMenuEvent *event)
|
|
||||||
{
|
|
||||||
if (!isContainment() || !KAuthorized::authorizeKAction("plasma/containment_context_menu")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KMenu desktopMenu;
|
|
||||||
//TODO: port to the new containmentactions architecture
|
|
||||||
Applet *applet = 0;//d->appletAt(event->pos());
|
|
||||||
//kDebug() << "context menu event " << (QObject*)applet;
|
|
||||||
|
|
||||||
if (applet) {
|
|
||||||
d->addAppletActions(desktopMenu, applet, event);
|
|
||||||
} else {
|
|
||||||
d->addContainmentActions(desktopMenu, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
//kDebug() << "executing at" << screenPos;
|
|
||||||
QMenu *menu = &desktopMenu;
|
|
||||||
//kDebug() << "showing menu, actions" << desktopMenu.actions().size() << desktopMenu.actions().first()->menu();
|
|
||||||
if (desktopMenu.actions().size() == 1 && desktopMenu.actions().first()->menu()) {
|
|
||||||
// we have a menu with a single top level menu; just show that top level menu instad.
|
|
||||||
menu = desktopMenu.actions().first()->menu();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!menu->isEmpty()) {
|
|
||||||
QPoint pos = event->globalPos();
|
|
||||||
if (applet && d->isPanelContainment()) {
|
|
||||||
menu->adjustSize();
|
|
||||||
pos = QPoint(); //TODO: port context menus away from Containment applet->popupPosition(menu->size());
|
|
||||||
if (event->reason() == QContextMenuEvent::Mouse) {
|
|
||||||
// if the menu pops up way away from the mouse press, then move it
|
|
||||||
// to the mouse press
|
|
||||||
if (d->formFactor == Vertical) {
|
|
||||||
if (pos.y() + menu->height() < event->globalPos().y()) {
|
|
||||||
pos.setY(event->globalPos().y());
|
|
||||||
}
|
|
||||||
} else if (d->formFactor == Horizontal) {
|
|
||||||
if (pos.x() + menu->width() < event->globalPos().x()) {
|
|
||||||
pos.setX(event->globalPos().x());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->exec(pos);
|
|
||||||
event->accept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::setFormFactor(FormFactor formFactor)
|
void Containment::setFormFactor(FormFactor formFactor)
|
||||||
{
|
{
|
||||||
if (d->formFactor == formFactor) {
|
if (d->formFactor == formFactor) {
|
||||||
@ -662,22 +602,6 @@ QStringList Containment::listContainmentTypes()
|
|||||||
return types.toList();
|
return types.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Containment::wheelEvent(QWheelEvent *event)
|
|
||||||
{
|
|
||||||
event->ignore();
|
|
||||||
|
|
||||||
QString trigger = ContainmentActions::eventToString(event);
|
|
||||||
|
|
||||||
if (d->prepareContainmentActions(trigger, event->globalPos())) {
|
|
||||||
if (event->delta() > 0) {
|
|
||||||
d->actionPlugins()->value(trigger)->performNext();
|
|
||||||
} else {
|
|
||||||
d->actionPlugins()->value(trigger)->performPrevious();
|
|
||||||
}
|
|
||||||
event->accept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Containment::enableAction(const QString &name, bool enable)
|
void Containment::enableAction(const QString &name, bool enable)
|
||||||
{
|
{
|
||||||
QAction *action = this->action(name);
|
QAction *action = this->action(name);
|
||||||
|
@ -322,12 +322,6 @@ class PLASMA_EXPORT Containment : public Applet
|
|||||||
*/
|
*/
|
||||||
QString activity() const;
|
QString activity() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Shows the context menu for the containment directly, bypassing Applets
|
|
||||||
* altogether.
|
|
||||||
*/
|
|
||||||
void showContextMenu(const QPointF &containmentPos, const QPoint &screenPos);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a visual clue for drag and drop
|
* Shows a visual clue for drag and drop
|
||||||
* The default implementation does nothing,
|
* The default implementation does nothing,
|
||||||
@ -483,9 +477,6 @@ Q_SIGNALS:
|
|||||||
*/
|
*/
|
||||||
virtual void restoreContents(KConfigGroup &group);
|
virtual void restoreContents(KConfigGroup &group);
|
||||||
|
|
||||||
//FIXME: events should go away
|
|
||||||
void contextMenuEvent(QContextMenuEvent *event);
|
|
||||||
void wheelEvent(QWheelEvent *event);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user