explicit set video queue to 500ms (sender)
[makneto-zunavac1.git] / src / wbwidget.h
blob4a3feee3996bf7b387ce4e5adbf714de78769f1c
1 /*
2 * wbwidget.h - a widget for processing and showing whiteboard
3 * messages.
4 * Copyright (C) 2006 Joonas Govenius
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef WBWIDGET_H
23 #define WBWIDGET_H
24 #include "wbscene.h"
25 #include <QWidget>
26 #include <QGraphicsView>
27 #include <QTimer>
28 #include <QTime>
29 #include <QFileDialog>
31 /*! \brief The whiteboard widget.
32 * Visualizes the whiteboard scene and provides different modes for editing and adding new elements.
33 * Local edits to existing elements are handled by the elements themselves
34 * as mouse events are passed on to them but new items are temporarily
35 * added to the scene while being drawn and only when finished, added to
36 * the WbScene.
38 * \sa WbScene
39 * \sa WbDlg
41 class WbWidget : public QGraphicsView
43 Q_OBJECT
44 public:
45 /*! \brief Mode
46 * Indicates the mode the widget is in.
48 enum Mode { Select, Translate, Rotate, Scale, Scroll, Erase, DrawPath, DrawLine, DrawRectangle, DrawEllipse, DrawCircle, DrawPolyline, DrawText, DrawImage };
50 /*! \brief Constructor
51 * Constructs a new widget with \a session and \a size with parent \a parent.
52 * \a ownJid is the Jid that should be used in item IDs created by this widget.
54 WbWidget(const QString &session, const QString &ownJid, const QSize &size, QWidget *parent=0);
55 /*! \brief Processes an incoming whiteboard element.*/
56 bool processWb(const QDomElement &wb);
57 /*! \brief Returns the session this widget is visualizing.*/
58 QString session();
59 /*! \brief Returns the JID used by the user in the session.*/
60 const QString & ownJid() const;
61 /*! \brief Returns the mode this widget is in.*/
62 Mode mode();
63 /*! \brief Sets the mode which determines how to react to user interaction.*/
64 void setMode(Mode mode);
65 /*! \brief Sets the size of the whiteboard.*/
66 void setSize(const QSize &s);
67 /*! \brief Sets the stroke color of new items.*/
68 void setStrokeColor(const QColor &color);
69 /*! \brief Sets the stroke color of new items.*/
70 void setFillColor(const QColor &color);
71 /*! \brief Sets the stroke width of new items.*/
72 void setStrokeWidth(int width);
73 /*! \brief Sets whether configure edits are accepted regardless of version.
74 * Default is false. Should be set true if the session state is Negotiation::DocumentBegun.
76 void setImporting(bool);
78 /*! \brief Returns the size set by setSize().*/
79 virtual QSize sizeHint() const;
81 /*! \brief A pointer to the WbScene.*/
82 WbScene* scene;
84 signals:
85 /*! \brief Emitted when a new whiteboard element is ready to be sent.*/
86 void newWb(const QDomElement &wb);
87 /*! \brief Emitted when mode is changed.*/
88 void modeChanged(WbWidget::Mode);
90 public slots:
91 /*! \brief Clears the whiteboard.
92 * If \a sendEdits is true, the remove edits are sent.
94 void clear(const bool &sendEdits = true);
96 protected:
97 /*! \brief Makes sure that area outside the whiteboard is not shown by zooming if necessary.*/
98 virtual void resizeEvent(QResizeEvent * event);
99 /*! \brief Passes events to items as specified by the mode.*/
100 virtual void mousePressEvent(QMouseEvent * event);
101 /*! \brief Passes events to items as specified by the mode.*/
102 virtual void mouseMoveEvent(QMouseEvent * event);
103 /*! \brief Passes events to items as specified by the mode.*/
104 virtual void mouseReleaseEvent(QMouseEvent * event);
106 private:
107 /*! \brief The user interaction mode the widget is in.*/
108 Mode mode_;
109 /*! \brief The stroke color used for new items.*/
110 QColor strokeColor_;
111 /*! \brief The fill color used for new items.*/
112 QColor fillColor_;
113 /*! \brief The stroke width used for new items.*/
114 int strokeWidth_;
116 /*! \brief Pointer to a new item that is being drawn.*/
117 WbItem* newWbItem_;
118 /*! \brief Boolean used to force adding a vertex to a path being drawn.*/
119 bool addVertex_;
120 /*! \brief Pointer to a control point to be used for the next vertex.*/
121 QPointF* controlPoint_;
122 /*! \brief Timer used for forcing the addition of a new vertex.*/
123 QTimer* adding_;
125 private slots:
126 /*! \brief Slot used for forcing the addition of a new vertex.*/
127 void addVertex();
130 #endif