[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: klfsidewidget.h 953 2016-12-27 00:13:10Z phfaist $ */
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 
36 struct KLFSideWidgetManagerBasePrivate;
37 
39 
66 {
67  Q_OBJECT
68 public:
74  KLFSideWidgetManagerBase(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
75  bool requireSideWidgetParentConsistency = false, QObject *managerParent = NULL);
76  virtual ~KLFSideWidgetManagerBase();
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 
98 signals:
103  void sideWidgetShown(bool shown);
104 
105 public slots:
107 
113  virtual void showSideWidget(bool show) = 0;
114 
116  void showSideWidget() { showSideWidget(true); }
118  void hideSideWidget(bool hide = true) { showSideWidget(!hide); }
121  void toggleSideWidget() { showSideWidget(!sideWidgetVisible()); }
122 
130  virtual void waitForShowHideActionFinished(int timeout_ms = 2000);
131 
132 protected:
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 
148 private:
150 };
151 
152 
153 // -----
154 
155 
156 struct 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) ;
174 public:
175  KLFShowHideSideWidgetManager(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
176  QObject *managerParent = NULL);
177  virtual ~KLFShowHideSideWidgetManager();
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 
186 public slots:
187  virtual void showSideWidget(bool show);
188  void setOrientation(Qt::Orientation o);
189  void setCalcSpacing(int cs);
190 
191 protected:
192  virtual bool event(QEvent *event);
193 
194  virtual void newSideWidgetSet(QWidget *oldSideWidget, QWidget *newSideWidget);
195  virtual void newParentWidgetSet(QWidget *oldParentWidget, QWidget *newParentWidget);
196 
197 private slots:
198  void resizeParentWidget(const QSize& size);
199 
200 private:
202 };
203 
204 
205 // ------
206 
207 struct KLFContainerSideWidgetManagerPrivate;
208 
210 
224 {
225  Q_OBJECT
226 
227 public:
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 
236 public slots:
237  virtual void showSideWidget(bool show);
238 
239 protected:
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 
251 private slots:
252  void aWidgetDestroyed(QObject *);
253 
254 private:
256 };
257 
258 
259 // ------
260 
261 // -------
262 
263 struct KLFFloatSideWidgetManagerPrivate;
264 
266 
273 {
274  Q_OBJECT
275 
276  Q_PROPERTY(Qt::WindowFlags wflags READ wflags WRITE setWFlags) ;
277 public:
278  KLFFloatSideWidgetManager(QWidget *parentWidget = NULL, QWidget *sideWidget = NULL,
279  QObject *managerParent = NULL);
280  virtual ~KLFFloatSideWidgetManager();
281 
282  Qt::WindowFlags wflags() const;
283 
284  virtual bool sideWidgetVisible() const;
285 
286 public slots:
287  virtual void showSideWidget(bool show);
288  void setWFlags(Qt::WindowFlags wflags);
289 
290 protected:
291  void newSideWidgetSet(QWidget *oldw, QWidget *w);
292 
293  virtual QWidget * createContainerWidget(QWidget * pw);
294 
295 private:
297 };
298 
299 
300 
301 // ------
302 
303 
314 {
315 public:
317  virtual ~KLFSideWidgetManagerFactory();
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 
330 private:
331  static KLFFactoryManager pFactoryManager;
332 };
333 
334 
335 
336 
337 // -----------------------------
338 
339 
340 
341 struct KLFSideWidgetPrivate;
342 
344 
373 class KLF_EXPORT KLFSideWidget : public QWidget
374 {
375  Q_OBJECT
376 
377  Q_PROPERTY(QString sideWidgetManagerType READ sideWidgetManagerType WRITE setSideWidgetManager) ;
378 public:
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 
408 signals:
412  void sideWidgetShown(bool shown);
417  void sideWidgetManagerTypeChanged(const QString& managerType);
418 
419 public 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 
451 private:
452 
454 
455  friend class KLFSideWidgetDesPlugin;
456  bool _inqtdesigner;
457 };
458 
459 
460 
461 
462 #endif
virtual bool showHideIsAnimating()
virtual bool sideWidgetVisible() const =0
returns TRUE if the side widget is currently visible
A Floating window show/hide manager.
Base declarations for klatexformula and some utilities.
const char * type
Definition: klfdatautil.cpp:96
A widget that can be shown or hidden, that expands a main widget, e.g. klatexformula expanded mode...
A generic container side widget show/hide manager (mac only)
Base class for factories.
Definition: klffactory.h:40
virtual bool event(QEvent *e)
#define KLF_EXPORT
Definition: klfdefs.h:41
virtual void newSideWidgetSet(QWidget *oldSideWidget, QWidget *newSideWidget)
A base abstract factory manager class.
Definition: klffactory.h:91
virtual bool eventFilter(QObject *watched, QEvent *event)
#define KLF_DECLARE_PRIVATE(ClassName)
Definition: klfdefs.h:74
void toggleSideWidget()
toggles the show/hide state of this side widget.
A factory for creating side widget managers.
virtual void newParentWidgetSet(QWidget *oldParentWidget, QWidget *newParentWidget)
Abstract core functionality of showing/hiding a KLFSideWidget.
Definition: klfsidewidget.h:65
void hideSideWidget(bool hide=true)
hide or show the side widget.
A show-widget/hide-widget side widget show/hide manager.
typedef WindowFlags
void hideSideWidget(bool hide=true)

Generated by doxygen 1.8.13