1 /***************************************************************************
2 imageviewer.h - An ImageViewer for KStars
4 begin : Mon Aug 27 2001
5 copyright : (C) 2001 by Thomas Kabelmann
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
24 #include <kpixmapio.h>
26 #include <ktempfile.h>
27 #include <kmainwindow.h>
30 *@short Image viewer widget for KStars
31 *@author Thomas Kabelmann
34 *This image-viewer automatically resizes the picture. The output
35 *works with kio-slaves and not directly with the QImage save-routines
36 *because normally the image-files are in GIF-format and QT does not
37 *save these files. For other formats, like PNG, this is not so important
38 *because they can directly saved by QImage.
40 *The download-slave works asynchron so the parent-widget can be used at
41 *this time. The save-slave works synchronously, but this is not important
42 *because the files are at this time local saved and this works not so long.
48 class ImageViewer
: public KMainWindow
{
53 ImageViewer (const KURL
*imageName
, const QString
&capText
, QWidget
*parent
, const char *name
= 0);
55 /**Destructor. If there is a partially downloaded image file, delete it.*/
59 /**Bitblt the image onto the viewer widget */
60 void paintEvent (QPaintEvent
*ev
);
62 /**The window is resized when a file finishes downloading, before it is displayed.
63 *The resizeEvent converts the downloaded QImage to a QPixmap
64 *@note (JH: not sure why this conversion is not done in showImage)
66 void resizeEvent (QResizeEvent
*ev
);
68 /**Make sure all events have been processed before closing the dialog */
69 void closeEvent (QCloseEvent
*ev
);
71 /**Keyboard shortcuts for saving files and closing the window
72 *@note (this should be deprecated; instead just assign KAccel
73 *to the close/save buttons)
75 void keyPressEvent (QKeyEvent
*ev
);
77 /**Unset the bool variables that indicate keys were pressed.
78 *(this should be deprecated; see above)
80 void keyReleaseEvent (QKeyEvent
*ev
);
83 /**Display the downloaded image. Resize the window to fit the image, If the image is
84 *larger than the screen, make the image as large as possible while preserving the
85 *original aspect ratio
87 void showImage( void );
89 /**Download the image file pointed to by the URL string.
91 void loadImageFromURL( void );
93 /**Save the downloaded image to a local file.
95 void saveFile (KURL
&url
);
97 /**Kill running download jobs, if close of window is forced.
110 bool ctrl
, key_s
, key_q
; // the keys
112 KIO::Job
*downloadJob
; // download job of image -> 0 == no job is running
115 /**Make sure download has finished, then make sure file exists, then display the image */
116 void downloadReady (KIO::Job
*);
118 /**Saves. File. To. Disc. */
119 void saveFileToDisc( void );
121 /**Close the window.*/