-rw-r--r-- | noncore/multimedia/showimg/showimg.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp index 7c43e11..24218e6 100644 --- a/noncore/multimedia/showimg/showimg.cpp +++ b/noncore/multimedia/showimg/showimg.cpp | |||
@@ -40,194 +40,194 @@ | |||
40 | #include <qkeycode.h> | 40 | #include <qkeycode.h> |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #include <qclipboard.h> | 42 | #include <qclipboard.h> |
43 | #include <qtimer.h> | 43 | #include <qtimer.h> |
44 | 44 | ||
45 | 45 | ||
46 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) | 46 | ImagePane::ImagePane( QWidget *parent ) : QWidget( parent ) |
47 | { | 47 | { |
48 | vb = new QVBoxLayout( this ); | 48 | vb = new QVBoxLayout( this ); |
49 | 49 | ||
50 | image = new ImageWidget( this ); | 50 | image = new ImageWidget( this ); |
51 | connect(image, SIGNAL( clicked() ), this, SLOT( imageClicked() )); | 51 | connect(image, SIGNAL( clicked() ), this, SLOT( imageClicked() )); |
52 | 52 | ||
53 | vb->addWidget( image ); | 53 | vb->addWidget( image ); |
54 | 54 | ||
55 | status = new QLabel( this ); | 55 | status = new QLabel( this ); |
56 | status->setFixedHeight( fontMetrics().height() + 4 ); | 56 | status->setFixedHeight( fontMetrics().height() + 4 ); |
57 | vb->addWidget( status ); | 57 | vb->addWidget( status ); |
58 | } | 58 | } |
59 | 59 | ||
60 | void ImagePane::setPixmap( const QPixmap &pm ) | 60 | void ImagePane::setPixmap( const QPixmap &pm ) |
61 | { | 61 | { |
62 | image->setPixmap( pm ); | 62 | image->setPixmap( pm ); |
63 | image->repaint( false ); | 63 | image->repaint( false ); |
64 | } | 64 | } |
65 | 65 | ||
66 | void ImagePane::imageClicked() | 66 | void ImagePane::imageClicked() |
67 | { | 67 | { |
68 | emit clicked(); | 68 | emit clicked(); |
69 | } | 69 | } |
70 | 70 | ||
71 | void ImagePane::showStatus() | 71 | void ImagePane::showStatus() |
72 | { | 72 | { |
73 | delete vb; | 73 | delete vb; |
74 | vb = new QVBoxLayout( this ); | 74 | vb = new QVBoxLayout( this ); |
75 | vb->addWidget( image ); | 75 | vb->addWidget( image ); |
76 | status->show(); | 76 | status->show(); |
77 | vb->addWidget( status ); | 77 | vb->addWidget( status ); |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | void ImagePane::hideStatus() | 81 | void ImagePane::hideStatus() |
82 | { | 82 | { |
83 | delete vb; | 83 | delete vb; |
84 | vb = new QVBoxLayout( this ); | 84 | vb = new QVBoxLayout( this ); |
85 | vb->addWidget( image ); | 85 | vb->addWidget( image ); |
86 | status->hide(); | 86 | status->hide(); |
87 | } | 87 | } |
88 | 88 | ||
89 | //=========================================================================== | 89 | //=========================================================================== |
90 | /* | 90 | /* |
91 | Draws the portion of the scaled pixmap that needs to be updated | 91 | Draws the portion of the scaled pixmap that needs to be updated |
92 | */ | 92 | */ |
93 | 93 | ||
94 | void ImageWidget::paintEvent( QPaintEvent *e ) | 94 | void ImageWidget::paintEvent( QPaintEvent *e ) |
95 | { | 95 | { |
96 | QPainter painter(this); | 96 | QPainter painter(this); |
97 | 97 | ||
98 | painter.setClipRect(e->rect()); | 98 | painter.setClipRect(e->rect()); |
99 | painter.setBrush( black ); | 99 | painter.setBrush( black ); |
100 | painter.drawRect( 0, 0, width(), height() ); | 100 | painter.drawRect( 0, 0, width(), height() ); |
101 | 101 | ||
102 | if ( pixmap.size() != QSize( 0, 0 ) ) { // is an image loaded? | 102 | if ( pixmap.size() != QSize( 0, 0 ) ) { // is an image loaded? |
103 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); | 103 | painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap); |
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) | 107 | void ImageWidget::mouseReleaseEvent(QMouseEvent *) |
108 | { | 108 | { |
109 | emit clicked(); | 109 | emit clicked(); |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | //=========================================================================== | 113 | //=========================================================================== |
114 | 114 | ||
115 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) | 115 | ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags ) |
116 | : QMainWindow( parent, name, wFlags ), filename( 0 ), | 116 | : QMainWindow( parent, name, wFlags ), filename( 0 ), |
117 | pickx( -1 ), picky( -1 ), clickx( -1 ), clicky( -1 ), bFromDocView( FALSE ) | 117 | pickx( -1 ), picky( -1 ), clickx( -1 ), clicky( -1 ), bFromDocView( FALSE ) |
118 | { | 118 | { |
119 | setCaption( tr("Image Viewer") ); | 119 | setCaption( tr("Image Viewer") ); |
120 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); | 120 | setIcon( Resource::loadPixmap( "ImageViewer" ) ); |
121 | 121 | ||
122 | isFullScreen = FALSE; | 122 | isFullScreen = FALSE; |
123 | 123 | ||
124 | setToolBarsMovable( FALSE ); | 124 | setToolBarsMovable( FALSE ); |
125 | 125 | ||
126 | toolBar = new QPEToolBar( this ); | 126 | toolBar = new QPEToolBar( this ); |
127 | toolBar->setHorizontalStretchable( TRUE ); | 127 | toolBar->setHorizontalStretchable( TRUE ); |
128 | 128 | ||
129 | menubar = new QPEMenuBar( toolBar ); | 129 | menubar = new QPEMenuBar( toolBar ); |
130 | 130 | ||
131 | QStrList fmt = QImage::outputFormats(); | 131 | QStrList fmt = QImage::outputFormats(); |
132 | 132 | ||
133 | QPopupMenu *edit = new QPopupMenu( menubar ); | 133 | QPopupMenu *edit = new QPopupMenu( menubar ); |
134 | QPopupMenu *view = new QPopupMenu( menubar ); | 134 | QPopupMenu *view = new QPopupMenu( menubar ); |
135 | 135 | ||
136 | menubar->insertItem( "Edit", edit ); | 136 | menubar->insertItem(tr("Edit"), edit ); |
137 | menubar->insertItem( "View", view ); | 137 | menubar->insertItem(tr("View"), view ); |
138 | 138 | ||
139 | edit->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); | 139 | edit->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0); |
140 | edit->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); | 140 | edit->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0); |
141 | 141 | ||
142 | stack = new QWidgetStack( this ); | 142 | stack = new QWidgetStack( this ); |
143 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | 143 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); |
144 | setCentralWidget( stack ); | 144 | setCentralWidget( stack ); |
145 | 145 | ||
146 | imagePanel = new ImagePane( stack ); | 146 | imagePanel = new ImagePane( stack ); |
147 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); | 147 | connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView())); |
148 | 148 | ||
149 | fileSelector = new FileSelector("image/*", stack, "fs"); | 149 | fileSelector = new FileSelector("image/*", stack, "fs"); |
150 | fileSelector->setNewVisible(FALSE); | 150 | fileSelector->setNewVisible(FALSE); |
151 | fileSelector->setCloseVisible(FALSE); | 151 | fileSelector->setCloseVisible(FALSE); |
152 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); | 152 | connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) ); |
153 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); | 153 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) ); |
154 | 154 | ||
155 | toolBar = new QPEToolBar( this ); | 155 | toolBar = new QPEToolBar( this ); |
156 | 156 | ||
157 | QAction *a; | 157 | QAction *a; |
158 | 158 | ||
159 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 159 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
160 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); | 160 | connect( a, SIGNAL( activated() ), this, SLOT( open() ) ); |
161 | a->addTo( toolBar ); | 161 | a->addTo( toolBar ); |
162 | 162 | ||
163 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); | 163 | a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 ); |
164 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); | 164 | connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) ); |
165 | a->addTo( toolBar ); | 165 | a->addTo( toolBar ); |
166 | a->addTo( edit ); | 166 | a->addTo( edit ); |
167 | 167 | ||
168 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); | 168 | a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0); |
169 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); | 169 | connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) ); |
170 | a->addTo( toolBar ); | 170 | a->addTo( toolBar ); |
171 | a->addTo( edit ); | 171 | a->addTo( edit ); |
172 | 172 | ||
173 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); | 173 | a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
174 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); | 174 | connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) ); |
175 | a->addTo( toolBar ); | 175 | a->addTo( toolBar ); |
176 | a->addTo( view); | 176 | a->addTo( view); |
177 | 177 | ||
178 | stack->raiseWidget( fileSelector ); | 178 | stack->raiseWidget( fileSelector ); |
179 | 179 | ||
180 | setMouseTracking( TRUE ); | 180 | setMouseTracking( TRUE ); |
181 | } | 181 | } |
182 | 182 | ||
183 | ImageViewer::~ImageViewer() | 183 | ImageViewer::~ImageViewer() |
184 | { | 184 | { |
185 | delete imagePanel; // in case it is fullscreen | 185 | delete imagePanel; // in case it is fullscreen |
186 | } | 186 | } |
187 | 187 | ||
188 | void ImageViewer::setDocument(const QString& fileref) | 188 | void ImageViewer::setDocument(const QString& fileref) |
189 | { | 189 | { |
190 | delayLoad = fileref; | 190 | delayLoad = fileref; |
191 | stack->raiseWidget(imagePanel); | 191 | stack->raiseWidget(imagePanel); |
192 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); | 192 | QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) ); |
193 | } | 193 | } |
194 | 194 | ||
195 | void ImageViewer::doDelayedLoad() | 195 | void ImageViewer::doDelayedLoad() |
196 | { | 196 | { |
197 | show(delayLoad); | 197 | show(delayLoad); |
198 | } | 198 | } |
199 | 199 | ||
200 | void ImageViewer::show() | 200 | void ImageViewer::show() |
201 | { | 201 | { |
202 | normalView(); | 202 | normalView(); |
203 | QMainWindow::show(); | 203 | QMainWindow::show(); |
204 | } | 204 | } |
205 | 205 | ||
206 | void ImageViewer::show(const QString& fileref) | 206 | void ImageViewer::show(const QString& fileref) |
207 | { | 207 | { |
208 | bFromDocView = TRUE; | 208 | bFromDocView = TRUE; |
209 | closeFileSelector(); | 209 | closeFileSelector(); |
210 | DocLnk link(fileref); | 210 | DocLnk link(fileref); |
211 | if ( link.isValid() ) { | 211 | if ( link.isValid() ) { |
212 | openFile(link); | 212 | openFile(link); |
213 | } else { | 213 | } else { |
214 | filename = fileref; | 214 | filename = fileref; |
215 | updateCaption( fileref ); | 215 | updateCaption( fileref ); |
216 | loadImage( fileref ); | 216 | loadImage( fileref ); |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | void ImageViewer::openFile( const DocLnk &file ) | 220 | void ImageViewer::openFile( const DocLnk &file ) |
221 | { | 221 | { |
222 | closeFileSelector(); | 222 | closeFileSelector(); |
223 | DocLnk link(file); | 223 | DocLnk link(file); |
224 | updateCaption( link.name() ); | 224 | updateCaption( link.name() ); |
225 | loadImage( link.file() ); | 225 | loadImage( link.file() ); |
226 | } | 226 | } |
227 | 227 | ||
228 | void ImageViewer::open() | 228 | void ImageViewer::open() |
229 | { | 229 | { |
230 | stack->raiseWidget(fileSelector); | 230 | stack->raiseWidget(fileSelector); |
231 | } | 231 | } |
232 | 232 | ||
233 | void ImageViewer::closeFileSelector() | 233 | void ImageViewer::closeFileSelector() |