summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-23 18:26:46 (UTC)
committer alwin <alwin>2005-03-23 18:26:46 (UTC)
commit76ea5ee6e306a4ee9fe6831dbe4c13ee53f6cdf5 (patch) (unidiff)
tree8269bc37e5d3addf36194e231e84bce8a9e49e8b
parent73928229c1ed258a78e815d9089667f0d99e72d8 (diff)
downloadopie-76ea5ee6e306a4ee9fe6831dbe4c13ee53f6cdf5.zip
opie-76ea5ee6e306a4ee9fe6831dbe4c13ee53f6cdf5.tar.gz
opie-76ea5ee6e306a4ee9fe6831dbe4c13ee53f6cdf5.tar.bz2
dirty hack let opie-eye crash
fixed display problems the right way now I hope ToDo: fix flicker when switching images in fullscreen mode while window is visible
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp2
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp27
2 files changed, 8 insertions, 21 deletions
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index 03df321..6c3f9cb 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,286 +1,286 @@
1#include "imageview.h" 1#include "imageview.h"
2 2
3#include <opie2/odebug.h> 3#include <opie2/odebug.h>
4#include <opie2/oconfig.h> 4#include <opie2/oconfig.h>
5#include <opie2/okeyconfigwidget.h> 5#include <opie2/okeyconfigwidget.h>
6 6
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/qcopenvelope_qws.h> 9#include <qpe/qcopenvelope_qws.h>
10 10
11#include <qpopupmenu.h> 11#include <qpopupmenu.h>
12#include <qtimer.h> 12#include <qtimer.h>
13#include <qaction.h> 13#include <qaction.h>
14 14
15using namespace Opie::Core; 15using namespace Opie::Core;
16 16
17ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) 17ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl )
18 : Opie::MM::OImageScrollView(parent,name,fl) 18 : Opie::MM::OImageScrollView(parent,name,fl)
19{ 19{
20 m_viewManager = 0; 20 m_viewManager = 0;
21 focus_in_count = 0; 21 focus_in_count = 0;
22 m_cfg = cfg; 22 m_cfg = cfg;
23 m_isFullScreen = false; 23 m_isFullScreen = false;
24 m_ignore_next_in = false; 24 m_ignore_next_in = false;
25 m_slideTimer = 0; 25 m_slideTimer = 0;
26 QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold); 26 QPEApplication::setStylusOperation(viewport(),QPEApplication::RightOnHold);
27 initKeys(); 27 initKeys();
28 m_slideValue = 5; 28 m_slideValue = 5;
29 m_gDisplayType = 0; 29 m_gDisplayType = 0;
30 m_gPrevNext = 0; 30 m_gPrevNext = 0;
31 m_hGroup = 0; 31 m_hGroup = 0;
32 m_Rotated = false; 32 m_Rotated = false;
33 closeIfHide = false; 33 closeIfHide = false;
34 int min = QApplication::desktop()->size().width()>QApplication::desktop()->size().height()? 34 int min = QApplication::desktop()->size().width()>QApplication::desktop()->size().height()?
35 QApplication::desktop()->size().height():QApplication::desktop()->size().width(); 35 QApplication::desktop()->size().height():QApplication::desktop()->size().width();
36 if (min>320) { 36 if (min>320) {
37 // bigscreen 37 // bigscreen
38 setMinimumSize(min/3,min/3); 38 setMinimumSize(min/3,min/3);
39 } else { 39 } else {
40 setMinimumSize(10,10); 40 setMinimumSize(10,10);
41 } 41 }
42 m_sysChannel = new QCopChannel( "QPE/System", this ); 42 m_sysChannel = new QCopChannel( "QPE/System", this );
43 connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 43 connect( m_sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
44 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 44 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
45} 45}
46 46
47void ImageView::systemMessage( const QCString& msg, const QByteArray& data ) 47void ImageView::systemMessage( const QCString& msg, const QByteArray& data )
48{ 48{
49 int _newrotation; 49 int _newrotation;
50 QDataStream stream( data, IO_ReadOnly ); 50 QDataStream stream( data, IO_ReadOnly );
51 odebug << "received system message: " << msg << oendl; 51 odebug << "received system message: " << msg << oendl;
52 if ( msg == "setCurrentRotation(int)" ) 52 if ( msg == "setCurrentRotation(int)" )
53 { 53 {
54 stream >> _newrotation; 54 stream >> _newrotation;
55 odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl; 55 odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl;
56 if (!fullScreen()) { 56 if (!fullScreen()) {
57 m_rotation = _newrotation; 57 m_rotation = _newrotation;
58 return; 58 return;
59 } 59 }
60 } 60 }
61} 61}
62 62
63void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup) 63void ImageView::setMenuActions(QActionGroup*hGroup,QActionGroup*nextprevGroup, QActionGroup*disptypeGroup)
64{ 64{
65 m_gDisplayType = disptypeGroup; 65 m_gDisplayType = disptypeGroup;
66 m_gPrevNext = nextprevGroup; 66 m_gPrevNext = nextprevGroup;
67 m_hGroup = hGroup; 67 m_hGroup = hGroup;
68} 68}
69 69
70ImageView::~ImageView() 70ImageView::~ImageView()
71{ 71{
72 odebug << "Destructor imageview" << oendl; 72 odebug << "Destructor imageview" << oendl;
73 delete m_viewManager; 73 delete m_viewManager;
74} 74}
75 75
76Opie::Core::OKeyConfigManager* ImageView::manager() 76Opie::Core::OKeyConfigManager* ImageView::manager()
77{ 77{
78 if (!m_viewManager) { 78 if (!m_viewManager) {
79 initKeys(); 79 initKeys();
80 } 80 }
81 return m_viewManager; 81 return m_viewManager;
82} 82}
83 83
84void ImageView::startSlide(int value) 84void ImageView::startSlide(int value)
85{ 85{
86 if (!m_slideTimer) { 86 if (!m_slideTimer) {
87 m_slideTimer = new QTimer(this); 87 m_slideTimer = new QTimer(this);
88 } 88 }
89 m_slideValue=value; 89 m_slideValue=value;
90 connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide())); 90 connect(m_slideTimer,SIGNAL(timeout()),SLOT(nextSlide()));
91 /* this "+1" is one millisecond. with that we can setup a slideshowvalue 91 /* this "+1" is one millisecond. with that we can setup a slideshowvalue
92 of 0. eg "as fast as possible". 92 of 0. eg "as fast as possible".
93 */ 93 */
94 m_slideTimer->start(m_slideValue*1000+1,true); 94 m_slideTimer->start(m_slideValue*1000+1,true);
95} 95}
96 96
97void ImageView::stopSlide() 97void ImageView::stopSlide()
98{ 98{
99 if (!m_slideTimer) { 99 if (!m_slideTimer) {
100 return; 100 return;
101 } 101 }
102 m_slideTimer->stop(); 102 m_slideTimer->stop();
103 delete m_slideTimer; 103 delete m_slideTimer;
104 m_slideTimer = 0; 104 m_slideTimer = 0;
105} 105}
106 106
107void ImageView::nextSlide() 107void ImageView::nextSlide()
108{ 108{
109 if (!m_slideTimer) { 109 if (!m_slideTimer) {
110 return; 110 return;
111 } 111 }
112#if 0 112#if 0
113 if (isHidden()) { 113 if (isHidden()) {
114 delete m_slideTimer; 114 delete m_slideTimer;
115 m_slideTimer = 0; 115 m_slideTimer = 0;
116 return; 116 return;
117 } 117 }
118#endif 118#endif
119 emit dispNext(); 119 emit dispNext();
120 m_slideTimer->start(m_slideValue*1000,true); 120 m_slideTimer->start(m_slideValue*1000,true);
121} 121}
122void ImageView::initKeys() 122void ImageView::initKeys()
123{ 123{
124 odebug << "init imageview keys" << oendl; 124 odebug << "init imageview keys" << oendl;
125 if (!m_cfg) { 125 if (!m_cfg) {
126 m_cfg = new Opie::Core::OConfig("opie-eye"); 126 m_cfg = new Opie::Core::OConfig("opie-eye");
127 m_cfg->setGroup("image_view_keys" ); 127 m_cfg->setGroup("image_view_keys" );
128 } 128 }
129 Opie::Core::OKeyPair::List lst; 129 Opie::Core::OKeyPair::List lst;
130 lst.append( Opie::Core::OKeyPair::upArrowKey() ); 130 lst.append( Opie::Core::OKeyPair::upArrowKey() );
131 lst.append( Opie::Core::OKeyPair::downArrowKey() ); 131 lst.append( Opie::Core::OKeyPair::downArrowKey() );
132 lst.append( Opie::Core::OKeyPair::leftArrowKey() ); 132 lst.append( Opie::Core::OKeyPair::leftArrowKey() );
133 lst.append( Opie::Core::OKeyPair::rightArrowKey() ); 133 lst.append( Opie::Core::OKeyPair::rightArrowKey() );
134 lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0)); 134 lst.append( Opie::Core::OKeyPair(Qt::Key_Escape,0));
135 135
136 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", 136 m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys",
137 lst, false,this, "image_view_keys" ); 137 lst, false,this, "image_view_keys" );
138 138
139 /** 139 /**
140 * Handle KeyEvents when they're pressed. This avoids problems 140 * Handle KeyEvents when they're pressed. This avoids problems
141 * with 'double next' on Return. 141 * with 'double next' on Return.
142 * The Return press would switch to this view and the return 142 * The Return press would switch to this view and the return
143 * release would emit the dispNext Signal. 143 * release would emit the dispNext Signal.
144 */ 144 */
145 m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed ); 145 m_viewManager->setEventMask( Opie::Core::OKeyConfigManager::MaskPressed );
146 146
147 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", 147 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo",
148 Resource::loadPixmap("1to1"), ViewInfo, 148 Resource::loadPixmap("1to1"), ViewInfo,
149 Opie::Core::OKeyPair(Qt::Key_I,0), 149 Opie::Core::OKeyPair(Qt::Key_I,0),
150 this, SLOT(slotShowImageInfo()))); 150 this, SLOT(slotShowImageInfo())));
151 151
152 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate", 152 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autorotate"), "imageautorotate",
153 Resource::loadPixmap("rotate"), Autorotate, 153 Resource::loadPixmap("rotate"), Autorotate,
154 Opie::Core::OKeyPair(Qt::Key_R,0), 154 Opie::Core::OKeyPair(Qt::Key_R,0),
155 this, SIGNAL(toggleAutorotate()))); 155 this, SIGNAL(toggleAutorotate())));
156 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale", 156 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle autoscale"), "imageautoscale",
157 Resource::loadPixmap("1to1"), Autoscale, 157 Resource::loadPixmap("1to1"), Autoscale,
158 Opie::Core::OKeyPair(Qt::Key_S,0), 158 Opie::Core::OKeyPair(Qt::Key_S,0),
159 this, SIGNAL(toggleAutoscale()))); 159 this, SIGNAL(toggleAutoscale())));
160 160
161 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext", 161 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to next image"), "imageshownext",
162 Resource::loadPixmap("forward"), ShowNext, 162 Resource::loadPixmap("forward"), ShowNext,
163 Opie::Core::OKeyPair(Qt::Key_Return,0), 163 Opie::Core::OKeyPair(Qt::Key_Return,0),
164 this, SIGNAL(dispNext()))); 164 this, SIGNAL(dispNext())));
165 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev", 165 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Switch to previous image"), "imageshowprev",
166 Resource::loadPixmap("back"), ShowPrevious, 166 Resource::loadPixmap("back"), ShowPrevious,
167 Opie::Core::OKeyPair(Qt::Key_P,0), 167 Opie::Core::OKeyPair(Qt::Key_P,0),
168 this, SIGNAL(dispPrev()))); 168 this, SIGNAL(dispPrev())));
169 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen", 169 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle fullscreen"), "imagefullscreen",
170 Resource::loadPixmap("fullscreen"), FullScreen, 170 Resource::loadPixmap("fullscreen"), FullScreen,
171 Opie::Core::OKeyPair(Qt::Key_F,0), 171 Opie::Core::OKeyPair(Qt::Key_F,0),
172 this, SIGNAL(toggleFullScreen()))); 172 this, SIGNAL(toggleFullScreen())));
173 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer", 173 m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Toggle thumbnail"), "imagezoomer",
174 Resource::loadPixmap("mag"), Zoomer, 174 Resource::loadPixmap("mag"), Zoomer,
175 Opie::Core::OKeyPair(Qt::Key_T,0), 175 Opie::Core::OKeyPair(Qt::Key_T,0),
176 this, SIGNAL(toggleZoomer()))); 176 this, SIGNAL(toggleZoomer())));
177 m_viewManager->handleWidget( this ); 177 m_viewManager->handleWidget( this );
178 m_viewManager->load(); 178 m_viewManager->load();
179} 179}
180 180
181void ImageView::keyReleaseEvent(QKeyEvent * e) 181void ImageView::keyReleaseEvent(QKeyEvent * e)
182{ 182{
183 if (!e || e->state()!=0) { 183 if (!e || e->state()!=0) {
184 return; 184 return;
185 } 185 }
186 if (e->key()==Qt::Key_Escape) { 186 if (e->key()==Qt::Key_Escape) {
187 if (fullScreen()) { 187 if (fullScreen()) {
188 emit hideMe(); 188 emit hideMe();
189 } 189 }
190 if (closeIfHide) { 190 if (closeIfHide) {
191 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 191 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
192 } 192 }
193 } 193 }
194} 194}
195 195
196void ImageView::setCloseIfHide(bool how) 196void ImageView::setCloseIfHide(bool how)
197{ 197{
198 closeIfHide = how; 198 closeIfHide = how;
199} 199}
200 200
201void ImageView::slotShowImageInfo() 201void ImageView::slotShowImageInfo()
202{ 202{
203 emit dispImageInfo(m_lastName); 203 emit dispImageInfo(m_lastName);
204} 204}
205 205
206void ImageView::contentsMousePressEvent ( QMouseEvent * e) 206void ImageView::contentsMousePressEvent ( QMouseEvent * e)
207{ 207{
208 if (e->button()==1) { 208 if (e->button()==1) {
209 return OImageScrollView::contentsMousePressEvent(e); 209 return OImageScrollView::contentsMousePressEvent(e);
210 } 210 }
211 odebug << "Popup " << oendl; 211 odebug << "Popup " << oendl;
212 QPopupMenu *m = new QPopupMenu(this); 212 QPopupMenu *m = new QPopupMenu(this);
213 if (!m) return; 213 if (!m) return;
214 if (m_hGroup) { 214 if (m_hGroup) {
215 m_hGroup->addTo(m); 215 m_hGroup->addTo(m);
216 } 216 }
217 if (fullScreen()) { 217 if (fullScreen()) {
218 if (m_gPrevNext) { 218 if (m_gPrevNext) {
219 m->insertSeparator(); 219 m->insertSeparator();
220 m_gPrevNext->addTo(m); 220 m_gPrevNext->addTo(m);
221 } 221 }
222 if (m_gDisplayType) { 222 if (m_gDisplayType) {
223 m->insertSeparator(); 223 m->insertSeparator();
224 m_gDisplayType->addTo(m); 224 m_gDisplayType->addTo(m);
225 } 225 }
226 } 226 }
227 m->setFocus(); 227 m->setFocus();
228 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 228 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
229 if (m_hGroup) { 229 if (m_hGroup) {
230 m_hGroup->removeFrom(m); 230 m_hGroup->removeFrom(m);
231 } 231 }
232 if (m_gPrevNext) { 232 if (m_gPrevNext) {
233 m_gPrevNext->removeFrom(m); 233 m_gPrevNext->removeFrom(m);
234 } 234 }
235 if (m_gDisplayType) { 235 if (m_gDisplayType) {
236 m_gDisplayType->removeFrom(m); 236 m_gDisplayType->removeFrom(m);
237 } 237 }
238 delete m; 238 delete m;
239} 239}
240 240
241void ImageView::setFullScreen(bool how,bool force) 241void ImageView::setFullScreen(bool how,bool force)
242{ 242{
243 m_isFullScreen = how; 243 m_isFullScreen = how;
244 if (how) { 244 if (how) {
245 m_ignore_next_in = true; 245 m_ignore_next_in = true;
246// setFixedSize(qApp->desktop()->size()); 246// setFixedSize(qApp->desktop()->size());
247 setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height()); 247 setGeometry(0,0,qApp->desktop()->size().width(),qApp->desktop()->size().height());
248 if (force) showFullScreen(); 248 if (force) showFullScreen();
249 } else { 249 } else {
250// setMinimumSize(10,10); 250// setMinimumSize(10,10);
251 } 251 }
252} 252}
253 253
254void ImageView::focusInEvent(QFocusEvent *) 254void ImageView::focusInEvent(QFocusEvent *)
255{ 255{
256 // Always do it here, no matter the size. 256 // Always do it here, no matter the size.
257 odebug << "Focus in (view)" << oendl; 257 odebug << "Focus in (view)" << oendl;
258 //if (fullScreen()) parentWidget()->showNormal(); 258 //if (fullScreen()) parentWidget()->showNormal();
259 if (m_ignore_next_in){m_ignore_next_in=false;return;} 259 if (m_ignore_next_in){m_ignore_next_in=false;return;}
260 if (fullScreen()) enableFullscreen(); 260 if (fullScreen()) enableFullscreen();
261} 261}
262 262
263void ImageView::hide() 263void ImageView::hide()
264{ 264{
265 if (fullScreen()) { 265 if (fullScreen()) {
266 m_ignore_next_in = true; 266 m_ignore_next_in = true;
267 showNormal(); 267 showNormal();
268 } 268 }
269 QWidget::hide(); 269 QWidget::hide();
270} 270}
271void ImageView::enableFullscreen() 271void ImageView::enableFullscreen()
272{ 272{
273 if (!fullScreen()) return; 273 if (!fullScreen()) return;
274 if (m_ignore_next_in) {m_ignore_next_in = false;return;} 274 if (m_ignore_next_in) {m_ignore_next_in = false;return;}
275 275
276 setUpdatesEnabled(false); 276 setUpdatesEnabled(false);
277 // This is needed because showNormal() forcefully changes the window 277 // This is needed because showNormal() forcefully changes the window
278 // style to WSTyle_TopLevel. 278 // style to WSTyle_TopLevel.
279 reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); 279 reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0));
280 // Enable fullscreen. 280 // Enable fullscreen.
281 /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus 281 /* this is the trick - I don't now why, but after a showFullScreen QTE toggles the focus
282 * so we must block it here! */ 282 * so we must block it here! */
283 m_ignore_next_in = true; 283 m_ignore_next_in = true;
284 showFullScreen(); 284 showFullScreen();
285 setUpdatesEnabled(true); 285 setUpdatesEnabled(true);
286} 286}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 3a89dfd..d11e4e1 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -1,834 +1,821 @@
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#include <opie2/owait.h> 22#include <opie2/owait.h>
23#include <opie2/oapplication.h> 23#include <opie2/oapplication.h>
24 24
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/ir.h> 27#include <qpe/ir.h>
28#include <qpe/storage.h> 28#include <qpe/storage.h>
29#include <qpe/applnk.h> 29#include <qpe/applnk.h>
30 30
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qtoolbutton.h> 32#include <qtoolbutton.h>
33#include <qlayout.h> 33#include <qlayout.h>
34#include <qdialog.h> 34#include <qdialog.h>
35#include <qmap.h> 35#include <qmap.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qframe.h> 37#include <qframe.h>
38#include <qmenubar.h> 38#include <qmenubar.h>
39#include <qaction.h> 39#include <qaction.h>
40#include <qspinbox.h> 40#include <qspinbox.h>
41 41
42//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) 42//OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
43OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>) 43OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow>)
44 44
45PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) 45PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
46 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) 46 : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
47{ 47{
48 setCaption( QObject::tr("Opie Eye" ) ); 48 setCaption( QObject::tr("Opie Eye" ) );
49 m_cfg = new Opie::Core::OConfig("opie-eye"); 49 m_cfg = new Opie::Core::OConfig("opie-eye");
50 m_cfg->setGroup("main" ); 50 m_cfg->setGroup("main" );
51 readConfig(); 51 readConfig();
52 m_setDocCalled = false; 52 m_setDocCalled = false;
53 m_polishDone = false; 53 m_polishDone = false;
54 m_SmallWindow = QApplication::desktop()->size().width()<330; 54 m_SmallWindow = QApplication::desktop()->size().width()<330;
55 55
56 m_storage = new StorageInfo(); 56 m_storage = new StorageInfo();
57 connect(m_storage, SIGNAL(disksChanged() ), 57 connect(m_storage, SIGNAL(disksChanged() ),
58 this, SLOT( dirChanged() ) ); 58 this, SLOT( dirChanged() ) );
59 59
60 m_stack = new Opie::Ui::OWidgetStack( this ); 60 m_stack = new Opie::Ui::OWidgetStack( this );
61 setCentralWidget( m_stack ); 61 setCentralWidget( m_stack );
62 62
63 m_view = new PIconView( m_stack, m_cfg ); 63 m_view = new PIconView( m_stack, m_cfg );
64 m_stack->addWidget( m_view, IconView ); 64 m_stack->addWidget( m_view, IconView );
65 m_stack->raiseWidget( IconView ); 65 m_stack->raiseWidget( IconView );
66 66
67 connect(m_view, SIGNAL(sig_display(const QString&)), 67 connect(m_view, SIGNAL(sig_display(const QString&)),
68 this, SLOT(slotDisplay(const QString&))); 68 this, SLOT(slotDisplay(const QString&)));
69 connect(m_view, SIGNAL(sig_showInfo(const QString&)), 69 connect(m_view, SIGNAL(sig_showInfo(const QString&)),
70 this, SLOT(slotShowInfo(const QString&)) ); 70 this, SLOT(slotShowInfo(const QString&)) );
71 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int))); 71 connect(this,SIGNAL(changeListMode(int)),m_view,SLOT(slotChangeMode(int)));
72 72
73 listviewMenu = 0; 73 listviewMenu = 0;
74 /* setup menu and toolbar */ 74 /* setup menu and toolbar */
75 setupActions(); 75 setupActions();
76 setupToolbar(); 76 setupToolbar();
77 setupMenu(); 77 setupMenu();
78 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true)); 78 m_aHideToolbar->setOn(m_cfg->readBoolEntry("showtoolbar",true));
79 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn()); 79 m_aAutoRotate->setEnabled(!m_aUnscaled->isOn());
80 if (m_aForceSmall) { 80 if (m_aForceSmall) {
81 m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true)); 81 m_aForceSmall->setOn(m_cfg->readBoolEntry("dontshowseperate",true));
82 } 82 }
83 odebug << "mainwindow constructor done" << oendl; 83 odebug << "mainwindow constructor done" << oendl;
84} 84}
85 85
86PMainWindow::~PMainWindow() { 86PMainWindow::~PMainWindow() {
87} 87}
88 88
89void PMainWindow::slotToggleZoomer() 89void PMainWindow::slotToggleZoomer()
90{ 90{
91 m_aZoomer->setOn(!m_aZoomer->isOn()); 91 m_aZoomer->setOn(!m_aZoomer->isOn());
92} 92}
93 93
94void PMainWindow::slotZoomerToggled(bool how) 94void PMainWindow::slotZoomerToggled(bool how)
95{ 95{
96 if (m_disp) { 96 if (m_disp) {
97 m_disp->setShowZoomer(how); 97 m_disp->setShowZoomer(how);
98 } 98 }
99 if (autoSave) { 99 if (autoSave) {
100 m_cfg->writeEntry("zoomeron",how); 100 m_cfg->writeEntry("zoomeron",how);
101 } 101 }
102} 102}
103 103
104void PMainWindow::slotToggleAutorotate() 104void PMainWindow::slotToggleAutorotate()
105{ 105{
106 if (!m_aAutoRotate->isEnabled()) return; 106 if (!m_aAutoRotate->isEnabled()) return;
107 m_aAutoRotate->setOn(!m_aAutoRotate->isOn()); 107 m_aAutoRotate->setOn(!m_aAutoRotate->isOn());
108} 108}
109 109
110void PMainWindow::slotToggleAutoscale() 110void PMainWindow::slotToggleAutoscale()
111{ 111{
112 m_aUnscaled->setOn(!m_aUnscaled->isOn()); 112 m_aUnscaled->setOn(!m_aUnscaled->isOn());
113} 113}
114 114
115void PMainWindow::slotRotateToggled(bool how) 115void PMainWindow::slotRotateToggled(bool how)
116{ 116{
117 if (autoSave) { 117 if (autoSave) {
118 m_cfg->writeEntry("autorotate",how); 118 m_cfg->writeEntry("autorotate",how);
119 } 119 }
120 if (m_disp) { 120 if (m_disp) {
121 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how); 121 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),how);
122 } 122 }
123} 123}
124 124
125void PMainWindow::slotScaleToggled(bool how) 125void PMainWindow::slotScaleToggled(bool how)
126{ 126{
127 if (autoSave) { 127 if (autoSave) {
128 m_cfg->writeEntry("unscaled",how); 128 m_cfg->writeEntry("unscaled",how);
129 } 129 }
130 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl; 130 odebug << "Unscaled: " << m_aUnscaled->isOn() << oendl;
131 odebug << "How: " << how << oendl; 131 odebug << "How: " << how << oendl;
132 if (how) { 132 if (how) {
133 m_aAutoRotate->setOn(false); 133 m_aAutoRotate->setOn(false);
134 } 134 }
135 if (m_disp) { 135 if (m_disp) {
136 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn()); 136 m_disp->setAutoScaleRotate(!m_aUnscaled->isOn(),m_aAutoRotate->isOn());
137 } 137 }
138 m_aAutoRotate->setEnabled(!how); 138 m_aAutoRotate->setEnabled(!how);
139 odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl; 139 odebug << "Autorotate: " << m_aAutoRotate->isOn() << oendl;
140} 140}
141 141
142void PMainWindow::slotConfig() { 142void PMainWindow::slotConfig() {
143 /* 143 /*
144 * have a tab with the possible views 144 * have a tab with the possible views
145 * a tab for globals image cache size.. scaled loading 145 * a tab for globals image cache size.. scaled loading
146 * and one tab for the KeyConfigs 146 * and one tab for the KeyConfigs
147 */ 147 */
148 QDialog dlg(this, 0, true); 148 QDialog dlg(this, 0, true);
149 dlg.setCaption( tr("Opie Eye - Config" ) ); 149 dlg.setCaption( tr("Opie Eye - Config" ) );
150 150
151 QHBoxLayout *lay = new QHBoxLayout(&dlg); 151 QHBoxLayout *lay = new QHBoxLayout(&dlg);
152 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); 152 Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg );
153 lay->addWidget( wid ); 153 lay->addWidget( wid );
154 154
155 BaseSetup*bSetup = new BaseSetup(m_cfg,wid); 155 BaseSetup*bSetup = new BaseSetup(m_cfg,wid);
156 wid->addTab(bSetup,"SettingsIcon","Basics setup"); 156 wid->addTab(bSetup,"SettingsIcon","Basics setup");
157 157
158 ViewMap *vM = viewMap(); 158 ViewMap *vM = viewMap();
159 ViewMap::Iterator _it = vM->begin(); 159 ViewMap::Iterator _it = vM->begin();
160 QMap<PDirView*, QWidget*> lst; 160 QMap<PDirView*, QWidget*> lst;
161 161
162 for( ; _it != vM->end(); ++_it ) { 162 for( ; _it != vM->end(); ++_it ) {
163 PDirView *view = (_it.data())(*m_cfg); 163 PDirView *view = (_it.data())(*m_cfg);
164 PInterfaceInfo *inf = view->interfaceInfo(); 164 PInterfaceInfo *inf = view->interfaceInfo();
165 QWidget *_wid = inf->configWidget( *m_cfg ); 165 QWidget *_wid = inf->configWidget( *m_cfg );
166 if (!_wid) continue; 166 if (!_wid) continue;
167 _wid->reparent(wid, QPoint() ); 167 _wid->reparent(wid, QPoint() );
168 lst.insert( view, _wid ); 168 lst.insert( view, _wid );
169 wid->addTab( _wid, "fileopen", inf->name() ); 169 wid->addTab( _wid, "fileopen", inf->name() );
170 } 170 }
171 171
172/* 172/*
173 * Add the KeyConfigWidget 173 * Add the KeyConfigWidget
174 */ 174 */
175 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); 175 Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" );
176 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); 176 keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue );
177 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); 177 keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() );
178 QWidget*w = m_stack->visibleWidget(); 178 QWidget*w = m_stack->visibleWidget();
179 179
180 bool reminfo = false; 180 bool reminfo = false;
181 if ( !m_info ) { 181 if ( !m_info ) {
182 reminfo = true; 182 reminfo = true;
183 initInfo(); 183 initInfo();
184 m_info->hide(); 184 m_info->hide();
185 } 185 }
186 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); 186 keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() );
187 187
188 bool remdisp = false; 188 bool remdisp = false;
189 if ( !m_disp ) { 189 if ( !m_disp ) {
190 remdisp = true; 190 remdisp = true;
191 initDisp(); 191 initDisp();
192 m_disp->hide(); 192 m_disp->hide();
193 } 193 }
194 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); 194 keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() );
195 195
196 keyWid->load(); 196 keyWid->load();
197 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); 197 wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") );
198 wid->setCurrentTab(0); 198 wid->setCurrentTab(0);
199 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 199 bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
200 200
201/* 201/*
202 * clean up 202 * clean up
203 *apply changes 203 *apply changes
204 */ 204 */
205 205
206 QMap<PDirView*, QWidget*>::Iterator it; 206 QMap<PDirView*, QWidget*>::Iterator it;
207 for ( it = lst.begin(); it != lst.end(); ++it ) { 207 for ( it = lst.begin(); it != lst.end(); ++it ) {
208 if ( act ) 208 if ( act )
209 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); 209 it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg);
210 delete it.key(); 210 delete it.key();
211 } 211 }
212 212
213 213
214 if ( act ) { 214 if ( act ) {
215 keyWid->save(); 215 keyWid->save();
216 m_disp->manager()->save(); 216 m_disp->manager()->save();
217 m_info->manager()->save(); 217 m_info->manager()->save();
218 m_view->manager()->save(); 218 m_view->manager()->save();
219 bSetup->save_values(); 219 bSetup->save_values();
220 m_view->resetView(); 220 m_view->resetView();
221 readConfig(); 221 readConfig();
222 } 222 }
223 delete keyWid; 223 delete keyWid;
224 224
225 m_stack->raiseWidget(w); 225 m_stack->raiseWidget(w);
226 if (remdisp) { 226 if (remdisp) {
227 m_disp->hide(); 227 m_disp->hide();
228 } 228 }
229 if (reminfo) { 229 if (reminfo) {
230 m_info->hide(); 230 m_info->hide();
231 } 231 }
232 if (m_disp) { 232 if (m_disp) {
233 m_disp->setIntensity(m_Intensity,true); 233 m_disp->setIntensity(m_Intensity,true);
234 } 234 }
235} 235}
236 236
237/* 237/*
238 * create a new image info component 238 * create a new image info component
239 * and detach the current one 239 * and detach the current one
240 * we will make the other delete on exit 240 * we will make the other delete on exit
241 */ 241 */
242template<class T> 242template<class T>
243void PMainWindow::initT( const char* name, T** ptr, int id) { 243void PMainWindow::initT( const char* name, T** ptr, int id) {
244 if ( *ptr ) { 244 if ( *ptr ) {
245 (*ptr)->disconnect(this, SLOT(slotReturn())); 245 (*ptr)->disconnect(this, SLOT(slotReturn()));
246 (*ptr)->setDestructiveClose(); 246 (*ptr)->setDestructiveClose();
247 m_stack->removeWidget( *ptr ); 247 m_stack->removeWidget( *ptr );
248 } 248 }
249 *ptr = new T(m_cfg, m_stack, name ); 249 *ptr = new T(m_cfg, m_stack, name );
250 m_stack->addWidget( *ptr, id ); 250 m_stack->addWidget( *ptr, id );
251 251
252 connect(*ptr, SIGNAL(sig_return()), 252 connect(*ptr, SIGNAL(sig_return()),
253 this,SLOT(slotReturn())); 253 this,SLOT(slotReturn()));
254 254
255} 255}
256 256
257void PMainWindow::initInfo() { 257void PMainWindow::initInfo() {
258 initT<imageinfo>( "Image Info", &m_info, ImageInfo ); 258 initT<imageinfo>( "Image Info", &m_info, ImageInfo );
259 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); 259 connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
260} 260}
261 261
262void PMainWindow::initDisp() { 262void PMainWindow::initDisp() {
263 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); 263 initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
264 if (m_disp) { 264 if (m_disp) {
265// if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 265// if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
266 //m_disp->setMinimumSize(QApplication::desktop()->size()/2); 266 //m_disp->setMinimumSize(QApplication::desktop()->size()/2);
267// } 267// }
268 m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType); 268 m_disp->setMenuActions(m_hGroup,m_gPrevNext,m_gDisplayType);
269 m_disp->setAutoScale(!m_aUnscaled->isOn()); 269 m_disp->setAutoScale(!m_aUnscaled->isOn());
270 m_disp->setAutoRotate(m_aAutoRotate->isOn()); 270 m_disp->setAutoRotate(m_aAutoRotate->isOn());
271 m_disp->setShowZoomer(m_aZoomer->isOn()); 271 m_disp->setShowZoomer(m_aZoomer->isOn());
272 m_disp->setBackgroundColor(white); 272 m_disp->setBackgroundColor(white);
273 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); 273 connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
274 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); 274 connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
275 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); 275 connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
276 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen())); 276 connect(m_disp,SIGNAL(toggleFullScreen()),this,SLOT(slotToggleFullScreen()));
277 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView())); 277 connect(m_disp,SIGNAL(hideMe()),this,SLOT(raiseIconView()));
278 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer())); 278 connect(m_disp,SIGNAL(toggleZoomer()),this,SLOT(slotToggleZoomer()));
279 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale())); 279 connect(m_disp,SIGNAL(toggleAutoscale()),this,SLOT(slotToggleAutoscale()));
280 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate())); 280 connect(m_disp,SIGNAL(toggleAutorotate()),this,SLOT(slotToggleAutorotate()));
281 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int))); 281 connect(m_view,SIGNAL(sig_startslide(int)),m_disp,SLOT(startSlide(int)));
282 slotFullScreenToggled(m_aFullScreen->isOn()); 282 slotFullScreenToggled(m_aFullScreen->isOn());
283 } 283 }
284} 284}
285 285
286void PMainWindow::slotToggleFullScreen() 286void PMainWindow::slotToggleFullScreen()
287{ 287{
288 bool current = !m_aFullScreen->isOn(); 288 bool current = !m_aFullScreen->isOn();
289 m_aFullScreen->setOn(current); 289 m_aFullScreen->setOn(current);
290} 290}
291 291
292void PMainWindow::slotFullScreenButton(bool current) 292void PMainWindow::slotFullScreenButton(bool current)
293{ 293{
294 if (autoSave) { 294 if (autoSave) {
295 m_cfg->writeEntry("fullscreen",current); 295 m_cfg->writeEntry("fullscreen",current);
296 } 296 }
297 if (!m_disp) return; 297 if (!m_disp) return;
298 if (m_disp->isVisible()) { 298 if (m_disp->isVisible()) {
299 setupViewWindow(current, true); 299 setupViewWindow(current, true);
300 } 300 }
301} 301}
302 302
303void PMainWindow::setupViewWindow(bool current, bool forceDisplay) 303void PMainWindow::setupViewWindow(bool current, bool forceDisplay)
304{ 304{
305 if (!m_disp) { 305 if (!m_disp) {
306 return; 306 return;
307 } 307 }
308 if (current) { 308 if (current) {
309 m_disp->setBackgroundColor(black); 309 m_disp->setBackgroundColor(black);
310 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorder, QPoint(0,0)); 310 m_disp->reparent(0, WStyle_Customize | WStyle_NoBorderEx, QPoint(0,0));
311 m_disp->setVScrollBarMode(QScrollView::AlwaysOff); 311 m_disp->setVScrollBarMode(QScrollView::AlwaysOff);
312 m_disp->setHScrollBarMode(QScrollView::AlwaysOff); 312 m_disp->setHScrollBarMode(QScrollView::AlwaysOff);
313 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height()); 313 m_disp->resize(qApp->desktop()->width(), qApp->desktop()->height());
314 m_disp->setFullScreen(current,forceDisplay); 314 m_disp->setFullScreen(current,forceDisplay);
315 } else { 315 } else {
316 setUpdatesEnabled(false); 316 setUpdatesEnabled(false);
317#if 0 317#if 0
318 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 318 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
319 319
320 //m_disp->setMinimumSize(QApplication::desktop()->size()/2); 320 //m_disp->setMinimumSize(QApplication::desktop()->size()/2);
321 } else { 321 } else {
322 //m_disp->setMinimumSize(10,10); 322 //m_disp->setMinimumSize(10,10);
323 } 323 }
324#endif 324#endif
325 m_disp->setBackgroundColor(white); 325 m_disp->setBackgroundColor(white);
326 m_stack->addWidget(m_disp,ImageDisplay); 326 m_stack->addWidget(m_disp,ImageDisplay);
327 m_disp->setVScrollBarMode(QScrollView::Auto); 327 m_disp->setVScrollBarMode(QScrollView::Auto);
328 m_disp->setHScrollBarMode(QScrollView::Auto); 328 m_disp->setHScrollBarMode(QScrollView::Auto);
329 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 329 if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
330 m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60); 330 m_disp->setGeometry(30,30,QApplication::desktop()->width()-60,QApplication::desktop()->height()-60);
331 } 331 }
332 if (forceDisplay || m_disp->isVisible()) { 332 if (forceDisplay || m_disp->isVisible()) {
333 m_stack->raiseWidget(m_disp); 333 m_stack->raiseWidget(m_disp);
334 m_disp->setFocus(); 334 m_disp->setFocus();
335 } 335 }
336 setUpdatesEnabled(true); 336 setUpdatesEnabled(true);
337 } 337 }
338 m_disp->setFullScreen(current,forceDisplay); 338 m_disp->setFullScreen(current,forceDisplay);
339} 339}
340 340
341void PMainWindow::slotFullScreenToggled(bool current) 341void PMainWindow::slotFullScreenToggled(bool current)
342{ 342{
343 setupViewWindow(current,true); 343 setupViewWindow(current,true);
344} 344}
345 345
346/** 346/**
347 * With big Screen the plan could be to 'detach' the image 347 * With big Screen the plan could be to 'detach' the image
348 * window if visible and to create a ne wone 348 * window if visible and to create a ne wone
349 * init* already supports it but I make no use of it for 349 * init* already supports it but I make no use of it for
350 * now. We set filename and raise 350 * now. We set filename and raise
351 * 351 *
352 * ### FIXME and talk to alwin 352 * ### FIXME and talk to alwin
353 */ 353 */
354void PMainWindow::slotShowInfo( const QString& inf ) { 354void PMainWindow::slotShowInfo( const QString& inf ) {
355 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 355 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
356 return; 356 return;
357 } 357 }
358 if ( !m_info ) { 358 if ( !m_info ) {
359 initInfo(); 359 initInfo();
360 } 360 }
361 m_info->setPath( inf ); 361 m_info->setPath( inf );
362 if (m_SmallWindow) { 362 if (m_SmallWindow) {
363 m_aNext->removeFrom(toolBar); 363 m_aNext->removeFrom(toolBar);
364 m_aPrevious->removeFrom(toolBar); 364 m_aPrevious->removeFrom(toolBar);
365 fsButton->hide(); 365 fsButton->hide();
366 } 366 }
367 m_aNext->setEnabled(false); 367 m_aNext->setEnabled(false);
368 m_aPrevious->setEnabled(false); 368 m_aPrevious->setEnabled(false);
369 m_aDirUp->setEnabled(false); 369 m_aDirUp->setEnabled(false);
370 m_aShowInfo->setEnabled(false); 370 m_aShowInfo->setEnabled(false);
371 m_aViewfile->setEnabled(true); 371 m_aViewfile->setEnabled(true);
372 m_aStartSlide->setEnabled(false); 372 m_aStartSlide->setEnabled(false);
373 m_stack->raiseWidget( ImageInfo ); 373 m_stack->raiseWidget( ImageInfo );
374} 374}
375 375
376void PMainWindow::slotDisplay( const QString& inf ) { 376void PMainWindow::slotDisplay( const QString& inf ) {
377 bool nwindow = false; 377 bool nwindow = false;
378 bool disp_hack = false;
379 int lb;
380 if (m_disp && m_disp->fullScreen()) {
381 lb = m_disp->Intensity();
382 delete m_disp;
383 m_disp = 0;
384
385 disp_hack = true;
386 }
387 if ( !m_disp ) { 378 if ( !m_disp ) {
388 nwindow = true; 379 nwindow = true;
389 initDisp(); 380 initDisp();
390 m_disp->setIntensity((disp_hack?lb:m_Intensity)); 381 m_disp->setIntensity(m_Intensity);
382 m_setCurrentBrightness->setEnabled(true);
391 } 383 }
392 m_setCurrentBrightness->setEnabled(true);
393
394 Opie::Ui::OWait wdlg;
395 wdlg.setTimerLength(30);
396 wdlg.show();
397 //qApp->processEvents(20);
398 m_disp->setImage( inf ); 384 m_disp->setImage( inf );
399 wdlg.hide();
400 //qApp->processEvents(20);
401 if (m_SmallWindow) { 385 if (m_SmallWindow) {
402 if (m_gPrevNext->isEnabled()==false) { 386 if (m_gPrevNext->isEnabled()==false) {
403 m_gPrevNext->addTo(toolBar); 387 m_gPrevNext->addTo(toolBar);
404 fsButton->hide(); 388 fsButton->hide();
405 } 389 }
406 } 390 }
407 m_gPrevNext->setEnabled(true); 391 m_gPrevNext->setEnabled(true);
408 m_aDirUp->setEnabled(false); 392 m_aDirUp->setEnabled(false);
409 m_aShowInfo->setEnabled(true); 393 m_aShowInfo->setEnabled(true);
410 m_aViewfile->setEnabled(false); 394 m_aViewfile->setEnabled(false);
411 m_aStartSlide->setEnabled(false); 395 m_aStartSlide->setEnabled(false);
412 396
413 if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) { 397 if (!nwindow && m_disp->fullScreen()!=m_aFullScreen->isOn()) {
414 slotFullScreenToggled(m_aFullScreen->isOn()); 398 slotFullScreenToggled(m_aFullScreen->isOn());
415 } 399 }
416 if (m_disp->fullScreen()) { 400 if (m_disp->fullScreen()) {
417 qwsDisplay()->requestFocus( m_disp->winId(), TRUE); 401 if (!m_disp->isVisible()) {
402 m_disp->showFullScreen();
403 qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
404 }
418 } else { 405 } else {
419 m_stack->raiseWidget( ImageDisplay ); 406 m_stack->raiseWidget( ImageDisplay );
420 } 407 }
421} 408}
422 409
423void PMainWindow::raiseIconView() { 410void PMainWindow::raiseIconView() {
424 setUpdatesEnabled(false); 411 setUpdatesEnabled(false);
425 if (m_SmallWindow) { 412 if (m_SmallWindow) {
426 m_gPrevNext->removeFrom(toolBar); 413 m_gPrevNext->removeFrom(toolBar);
427 fsButton->show(); 414 fsButton->show();
428 } 415 }
429 m_gPrevNext->setEnabled(false); 416 m_gPrevNext->setEnabled(false);
430 m_aDirUp->setEnabled(true); 417 m_aDirUp->setEnabled(true);
431 m_aShowInfo->setEnabled(true); 418 m_aShowInfo->setEnabled(true);
432 m_aViewfile->setEnabled(true); 419 m_aViewfile->setEnabled(true);
433 m_aStartSlide->setEnabled(true); 420 m_aStartSlide->setEnabled(true);
434 421
435 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) { 422 if (m_disp && m_disp->fullScreen() && m_disp->isVisible()) {
436 m_disp->stopSlide(); 423 m_disp->stopSlide();
437 m_disp->hide(); 424 m_disp->hide();
438 } 425 }
439 m_stack->raiseWidget( IconView ); 426 m_stack->raiseWidget( IconView );
440 setUpdatesEnabled(true); 427 setUpdatesEnabled(true);
441 repaint(); 428 repaint();
442} 429}
443 430
444void PMainWindow::slotReturn() { 431void PMainWindow::slotReturn() {
445 raiseIconView(); 432 raiseIconView();
446} 433}
447 434
448 435
449void PMainWindow::closeEvent( QCloseEvent* ev ) { 436void PMainWindow::closeEvent( QCloseEvent* ev ) {
450 /* 437 /*
451 * return from view 438 * return from view
452 * or properly quit 439 * or properly quit
453 */ 440 */
454 if (!m_setDocCalled) { 441 if (!m_setDocCalled) {
455 if ( m_stack->visibleWidget() == m_info || 442 if ( m_stack->visibleWidget() == m_info ||
456 m_stack->visibleWidget() == m_disp ) { 443 m_stack->visibleWidget() == m_disp ) {
457 ev->ignore(); 444 ev->ignore();
458 raiseIconView(); 445 raiseIconView();
459 return; 446 return;
460 } 447 }
461 } 448 }
462 if (m_disp && m_disp->fullScreen()) { 449 if (m_disp && m_disp->fullScreen()) {
463 /* otherwise opie-eye crashes in bigscreen mode! */ 450 /* otherwise opie-eye crashes in bigscreen mode! */
464 m_disp->reparent(0,QPoint(0,0)); 451 m_disp->reparent(0,QPoint(0,0));
465 m_stack->addWidget(m_disp,ImageDisplay); 452 m_stack->addWidget(m_disp,ImageDisplay);
466 } 453 }
467 ev->accept(); 454 ev->accept();
468 QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); 455 QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
469} 456}
470 457
471void PMainWindow::setDocument( const QString& showImg ) 458void PMainWindow::setDocument( const QString& showImg )
472{ 459{
473 QString file = showImg; 460 QString file = showImg;
474 DocLnk lnk(showImg); 461 DocLnk lnk(showImg);
475 if (lnk.isValid() ) 462 if (lnk.isValid() )
476 file = lnk.file(); 463 file = lnk.file();
477 slotDisplay( file ); 464 slotDisplay( file );
478#if 0 465#if 0
479 if (!m_polishDone) { 466 if (!m_polishDone) {
480 QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); 467 QTimer::singleShot(0,this,SLOT(check_view_fullscreen()));
481 } 468 }
482#endif 469#endif
483} 470}
484 471
485void PMainWindow::check_view_fullscreen() 472void PMainWindow::check_view_fullscreen()
486{ 473{
487 if (!m_view) return; 474 if (!m_view) return;
488 if (!m_view->hasFocus()&&m_aFullScreen->isOn()) { 475 if (!m_view->hasFocus()&&m_aFullScreen->isOn()) {
489 qwsDisplay()->requestFocus( m_disp->winId(), TRUE); 476 qwsDisplay()->requestFocus( m_disp->winId(), TRUE);
490 } 477 }
491} 478}
492 479
493void PMainWindow::slotSelectDir(int id) 480void PMainWindow::slotSelectDir(int id)
494{ 481{
495 emit changeDir( m_dev[fsMenu->text(id )] ); 482 emit changeDir( m_dev[fsMenu->text(id )] );
496} 483}
497 484
498void PMainWindow::dirChanged() 485void PMainWindow::dirChanged()
499{ 486{
500 fsMenu->clear(); 487 fsMenu->clear();
501 m_dev.clear(); 488 m_dev.clear();
502 489
503 /* home dir, too */ 490 /* home dir, too */
504 QString f = getenv( "HOME" ); 491 QString f = getenv( "HOME" );
505 if (!f.isEmpty()) { 492 if (!f.isEmpty()) {
506 m_dev.insert("Home directory",f); 493 m_dev.insert("Home directory",f);
507 fsMenu->insertItem("Home directory"); 494 fsMenu->insertItem("Home directory");
508 } 495 }
509 const QList<FileSystem> &fs = m_storage->fileSystems(); 496 const QList<FileSystem> &fs = m_storage->fileSystems();
510 QListIterator<FileSystem> it(fs ); 497 QListIterator<FileSystem> it(fs );
511 for ( ; it.current(); ++it ) { 498 for ( ; it.current(); ++it ) {
512 const QString disk = (*it)->name(); 499 const QString disk = (*it)->name();
513 const QString path = (*it)->path(); 500 const QString path = (*it)->path();
514 m_dev.insert( disk, path ); 501 m_dev.insert( disk, path );
515 fsMenu->insertItem( disk ); 502 fsMenu->insertItem( disk );
516 } 503 }
517} 504}
518 505
519void PMainWindow::showToolbar(bool how) 506void PMainWindow::showToolbar(bool how)
520{ 507{
521 if (!how) toolBar->hide(); 508 if (!how) toolBar->hide();
522 else toolBar->show(); 509 else toolBar->show();
523 if (autoSave) { 510 if (autoSave) {
524 m_cfg->writeEntry("showtoolbar",how); 511 m_cfg->writeEntry("showtoolbar",how);
525 } 512 }
526} 513}
527 514
528void PMainWindow::setupActions() 515void PMainWindow::setupActions()
529{ 516{
530 m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true ); 517 m_aDirUp = new QAction( tr( "Go dir up" ), Resource::loadIconSet( "up" ), 0, 0, this, 0, true );
531 m_aDirUp->setToggleAction(false); 518 m_aDirUp->setToggleAction(false);
532 connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp())); 519 connect(m_aDirUp,SIGNAL(activated()),m_view,SLOT(slotDirUp()));
533 520
534 if ( Ir::supported() ) { 521 if ( Ir::supported() ) {
535 m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true ); 522 m_aBeam = new QAction( tr( "Beam file" ), Resource::loadIconSet( "beam" ),0, 0, this, 0, true );
536 m_aBeam->setToggleAction(false); 523 m_aBeam->setToggleAction(false);
537 connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam())); 524 connect(m_aBeam,SIGNAL(activated()),m_view,SLOT(slotBeam()));
538 } else { 525 } else {
539 m_aBeam = 0; 526 m_aBeam = 0;
540 } 527 }
541 528
542 m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true ); 529 m_aShowInfo = new QAction( tr( "Show imageinfo" ), Resource::loadIconSet( "edit" ), 0, 0, this, 0, true );
543 m_aShowInfo->setToggleAction(false); 530 m_aShowInfo->setToggleAction(false);
544 connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo())); 531 connect(m_aShowInfo,SIGNAL(activated()),m_view,SLOT(slotImageInfo()));
545 532
546 m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true ); 533 m_aTrash = new QAction( tr( "Delete file" ), Resource::loadIconSet("trash"), 0, 0, this, 0, true );
547 m_aTrash->setToggleAction(false); 534 m_aTrash->setToggleAction(false);
548 connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash())); 535 connect(m_aTrash,SIGNAL(activated()),m_view,SLOT(slotTrash()));
549 536
550 m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true ); 537 m_aViewfile = new QAction( tr( "Display image" ), Resource::loadIconSet("mag"), 0, 0, this, 0, true );
551 m_aViewfile->setToggleAction(false); 538 m_aViewfile->setToggleAction(false);
552 connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage())); 539 connect(m_aViewfile,SIGNAL(activated()),m_view,SLOT(slotShowImage()));
553 540
554 m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true ); 541 m_aStartSlide = new QAction( tr( "Start slideshow" ), Resource::loadIconSet("play"),0, 0, this, 0, true );
555 m_aStartSlide->setToggleAction(false); 542 m_aStartSlide->setToggleAction(false);
556 connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide())); 543 connect(m_aStartSlide,SIGNAL(activated()),m_view,SLOT(slotStartSlide()));
557 544
558 m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true ); 545 m_aHideToolbar = new QAction( tr( "Show toolbar" ), Resource::loadIconSet( "UtilsIcon" ), 0, 0, this, 0, true );
559 m_aHideToolbar->setOn (true); 546 m_aHideToolbar->setOn (true);
560 connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool))); 547 connect(m_aHideToolbar,SIGNAL(toggled(bool)),this,SLOT(showToolbar(bool)));
561 548
562 m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true ); 549 m_aSetup = new QAction( tr( "Settings" ), Resource::loadIconSet("SettingsIcon"), 0, 0, this, 0, true );
563 m_aSetup->setToggleAction(false); 550 m_aSetup->setToggleAction(false);
564 connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig())); 551 connect(m_aSetup,SIGNAL(activated()),this,SLOT(slotConfig()));
565 552
566 m_gListViewMode = new QActionGroup(this,"Select listmode",true); 553 m_gListViewMode = new QActionGroup(this,"Select listmode",true);
567 connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*))); 554 connect(m_gListViewMode,SIGNAL(selected(QAction*)),this,SLOT(listviewselected(QAction*)));
568 555
569 m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true ); 556 m_aDirLong = new QAction( tr( "Thumbnail and Imageinfo" ),Resource::loadIconSet("opie-eye/opie-eye-thumb"), 0, 0, this, 0, true );
570 m_aDirLong->setToggleAction(true); 557 m_aDirLong->setToggleAction(true);
571 m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true ); 558 m_aDirShort = new QAction( tr( "Thumbnail and name" ),Resource::loadIconSet("opie-eye/opie-eye-thumbonly"), 0, 0, this, 0, true );
572 m_aDirShort->setToggleAction(true); 559 m_aDirShort->setToggleAction(true);
573 m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true ); 560 m_aDirName = new QAction( tr( "Name only" ), Resource::loadIconSet("opie-eye/opie-eye-textview"),0, 0, this, 0, true );
574 m_aDirName->setToggleAction(true); 561 m_aDirName->setToggleAction(true);
575 int mode = m_cfg->readNumEntry("ListViewMode", 1); 562 int mode = m_cfg->readNumEntry("ListViewMode", 1);
576 if (mode < 1 || mode>3) mode = 1; 563 if (mode < 1 || mode>3) mode = 1;
577 switch (mode) { 564 switch (mode) {
578 case 3: 565 case 3:
579 m_aDirName->setOn(true); 566 m_aDirName->setOn(true);
580 break; 567 break;
581 case 2: 568 case 2:
582 m_aDirShort->setOn(true); 569 m_aDirShort->setOn(true);
583 break; 570 break;
584 case 1: 571 case 1:
585 default: 572 default:
586 m_aDirLong->setOn(true); 573 m_aDirLong->setOn(true);
587 } 574 }
588 m_gListViewMode->insert(m_aDirLong); 575 m_gListViewMode->insert(m_aDirLong);
589 m_gListViewMode->insert(m_aDirShort); 576 m_gListViewMode->insert(m_aDirShort);
590 m_gListViewMode->insert(m_aDirName); 577 m_gListViewMode->insert(m_aDirName);
591 578
592 m_gPrevNext = new QActionGroup(this,"imageprevnext",false); 579 m_gPrevNext = new QActionGroup(this,"imageprevnext",false);
593 m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true ); 580 m_aNext = new QAction( tr( "Next image" ), Resource::loadIconSet("forward"), 0, 0, this, 0, true );
594 m_aNext->setToggleAction(false); 581 m_aNext->setToggleAction(false);
595 connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext())); 582 connect(m_aNext,SIGNAL(activated()),m_view,SLOT(slotShowNext()));
596 m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true ); 583 m_aPrevious = new QAction( tr( "Previous image" ), Resource::loadIconSet("back"), 0, 0, this, 0, true );
597 m_aPrevious->setToggleAction(false); 584 m_aPrevious->setToggleAction(false);
598 connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev())); 585 connect(m_aPrevious,SIGNAL(activated()),m_view,SLOT(slotShowPrev()));
599 m_gPrevNext->insert(m_aPrevious); 586 m_gPrevNext->insert(m_aPrevious);
600 m_gPrevNext->insert(m_aNext); 587 m_gPrevNext->insert(m_aNext);
601 588
602 m_aFullScreen = new QAction( tr( "Show images fullscreen" ), 589 m_aFullScreen = new QAction( tr( "Show images fullscreen" ),
603 Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true ); 590 Resource::loadIconSet("fullscreen"), 0, 0, this, 0, true );
604 m_aFullScreen->setToggleAction(true); 591 m_aFullScreen->setToggleAction(true);
605 if (autoSave) { 592 if (autoSave) {
606 m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false)); 593 m_aFullScreen->setOn(m_cfg->readBoolEntry("fullscreen",false));
607 } else { 594 } else {
608 m_aFullScreen->setOn(false); 595 m_aFullScreen->setOn(false);
609 } 596 }
610 connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool))); 597 connect(m_aFullScreen,SIGNAL(toggled(bool)),this,SLOT(slotFullScreenButton(bool)));
611 598
612 m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false); 599 m_gDisplayType = new QActionGroup(this,"imagedisplaytype",false);
613 m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true ); 600 m_aAutoRotate = new QAction( tr( "Auto rotate images" ), Resource::loadIconSet( "rotate" ), 0, 0, this, 0, true );
614 m_aAutoRotate->setToggleAction(true); 601 m_aAutoRotate->setToggleAction(true);
615 602
616 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { 603 if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
617 m_aAutoRotate->setOn(true); 604 m_aAutoRotate->setOn(true);
618 } else { 605 } else {
619 m_aAutoRotate->setOn(false); 606 m_aAutoRotate->setOn(false);
620 } 607 }
621 if (autoSave) { 608 if (autoSave) {
622 m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn())); 609 m_aAutoRotate->setOn(m_cfg->readBoolEntry("autorotate",m_aAutoRotate->isOn()));
623 } 610 }
624 connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); 611 connect(m_aAutoRotate,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
625 612
626 m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true ); 613 m_aUnscaled = new QAction( tr( "Show images unscaled" ), Resource::loadIconSet( "1to1" ), 0, 0, this, 0, true );
627 m_aUnscaled->setToggleAction(true); 614 m_aUnscaled->setToggleAction(true);
628 connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); 615 connect(m_aUnscaled,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
629 if (autoSave) { 616 if (autoSave) {
630 m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false)); 617 m_aUnscaled->setOn(m_cfg->readBoolEntry("unscaled",false));
631 } else { 618 } else {
632 m_aUnscaled->setOn(false); 619 m_aUnscaled->setOn(false);
633 } 620 }
634 621
635 m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true ); 622 m_aZoomer = new QAction( tr( "Show zoomer window when unscaled" ), Resource::loadIconSet( "mag" ), 0, 0, this, 0, true );
636 m_aZoomer->setToggleAction(true); 623 m_aZoomer->setToggleAction(true);
637 if (autoSave) { 624 if (autoSave) {
638 m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true)); 625 m_aZoomer->setOn(m_cfg->readBoolEntry("zoomeron",true));
639 } else { 626 } else {
640 m_aZoomer->setOn (true); 627 m_aZoomer->setOn (true);
641 } 628 }
642 connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); 629 connect(m_aZoomer,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
643 m_gDisplayType->insert(m_aAutoRotate); 630 m_gDisplayType->insert(m_aAutoRotate);
644 m_gDisplayType->insert(m_aUnscaled); 631 m_gDisplayType->insert(m_aUnscaled);
645 m_gDisplayType->insert(m_aZoomer); 632 m_gDisplayType->insert(m_aZoomer);
646 633
647 m_hGroup = new QActionGroup(this,"actioncollection",false); 634 m_hGroup = new QActionGroup(this,"actioncollection",false);
648 m_hGroup->insert(m_aFullScreen); 635 m_hGroup->insert(m_aFullScreen);
649 636
650 if (!m_SmallWindow) { 637 if (!m_SmallWindow) {
651 m_aForceSmall = new QAction(tr("Dont show seperate windows"),Resource::loadIconSet( "AppsIcon" ), 0, 0, this, 0, true); 638 m_aForceSmall = new QAction(tr("Dont show seperate windows"),Resource::loadIconSet( "AppsIcon" ), 0, 0, this, 0, true);
652 m_aForceSmall->setToggleAction(true); 639 m_aForceSmall->setToggleAction(true);
653 connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool))); 640 connect(m_aForceSmall,SIGNAL(toggled(bool)),this,SLOT(slotForceSmall(bool)));
654 } else { 641 } else {
655 m_aForceSmall = 0; 642 m_aForceSmall = 0;
656 } 643 }
657 m_setCurrentBrightness = new QAction(tr("Display brightness..."), 0, 0, this, 0, false); 644 m_setCurrentBrightness = new QAction(tr("Display brightness..."), 0, 0, this, 0, false);
658 connect(m_setCurrentBrightness,SIGNAL(activated()),this,SLOT(setupBrightness())); 645 connect(m_setCurrentBrightness,SIGNAL(activated()),this,SLOT(setupBrightness()));
659} 646}
660 647
661void PMainWindow::setupBrightness() 648void PMainWindow::setupBrightness()
662{ 649{
663 if (!m_disp) { 650 if (!m_disp) {
664 return; 651 return;
665 } 652 }
666 int lb = m_disp->Intensity(); 653 int lb = m_disp->Intensity();
667 if (Valuebox(0,-255,255,lb,lb)) { 654 if (Valuebox(0,-255,255,lb,lb)) {
668 m_disp->setIntensity(lb,true); 655 m_disp->setIntensity(lb,true);
669 } 656 }
670} 657}
671 658
672void PMainWindow::setupToolbar() 659void PMainWindow::setupToolbar()
673{ 660{
674 toolBar = new QToolBar( this ); 661 toolBar = new QToolBar( this );
675 addToolBar(toolBar); 662 addToolBar(toolBar);
676 toolBar->setHorizontalStretchable( true ); 663 toolBar->setHorizontalStretchable( true );
677 setToolBarsMovable( false ); 664 setToolBarsMovable( false );
678 m_aDirUp->addTo( toolBar ); 665 m_aDirUp->addTo( toolBar );
679 666
680 fsButton = new PFileSystem( toolBar ); 667 fsButton = new PFileSystem( toolBar );
681 connect( fsButton, SIGNAL( changeDir( const QString& ) ), 668 connect( fsButton, SIGNAL( changeDir( const QString& ) ),
682 m_view, SLOT(slotChangeDir( const QString& ) ) ); 669 m_view, SLOT(slotChangeDir( const QString& ) ) );
683 connect( this, SIGNAL( changeDir( const QString& ) ), 670 connect( this, SIGNAL( changeDir( const QString& ) ),
684 m_view, SLOT(slotChangeDir( const QString& ) ) ); 671 m_view, SLOT(slotChangeDir( const QString& ) ) );
685 672
686 if (m_aBeam) { 673 if (m_aBeam) {
687 m_aBeam->addTo( toolBar ); 674 m_aBeam->addTo( toolBar );
688 } 675 }
689 m_aShowInfo->addTo(toolBar); 676 m_aShowInfo->addTo(toolBar);
690 m_aTrash->addTo(toolBar); 677 m_aTrash->addTo(toolBar);
691// m_aSetup->addTo(toolBar); 678// m_aSetup->addTo(toolBar);
692 679
693 m_gDisplayType->addTo(toolBar); 680 m_gDisplayType->addTo(toolBar);
694 681
695 if (!m_SmallWindow) { 682 if (!m_SmallWindow) {
696 m_gPrevNext->addTo(toolBar); 683 m_gPrevNext->addTo(toolBar);
697 } else { 684 } else {
698 m_gPrevNext->setEnabled(false); 685 m_gPrevNext->setEnabled(false);
699 } 686 }
700} 687}
701 688
702void PMainWindow::setupMenu() 689void PMainWindow::setupMenu()
703{ 690{
704 fileMenu = new QPopupMenu( menuBar() ); 691 fileMenu = new QPopupMenu( menuBar() );
705 menuBar()->insertItem( tr( "File" ), fileMenu ); 692 menuBar()->insertItem( tr( "File" ), fileMenu );
706 dispMenu = new QPopupMenu( menuBar() ); 693 dispMenu = new QPopupMenu( menuBar() );
707 menuBar()->insertItem( tr( "Show" ), dispMenu ); 694 menuBar()->insertItem( tr( "Show" ), dispMenu );
708 settingsMenu = new QPopupMenu( menuBar() ); 695 settingsMenu = new QPopupMenu( menuBar() );
709 menuBar()->insertItem( tr( "Settings" ), settingsMenu ); 696 menuBar()->insertItem( tr( "Settings" ), settingsMenu );
710 697
711 m_aViewfile->addTo(fileMenu); 698 m_aViewfile->addTo(fileMenu);
712 m_aShowInfo->addTo(fileMenu); 699 m_aShowInfo->addTo(fileMenu);
713 m_aStartSlide->addTo(fileMenu); 700 m_aStartSlide->addTo(fileMenu);
714 701
715 fileMenu->insertSeparator(); 702 fileMenu->insertSeparator();
716 m_aDirUp->addTo( fileMenu ); 703 m_aDirUp->addTo( fileMenu );
717 704
718 fsMenu = new QPopupMenu(fileMenu); 705 fsMenu = new QPopupMenu(fileMenu);
719 fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu); 706 fileMenu->insertItem(Resource::loadIconSet( "cardmon/pcmcia" ),tr("Select filesystem"),fsMenu);
720 connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) ); 707 connect( fsMenu, SIGNAL( activated( int ) ), this, SLOT(slotSelectDir( int ) ) );
721 dirChanged(); 708 dirChanged();
722 709
723 if ( m_aBeam ) { 710 if ( m_aBeam ) {
724 fileMenu->insertSeparator(); 711 fileMenu->insertSeparator();
725 m_aBeam->addTo( fileMenu ); 712 m_aBeam->addTo( fileMenu );
726 } 713 }
727 fileMenu->insertSeparator(); 714 fileMenu->insertSeparator();
728 m_aTrash->addTo(fileMenu); 715 m_aTrash->addTo(fileMenu);
729 716
730 listviewMenu = new QPopupMenu(dispMenu); 717 listviewMenu = new QPopupMenu(dispMenu);
731 dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu); 718 dispMenu->insertItem(Resource::loadIconSet("opie-eye/opie-eye-thumb"),tr("Listview mode"),listviewMenu);
732 m_gListViewMode->addTo(listviewMenu); 719 m_gListViewMode->addTo(listviewMenu);
733 dispMenu->insertSeparator(); 720 dispMenu->insertSeparator();
734 m_aFullScreen->addTo(dispMenu); 721 m_aFullScreen->addTo(dispMenu);
735 m_gDisplayType->addTo(dispMenu); 722 m_gDisplayType->addTo(dispMenu);
736 dispMenu->insertSeparator(); 723 dispMenu->insertSeparator();
737 m_gPrevNext->addTo(dispMenu); 724 m_gPrevNext->addTo(dispMenu);
738 m_setCurrentBrightness->addTo(dispMenu); 725 m_setCurrentBrightness->addTo(dispMenu);
739 m_setCurrentBrightness->setEnabled(false); 726 m_setCurrentBrightness->setEnabled(false);
740 if (m_aForceSmall) { 727 if (m_aForceSmall) {
741 dispMenu->insertSeparator(); 728 dispMenu->insertSeparator();
742 m_aForceSmall->addTo(dispMenu); 729 m_aForceSmall->addTo(dispMenu);
743 } 730 }
744 731
745 m_aSetup->addTo(settingsMenu); 732 m_aSetup->addTo(settingsMenu);
746 m_aHideToolbar->addTo(settingsMenu); 733 m_aHideToolbar->addTo(settingsMenu);
747} 734}
748 735
749void PMainWindow::listviewselected(QAction*which) 736void PMainWindow::listviewselected(QAction*which)
750{ 737{
751 if (!which || which->isOn()==false) return; 738 if (!which || which->isOn()==false) return;
752 int val = 1; 739 int val = 1;
753 740
754 if (which==m_aDirName) { 741 if (which==m_aDirName) {
755 val = 3; 742 val = 3;
756 } else if (which==m_aDirShort) { 743 } else if (which==m_aDirShort) {
757 val = 2; 744 val = 2;
758 } else if (which==m_aDirLong) { 745 } else if (which==m_aDirLong) {
759 val = 1; 746 val = 1;
760 } 747 }
761 emit changeListMode(val); 748 emit changeListMode(val);
762} 749}
763 750
764void PMainWindow::readConfig() 751void PMainWindow::readConfig()
765{ 752{
766 autoSave =m_cfg->readBoolEntry("savestatus",true); 753 autoSave =m_cfg->readBoolEntry("savestatus",true);
767 m_Intensity = m_cfg->readNumEntry("intensity",0); 754 m_Intensity = m_cfg->readNumEntry("intensity",0);
768} 755}
769 756
770void PMainWindow::polish() 757void PMainWindow::polish()
771{ 758{
772 if (m_disp) { 759 if (m_disp) {
773 odebug << "======================\n" 760 odebug << "======================\n"
774 << "Called via setdocument\n" 761 << "Called via setdocument\n"
775 << "======================" << oendl; 762 << "======================" << oendl;
776 m_setDocCalled = true; 763 m_setDocCalled = true;
777 m_view->setDoccalled(true); 764 m_view->setDoccalled(true);
778 m_disp->setCloseIfHide(true); 765 m_disp->setCloseIfHide(true);
779 } else { 766 } else {
780 m_setDocCalled = false; 767 m_setDocCalled = false;
781 m_view->setDoccalled(false); 768 m_view->setDoccalled(false);
782 } 769 }
783 m_polishDone = true; 770 m_polishDone = true;
784 QMainWindow::polish(); 771 QMainWindow::polish();
785 if (m_setDocCalled) { 772 if (m_setDocCalled) {
786 if (m_aFullScreen->isOn()) { 773 if (m_aFullScreen->isOn()) {
787 QTimer::singleShot(0,this,SLOT(check_view_fullscreen())); 774 QTimer::singleShot(0,this,SLOT(check_view_fullscreen()));
788 } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { 775 } else if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
789 } 776 }
790 } 777 }
791} 778}
792 779
793void PMainWindow::slotForceSmall(bool how) 780void PMainWindow::slotForceSmall(bool how)
794{ 781{
795 odebug << "Disable separate windows: " << how << oendl; 782 odebug << "Disable separate windows: " << how << oendl;
796 if (m_stack) { 783 if (m_stack) {
797 if (how) { 784 if (how) {
798 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen); 785 m_stack->forceMode(Opie::Ui::OWidgetStack::SmallScreen);
799 } else { 786 } else {
800 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); 787 m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
801 } 788 }
802 } 789 }
803 if (autoSave) { 790 if (autoSave) {
804 m_cfg->writeEntry("dontshowseperate",how); 791 m_cfg->writeEntry("dontshowseperate",how);
805 } 792 }
806} 793}
807 794
808bool PMainWindow::Valuebox(QWidget*parent,int min, int max, int current,int&store) 795bool PMainWindow::Valuebox(QWidget*parent,int min, int max, int current,int&store)
809{ 796{
810 QDialog dlg(parent,"brightnessbox",true); 797 QDialog dlg(parent,"brightnessbox",true);
811 QVBoxLayout * m_MainLayout; 798 QVBoxLayout * m_MainLayout;
812 QGridLayout * m_IntensityLayout; 799 QGridLayout * m_IntensityLayout;
813 QSpinBox * m_Intensity; 800 QSpinBox * m_Intensity;
814 QLabel * m_IntensityLabel; 801 QLabel * m_IntensityLabel;
815 802
816 m_MainLayout = new QVBoxLayout( &dlg, 11, 6, "m_MainLayout"); 803 m_MainLayout = new QVBoxLayout( &dlg, 11, 6, "m_MainLayout");
817 m_IntensityLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IntensityLayout"); 804 m_IntensityLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IntensityLayout");
818 m_Intensity = new QSpinBox( &dlg, "m_Intensity" ); 805 m_Intensity = new QSpinBox( &dlg, "m_Intensity" );
819 m_Intensity->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); 806 m_Intensity->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed));
820 m_Intensity->setButtonSymbols( QSpinBox::PlusMinus ); 807 m_Intensity->setButtonSymbols( QSpinBox::PlusMinus );
821 m_Intensity->setMaxValue( max ); 808 m_Intensity->setMaxValue( max );
822 m_Intensity->setMinValue(min); 809 m_Intensity->setMinValue(min);
823 m_Intensity->setValue( current ); 810 m_Intensity->setValue( current );
824 m_IntensityLayout->addWidget( m_Intensity, 0, 1 ); 811 m_IntensityLayout->addWidget( m_Intensity, 0, 1 );
825 m_IntensityLabel = new QLabel( &dlg, "m_IntensityLabel" ); 812 m_IntensityLabel = new QLabel( &dlg, "m_IntensityLabel" );
826 m_IntensityLabel->setText(QObject::tr("Display brightness:")); 813 m_IntensityLabel->setText(QObject::tr("Display brightness:"));
827 m_IntensityLayout->addWidget(m_IntensityLabel, 0, 0 ); 814 m_IntensityLayout->addWidget(m_IntensityLabel, 0, 0 );
828 m_MainLayout->addLayout(m_IntensityLayout); 815 m_MainLayout->addLayout(m_IntensityLayout);
829 if (dlg.exec()) { 816 if (dlg.exec()) {
830 store = m_Intensity->value(); 817 store = m_Intensity->value();
831 return true; 818 return true;
832 } 819 }
833 return false; 820 return false;
834} 821}