2
* wbdlg.h - dialog for whiteboarding
3
* Copyright (C) 2006 Joonas Govenius
5
* Originally developed from:
6
* wbdlg.h - dialog for handling chats
7
* Copyright (C) 2001, 2002 Justin Karneges
9
* This program is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU General Public License
11
* as published by the Free Software Foundation; either version 2
12
* of the License, or (at your option) any later version.
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this library; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31
#include <QContextMenuEvent>
34
#include <QResizeEvent>
35
#include <QCloseEvent>
36
#include <QInputDialog>
37
// #include <QMessageBoxEx>
39
#include "advwidget.h"
43
#include "iconlabel.h"
44
#include "psiaccount.h"
45
#include "psioptions.h"
51
/*! \brief The dialog for a whiteboard session.
52
* Inherits Advanced Widget.
54
* Takes in whiteboard elements for the session from the WbManager and passes
55
* them on to the WbWidget.
57
* Contains the WbWidget and provides controls for setting the mode, stroke
58
* width and color of new items. TODO: Also provides controls for setting general
59
* properties of the session and a control for ending the session.
64
class WbDlg : public AdvancedWidget<QWidget>
68
struct incomingElement {
74
/*! \brief Constructor.
75
* Creates a new dialog for the specified jid and session.
77
WbDlg(const Jid &target, const QString &session, const Jid &ownJid, bool groupChat, PsiAccount *pa);
78
/*! \brief Destructor.
79
* Emits sessionEnded()
83
/*! \brief Passes the incoming element to the WbWidget and remembers the last edit.*/
84
void incomingWbElement(const QDomElement &, const Jid &sender);
85
/*! \brief Returns true if the target is a groupchat.*/
86
const bool groupChat() const;
87
/*! \brief Returns the target contact's JID.*/
88
const Jid target() const;
89
/*! \brief Returns the session identifier.*/
90
const QString session() const;
91
/*! \brief Returns the JID used by the user in the session.*/
92
const Jid ownJid() const;
93
/*! \brief Returns whether further edits to the session are allowed.*/
94
bool allowEdits() const;
95
/*! \brief Sets whether further edits to the session are allowed.*/
96
void setAllowEdits(bool);
97
/*! \brief Asks whether dialog should be deleted if peer left the session.*/
98
void peerLeftSession();
99
/*! \brief Sets whether new wb elements should be queued.*/
100
void setQueueing(bool);
101
/*! \brief Erases the wb elements from the incoming queue up to and including the wb identified by the parameters.
102
* The parameters correspond to the attributes of the last-edit element.
104
void eraseQueueUntil(QString sender, QString hash);
105
/*! \brief Return the snapshot that was created when queueing was set true.*/
106
QList<WbItem*> snapshot() const;
107
/*! \brief Sets whether configure edits are accepted regardless of version.
108
* Default is false. Should be set true if the session state is Negotiation::DocumentBegun.
109
* Clears the whiteboard without emitting emitting wb elements when set true.
111
void setImporting(bool);
112
/*! \brief Return a hash with information identifying the last processed wb element.*/
113
QHash<QString, QString> lastWb() const;
114
/*! \brief Sets the information identifying the last processed wb.*/
115
void setLastWb(const QString &sender, const QString &hash);
118
/*! \brief Ends the session.
119
* Asks for confirmation if invoked by user's action.
122
/*! \brief Removes indicators of new edits.*/
126
/*! \brief Passes the new whiteboard elements from the widget.*/
127
void newWbElement(const QDomElement &, const Jid &, bool groupChat);
128
/*! \brief Signals that the session ended and the dialog is to be deleted.*/
129
void sessionEnded(const QString &);
133
/*! \brief Catches keyboard shortcuts.*/
134
void keyPressEvent(QKeyEvent *);
135
/*! \brief Sets the destruction times as specified by options.*/
136
void closeEvent(QCloseEvent *);
137
/*! \brief Saves the size of the dialog as default if so specified in options.*/
138
void resizeEvent(QResizeEvent *);
139
/*! \brief Removes the destruction timer.*/
140
void showEvent(QShowEvent *);
141
/*! \brief Invokes activated() if activated.*/
142
void changeEvent(QEvent *e);
145
/*! \brief Popsup a dialog asking for a new viewBox for the whiteboard.*/
147
/*! \brief Popsup a color dialog and sets the selected color as the default stroke color for new items.*/
148
void setStrokeColor();
149
/*! \brief Popsup a color dialog and sets the selected color as the default fill color for new items.*/
151
/*! \brief Sets the stroke width for new elements based on the invoker.*/
152
void setStrokeWidth(QAction *);
153
/*! \brief Sets the WbWidget's mode based on the invoker.*/
154
void setMode(QAction *);
155
/*! \brief Emits the newWbElement() signal with the given element (usually from WbWidget).*/
156
void doSend(const QDomElement &);
157
/*! \brief Sets keep open false.*/
158
void setKeepOpenFalse();
159
/*! \brief Constructs the context menu.*/
163
/*! \brief Pops up the context menu.*/
164
void contextMenuEvent(QContextMenuEvent *);
165
/*! \brief Set a timer for self destruction in the give n number of minutes.*/
166
void setSelfDestruct(int);
167
/*! \brief Update the caption to indicate the number of unseen whiteboard messages.*/
168
void updateCaption();
170
/*! \brief The target JID.*/
173
/*! \brief The main widget.*/
176
/*! \brief The label showing own identity.*/
177
AccountLabel *lb_ident_;
178
/*! \brief The line edit showing target JID.*/
180
/*! \brief The context menu.*/
183
/*! \brief The main toolbar.*/
185
/*! \brief The action group for colors.*/
186
QActionGroup *group_colors_;
187
/*! \brief The action group for widths.*/
188
QActionGroup *group_widths_;
189
/*! \brief The action group for modes.*/
190
QActionGroup *group_modes_;
191
/*! \brief The menu for colors.*/
193
/*! \brief The menu for widths.*/
195
/*! \brief The menu for modes.*/
197
QAction *act_color_, *act_fill_;
198
IconAction *act_end_, *act_clear_, *act_geometry_, *act_widths_, *act_modes_;
199
/*! \brief List of queued incoming wb elements.*/
200
QList<incomingElement> queuedIncomingElements_;
201
/*! \brief List of queued outgoing wb elements.*/
202
QList<QDomElement> queuedOutgoingElements_;
203
/*! \brief An SVG document representing the the whiteboard when queued was set true.*/
204
QList<WbItem*> snapshot_;
205
/*! \brief True if the target is a groupchat.*/
207
/*! \brief The number of whiteboard messages since last activation.*/
209
/*! \brief Boolean set true if a new edit was just received.*/
211
/*! \brief Boolean about whether further edits to the session are allowed.*/
213
/*! \brief If true, new wb elements are queued rather than processed.*/
215
/*! \brief A string that identifies the last edit that was processed.*/
216
QHash<QString, QString> lastWb_;
218
/*! \brief Pointer to the timer that will invoke destruction.*/
219
QTimer *selfDestruct_;