2009-08-18 01:40:25 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2009 by Chani Armitage <chani@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "test.h"
|
|
|
|
|
|
|
|
#include <QGraphicsSceneMouseEvent>
|
|
|
|
#include <QGraphicsSceneWheelEvent>
|
|
|
|
|
2013-08-09 04:14:26 +02:00
|
|
|
#include <QDebug>
|
2013-07-09 00:55:03 +02:00
|
|
|
#include <QMenu>
|
2009-08-18 01:40:25 +02:00
|
|
|
|
|
|
|
#include <Plasma/Containment>
|
|
|
|
|
|
|
|
ContextTest::ContextTest(QObject *parent, const QVariantList &args)
|
|
|
|
: Plasma::ContainmentActions(parent, args)
|
|
|
|
{
|
|
|
|
setConfigurationRequired(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContextTest::contextEvent(QEvent *event)
|
|
|
|
{
|
|
|
|
switch (event->type()) {
|
2009-08-25 18:14:49 +02:00
|
|
|
case QEvent::GraphicsSceneMousePress:
|
2009-08-29 20:30:36 +02:00
|
|
|
contextEvent(static_cast<QGraphicsSceneMouseEvent*>(event));
|
2009-08-18 01:40:25 +02:00
|
|
|
break;
|
|
|
|
case QEvent::GraphicsSceneWheel:
|
2009-08-29 20:30:36 +02:00
|
|
|
wheelEvent(static_cast<QGraphicsSceneWheelEvent*>(event));
|
2009-08-18 01:40:25 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContextTest::contextEvent(QGraphicsSceneMouseEvent *event)
|
|
|
|
{
|
2013-07-29 19:05:59 +02:00
|
|
|
// qDebug() << "test!!!!!!!!!!!!!!!!!!!!!!!" << event->pos();
|
|
|
|
// qDebug() << event->buttons() << event->modifiers();
|
2009-08-18 01:40:25 +02:00
|
|
|
|
|
|
|
Plasma::Containment *c = containment();
|
|
|
|
if (c) {
|
2013-07-29 19:05:59 +02:00
|
|
|
// qDebug() << c->name();
|
2009-08-18 01:40:25 +02:00
|
|
|
} else {
|
2013-07-29 19:05:59 +02:00
|
|
|
// qDebug() << "fail";
|
2009-08-18 01:40:25 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-09 00:55:03 +02:00
|
|
|
QMenu desktopMenu;
|
2009-08-18 01:40:25 +02:00
|
|
|
desktopMenu.addTitle(m_text);
|
|
|
|
desktopMenu.addAction(c->action("configure"));
|
|
|
|
desktopMenu.exec(event->screenPos());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContextTest::wheelEvent(QGraphicsSceneWheelEvent *event)
|
|
|
|
{
|
2013-07-29 19:05:59 +02:00
|
|
|
// qDebug() << "test!!!!!!!!!!!!!11111111!!";
|
|
|
|
// qDebug() << event->orientation() << event->delta();
|
|
|
|
// qDebug() << event->buttons() << event->modifiers();
|
2009-08-18 01:40:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ContextTest::init(const KConfigGroup &config)
|
|
|
|
{
|
|
|
|
m_text = config.readEntry("test-text", QString());
|
|
|
|
setConfigurationRequired(m_text.isEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget* ContextTest::createConfigurationInterface(QWidget* parent)
|
|
|
|
{
|
|
|
|
//m_currentText = m_text;
|
|
|
|
QWidget *widget = new QWidget(parent);
|
|
|
|
m_ui.setupUi(widget);
|
|
|
|
|
|
|
|
m_ui.text->setText(m_text);
|
|
|
|
//FIXME this way or just get it on close?
|
2012-01-22 03:11:26 +01:00
|
|
|
//connect(m_ui.text, SIGNAL(changed(QColor)), this, SLOT(setColor(QColor)));
|
2009-08-18 01:40:25 +02:00
|
|
|
//connect(this, SIGNAL(settingsChanged(bool)), parent, SLOT(settingsChanged(bool)));
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContextTest::configurationAccepted()
|
|
|
|
{
|
|
|
|
m_text = m_ui.text->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContextTest::save(KConfigGroup &config)
|
|
|
|
{
|
|
|
|
config.writeEntry("test-text", m_text);
|
|
|
|
}
|
|
|
|
|
|
|
|
|