[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfsidewidget.h
Go to the documentation of this file.
1/***************************************************************************
2 * file klfsidewidget.h
3 * This file is part of the KLatexFormula Project.
4 * Copyright (C) 2011 by Philippe Faist
5 * philippe.faist at bluewin.ch
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22/* $Id$ */
23
24#ifndef KLFSIDEWIDGET_H
25#define KLFSIDEWIDGET_H
26
27
28#include <QObject>
29#include <QWidget>
30#include <QPointer>
31
32#include <klfdefs.h>
33#include <klffactory.h>
34
35
36struct KLFSideWidgetManagerBasePrivate;
37
39
66{
67 Q_OBJECT
68public:
74 KLFSideWidgetManagerBase(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
75 bool requireSideWidgetParentConsistency = false, QObject *managerParent = NULL);
77
79 virtual QWidget * sideWidget() const;
81 virtual QWidget * ourParentWidget() const;
82
87 void setSideWidget(QWidget *widget);
90 void setOurParentWidget(QWidget *widget);
91
93
96 virtual bool sideWidgetVisible() const = 0;
97
98signals:
103 void sideWidgetShown(bool shown);
104
105public slots:
107
113 virtual void showSideWidget(bool show) = 0;
114
118 void hideSideWidget(bool hide = true) { showSideWidget(!hide); }
121 void toggleSideWidget() { showSideWidget(!sideWidgetVisible()); }
122
130 virtual void waitForShowHideActionFinished(int timeout_ms = 2000);
131
132protected:
134 virtual void newSideWidgetSet(QWidget *oldSideWidget, QWidget *newSideWidget)
135 { Q_UNUSED(oldSideWidget); Q_UNUSED(newSideWidget); }
137 virtual void newParentWidgetSet(QWidget *oldParentWidget, QWidget *newParentWidget)
138 { Q_UNUSED(oldParentWidget); Q_UNUSED(newParentWidget); }
139
146 virtual bool showHideIsAnimating() { return false; }
147
148private:
150};
151
152
153// -----
154
155
156struct KLFShowHideSideWidgetManagerPrivate;
157
159
169{
170 Q_OBJECT
171
172 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation) ;
173 Q_PROPERTY(int calcSpacing READ calcSpacing WRITE setCalcSpacing) ;
174public:
175 KLFShowHideSideWidgetManager(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
176 QObject *managerParent = NULL);
178
179 Qt::Orientation orientation() const;
180 int calcSpacing() const;
181
182 virtual bool eventFilter(QObject *obj, QEvent *event);
183
184 virtual bool sideWidgetVisible() const;
185
186public slots:
187 virtual void showSideWidget(bool show);
188 void setOrientation(Qt::Orientation o);
189 void setCalcSpacing(int cs);
190
191protected:
192 virtual bool event(QEvent *event);
193
194 virtual void newSideWidgetSet(QWidget *oldSideWidget, QWidget *newSideWidget);
195 virtual void newParentWidgetSet(QWidget *oldParentWidget, QWidget *newParentWidget);
196
197private slots:
198 void resizeParentWidget(const QSize& size);
199
200private:
202};
203
204
205// ------
206
207struct KLFContainerSideWidgetManagerPrivate;
208
210
224{
225 Q_OBJECT
226
227public:
228 KLFContainerSideWidgetManager(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
229 QObject *managerParent = NULL);
231
232 virtual bool sideWidgetVisible() const;
233
234 bool eventFilter(QObject *obj, QEvent *event);
235
236public slots:
237 virtual void showSideWidget(bool show);
238
239protected:
241 void init();
242
244 virtual QWidget * createContainerWidget(QWidget * pw) = 0;
245
246 virtual QWidget * containerWidget() const;
247
248 virtual void newSideWidgetSet(QWidget *oldSideWidget, QWidget *newSideWidget);
249 virtual void newParentWidgetSet(QWidget *oldWidget, QWidget *newWidget);
250
251private slots:
252 void aWidgetDestroyed(QObject *);
253
254private:
256};
257
258
259// ------
260
261// -------
262
263struct KLFFloatSideWidgetManagerPrivate;
264
266
273{
274 Q_OBJECT
275
276 Q_PROPERTY(Qt::WindowFlags wflags READ wflags WRITE setWFlags) ;
277public:
278 KLFFloatSideWidgetManager(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
279 QObject *managerParent = NULL);
281
282 Qt::WindowFlags wflags() const;
283
284 virtual bool sideWidgetVisible() const;
285
286public slots:
287 virtual void showSideWidget(bool show);
288 void setWFlags(Qt::WindowFlags wflags);
289
290protected:
291 void newSideWidgetSet(QWidget *oldw, QWidget *w);
292
293 virtual QWidget * createContainerWidget(QWidget * pw);
294
295private:
297};
298
299
300
301// ------
302
303
314{
315public:
318
319 virtual QStringList supportedTypes() const;
321 virtual QString getTitleFor(const QString& type) const;
322 virtual KLFSideWidgetManagerBase * createSideWidgetManager(const QString& type, QWidget *parentWidget,
323 QWidget *sideWidget, QObject *parent);
324
325 static QStringList allSupportedTypes();
326 static KLFSideWidgetManagerBase * findCreateSideWidgetManager(const QString& type, QWidget *parentWidget,
327 QWidget *sideWidget, QObject *parent);
328 static KLFSideWidgetManagerFactory * findFactoryFor(const QString& managertype);
329
330private:
331 static KLFFactoryManager pFactoryManager;
332};
333
334
335
336
337// -----------------------------
338
339
340
341struct KLFSideWidgetPrivate;
342
344
373class KLF_EXPORT KLFSideWidget : public QWidget
374{
375 Q_OBJECT
376
377 Q_PROPERTY(QString sideWidgetManagerType READ sideWidgetManagerType WRITE setSideWidgetManager) ;
378public:
379 enum SideWidgetManager { ShowHide = 1, Float, Drawer } ;
380
381 // KLFSideWidget(SideWidgetManager mtype = Float, QWidget *parent = NULL);
382 // KLFSideWidget(const QString& mtype = QLatin1String("Float"), QWidget *parent = NULL);
383 KLFSideWidget(QWidget *parent = NULL);
384 virtual ~KLFSideWidget();
385
390 bool sideWidgetVisible() const;
391
400 QString sideWidgetManagerType() const;
401
406 KLFSideWidgetManagerBase * sideWidgetManager();
407
408signals:
412 void sideWidgetShown(bool shown);
417 void sideWidgetManagerTypeChanged(const QString& managerType);
418
419public slots:
426 void showSideWidget(bool show = true);
431 void hideSideWidget(bool hide = true) { showSideWidget(!hide); }
436 void toggleSideWidget() { showSideWidget(!sideWidgetVisible()); }
437
439 void setSideWidgetManager(SideWidgetManager mtype);
443 void setSideWidgetManager(const QString& mtype);
444
449 void debug_unlock_qtdesigner();
450
451private:
452
454
455 friend class KLFSideWidgetDesPlugin;
456 bool _inqtdesigner;
457};
458
459
460
461
462#endif
A generic container side widget show/hide manager (mac only)
virtual bool sideWidgetVisible() const
KLFContainerSideWidgetManager(QWidget *parentWidget=NULL, QWidget *sideWidget=NULL, QObject *managerParent=NULL)
virtual QWidget * containerWidget() const
bool eventFilter(QObject *obj, QEvent *event)
void init()
Must be called in subclasses' constructor.
virtual QWidget * createContainerWidget(QWidget *pw)=0
Must be reimplemented to create the container widget.
virtual void newSideWidgetSet(QWidget *oldSideWidget, QWidget *newSideWidget)
virtual void newParentWidgetSet(QWidget *oldWidget, QWidget *newWidget)
Base class for factories.
Definition klffactory.h:41
A base abstract factory manager class.
Definition klffactory.h:92
A Floating window show/hide manager.
A show-widget/hide-widget side widget show/hide manager.
void setOrientation(Qt::Orientation o)
Qt::Orientation orientation() const
A widget that can be shown or hidden, that expands a main widget, e.g. klatexformula expanded mode.
void sideWidgetManagerTypeChanged(const QString &managerType)
emitted whenver the manager associated to this side widget has changed.
void toggleSideWidget()
toggles the show/hide state of this side widget.
void hideSideWidget(bool hide=true)
hide or show the side widget.
void sideWidgetShown(bool shown)
emitted whenever this side widget is shown or hidden
Abstract core functionality of showing/hiding a KLFSideWidget.
void sideWidgetShown(bool shown)
Emitted whenever the shown status of the side widget has changed.
void hideSideWidget(bool hide=true)
virtual void newParentWidgetSet(QWidget *oldParentWidget, QWidget *newParentWidget)
virtual bool sideWidgetVisible() const =0
returns TRUE if the side widget is currently visible
virtual QWidget * sideWidget() const
virtual void showSideWidget(bool show)=0
Show or hide the side widget.
virtual void newSideWidgetSet(QWidget *oldSideWidget, QWidget *newSideWidget)
virtual bool showHideIsAnimating()
A factory for creating side widget managers.
const char * type
Base declarations for klatexformula and some utilities.
#define KLF_DECLARE_PRIVATE(ClassName)
Definition klfdefs.h:74
#define KLF_EXPORT
Definition klfdefs.h:41
virtual bool event(QEvent *e)
virtual bool eventFilter(QObject *watched, QEvent *event)
typedef WindowFlags

Generated by doxygen 1.12.0