File indexing completed on 2024-12-22 04:17:25

0001 /***************************************************************************
0002  *                                                                         *
0003  *   copyright : (C) 2011 Joshua Netterfield                               *
0004  *                   joshua.netterfield@gmail.com                          *
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  ***************************************************************************/
0012 
0013 #ifndef BUTTONITEM_H
0014 #define BUTTONITEM_H
0015 
0016 #include "viewitem.h"
0017 #include "graphicsfactory.h"
0018 #include <QLocalSocket>
0019 
0020 class QPushButton;
0021 
0022 namespace Kst {
0023 
0024 /** For scripting, a button which sends via a socket on trigger. */
0025 
0026 class ButtonItem : public ViewItem
0027 {
0028   Q_OBJECT
0029   protected:
0030     QList<QLocalSocket*> _sockets;
0031     QPushButton* _pushButton;
0032     QGraphicsProxyWidget* _proxy;
0033   public:
0034     explicit ButtonItem(View *parent);
0035     virtual ~ButtonItem();
0036 
0037     const QString defaultsGroupName() const {return ButtonItem::staticDefaultsGroupName();}
0038     static QString staticDefaultsGroupName() { return QString("button");}
0039 
0040     // for view item dialogs
0041     virtual bool hasStroke() const {return true;}
0042     virtual bool hasBrush() const {return true;}
0043 
0044     virtual void save(QXmlStreamWriter &xml);
0045     virtual void paint(QPainter *painter);
0046 
0047   public slots:
0048     void setText(QString);
0049     void addSocket(QLocalSocket* s);
0050     void notifyScripts();
0051 
0052     friend class ButtonItemFactory;
0053 };
0054 
0055 class ButtonItemFactory : public GraphicsFactory {
0056   public:
0057     ButtonItemFactory();
0058     ~ButtonItemFactory();
0059     ViewItem* generateGraphics(QXmlStreamReader& stream, ObjectStore *store, View *view, ViewItem *parent = 0);
0060 };
0061 
0062 }
0063 
0064 #endif
0065 
0066 // vim: ts=2 sw=2 et