1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
|
/***************************************************************************
imageviewer.h - description
-------------------
begin : Sat Dec 1 2001
copyright : (C) 2001 by Richard Groult
email : rgroult@jalix.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
* USA. *
* *
* For license exceptions see LICENSE.EXC file, attached with the source *
* code. *
* *
***************************************************************************/
#ifndef SHOWIMG_H
#define SHOWIMG_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
// QT
#include <qwidget.h>
// KDE
#include <ktrader.h>
class ImageListView;
class MainWindow;
class KAction;
class KActionCollection;
class KPixmapIO;
class KPopupMenu;
class KToggleAction;
class KLocale;
class QLabel;
class QMenuBar;
class QPopupMenu;
class QWidget;
#define EFFECT_NORMALIZE 1
#define EFFECT_EQUALIZE 2
#define EFFECT_INTENSITY 3
#define EFFECT_INVERT 9
#define EFFECT_GRAYSCALE 10
#define EFFECT_EMBOSS 4
#define EFFECT_SWIRL 5
#define EFFECT_SPREAD 6
#define EFFECT_IMPLODE 7
#define EFFECT_CHARCOAL 8
class ImageViewer:public QWidget
{
Q_OBJECT
public:
enum ImagePosition
{
TopLeft = 0,
TopCentered,
TopRight,
RightCentered,
Centered,
LeftCentered,
BottomLeft,
BottomCentered,
BottomRight
};
/**
create the imageViewer
@param parent the parent widget
@param ImageListView the list of the images
@param MainWindow the mainwindow
@param name
@param wFlags
*/
ImageViewer (QWidget * parent = NULL,
ImageListView * il = NULL,
MainWindow *mw = NULL,
QString name = NULL, int wFlags = 0);
/**
init the menu given the actionCollection
*/
void initMenu(KActionCollection *actionCollection);
/**
init actions given the actionCollection
*/
void initActions(KActionCollection *actionCollection);
/**
set the grayscale level
@param togray between 0 and 100
*/
void setToGrayscale(int togray);
int toGrayscale();
/**
load and display an image given the full filaname
@param fileName the full filaname of the picture to display
*/
bool loadImage (const QString& fileName="", int index=-1);
void reload();
/**
preload in memory an image given the full filaname
@param fileName the full filaname of the picture to load
*/
bool preloadImage (const QString& fileName);
/**
upadate the status of the mainwindow
*/
void updateStatus ();
/**
@return true if an image is loaded
*/
bool hasImage();
/**
flip or miror the diplayed image
*/
void mirror (bool horizontal, bool vertical, bool r=true);
/**
rotate to the left
*/
void rotateLeft(bool r=true);
/**
rotate to the right
*/
void rotateRight(bool r=true);
/**
display the image with its original size (i.e zoom=1)
*/
void originalSize();
/**
fit or unfit the image ti the screen
@param fit if true, fit the image
@keep if true, store this param for te next images
*/
void setFit(bool fit, bool keep=false);
/**
set smooth for the next image, required for memory and time
*/
void setSmooth(bool s);
/**
zoom into the image given the rate
*/
void zoomIn(float rate);
/**
zoom out the image given the rate
*/
void zoomOut(float rate);
/**
zoom into the image given the value
*/
void setZoomValue(float val);
/**
if true, store the zoom rate
*/
void setZoomLock(bool lock);
/**
scroll the image of dx and dy pixels
*/
void scroll ( int dx, int dy ) ;
bool scrollUp ();
bool scrollDown ();
void applyFilter(int filter, bool activate);
void applyFilter();
void applyFilterPreloaded();
void setImagePosition(ImagePosition pos);
ImagePosition getImagePosition();
/**
@return a pixmap of the displayed image
*/
QPixmap getPixmap();
/**
@return the fullname of the displayed image
*/
QString getFilename();
/**
@param shrink if true, shrink the image if it's larger than the screen
*/
void setShrink(bool shrink);
/**
@param enlarge if true, enlarge the image if it's smaller than the screen
*/
void setEnlarge( bool enlarge);
const bool& getEnlarge();
/**
set the background color
*/
void setBackgroundColor(const QColor col);
QLabel *status;
int total;
int nbImg;
MainWindow *mw;
bool smooth () const;
void setMessage(const QString& msg);
void setZoom(float zoom);
void setFilterList(const QStringList& list);
QStringList getFilterList();
void setUseEXIF(bool use);
bool useEXIF();
//
QColor bgColor();
//
void readConfig(KConfig* config, const QString& group);
void writeConfig(KConfig* config, const QString& group);
signals:
void sigSetMessage(QString);
public slots:
void wallpaperC();
void wallpaperM();
void wallpaperCM();
void wallpaperCMa();
void wallpaperA();
void wallpaperL();
void wallpaper (int mode=1);
void fitHeight(bool setFitHeight=true, bool redraw=true);
void fitWidth(bool setFitWidth=true, bool redraw=true);
///
void slotfitWidth();
void slotfitHeight();
void slotZoomIn();
void slotZoomOut();
void slotZoom();
void slotZoomNo();
void slotShrink();
void slotEnlarge();
void slotZoomLock();
void slotSmooth();
///
bool scrolldxR();
bool scrolldyB();
bool scrolldxL();
bool scrolldyT();
bool scrolldyB(int dB);
bool scrolldyT(int dT);
QString slotSave(const QString& path);
void slotPrint();
//
void selectionChanged(bool selected);
void slotSetFilter();
void slotRotateLeft ();
void slotRotateRight ();
void slotMirrorH ();
void slotMirrorV ();
void slotDisplayExifDialog();
protected:
void paintEvent (QPaintEvent *);
void resizeEvent (QResizeEvent *);
void wheelEvent (QWheelEvent * e);
void mousePressEvent (QMouseEvent * e);
void mouseReleaseEvent (QMouseEvent * e);
void mouseMoveEvent (QMouseEvent * e);
void mouseDoubleClickEvent (QMouseEvent * e);
bool isScrolling();
protected slots:
void movieUpdated(const QRect& area);
void movieStatus(int status);
void startMovie();
private:
bool autoRotate(bool r=false);
int virtualScreenWidth();
int virtualScreenHeight();
int virtualPictureWidth();
int virtualPictureHeight();
void setVirtualPosX(double posX);
void setVirtualPosY(double posY);
int getVirtualPosX();
int getVirtualPosY();
QPoint getVirtualPos();
void setVirtualPos(const QPoint pos);
void setPosX(double posX);
void setPosY(double posY);
void setPos(const QPoint pos);
int getPosX();
int getPosY();
QPoint getPos();
bool posXForTopXIsOK(double posX);
bool posYForTopYIsOK(double posY);
void placeImage(bool redraw=false);
void placeImage(ImagePosition pos, bool redraw=false);
void centerImage(int posX, int posY, bool redraw=false);
void centerImage(bool redraw=false);
void centerXImage(bool redraw=false);
void centerYImage(bool redraw=false);
void doScale (bool repaint=true);
void scaleFit();
void fitSize(bool redraw=true);
void scalePreload ();
bool reconvertImage ();
QString filename;
bool ss; //true if smooth image
QImage *image;// the loaded image
QImage *imageScaled; // the preloaded scaled image
QString imageName;
QString imageType;
int imageIndex;
KPixmapIO *pIO;
QString preimageName;
QImage *preloadedImage; // the preloaded image
QImage *preloadedScaledImage; // the preloaded image
KActionCollection *actionCollection;
QPopupMenu *file;
KPopupMenu *m_popup, *m_popup_openWith ;
int grayscale_;
ImageListView *il;
QPoint *sp, *ep, *lp; //start, end, and last Points
QBrush bgBrush;
QColor bgColor_;
QPixmap *pbgxpm;
float scale;
double realPosX, realPosY;
double dragStartPosX, dragStartPosY;
double topPosX, topPosY;
double difTopPosX, difTopPosY;
ButtonState button;
QMovie* movie;
void initMovie();
bool fit, isFitWidth, isFitHeight;
bool hasimage;
bool isScrolling_;
protected:
bool shrink, enlarge, lock;
bool _useEXIF_;
bool e_normalize, e_equalize, e_intensity, e_emboss, e_swirl, e_spread, e_implode, e_charcoal, e_invert, e_grayscale;
ImagePosition currentImagePosition_;
private:
KToggleAction
*aEnlarge, *aShrink,
*aZoomLock, *aZoomFitWidth, *aZoomFitHeight,
*aSmooth,
*aEffect_NORMALIZE,*aEffect_EQUALIZE,*aEffect_INTENSITY, *aEffect_INVERT, *aEffect_GRAYSCALE,
*aEffect_EMBOSS,*aEffect_SWIRL,*aEffect_SPREAD,*aEffect_IMPLODE,*aEffect_CHARCOAL,
*aEffect_NONE;
KAction
*aZoomIn,*aZoomOut,*aZoomNo,*aZoomFit,
*aRotLeft,*aRotRight,*aHMirror,*aVMirror,
*aPrint,
*aDisplayExifDialog;
KLocale *m_kKocale;
};
#endif // SHOWIMG_H
|