Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef KLFDISPLAYLABEL_H
00025 #define KLFDISPLAYLABEL_H
00026
00027 #include <QLabel>
00028 #include <QPicture>
00029 #include <QTemporaryFile>
00030
00031 #include <klfdefs.h>
00032
00046 class KLF_EXPORT KLFDisplayLabel : public QLabel
00047 {
00048 Q_OBJECT
00049
00050 Q_PROPERTY(bool enableToolTipPreview READ enableToolTipPreview WRITE setEnableToolTipPreview) ;
00051
00052 Q_PROPERTY(QString bigPreviewText READ bigPreviewText) ;
00053 Q_PROPERTY(bool glowEffect READ glowEffect WRITE setGlowEffect) ;
00054 Q_PROPERTY(QColor glowEffectColor READ glowEffectColor WRITE setGlowEffectColor) ;
00055 Q_PROPERTY(int glowEffectRadius READ glowEffectRadius WRITE setGlowEffectRadius) ;
00056 Q_PROPERTY(bool labelEnabled READ labelEnabled WRITE setLabelEnabled) ;
00057 public:
00058 KLFDisplayLabel(QWidget *parent);
00059 virtual ~KLFDisplayLabel();
00060
00061 enum DisplayState { Clear = 0, Ok, Error };
00062 virtual DisplayState currentDisplayState() const { return pDisplayState; }
00063
00070 virtual QSize labelSize() const { return size(); }
00071
00072 virtual bool enableToolTipPreview() const { return pEnableToolTipPreview; }
00073
00074 virtual QString bigPreviewText() const { return _bigPreviewText; }
00075
00076 inline bool glowEffect() const { return pGE; }
00077 inline QColor glowEffectColor() const { return pGEcolor; }
00078 inline int glowEffectRadius() const { return pGEradius; }
00079
00080 inline bool labelEnabled() const { return pLabelEnabled; }
00081
00082 signals:
00083 void labelDrag();
00084
00085 public slots:
00086 virtual void setEnableToolTipPreview(bool enable) { pEnableToolTipPreview = enable; display_state(pDisplayState); }
00087
00088 virtual void displayClear();
00089 virtual void display(QImage displayimg, QImage tooltipimage, bool labelenabled = true);
00090 virtual void displayError(bool labelenabled = false)
00091 { displayError(QString(), labelenabled); }
00092 virtual void displayError(const QString& errorMessage, bool labelenabled = false);
00093
00094 void setGlowEffect(bool on) { pGE = on; display_state(pDisplayState); }
00095 void setGlowEffectColor(const QColor& color) { pGEcolor = color; display_state(pDisplayState); }
00096 void setGlowEffectRadius(int r) { pGEradius = r; display_state(pDisplayState); }
00097
00098 void setLabelEnabled(bool enabled) { pLabelEnabled = enabled; display_state(pDisplayState); }
00099
00100 protected:
00101 virtual void mouseMoveEvent(QMouseEvent *e);
00102
00103 private:
00104
00105 QPicture calc_display_picture();
00106 void display_state(DisplayState state);
00107
00108 DisplayState pDisplayState;
00109 QString pDisplayError;
00110 QImage pDisplayImage;
00111 QImage pDisplayTooltip;
00112
00113 QSize pLabelFixedSize;
00114 bool pEnableToolTipPreview;
00115 QTemporaryFile *mToolTipFile;
00116
00117 QPalette pDefaultPalette;
00118 QPalette pErrorPalette;
00119
00120 QString _bigPreviewText;
00121
00122 bool pGE;
00123 QColor pGEcolor;
00124 int pGEradius;
00125
00126 void set_error(bool error_on);
00127
00128 bool pLabelEnabled;
00129 };
00130
00131
00132
00133
00134
00135
00136
00137 #endif