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