rename folder
svn path=/trunk/KDE/kdebase/workspace/plasma/containmentactions/test/; revision=1012692
This commit is contained in:
parent
de4e6d5bf1
commit
b6cd1d8582
12
tests/testcontainmentactionsplugin/CMakeLists.txt
Normal file
12
tests/testcontainmentactionsplugin/CMakeLists.txt
Normal file
@ -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})
|
30
tests/testcontainmentactionsplugin/config.ui
Normal file
30
tests/testcontainmentactionsplugin/config.ui
Normal file
@ -0,0 +1,30 @@
|
||||
<ui version="4.0" >
|
||||
<class>Config</class>
|
||||
<widget class="QWidget" name="Config" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>355</width>
|
||||
<height>102</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||
<item>
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string>text:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="text" />
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -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
|
||||
|
108
tests/testcontainmentactionsplugin/test.cpp
Normal file
108
tests/testcontainmentactionsplugin/test.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
setHasConfigurationInterface(true);
|
||||
setConfigurationRequired(true);
|
||||
}
|
||||
|
||||
void ContextTest::contextEvent(QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::GraphicsSceneMouseRelease:
|
||||
contextEvent(dynamic_cast<QGraphicsSceneMouseEvent*>(event));
|
||||
break;
|
||||
case QEvent::GraphicsSceneWheel:
|
||||
wheelEvent(dynamic_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(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"
|
49
tests/testcontainmentactionsplugin/test.h
Normal file
49
tests/testcontainmentactionsplugin/test.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef CONTEXTTEST_HEADER
|
||||
#define CONTEXTTEST_HEADER
|
||||
|
||||
#include "ui_config.h"
|
||||
#include <plasma/containmentactions.h>
|
||||
#include <QString>
|
||||
|
||||
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
|
Loading…
Reference in New Issue
Block a user