[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/base/plasma/applets/test
From:       Alex Merry <huntedhacker () tiscali ! co ! uk>
Date:       2008-07-30 18:31:36
Message-ID: 1217442696.817912.10539.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 839750 by alexmerry:

Modify so that it (a) builds and (b) displays and icon.

Currently being used for debugging Plasma::Icon.



 M  +6 -0      CMakeLists.txt  
 M  +21 -53    testapplet.cpp  
 M  +3 -9      testapplet.h  


--- trunk/playground/base/plasma/applets/test/CMakeLists.txt #839749:839750
@@ -1,5 +1,11 @@
 project(plasma-testapplet)
 
+find_package(KDE4 REQUIRED)
+include (KDE4Defaults)
+find_package(Plasma REQUIRED)
+add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
+include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
+
 set(testapplet_SRCS
     testapplet.cpp)
 
--- trunk/playground/base/plasma/applets/test/testapplet.cpp #839749:839750
@@ -19,74 +19,42 @@
 
 #include "testapplet.h"
 
-#include <QPainter>
+#include <QGraphicsLinearLayout>
 
-#include <plasma/svg.h>
-#include <plasma/layouts/vboxlayout.h>
-#include <plasma/widgets/lineedit.h>
+#include <plasma/widgets/icon.h>
 
-class LimitedLineEdit : public Plasma::LineEdit
-{
-public:
-    explicit LimitedLineEdit(QGraphicsItem *parent = 0)
-        : Plasma::LineEdit(parent)
-        , m_height(300)
-    {
-    }
-    QRectF boundingRect()
-    {
-        QRectF rect(Plasma::LineEdit::boundingRect());
-        rect.setHeight(m_height);
-        return rect;
-    }
-    void setHeight(qreal height)
-    {
-        m_height = height;
-    }
-private:
-    qreal m_height;
-};
-
 TestApplet::TestApplet(QObject *parent, const QVariantList &args)
     : Plasma::Applet(parent, args)
-    , m_edit( new LimitedLineEdit(this) )
-    , m_svg( 0 )
+    , m_icon( new Plasma::Icon("Foo", this) )
 {
+    m_icon->setIcon("run-build");
+    m_icon->setOrientation(Qt::Horizontal);
+    m_icon->setDrawBackground(true);
+    QSizeF iconSize = m_icon->sizeFromIconSize(22);
+    //m_icon->setMinimumSize(iconSize);
+    //m_icon->setMaximumSize(iconSize);
+    m_icon->resize(m_icon->size());
 
-    m_edit->setMultiLine(true);
-    m_edit->setTextWidth(300);
-    m_edit->setHeight(200);
+    //QGraphicsLinearLayout* layout = new QGraphicsLinearLayout;
+    //layout->addItem(m_icon);
+    //setLayout(layout);
 
-    //m_svg = new Plasma::Svg("widgets/wallpaper", this);
-    //m_svg->resize(640,480);
-    //kDebug() << "SVG size: " << m_svg->size();
+    resize(150, 50);
 
-    connect(m_edit, SIGNAL(textChanged(QString)), this, SLOT(editUpdate(QString)));
+    connect(m_icon, SIGNAL(clicked()), this, SLOT(buttonClicked()));
 }
 
 TestApplet::~TestApplet()
 {
 }
 
-void TestApplet::editUpdate(const QString&)
+void TestApplet::buttonClicked()
 {
-    prepareGeometryChange();
+    if (m_icon->text() == "Foo") {
+        m_icon->setText("Foo Bar Baz");
+    } else {
+        m_icon->setText("Foo");
+    }
 }
 
-QSizeF TestApplet::contentSizeHint() const
-{
-    //return QSizeF(300, 300);
-    return m_edit->sizeHint();
-    //return m_svg->size();
-}
-
-
-void TestApplet::paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, \
                const QRect &contentsRect)
-{
-    Q_UNUSED(option)
-    //p->setPen(Qt::blue);
-    //p->drawRoundRect(contentsRect);
-    //m_svg->paint(p, contentsRect.topLeft());
-}
-
 #include "testapplet.moc"
--- trunk/playground/base/plasma/applets/test/testapplet.h #839749:839750
@@ -24,10 +24,8 @@
 
 namespace Plasma
 {
-    class LineEdit;
-    class Svg;
+    class Icon;
 } // namespace Plasma
-class LimitedLineEdit;
 
 class TestApplet : public Plasma::Applet
 {
@@ -36,15 +34,11 @@
         TestApplet(QObject *parent, const QVariantList &args);
         ~TestApplet();
 
-        QSizeF contentSizeHint() const;
-        void paintInterface(QPainter *painter, const QStyleOptionGraphicsItem \
                *option, const QRect &contentsRect);
-
     public slots:
-        void editUpdate(const QString& text);
+        void buttonClicked();
 
     private:
-        LimitedLineEdit* m_edit;
-        Plasma::Svg* m_svg;
+        Plasma::Icon* m_icon;
 };
 
 K_EXPORT_PLASMA_APPLET(testapplet, TestApplet)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic