summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/graphics/opie-eye/gui/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 5e94f93..529bee4 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,58 +1,58 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 * No WArranty... 3 * No WArranty...
4 */ 4 */
5#include "mainwindow.h" 5#include "mainwindow.h"
6 6
7#include "iconview.h" 7#include "iconview.h"
8#include "filesystem.h" 8#include "filesystem.h"
9#include "imageinfoui.h" 9#include "imageinfoui.h"
10#include "imagescrollview.h" 10#include "imageview.h"
11 11
12#include <iface/ifaceinfo.h> 12#include <iface/ifaceinfo.h>
13#include <iface/dirview.h> 13#include <iface/dirview.h>
14 14
15#include <opie2/odebug.h> 15#include <opie2/odebug.h>
16#include <opie2/owidgetstack.h> 16#include <opie2/owidgetstack.h>
17#include <opie2/oapplicationfactory.h> 17#include <opie2/oapplicationfactory.h>
18#include <opie2/otabwidget.h> 18#include <opie2/otabwidget.h>
19#include <opie2/okeyconfigwidget.h> 19#include <opie2/okeyconfigwidget.h>
20 20
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/ir.h> 23#include <qpe/ir.h>
24 24
25#include <qtoolbar.h> 25#include <qtoolbar.h>
26#include <qtoolbutton.h> 26#include <qtoolbutton.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qmap.h> 29#include <qmap.h>
30#include <qtimer.h> 30#include <qtimer.h>
31 31
32 32
33 33
34 34
35OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) 35OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
36 36
37PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 37PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
38 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) 38 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
39{ 39{
40 setCaption( QObject::tr("Opie Eye Caramba" ) ); 40 setCaption( QObject::tr("Opie Eye Caramba" ) );
41 m_cfg = new Opie::Core::OConfig("phunkview"); 41 m_cfg = new Opie::Core::OConfig("phunkview");
42 m_cfg->setGroup("Zecke_view" ); 42 m_cfg->setGroup("Zecke_view" );
43// qDebug( "Process-wide OApplication object @ %0x", oApp ); 43// qDebug( "Process-wide OApplication object @ %0x", oApp );
44 /* 44 /*
45 * Initialize ToolBar and IconView 45 * Initialize ToolBar and IconView
46 * And Connect Them 46 * And Connect Them
47 */ 47 */
48 QToolBar *bar = new QToolBar( this ); 48 QToolBar *bar = new QToolBar( this );
49 bar->setHorizontalStretchable( true ); 49 bar->setHorizontalStretchable( true );
50 setToolBarsMovable( false ); 50 setToolBarsMovable( false );
51 51
52 m_stack = new Opie::Ui::OWidgetStack( this ); 52 m_stack = new Opie::Ui::OWidgetStack( this );
53 setCentralWidget( m_stack ); 53 setCentralWidget( m_stack );
54 54
55 m_view = new PIconView( m_stack, m_cfg ); 55 m_view = new PIconView( m_stack, m_cfg );
56 m_stack->addWidget( m_view, IconView ); 56 m_stack->addWidget( m_view, IconView );
57 m_stack->raiseWidget( IconView ); 57 m_stack->raiseWidget( IconView );
58 connect(m_view, SIGNAL(sig_display(const QString&)), 58 connect(m_view, SIGNAL(sig_display(const QString&)),
@@ -117,155 +117,162 @@ void PMainWindow::slotRotateToggled(bool how)
117 if (m_disp) { 117 if (m_disp) {
118 m_disp->setAutoRotate(how); 118 m_disp->setAutoRotate(how);
119 } 119 }
120} 120}
121 121
122void PMainWindow::slotScaleToggled(bool how) 122void PMainWindow::slotScaleToggled(bool how)
123{ 123{
124 autoScale = !how; 124 autoScale = !how;
125 if (m_disp) { 125 if (m_disp) {
126 m_disp->setAutoScale(autoScale); 126 m_disp->setAutoScale(autoScale);
127 } 127 }
128 if (!autoScale && autoRotate) { 128 if (!autoScale && autoRotate) {
129 rotateButton->setOn(false); 129 rotateButton->setOn(false);
130 } 130 }
131 rotateButton->setEnabled(!how); 131 rotateButton->setEnabled(!how);
132} 132}
133 133
134void PMainWindow::slotConfig() { 134void PMainWindow::slotConfig() {
135 /* 135 /*
136 * have a tab with the possible views 136 * have a tab with the possible views
137 * a tab for globals image cache size.. scaled loading 137 * a tab for globals image cache size.. scaled loading
138 * and one tab for the KeyConfigs 138 * and one tab for the KeyConfigs
139 */ 139 */
140 QDialog dlg(this, 0, true); 140 QDialog dlg(this, 0, true);
141 dlg.setCaption( tr("Phunk View - Config" ) ); 141 dlg.setCaption( tr("Phunk View - Config" ) );
142 142
143 QHBoxLayout *lay = new QHBoxLayout(&dlg); 143 QHBoxLayout *lay = new QHBoxLayout(&dlg);
144 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); 144 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
145 lay->addWidget( wid ); 145 lay->addWidget( wid );
146 ViewMap *vM = viewMap(); 146 ViewMap *vM = viewMap();
147 ViewMap::Iterator _it = vM->begin(); 147 ViewMap::Iterator _it = vM->begin();
148 QMap<PDirView*, QWidget*> lst; 148 QMap<PDirView*, QWidget*> lst;
149 149
150 for( ; _it != vM->end(); ++_it ) { 150 for( ; _it != vM->end(); ++_it ) {
151 PDirView *view = (_it.data())(*m_cfg); 151 PDirView *view = (_it.data())(*m_cfg);
152 PInterfaceInfo *inf = view->interfaceInfo(); 152 PInterfaceInfo *inf = view->interfaceInfo();
153 QWidget *_wid = inf->configWidget( *m_cfg ); 153 QWidget *_wid = inf->configWidget( *m_cfg );
154 _wid->reparent(wid, QPoint() ); 154 _wid->reparent(wid, QPoint() );
155 lst.insert( view, _wid ); 155 lst.insert( view, _wid );
156 wid->addTab( _wid, "fileopen", inf->name() ); 156 wid->addTab( _wid, "fileopen", inf->name() );
157 } 157 }
158 158
159/* 159/*
160 * Add the KeyConfigWidget 160 * Add the KeyConfigWidget
161 */ 161 */
162 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); 162 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
163 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); 163 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
164 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); 164 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
165
165 if ( !m_info ) { 166 if ( !m_info ) {
166 initInfo(); 167 initInfo();
167 } 168 }
168 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); 169 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
170
171 if ( !m_disp ) {
172 initDisp();
173 }
174 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
175
169 keyWid->load(); 176 keyWid->load();
170 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); 177 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
171 178
172 179
173 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 180 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
174 181
175/* 182/*
176 * clean up 183 * clean up
177 *apply changes 184 *apply changes
178 */ 185 */
179 186
180 QMap<PDirView*, QWidget*>::Iterator it; 187 QMap<PDirView*, QWidget*>::Iterator it;
181 for ( it = lst.begin(); it != lst.end(); ++it ) { 188 for ( it = lst.begin(); it != lst.end(); ++it ) {
182 if ( act ) 189 if ( act )
183 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); 190 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
184 delete it.key(); 191 delete it.key();
185 } 192 }
186 193
187 194
188 if ( act ) { 195 if ( act ) {
189 m_view->resetView(); 196 m_view->resetView();
190 keyWid->save(); 197 keyWid->save();
191 } 198 }
192} 199}
193 200
194/* 201/*
195 * create a new image info component 202 * create a new image info component
196 * and detach the current one 203 * and detach the current one
197 * we will make the other delete on exit 204 * we will make the other delete on exit
198 */ 205 */
199template<class T> 206template<class T>
200void PMainWindow::initT( const char* name, T** ptr, int id) { 207void PMainWindow::initT( const char* name, T** ptr, int id) {
201 if ( *ptr ) { 208 if ( *ptr ) {
202 (*ptr)->disconnect(this, SLOT(slotReturn())); 209 (*ptr)->disconnect(this, SLOT(slotReturn()));
203 (*ptr)->setDestructiveClose(); 210 (*ptr)->setDestructiveClose();
204 m_stack->removeWidget( *ptr ); 211 m_stack->removeWidget( *ptr );
205 } 212 }
206 *ptr = new T( m_stack, name ); 213 *ptr = new T( m_stack, name );
207 m_stack->addWidget( *ptr, id ); 214 m_stack->addWidget( *ptr, id );
208 215
209 connect(*ptr, SIGNAL(sig_return()), 216 connect(*ptr, SIGNAL(sig_return()),
210 this,SLOT(slotReturn())); 217 this,SLOT(slotReturn()));
211 218
212} 219}
213void PMainWindow::initInfo() { 220void PMainWindow::initInfo() {
214 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 221 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
215 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 222 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
216} 223}
217void PMainWindow::initDisp() { 224void PMainWindow::initDisp() {
218 initT<ImageScrollView>( "Image ScrollView", &m_disp, ImageDisplay ); 225 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
219 if (m_disp) { 226 if (m_disp) {
220 m_disp->setAutoScale(autoScale); 227 m_disp->setAutoScale(autoScale);
221 m_disp->setAutoRotate(autoRotate); 228 m_disp->setAutoRotate(autoRotate);
229 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
222 } 230 }
223
224} 231}
225 232
226/** 233/**
227 * With big Screen the plan could be to 'detach' the image 234 * With big Screen the plan could be to 'detach' the image
228 * window if visible and to create a ne wone 235 * window if visible and to create a ne wone
229 * init* already supports it but I make no use of it for 236 * init* already supports it but I make no use of it for
230 * now. We set filename and raise 237 * now. We set filename and raise
231 * 238 *
232 * ### FIXME and talk to alwin 239 * ### FIXME and talk to alwin
233 */ 240 */
234void PMainWindow::slotShowInfo( const QString& inf ) { 241void PMainWindow::slotShowInfo( const QString& inf ) {
235 if ( !m_info ) { 242 if ( !m_info ) {
236 initInfo(); 243 initInfo();
237 } 244 }
238 m_info->setPath( inf ); 245 m_info->setPath( inf );
239 m_stack->raiseWidget( ImageInfo ); 246 m_stack->raiseWidget( ImageInfo );
240} 247}
241 248
242void PMainWindow::slotDisplay( const QString& inf ) { 249void PMainWindow::slotDisplay( const QString& inf ) {
243 if ( !m_disp ) { 250 if ( !m_disp ) {
244 initDisp(); 251 initDisp();
245 } 252 }
246 m_disp->setImage( inf ); 253 m_disp->setImage( inf );
247 m_stack->raiseWidget( ImageDisplay ); 254 m_stack->raiseWidget( ImageDisplay );
248} 255}
249 256
250void PMainWindow::slotReturn() { 257void PMainWindow::slotReturn() {
251 raiseIconView(); 258 raiseIconView();
252} 259}
253 260
254 261
255void PMainWindow::closeEvent( QCloseEvent* ev ) { 262void PMainWindow::closeEvent( QCloseEvent* ev ) {
256 /* 263 /*
257 * return from view 264 * return from view
258 * or properly quit 265 * or properly quit
259 */ 266 */
260 if ( m_stack->visibleWidget() == m_info || 267 if ( m_stack->visibleWidget() == m_info ||
261 m_stack->visibleWidget() == m_disp ) { 268 m_stack->visibleWidget() == m_disp ) {
262 raiseIconView(); 269 raiseIconView();
263 ev->ignore(); 270 ev->ignore();
264 return; 271 return;
265 } 272 }
266 ev->accept(); 273 ev->accept();
267 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 274 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
268} 275}
269 276
270void PMainWindow::raiseIconView() { 277void PMainWindow::raiseIconView() {
271 m_stack->raiseWidget( IconView ); 278 m_stack->raiseWidget( IconView );