superkaramba
imagelabel.h
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 IMAGELABEL_H
00025 #define IMAGELABEL_H
00026
00027 #include <QPainter>
00028 #include <QGraphicsSceneMouseEvent>
00029
00030 #include <kio/netaccess.h>
00031 #include <kio/copyjob.h>
00032 #include <KSvgRenderer>
00033
00034 #include "karamba.h"
00035 #include "meter.h"
00036
00037 class ImageLabel;
00038
00039
00040 class Effect : public QObject
00041 {
00042
00043 Q_OBJECT
00044
00045 public:
00046 Effect(ImageLabel*, int millisec);
00047
00048 virtual ~Effect();
00049
00050 virtual QPixmap apply(QPixmap pixmap) = 0;
00051
00052 void startTimer();
00053
00054 protected:
00055 ImageLabel* myImage;
00056
00057 int millisec;
00058 };
00059
00060
00061 class Intensity : public Effect
00062 {
00063 public:
00064 Intensity(ImageLabel*, float r, int millisec);
00065
00066 QPixmap apply(QPixmap pixmap);
00067
00068 private:
00069 float ratio;
00070 };
00071
00072
00073
00074 class ChannelIntensity : public Effect
00075 {
00076 public:
00077 ChannelIntensity(ImageLabel*, float r, const QString &c, int millisec);
00078
00079 QPixmap apply(QPixmap pixmap);
00080
00081 private:
00082 float ratio;
00083 int channel;
00084 };
00085
00086
00087 class ToGray : public Effect
00088 {
00089 public:
00090 ToGray(ImageLabel*, int millisec);
00091
00092 QPixmap apply(QPixmap pixmap);
00093 };
00094
00095
00096 class ToAlpha : public Effect
00097 {
00098 public:
00099 ToAlpha(ImageLabel*, const QColor &alphaColor, int alpha, int millisec);
00100
00101 QPixmap apply(QPixmap pixmap);
00102
00103 private:
00104 QColor m_alphaColor;
00105 int m_alpha;
00106 };
00107
00108 class ImageLabel : public Meter
00109 {
00110
00111 Q_OBJECT
00112
00113 public:
00114 ImageLabel(Karamba* k, int ix, int iy, int iw, int ih);
00115 ImageLabel(Karamba* k);
00116 ~ImageLabel();
00117 void setValue(const QString &imagePath);
00118
00119 void setValue(int);
00120 void setValue(QPixmap&);
00121 QString getStringValue() const
00122 {
00123 return imagePath;
00124 }
00125 void scale(int, int);
00126 void smoothScale(int, int);
00127
00128 void rotate(int);
00129 void removeImageTransformations();
00130 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
00131 QWidget *widget);
00132
00133 void rolloverImage(QGraphicsSceneHoverEvent *e);
00134 void parseImages(const QString &fn, const QString &fn_roll, int, int, int, int);
00135 virtual void show();
00136 virtual void hide();
00137
00138 void setTooltip(QString txt);
00139 int background;
00140
00141 void removeEffects();
00142 void intensity(float ratio, int millisec);
00143 void channelIntensity(float ratio, QString channel, int millisec);
00144 void toGray(int millisec);
00145 void toAlpha(const QColor &alphaColor, int alpha, int millisec);
00146 void setBackground(int b);
00147
00148 void attachClickArea(QString leftMouseButton, QString middleMouseButton,
00149 QString rightMouseButton);
00150
00151 bool mouseEvent(QEvent *e);
00152
00153 void allowClick(bool);
00154 bool clickable();
00155 void setPixel(const QPoint &point, const QColor &pixel);
00156
00157 bool enableAnimation(bool enable);
00158 bool animationEnabled() const;
00159
00160 bool drawElement(const QString &element);
00161 QString elementDrawn() const;
00162
00163 private slots:
00164
00165
00166 void slotEffectExpired();
00167 void slotCopyResult(KJob* job);
00168 void repaintSvg();
00169
00170 signals:
00171 void pixmapLoaded();
00172
00173 private:
00174 void applyTransformations(bool useSmoothScale = false);
00175 int pixmapWidth;
00176 int pixmapHeight;
00177 int pixmapOffWidth;
00178 int pixmapOffHeight;
00179 int pixmapOnWidth;
00180 int pixmapOnHeight;
00181
00182 bool m_allowClick;
00183
00184
00185 bool doScale;
00186
00187 bool doRotate;
00188
00189
00190 Effect* imageEffect;
00191
00192
00193
00194 int scale_w;
00195 int scale_h;
00196
00197
00198 int rot_angle;
00199
00200 QPixmap pixmap;
00201 QPixmap realpixmap;
00202
00203 QRect rect_off, rect_on;
00204 QRect old_tip_rect;
00205
00206 bool zoomed;
00207
00208 bool rollover;
00209 QPixmap pixmap_off;
00210 QPixmap pixmap_on;
00211 int xoff, xon;
00212 int yoff, yon;
00213 QString imagePath;
00214
00215 QString m_leftMouseButtonAction;
00216 QString m_middleMouseButtonAction;
00217 QString m_rightMouseButtonAction;
00218
00219 KSvgRenderer *m_renderer;
00220 bool m_connected;
00221
00222 QString m_element;
00223 };
00224
00225 #endif // IMAGELABEL_H