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