From 2bfec8af423ae15b3c49b272aa9dee9983bcc044 Mon Sep 17 00:00:00 2001 From: Carsten Niehaus Date: Fri, 29 Jun 2007 14:29:05 +0000 Subject: [PATCH] * Adding the applet. Annma: Could you have a look while updated() is * _never_ called? I read code, read APIDOCs, chatted with ruphy... * Whatever I do the updated() is never called. That is why I cannot * improve the applet any further: Without updated() no data, without * data, nothing to display... Anyone? svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=681595 --- plasma/CMakeLists.txt | 1 + plasma/applets/CMakeLists.txt | 1 + plasma/applets/rypton/CMakeLists.txt | 13 ++ .../rypton/plasma-rypton-default.desktop | 16 ++ plasma/applets/rypton/rypton.cpp | 141 ++++++++++++++++++ plasma/applets/rypton/rypton.h | 103 +++++++++++++ 6 files changed, 275 insertions(+) create mode 100644 plasma/applets/CMakeLists.txt create mode 100644 plasma/applets/rypton/CMakeLists.txt create mode 100644 plasma/applets/rypton/plasma-rypton-default.desktop create mode 100644 plasma/applets/rypton/rypton.cpp create mode 100644 plasma/applets/rypton/rypton.h diff --git a/plasma/CMakeLists.txt b/plasma/CMakeLists.txt index 6f86840..157804a 100644 --- a/plasma/CMakeLists.txt +++ b/plasma/CMakeLists.txt @@ -1,3 +1,4 @@ find_package(Plasma REQUIRED) include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES}) add_subdirectory(engines) +add_subdirectory(applets) diff --git a/plasma/applets/CMakeLists.txt b/plasma/applets/CMakeLists.txt new file mode 100644 index 0000000..e5bb6f5 --- /dev/null +++ b/plasma/applets/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(rypton) diff --git a/plasma/applets/rypton/CMakeLists.txt b/plasma/applets/rypton/CMakeLists.txt new file mode 100644 index 0000000..b460122 --- /dev/null +++ b/plasma/applets/rypton/CMakeLists.txt @@ -0,0 +1,13 @@ +project(plasma-rypton) + +set(rypton_SRCS + rypton.cpp) + +kde4_automoc(${rypton_SRCS}) + +kde4_add_plugin(plasma_applet_rypton ${rypton_SRCS}) +target_link_libraries(plasma_applet_rypton plasma ${KDE4_KIO_LIBS} ${KDE4_KDEUI_LIBS}) +set_target_properties(plasma_applet_rypton PROPERTIES VERSION 1.0.0 SOVERSION 1) + +install(TARGETS plasma_applet_rypton DESTINATION ${PLUGIN_INSTALL_DIR}) +install(FILES plasma-rypton-default.desktop DESTINATION ${SERVICES_INSTALL_DIR}) diff --git a/plasma/applets/rypton/plasma-rypton-default.desktop b/plasma/applets/rypton/plasma-rypton-default.desktop new file mode 100644 index 0000000..448bafa --- /dev/null +++ b/plasma/applets/rypton/plasma-rypton-default.desktop @@ -0,0 +1,16 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Rypton +Type=Service +ServiceTypes=Plasma/Applet + +X-KDE-Library=plasma_applet_rypton +X-KDE-PluginInfo-Author=Carsten Niehaus +X-KDE-PluginInfo-Email=kalzium@kde.org +X-KDE-PluginInfo-Name=Rypton +X-KDE-PluginInfo-Version=pre0.1 +X-KDE-PluginInfo-Website=http://plasma.kde.org/ +X-KDE-PluginInfo-Category= +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true diff --git a/plasma/applets/rypton/rypton.cpp b/plasma/applets/rypton/rypton.cpp new file mode 100644 index 0000000..4d5099a --- /dev/null +++ b/plasma/applets/rypton/rypton.cpp @@ -0,0 +1,141 @@ +/*************************************************************************** + * Copyright (C) 2007 by Thomas Georgiou * + * Copyright (C) 2007 by Jeff Cooper * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, 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 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 "rypton.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace Plasma; + +Rypton::Rypton(QObject *parent, const QStringList &args) + : Plasma::Applet(parent, args), + m_defDisplay(0), + m_dialog(0), + m_showTimeStringCheckBox(0), + m_spinWidth(0) +{ + setFlags(QGraphicsItem::ItemIsMovable); + + KConfigGroup cg = appletConfig(); + m_width = cg.readEntry("width", 500); + m_wordEdit = new Plasma::LineEdit(this); + m_wordEdit->setTextInteractionFlags(Qt::TextEditorInteraction); + m_wordEdit->setDefaultText(i18n("Enter word to define here")); + Phase::self()->animateItem(m_wordEdit, Phase::Appear); + m_defEdit = new Plasma::LineEdit(this); + m_defEdit->setTextInteractionFlags(Qt::TextBrowserInteraction); + + m_defEdit->hide(); + m_wordEdit->setZValue(m_defEdit->zValue()+1); + + // Icon in upper-left corner + QIcon *m_icon = new KIcon("dictionary"); + m_graphicsIcon = new QGraphicsPixmapItem(m_icon->pixmap(32,32), this); + + // Position lineedits + const int wordEditOffset = 40; + m_graphicsIcon->setPos(-40 + wordEditOffset,-7); + m_wordEdit->setPos(wordEditOffset,0); + m_wordEdit->setTextWidth(m_width-wordEditOffset); + m_defEdit->setTextWidth(m_width); + m_defEdit->setPos(0,40); + + m_word = QString("22"); + Plasma::DataEngine* m_dataEngine = dataEngine("chemicaldata"); + m_dataEngine->connectSource(m_word, this); + connect(m_wordEdit, SIGNAL(editingFinished()), this, SLOT(define())); +} + +void Rypton::define() +{ + kDebug() << "Rypton::define()" << endl; + + m_word = m_wordEdit->toPlainText(); + Plasma::DataEngine* m_dataEngine = dataEngine("chemicaldata"); + m_dataEngine->connectSource(m_word, this); +} + +QRectF Rypton::boundingRect() const +{ + if (m_defEdit->isVisible()) + return m_defEdit->geometry().adjusted(-15,-12,15,12+40); + else + return m_defEdit->geometry().adjusted(-15,-12,15,12); +} + +void Rypton::constraintsUpdated() +{ + kDebug() << "Rypton::constraintsUpdated()" << endl; + prepareGeometryChange(); +} + +void Rypton::updated(const QString& source, const Plasma::DataEngine::Data &data) +{ + kDebug() << "Rypton::updated()" << endl; + Q_UNUSED(source); +//X +//X kDebug() << data["Mass"].toString() << endl; +//X update(); +} + +void Rypton::configureDialog() +{ +} + +void Rypton::configAccepted() +{ +} + +Rypton::~Rypton() +{ +} + +void Rypton::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ +} +#include "rypton.moc" diff --git a/plasma/applets/rypton/rypton.h b/plasma/applets/rypton/rypton.h new file mode 100644 index 0000000..ed9cc94 --- /dev/null +++ b/plasma/applets/rypton/rypton.h @@ -0,0 +1,103 @@ +/*************************************************************************** + * Copyright (C) 2007 by Carsten Niehaus > * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, 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 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 Rypton_H +#define Rypton_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +class QTimer; +class QCheckBox; +class QSpinBox; +class QLineEdit; + + +class KDialog; +class KTimeZoneWidget; + +namespace Plasma +{ + class Svg; +} + +class Rypton : public Plasma::Applet +{ + Q_OBJECT + public: + Rypton(QObject *parent, const QStringList &args); + ~Rypton(); + + void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget =0); + void setPath(const QString&); + QRectF boundingRect() const; + void constraintsUpdated(); + + public slots: + void updated(const QString &name, const Plasma::DataEngine::Data &data); + void define(); + void configureDialog(); + + protected slots: + void configAccepted(); + + private: + QRectF m_bounds; + int m_pixelSize; + QString m_timezone; + Plasma::Svg* m_theme; + QTime m_time; + QVariant m_thedef; + KDialog *m_dialog; //should we move this into another class? + QCheckBox *m_showTimeStringCheckBox; + QCheckBox *m_showSecondHandCheckBox; + QCheckBox *m_swapTzs; + QSpinBox *m_spinWidth; + QTextEdit *m_defDisplay; + QLineEdit *m_wordChooser; + QString m_word; + QTimer* m_timer; + int m_width; + QGraphicsPixmapItem *m_graphicsIcon; + Plasma::LineEdit *m_wordEdit; + Plasma::LineEdit *m_defEdit; + QStringList m_defList; + QStringList::iterator m_i; +}; + +K_EXPORT_PLASMA_APPLET(rypton, Rypton) + +#endif -- 2.47.3