summaryrefslogtreecommitdiff
authorzecke <zecke>2005-03-06 14:07:46 (UTC)
committer zecke <zecke>2005-03-06 14:07:46 (UTC)
commita81251b503cba26ad326ac6c68a80a2930bef896 (patch) (unidiff)
tree07b028d708fe8add7b9766213f32d77e48c3f7be
parent125fa91f604cf9b7f3272798e72b6725fca9e23f (diff)
downloadopie-a81251b503cba26ad326ac6c68a80a2930bef896.zip
opie-a81251b503cba26ad326ac6c68a80a2930bef896.tar.gz
opie-a81251b503cba26ad326ac6c68a80a2930bef896.tar.bz2
-NoForce is the default mode of the OWidgetStack. There is no need
to set it here.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index a96bfbd..e532867 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,263 +1,261 @@
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#include "imageview.h" 6#include "imageview.h"
7 7
8#include "iconview.h" 8#include "iconview.h"
9#include "filesystem.h" 9#include "filesystem.h"
10#include "imageinfoui.h" 10#include "imageinfoui.h"
11#include "viewmodebutton.h" 11#include "viewmodebutton.h"
12#include "basesetup.h" 12#include "basesetup.h"
13 13
14#include <iface/ifaceinfo.h> 14#include <iface/ifaceinfo.h>
15#include <iface/dirview.h> 15#include <iface/dirview.h>
16 16
17#include <opie2/odebug.h> 17#include <opie2/odebug.h>
18#include <opie2/owidgetstack.h> 18#include <opie2/owidgetstack.h>
19#include <opie2/oapplicationfactory.h> 19#include <opie2/oapplicationfactory.h>
20#include <opie2/otabwidget.h> 20#include <opie2/otabwidget.h>
21#include <opie2/okeyconfigwidget.h> 21#include <opie2/okeyconfigwidget.h>
22 22
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpe/ir.h> 25#include <qpe/ir.h>
26#include <qpe/storage.h> 26#include <qpe/storage.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28 28
29#include <qtoolbar.h> 29#include <qtoolbar.h>
30#include <qtoolbutton.h> 30#include <qtoolbutton.h>
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qmap.h> 33#include <qmap.h>
34#include <qtimer.h> 34#include <qtimer.h>
35#include <qframe.h> 35#include <qframe.h>
36#include <qmenubar.h> 36#include <qmenubar.h>
37#include <qaction.h> 37#include <qaction.h>
38 38
39//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) 39//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
40OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) 40OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>)
41 41
42PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 42PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
43 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) 43 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
44{ 44{
45 setCaption( QObject::tr("Opie Eye" ) ); 45 setCaption( QObject::tr("Opie Eye" ) );
46 m_cfg = new Opie::Core::OConfig("opie-eye"); 46 m_cfg = new Opie::Core::OConfig("opie-eye");
47 m_cfg->setGroup("main" ); 47 m_cfg->setGroup("main" );
48 readConfig(); 48 readConfig();
49 m_setDocCalled = false; 49 m_setDocCalled = false;
50 m_polishDone = false; 50 m_polishDone = false;
51 m_SmallWindow = QApplication::desktop()->size().width()<330; 51 m_SmallWindow = QApplication::desktop()->size().width()<330;
52 52
53 m_storage = new StorageInfo(); 53 m_storage = new StorageInfo();
54 connect(m_storage, SIGNAL(disksChanged() ), 54 connect(m_storage, SIGNAL(disksChanged() ),
55 this, SLOT( dirChanged() ) ); 55 this, SLOT( dirChanged() ) );
56 56
57 m_stack = new Opie::Ui::OWidgetStack( this ); 57 m_stack = new Opie::Ui::OWidgetStack( this );
58 setCentralWidget( m_stack ); 58 setCentralWidget( m_stack );
59 59
60 m_view = new PIconView( m_stack, m_cfg ); 60 m_view = new PIconView( m_stack, m_cfg );
61 m_stack->addWidget( m_view, IconView ); 61 m_stack->addWidget( m_view, IconView );
62 m_stack->raiseWidget( IconView ); 62 m_stack->raiseWidget( IconView );
63 63
64 connect(m_view, SIGNAL(sig_display(const QString&)), 64 connect(m_view, SIGNAL(sig_display(const QString&)),
65 this, SLOT(slotDisplay(const QString&))); 65 this, SLOT(slotDisplay(const QString&)));
66 connect(m_view, SIGNAL(sig_showInfo(const QString&)), 66 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
67 this, SLOT(slotShowInfo(const QString&)) ); 67 this, SLOT(slotShowInfo(const QString&)) );
68 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); 68 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int)));
69 69
70 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
71
72 listviewMenu = 0; 70 listviewMenu = 0;
73 /* setup menu and toolbar */ 71 /* setup menu and toolbar */
74 setupActions(); 72 setupActions();
75 setupToolbar(); 73 setupToolbar();
76 setupMenu(); 74 setupMenu();
77 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); 75 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true));
78 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); 76 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn());
79 if (m_aForceSmall) { 77 if (m_aForceSmall) {
80 m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true)); 78 m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true));
81 } 79 }
82 odebug << "mainwindow constructor done" << oendl; 80 odebug << "mainwindow constructor done" << oendl;
83} 81}
84 82
85PMainWindow::~PMainWindow() { 83PMainWindow::~PMainWindow() {
86} 84}
87 85
88void PMainWindow::slotToggleZoomer() 86void PMainWindow::slotToggleZoomer()
89{ 87{
90 m_aZoomer->setOn(!m_aZoomer->isOn()); 88 m_aZoomer->setOn(!m_aZoomer->isOn());
91} 89}
92 90
93void PMainWindow::slotZoomerToggled(bool how) 91void PMainWindow::slotZoomerToggled(bool how)
94{ 92{
95 if (m_disp) { 93 if (m_disp) {
96 m_disp->setShowZoomer(how); 94 m_disp->setShowZoomer(how);
97 } 95 }
98 if (autoSave) { 96 if (autoSave) {
99 m_cfg->writeEntry("zoomeron",how); 97 m_cfg->writeEntry("zoomeron",how);
100 } 98 }
101} 99}
102 100
103void PMainWindow::slotToggleAutorotate() 101void PMainWindow::slotToggleAutorotate()
104{ 102{
105 if (!m_aAutoRotate->isEnabled()) return; 103 if (!m_aAutoRotate->isEnabled()) return;
106 m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); 104 m_aAutoRotate->setOn(!m_aAutoRotate->isOn());
107} 105}
108 106
109void PMainWindow::slotToggleAutoscale() 107void PMainWindow::slotToggleAutoscale()
110{ 108{
111 m_aUnscaled->setOn(!m_aUnscaled->isOn()); 109 m_aUnscaled->setOn(!m_aUnscaled->isOn());
112} 110}
113 111
114void PMainWindow::slotRotateToggled(bool how) 112void PMainWindow::slotRotateToggled(bool how)
115{ 113{
116 if (autoSave) { 114 if (autoSave) {
117 m_cfg->writeEntry("autorotate",how); 115 m_cfg->writeEntry("autorotate",how);
118 } 116 }
119 if (m_disp) { 117 if (m_disp) {
120 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how); 118 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how);
121 } 119 }
122} 120}
123 121
124void PMainWindow::slotScaleToggled(bool how) 122void PMainWindow::slotScaleToggled(bool how)
125{ 123{
126 if (autoSave) { 124 if (autoSave) {
127 m_cfg->writeEntry("unscaled",how); 125 m_cfg->writeEntry("unscaled",how);
128 } 126 }
129 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl; 127 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl;
130 odebug << "How: " << how << oendl; 128 odebug << "How: " << how << oendl;
131 if (how) { 129 if (how) {
132 m_aAutoRotate->setOn(false); 130 m_aAutoRotate->setOn(false);
133 } 131 }
134 if (m_disp) { 132 if (m_disp) {
135 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn()); 133 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn());
136 } 134 }
137 m_aAutoRotate->setEnabled(!how); 135 m_aAutoRotate->setEnabled(!how);
138 odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl; 136 odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl;
139} 137}
140 138
141void PMainWindow::slotConfig() { 139void PMainWindow::slotConfig() {
142 /* 140 /*
143 * have a tab with the possible views 141 * have a tab with the possible views
144 * a tab for globals image cache size.. scaled loading 142 * a tab for globals image cache size.. scaled loading
145 * and one tab for the KeyConfigs 143 * and one tab for the KeyConfigs
146 */ 144 */
147 QDialog dlg(this, 0, true); 145 QDialog dlg(this, 0, true);
148 dlg.setCaption( tr("Opie Eye - Config" ) ); 146 dlg.setCaption( tr("Opie Eye - Config" ) );
149 147
150 QHBoxLayout *lay = new QHBoxLayout(&dlg); 148 QHBoxLayout *lay = new QHBoxLayout(&dlg);
151 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); 149 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
152 lay->addWidget( wid ); 150 lay->addWidget( wid );
153 151
154 BaseSetup*bSetup = new BaseSetup(m_cfg,wid); 152 BaseSetup*bSetup = new BaseSetup(m_cfg,wid);
155 wid->addTab(bSetup,"SettingsIcon","Basics setup"); 153 wid->addTab(bSetup,"SettingsIcon","Basics setup");
156 154
157 ViewMap *vM = viewMap(); 155 ViewMap *vM = viewMap();
158 ViewMap::Iterator _it = vM->begin(); 156 ViewMap::Iterator _it = vM->begin();
159 QMap<PDirView*, QWidget*> lst; 157 QMap<PDirView*, QWidget*> lst;
160 158
161 for( ; _it != vM->end(); ++_it ) { 159 for( ; _it != vM->end(); ++_it ) {
162 PDirView *view = (_it.data())(*m_cfg); 160 PDirView *view = (_it.data())(*m_cfg);
163 PInterfaceInfo *inf = view->interfaceInfo(); 161 PInterfaceInfo *inf = view->interfaceInfo();
164 QWidget *_wid = inf->configWidget( *m_cfg ); 162 QWidget *_wid = inf->configWidget( *m_cfg );
165 if (!_wid) continue; 163 if (!_wid) continue;
166 _wid->reparent(wid, QPoint() ); 164 _wid->reparent(wid, QPoint() );
167 lst.insert( view, _wid ); 165 lst.insert( view, _wid );
168 wid->addTab( _wid, "fileopen", inf->name() ); 166 wid->addTab( _wid, "fileopen", inf->name() );
169 } 167 }
170 168
171/* 169/*
172 * Add the KeyConfigWidget 170 * Add the KeyConfigWidget
173 */ 171 */
174 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); 172 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
175 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); 173 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
176 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); 174 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
177 QWidget*w = m_stack->visibleWidget(); 175 QWidget*w = m_stack->visibleWidget();
178 176
179 bool reminfo = false; 177 bool reminfo = false;
180 if ( !m_info ) { 178 if ( !m_info ) {
181 reminfo = true; 179 reminfo = true;
182 initInfo(); 180 initInfo();
183 m_info->hide(); 181 m_info->hide();
184 } 182 }
185 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); 183 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
186 184
187 bool remdisp = false; 185 bool remdisp = false;
188 if ( !m_disp ) { 186 if ( !m_disp ) {
189 remdisp = true; 187 remdisp = true;
190 initDisp(); 188 initDisp();
191 m_disp->hide(); 189 m_disp->hide();
192 } 190 }
193 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); 191 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
194 192
195 keyWid->load(); 193 keyWid->load();
196 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); 194 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
197 wid->setCurrentTab(0); 195 wid->setCurrentTab(0);
198 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 196 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
199 197
200/* 198/*
201 * clean up 199 * clean up
202 *apply changes 200 *apply changes
203 */ 201 */
204 202
205 QMap<PDirView*, QWidget*>::Iterator it; 203 QMap<PDirView*, QWidget*>::Iterator it;
206 for ( it = lst.begin(); it != lst.end(); ++it ) { 204 for ( it = lst.begin(); it != lst.end(); ++it ) {
207 if ( act ) 205 if ( act )
208 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); 206 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
209 delete it.key(); 207 delete it.key();
210 } 208 }
211 209
212 210
213 if ( act ) { 211 if ( act ) {
214 keyWid->save(); 212 keyWid->save();
215 m_disp->manager()->save(); 213 m_disp->manager()->save();
216 m_info->manager()->save(); 214 m_info->manager()->save();
217 m_view->manager()->save(); 215 m_view->manager()->save();
218 bSetup->save_values(); 216 bSetup->save_values();
219 m_view->resetView(); 217 m_view->resetView();
220 readConfig(); 218 readConfig();
221 } 219 }
222 delete keyWid; 220 delete keyWid;
223 221
224 m_stack->raiseWidget(w); 222 m_stack->raiseWidget(w);
225 if (remdisp) { 223 if (remdisp) {
226 m_disp->hide(); 224 m_disp->hide();
227 } 225 }
228 if (reminfo) { 226 if (reminfo) {
229 m_info->hide(); 227 m_info->hide();
230 } 228 }
231} 229}
232 230
233/* 231/*
234 * create a new image info component 232 * create a new image info component
235 * and detach the current one 233 * and detach the current one
236 * we will make the other delete on exit 234 * we will make the other delete on exit
237 */ 235 */
238template<class T> 236template<class T>
239void PMainWindow::initT( const char* name, T** ptr, int id) { 237void PMainWindow::initT( const char* name, T** ptr, int id) {
240 if ( *ptr ) { 238 if ( *ptr ) {
241 (*ptr)->disconnect(this, SLOT(slotReturn())); 239 (*ptr)->disconnect(this, SLOT(slotReturn()));
242 (*ptr)->setDestructiveClose(); 240 (*ptr)->setDestructiveClose();
243 m_stack->removeWidget( *ptr ); 241 m_stack->removeWidget( *ptr );
244 } 242 }
245 *ptr = new T(m_cfg, m_stack, name ); 243 *ptr = new T(m_cfg, m_stack, name );
246 m_stack->addWidget( *ptr, id ); 244 m_stack->addWidget( *ptr, id );
247 245
248 connect(*ptr, SIGNAL(sig_return()), 246 connect(*ptr, SIGNAL(sig_return()),
249 this,SLOT(slotReturn())); 247 this,SLOT(slotReturn()));
250 248
251} 249}
252 250
253void PMainWindow::initInfo() { 251void PMainWindow::initInfo() {
254 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 252 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
255 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 253 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
256} 254}
257 255
258void PMainWindow::initDisp() { 256void PMainWindow::initDisp() {
259 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); 257 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
260 if (m_disp) { 258 if (m_disp) {
261// if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 259// if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
262 //m_disp->setMinimumSize(QApplication::desktop()->size()/2); 260 //m_disp->setMinimumSize(QApplication::desktop()->size()/2);
263// } 261// }