plasma-framework/tests/testcontainmentactionsplugin/test.cpp
David Faure 083d157684 Merge remote-tracking branch 'origin/KDE/4.8' into origin-frameworks
Conflicts:
	kdecore/network/k3datagramsocket.cpp
	kdeui/actions/kstandardaction.cpp
	kdeui/dialogs/kconfigdialogmanager.cpp
	kdeui/icons/kicondialog.cpp
	kdeui/itemviews/kviewstatesaver.h
	kfile/knewfilemenu.cpp
	kio/misc/kpac/downloader.cpp
	kio/tests/kdirlistertest.cpp
	kparts/browserextension.cpp
	nepomuk/core/nepomukmainmodel.cpp
	nepomuk/query/queryserviceclient.cpp
	nepomuk/test/ratingpaintertestwidget.cpp
	nepomuk/ui/kedittagsdialog.cpp
	nepomuk/ui/ktagcloudwidget.cpp
	nepomuk/ui/ktagdisplaywidget.cpp
	nepomuk/ui/nepomukmassupdatejob.cpp
	nepomuk/ui/tagwidget.cpp
	nepomuk/utils/daterangeselectionwidget.cpp
	nepomuk/utils/facetwidget.cpp
	nepomuk/utils/searchwidget.cpp
	plasma/containment.cpp
	plasma/datacontainer.cpp
	plasma/deprecated/animator.cpp
	plasma/extenders/extender.cpp
	plasma/plasma.h
	plasma/scripting/wallpaperscript.cpp
	tier1/solid/tests/networkingclient.cpp
(signal/slot normalization changes conflicted with KUrl->QUrl changes
and with other changes in frameworks)
2012-02-14 12:32:25 +01:00

107 lines
2.9 KiB
C++

/*
* 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>
#include <KDebug>
#include <KMenu>
#include <Plasma/Containment>
ContextTest::ContextTest(QObject *parent, const QVariantList &args)
: Plasma::ContainmentActions(parent, args)
{
setConfigurationRequired(true);
}
void ContextTest::contextEvent(QEvent *event)
{
switch (event->type()) {
case QEvent::GraphicsSceneMousePress:
contextEvent(static_cast<QGraphicsSceneMouseEvent*>(event));
break;
case QEvent::GraphicsSceneWheel:
wheelEvent(static_cast<QGraphicsSceneWheelEvent*>(event));
break;
default:
break;
}
}
void ContextTest::contextEvent(QGraphicsSceneMouseEvent *event)
{
kDebug() << "test!!!!!!!!!!!!!!!!!!!!!!!" << event->pos();
kDebug() << event->buttons() << event->modifiers();
Plasma::Containment *c = containment();
if (c) {
kDebug() << c->name();
} else {
kDebug() << "fail";
return;
}
KMenu desktopMenu;
desktopMenu.addTitle(m_text);
desktopMenu.addAction(c->action("configure"));
desktopMenu.exec(event->screenPos());
}
void ContextTest::wheelEvent(QGraphicsSceneWheelEvent *event)
{
kDebug() << "test!!!!!!!!!!!!!11111111!!";
kDebug() << event->orientation() << event->delta();
kDebug() << event->buttons() << event->modifiers();
}
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?
//connect(m_ui.text, SIGNAL(changed(QColor)), this, SLOT(setColor(QColor)));
//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);
}