]> Git trees. - libqmvoc.git/commitdiff
* Adding the applet. Annma: Could you have a look while updated() is
authorCarsten Niehaus <cniehaus@gmx.de>
Fri, 29 Jun 2007 14:29:05 +0000 (14:29 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Fri, 29 Jun 2007 14:29:05 +0000 (14:29 +0000)
* _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
plasma/applets/CMakeLists.txt [new file with mode: 0644]
plasma/applets/rypton/CMakeLists.txt [new file with mode: 0644]
plasma/applets/rypton/plasma-rypton-default.desktop [new file with mode: 0644]
plasma/applets/rypton/rypton.cpp [new file with mode: 0644]
plasma/applets/rypton/rypton.h [new file with mode: 0644]

index 6f8684083fb2bde07ab7d7ed039a3c3cb48edcbf..157804a721fd217b5adfd71c07af6ab0edcb874a 100644 (file)
@@ -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 (file)
index 0000000..e5bb6f5
--- /dev/null
@@ -0,0 +1 @@
+add_subdirectory(rypton)
diff --git a/plasma/applets/rypton/CMakeLists.txt b/plasma/applets/rypton/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b460122
--- /dev/null
@@ -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 (file)
index 0000000..448bafa
--- /dev/null
@@ -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 (file)
index 0000000..4d5099a
--- /dev/null
@@ -0,0 +1,141 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Thomas Georgiou <TAGeorgiou@gmail.com>          *
+ *   Copyright (C) 2007 by Jeff Cooper <weirdsox11@gmail.com>              *
+ *                                                                         *
+ *   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 <math.h>
+
+#include <QApplication>
+#include <QBitmap>
+#include <QGraphicsScene>
+#include <QMatrix>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QPixmap>
+#include <QStyleOptionGraphicsItem>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QCheckBox>
+#include <QPushButton>
+#include <QSpinBox>
+//#include <QTextArea>
+#include <QLineEdit>
+#include <iostream>
+
+
+#include <KDebug>
+#include <KLocale>
+#include <KIcon>
+#include <KSharedConfig>
+#include <KTimeZoneWidget>
+#include <KDialog>
+#include <QTime>
+#include <plasma/svg.h>
+#include <plasma/phase.h>
+
+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 (file)
index 0000000..ed9cc94
--- /dev/null
@@ -0,0 +1,103 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Carsten Niehaus <cniehaus@kde.org>   >          *
+ *                                                                         *
+ *   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 <QImage>
+#include <QPaintDevice>
+#include <QLabel>
+#include <QPixmap>
+#include <QTimer>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QTime>
+#include <QX11Info>
+#include <QWidget>
+#include <QGraphicsItem>
+#include <QColor>
+#include <QTextEdit>
+
+#include <plasma/applet.h>
+#include <plasma/dataengine.h>
+#include <plasma/widgets/vboxlayout.h>
+#include <plasma/widgets/lineedit.h>
+#include <plasma/widgets/pushbutton.h>
+
+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