From b6cd1d8582ba8ab3f286e62f85eecc4ff705192c Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Mon, 17 Aug 2009 23:40:25 +0000 Subject: [PATCH] rename folder svn path=/trunk/KDE/kdebase/workspace/plasma/containmentactions/test/; revision=1012692 --- .../CMakeLists.txt | 12 ++ tests/testcontainmentactionsplugin/config.ui | 30 +++++ .../plasma-containmentactions-test.desktop | 17 +++ tests/testcontainmentactionsplugin/test.cpp | 108 ++++++++++++++++++ tests/testcontainmentactionsplugin/test.h | 49 ++++++++ 5 files changed, 216 insertions(+) create mode 100644 tests/testcontainmentactionsplugin/CMakeLists.txt create mode 100644 tests/testcontainmentactionsplugin/config.ui create mode 100644 tests/testcontainmentactionsplugin/plasma-containmentactions-test.desktop create mode 100644 tests/testcontainmentactionsplugin/test.cpp create mode 100644 tests/testcontainmentactionsplugin/test.h diff --git a/tests/testcontainmentactionsplugin/CMakeLists.txt b/tests/testcontainmentactionsplugin/CMakeLists.txt new file mode 100644 index 000000000..87531409e --- /dev/null +++ b/tests/testcontainmentactionsplugin/CMakeLists.txt @@ -0,0 +1,12 @@ +project(plasma-containmentactions-test) + +set(test_SRCS + test.cpp +) +kde4_add_ui_files(test_SRCS config.ui) + +kde4_add_plugin(plasma_containmentactions_test ${test_SRCS}) +target_link_libraries(plasma_containmentactions_test ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS}) + +install(TARGETS plasma_containmentactions_test DESTINATION ${PLUGIN_INSTALL_DIR}) +install(FILES plasma-containmentactions-test.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/tests/testcontainmentactionsplugin/config.ui b/tests/testcontainmentactionsplugin/config.ui new file mode 100644 index 000000000..156faf00a --- /dev/null +++ b/tests/testcontainmentactionsplugin/config.ui @@ -0,0 +1,30 @@ + + Config + + + + 0 + 0 + 355 + 102 + + + + Form + + + + + + text: + + + + + + + + + + + diff --git a/tests/testcontainmentactionsplugin/plasma-containmentactions-test.desktop b/tests/testcontainmentactionsplugin/plasma-containmentactions-test.desktop new file mode 100644 index 000000000..68c718a4c --- /dev/null +++ b/tests/testcontainmentactionsplugin/plasma-containmentactions-test.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Name=Test +Comment=A dummy plugin for testing +Type=Service +Icon=preferences-desktop-color +ServiceTypes=Plasma/ContainmentActions + +X-KDE-Library=plasma_containmentactions_test +X-KDE-PluginInfo-Author=Chani +X-KDE-PluginInfo-Email=chani@kde.org +X-KDE-PluginInfo-Name=test +X-KDE-PluginInfo-Version=pre0.1 +X-KDE-PluginInfo-Website=http://plasma.kde.org/ +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + diff --git a/tests/testcontainmentactionsplugin/test.cpp b/tests/testcontainmentactionsplugin/test.cpp new file mode 100644 index 000000000..7e1793e78 --- /dev/null +++ b/tests/testcontainmentactionsplugin/test.cpp @@ -0,0 +1,108 @@ +/* + * Copyright 2009 by Chani Armitage + * + * 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 +#include + +#include +#include + +#include + +ContextTest::ContextTest(QObject *parent, const QVariantList &args) + : Plasma::ContainmentActions(parent, args) +{ + setHasConfigurationInterface(true); + setConfigurationRequired(true); +} + +void ContextTest::contextEvent(QEvent *event) +{ + switch (event->type()) { + case QEvent::GraphicsSceneMouseRelease: + contextEvent(dynamic_cast(event)); + break; + case QEvent::GraphicsSceneWheel: + wheelEvent(dynamic_cast(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(const QColor&)), this, SLOT(setColor(const 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); +} + + +#include "test.moc" diff --git a/tests/testcontainmentactionsplugin/test.h b/tests/testcontainmentactionsplugin/test.h new file mode 100644 index 000000000..5cc5a6c07 --- /dev/null +++ b/tests/testcontainmentactionsplugin/test.h @@ -0,0 +1,49 @@ +/* + * Copyright 2009 by Chani Armitage + * + * 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. + */ + +#ifndef CONTEXTTEST_HEADER +#define CONTEXTTEST_HEADER + +#include "ui_config.h" +#include +#include + +class ContextTest : public Plasma::ContainmentActions +{ + Q_OBJECT + public: + ContextTest(QObject* parent, const QVariantList& args); + + void init(const KConfigGroup &config); + void contextEvent(QEvent *event); + void contextEvent(QGraphicsSceneMouseEvent *event); + void wheelEvent(QGraphicsSceneWheelEvent *event); + + QWidget* createConfigurationInterface(QWidget* parent); + void configurationAccepted(); + void save(KConfigGroup &config); + + private: + Ui::Config m_ui; + QString m_text; +}; + +K_EXPORT_PLASMA_CONTAINMENTACTIONS(test, ContextTest) + +#endif