[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfguiutil.h
Go to the documentation of this file.
1/***************************************************************************
2 * file klfguiutil.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 KLFGUIUTIL_H
25#define KLFGUIUTIL_H
26
27
28#include <QString>
29#include <QByteArray>
30#include <QComboBox>
31#include <QWidget>
32#include <QDialog>
33#include <QProgressDialog>
34#include <QMouseEvent>
35#include <QPaintEvent>
36#include <QTime>
37#include <QGridLayout>
38#include <QDoubleSpinBox>
39#include <QLabel>
40#include <QMovie>
41#include <QPainter>
42
43#include <klfutil.h>
44
45
47
64{
65 Q_OBJECT
66public:
67 KLFProgressReporter(int min, int max, QObject *parent = NULL);
69 virtual ~KLFProgressReporter();
70
71 inline int min() const { return pMin; }
72 inline int max() const { return pMax; }
73
74signals:
84 void progress(int progressValue);
85
90 void finished();
91
92public slots:
99 void doReportProgress(int value);
100
101private:
102 int pMin;
103 int pMax;
104 bool pFinished;
105};
106
172class KLF_EXPORT KLFProgressDialog : public QProgressDialog
173{
174 Q_OBJECT
175public:
177 KLFProgressDialog(QString labelText = QString(), QWidget *parent = NULL);
178
181 KLFProgressDialog(bool canCancel, QString labelText, QWidget *parent);
182
183 virtual ~KLFProgressDialog();
184
185
186public slots:
187
190 virtual void setDescriptiveText(const QString& labelText);
194 virtual void startReportingProgress(KLFProgressReporter *progressReporter,
195 const QString& descriptiveText);
199 virtual void startReportingProgress(KLFProgressReporter *progressReporter);
200
202 virtual void setValue(int value);
203
204protected:
205 void paintEvent(QPaintEvent *event);
206
207private:
208 void setup(bool canCancel);
209 void init(const QString& labelText);
210
211 KLFProgressReporter *pProgressReporter;
212
213 bool pGotPaintEvent;
214};
215
216
237class KLF_EXPORT KLFPleaseWaitPopup : public QLabel
238{
239 Q_OBJECT
240 Q_PROPERTY(bool disableUi READ willDisableUi WRITE setDisableUi) ;
241public:
260 KLFPleaseWaitPopup(const QString& text, QWidget *callingWidget = NULL, bool alwaysAbove = false);
261 virtual ~KLFPleaseWaitPopup();
262
263 inline bool willDisableUi() const { return pDisableUi; }
264
269 virtual void setDisableUi(bool disableUi);
270
272 virtual bool pleaseWaitShown() const { return pGotPaintEvent; }
273
276 virtual bool wasUserDiscarded() const { return pDiscarded; }
277
278public slots:
280 virtual void showPleaseWait();
281
282protected:
283 virtual void mousePressEvent(QMouseEvent *event);
284 virtual void paintEvent(QPaintEvent *event);
285
286private:
287 QWidget *pParentWidget;
288 bool pDisableUi;
289 bool pGotPaintEvent;
290 bool pDiscarded;
291};
292
293
306{
307 Q_OBJECT
308public:
309 KLFDelayedPleaseWaitPopup(const QString& text, QWidget *callingWidget = NULL);
311
312 virtual void setDelay(int ms);
313
314public slots:
315 virtual void process();
316
317private:
318 int pDelay;
319 QTime timer;
320};
321
322
339class KLF_EXPORT KLFEnumComboBox : public QComboBox
340{
341 Q_OBJECT
342
343 Q_PROPERTY(int selectedValue READ selectedValue WRITE setSelectedValue)
344public:
345 KLFEnumComboBox(QWidget *parent = 0);
346 KLFEnumComboBox(const QList<int>& enumValues, const QStringList& enumTitles,
347 QWidget *parent = 0);
348 virtual ~KLFEnumComboBox();
349
350 int selectedValue() const;
351
352 QString enumText(int enumValue) const;
353
354signals:
355 void selectedValueChanged(int enumValue);
356
357public slots:
358 void setSelectedValue(int val);
359
360 void setEnumValues(const QList<int>& enumValues, const QStringList& enumTitles);
361
362private slots:
363 void internalCurrentIndexChanged(int index);
364
365private:
366 QList<int> pEnumValueList;
367 QMap<int,QString> pEnumValues;
368 QMap<int,int> pEnumCbxIndexes;
369};
370
371
372
373
374
381class KLF_EXPORT KLFGridFlowLayout : public QGridLayout
382{
383 Q_OBJECT
384public:
385 KLFGridFlowLayout(int columns, QWidget *parent);
386 virtual ~KLFGridFlowLayout() { }
387
388 virtual int ncolumns() const { return _ncols; }
389
390 virtual void insertGridFlowWidget(QWidget *w, Qt::Alignment align = 0);
391
392 void clearAll();
393
394protected:
397 int _currow, _curcol;
398};
399
400
401
402
404
412class KLFWaitAnimationOverlay : public QLabel
413{
414 Q_OBJECT
415 Q_PROPERTY(QString waitMovie READ waitMovieFileName WRITE setWaitMovie) ;
416 Q_PROPERTY(int widthPercent READ widthPercent WRITE setWidthPercent) ;
417 Q_PROPERTY(int heightPercent READ heightPercent WRITE setHeightPercent) ;
418 Q_PROPERTY(int positionXPercent READ positionXPercent WRITE setPositionXPercent) ;
419 Q_PROPERTY(int positionYPercent READ positionYPercent WRITE setPositionYPercent) ;
421public:
422 KLFWaitAnimationOverlay(QWidget *parent);
423 virtual ~KLFWaitAnimationOverlay();
424
425 inline QString waitMovieFileName() const { return (pAnimMovie!=NULL) ? pAnimMovie->fileName() : QString(); }
426
427 inline int widthPercent() const { return pWidthPercent; }
428 inline int heightPercent() const { return pHeightPercent; }
429 inline int positionXPercent() const { return pPositionXPercent; }
430 inline int positionYPercent() const { return pPositionYPercent; }
431
432 QColor backgroundColor() const;
433
434public slots:
444 virtual void setWaitMovie(QMovie *movie);
447 virtual void setWaitMovie(const QString& file);
448
450
461 void setWidthPercent(int widthpercent) { pWidthPercent = widthpercent; }
462
464
466 void setHeightPercent(int heightpercent) { pHeightPercent = heightpercent; }
467
469
480 void setPositionXPercent(int xpc) { pPositionXPercent = xpc; }
481
483
485 void setPositionYPercent(int ypc) { pPositionYPercent = ypc; }
486
488
493 void setBackgroundColor(const QColor& c);
494
496 virtual void startWait();
497
499 virtual void stopWait();
500
501protected:
502 virtual void timerEvent(QTimerEvent *event);
503
510
511private:
512 bool pIsWaiting;
513 QMovie *pAnimMovie;
514 int pAnimTimerId;
515
516 int pWidthPercent;
517 int pHeightPercent;
518 int pPositionXPercent;
519 int pPositionYPercent;
520};
521
522
523
527{
528public:
530 OpenDataOk = 0,
531 OpenDataFailed = 1,
532 OpenDataCantHandle = 2
533 };
534
535 virtual bool canOpenDropData(const QMimeData * data) = 0;
537 virtual int openDropData(const QMimeData *data) = 0;
538};
539
540
541
542
543
544
560KLF_EXPORT void klfDrawGlowedImage(QPainter *painter, const QImage& foreground,
561 const QColor& glow_color = QColor(128, 255, 128, 8),
562 int radius = 4, bool also_draw_image = true);
563
564
565
574KLF_EXPORT QImage klfImageScaled(const QImage& source, const QSize& newSize);
575
576
577
581{
582 Q_OBJECT
583public:
584 KLFWindowGeometryRestorer(QWidget *window);
586
587 virtual bool eventFilter(QObject *obj, QEvent *event);
588private:
589 QWidget *pWindow;
590};
591
592
595
596
597
598#endif
A popup screen inviting user to wait, appearing after a delay.
Definition: klfguiutil.h:306
An abstract handler for when data is dropped.
Definition: klfguiutil.h:527
virtual int openDropData(const QMimeData *data)=0
virtual bool canOpenDropData(const QMimeData *data)=0
a combo box proposing a list of (integer) enumeration values.
Definition: klfguiutil.h:340
void selectedValueChanged(int enumValue)
A Layout that lays out its children in a grid, flowing left to right, top to bottom.
Definition: klfguiutil.h:382
virtual ~KLFGridFlowLayout()
Definition: klfguiutil.h:386
virtual int ncolumns() const
Definition: klfguiutil.h:388
QList< QWidget * > mGridFlowWidgets
Definition: klfguiutil.h:395
A popup screen inviting the user to wait.
Definition: klfguiutil.h:238
bool willDisableUi() const
Definition: klfguiutil.h:263
virtual bool wasUserDiscarded() const
Definition: klfguiutil.h:276
virtual bool pleaseWaitShown() const
Definition: klfguiutil.h:272
A Progress Dialog.
Definition: klfguiutil.h:173
Object that emits progress information of a (lengthy) operation.
Definition: klfguiutil.h:64
void progress(int progressValue)
int max() const
Definition: klfguiutil.h:72
int min() const
Definition: klfguiutil.h:71
An animation display.
Definition: klfguiutil.h:413
KLFWaitAnimationOverlay(QWidget *parent)
Definition: klfguiutil.cpp:338
virtual void timerEvent(QTimerEvent *event)
Definition: klfguiutil.cpp:429
void setBackgroundColor(const QColor &c)
Set the label background color.
Definition: klfguiutil.cpp:389
int positionYPercent() const
Definition: klfguiutil.h:430
virtual ~KLFWaitAnimationOverlay()
Definition: klfguiutil.cpp:363
virtual void setWaitMovie(QMovie *movie)
Set which animation to display while searching.
Definition: klfguiutil.cpp:372
void setWidthPercent(int widthpercent)
Sets the width of this label.
Definition: klfguiutil.h:461
void setPositionXPercent(int xpc)
Sets the horizontal position of this label relative to the parent widget.
Definition: klfguiutil.h:480
QString waitMovieFileName() const
Definition: klfguiutil.h:425
int heightPercent() const
Definition: klfguiutil.h:428
int positionXPercent() const
Definition: klfguiutil.h:429
virtual QRect calcAnimationLabelGeometry()
Definition: klfguiutil.cpp:439
int widthPercent() const
Definition: klfguiutil.h:427
void setHeightPercent(int heightpercent)
Sets the height of this label.
Definition: klfguiutil.h:466
void setPositionYPercent(int ypc)
Sets the vertical position of this label relative to the parent widget.
Definition: klfguiutil.h:485
virtual void startWait()
Display the animation.
Definition: klfguiutil.cpp:396
virtual void stopWait()
Hide the animation.
Definition: klfguiutil.cpp:416
Helper class that restores window geometry after show/hide events.
Definition: klfguiutil.h:581
virtual bool eventFilter(QObject *obj, QEvent *event)
Definition: klfguiutil.cpp:556
virtual ~KLFWindowGeometryRestorer()
Definition: klfguiutil.cpp:552
KLFWindowGeometryRestorer(QWidget *window)
Definition: klfguiutil.cpp:546
#define KLF_EXPORT
Definition: klfdefs.h:41
KLF_EXPORT QImage klfImageScaled(const QImage &source, const QSize &newSize)
Scale image, preserve aspect ratio and meta-information.
Definition: klfguiutil.cpp:512
KLF_EXPORT void klfHideWindows()
Definition: klfguiutil.cpp:597
KLF_EXPORT void klfRestoreWindows()
Definition: klfguiutil.cpp:636
KLF_EXPORT void klfDrawGlowedImage(QPainter *painter, const QImage &foreground, const QColor &glow_color=QColor(128, 255, 128, 8), int radius=4, bool also_draw_image=true)
Draws the given image with a glow effect.
Definition: klfguiutil.cpp:461
QString fileName() const
virtual bool event(QEvent *e)
typedef Alignment

Generated by doxygen 1.9.4