author | alwin <alwin> | 2004-04-15 16:14:56 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-04-15 16:14:56 (UTC) |
commit | a002be54e33d64e69c7edf2960d5e68a9a0609e4 (patch) (unidiff) | |
tree | c58f7bce41920a86f077d0c371bcf166a03d6489 | |
parent | fd31b11688704c214034a0e28ca7c0a56a6a2988 (diff) | |
download | opie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.zip opie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.tar.gz opie-a002be54e33d64e69c7edf2960d5e68a9a0609e4.tar.bz2 |
previous/next image keys implemented
ToDo: make it via keywidget, this moment the keywidget sends a key twice
(on press and on release)
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 48 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 6 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.cpp | 25 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/imageview.h | 5 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 2 |
5 files changed, 86 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 5633312..f6e1816 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,503 +1,551 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "iconview.h" | 6 | #include "iconview.h" |
7 | 7 | ||
8 | #include <lib/imagecache.h> | 8 | #include <lib/imagecache.h> |
9 | #include <gui/imageinfoui.h> | 9 | #include <gui/imageinfoui.h> |
10 | 10 | ||
11 | #include <iface/dirview.h> | 11 | #include <iface/dirview.h> |
12 | #include <iface/dirlister.h> | 12 | #include <iface/dirlister.h> |
13 | 13 | ||
14 | #include <opie2/oconfig.h> | 14 | #include <opie2/oconfig.h> |
15 | #include <opie2/okeyconfigwidget.h> | 15 | #include <opie2/okeyconfigwidget.h> |
16 | #include <opie2/odebug.h> | 16 | #include <opie2/odebug.h> |
17 | #include <opie2/oimagescrollview.h> | 17 | #include <opie2/oimagescrollview.h> |
18 | 18 | ||
19 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
20 | #include <qpe/qpemessagebox.h> | 20 | #include <qpe/qpemessagebox.h> |
21 | #include <qpe/ir.h> | 21 | #include <qpe/ir.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | #include <qiconview.h> | 25 | #include <qiconview.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qhbox.h> | 27 | #include <qhbox.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | #include <qmainwindow.h> | 31 | #include <qmainwindow.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qstyle.h> | 33 | #include <qstyle.h> |
34 | 34 | ||
35 | 35 | ||
36 | using Opie::Core::OKeyConfigItem; | 36 | using Opie::Core::OKeyConfigItem; |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * The Icons, Request Cache and IconViewItem for the IconView | 39 | * The Icons, Request Cache and IconViewItem for the IconView |
40 | */ | 40 | */ |
41 | namespace { | 41 | namespace { |
42 | static QPixmap* _dirPix = 0; | 42 | static QPixmap* _dirPix = 0; |
43 | static QPixmap* _unkPix = 0; | 43 | static QPixmap* _unkPix = 0; |
44 | static QPixmap* _picPix = 0; | 44 | static QPixmap* _picPix = 0; |
45 | class IconViewItem : public QIconViewItem { | 45 | class IconViewItem : public QIconViewItem { |
46 | public: | 46 | public: |
47 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 47 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
48 | QPixmap* pixmap()const; | 48 | QPixmap* pixmap()const; |
49 | QString path()const { return m_path; } | 49 | QString path()const { return m_path; } |
50 | bool isDir()const { return m_isDir; } | 50 | bool isDir()const { return m_isDir; } |
51 | void setText( const QString& ); | 51 | void setText( const QString& ); |
52 | 52 | ||
53 | protected: | 53 | protected: |
54 | mutable QPixmap* m_pix; | 54 | mutable QPixmap* m_pix; |
55 | 55 | ||
56 | private: | 56 | private: |
57 | QString m_path; | 57 | QString m_path; |
58 | bool m_isDir : 1; | 58 | bool m_isDir : 1; |
59 | bool m_noInfo :1; | 59 | bool m_noInfo :1; |
60 | }; | 60 | }; |
61 | class TextViewItem : public IconViewItem { | 61 | class TextViewItem : public IconViewItem { |
62 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 62 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
63 | QPixmap *pixmap()const; | 63 | QPixmap *pixmap()const; |
64 | void setText( const QString& ); | 64 | void setText( const QString& ); |
65 | }; | 65 | }; |
66 | class ThumbViewItem : public IconViewItem { | 66 | class ThumbViewItem : public IconViewItem { |
67 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 67 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); |
68 | QPixmap *pixmap()const; | 68 | QPixmap *pixmap()const; |
69 | void setText( const QString& ); | 69 | void setText( const QString& ); |
70 | }; | 70 | }; |
71 | 71 | ||
72 | 72 | ||
73 | /* | 73 | /* |
74 | * If we request an Image or String | 74 | * If we request an Image or String |
75 | * we add it to the map | 75 | * we add it to the map |
76 | */ | 76 | */ |
77 | static QMap<QString, IconViewItem*> g_stringInf; | 77 | static QMap<QString, IconViewItem*> g_stringInf; |
78 | static QMap<QString, IconViewItem*> g_stringPix; | 78 | static QMap<QString, IconViewItem*> g_stringPix; |
79 | 79 | ||
80 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 80 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
81 | const QString& name, bool isDir ) | 81 | const QString& name, bool isDir ) |
82 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 82 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
83 | m_noInfo( false ) | 83 | m_noInfo( false ) |
84 | { | 84 | { |
85 | if ( isDir && !_dirPix ) | 85 | if ( isDir && !_dirPix ) |
86 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 86 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
87 | else if ( !isDir && !_unkPix ) | 87 | else if ( !isDir && !_unkPix ) |
88 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 88 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
89 | } | 89 | } |
90 | inline QPixmap* IconViewItem::pixmap()const { | 90 | inline QPixmap* IconViewItem::pixmap()const { |
91 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", | 91 | // qWarning( "Name is " + m_path.right( 15 ) + " rect is %d %d %d %d | %d %d", |
92 | // rect().x(),rect().y(),rect().width(),rect().height(), | 92 | // rect().x(),rect().y(),rect().width(),rect().height(), |
93 | // iconView()->contentsX(), iconView()->contentsY()); | 93 | // iconView()->contentsX(), iconView()->contentsY()); |
94 | 94 | ||
95 | if ( m_isDir ) | 95 | if ( m_isDir ) |
96 | return _dirPix; | 96 | return _dirPix; |
97 | else{ | 97 | else{ |
98 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 98 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
99 | currentView()->dirLister()->imageInfo( m_path ); | 99 | currentView()->dirLister()->imageInfo( m_path ); |
100 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 100 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
101 | } | 101 | } |
102 | 102 | ||
103 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 103 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
104 | if ( !m_pix && !g_stringPix.contains( m_path )) { | 104 | if ( !m_pix && !g_stringPix.contains( m_path )) { |
105 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 105 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
106 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 106 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
107 | } | 107 | } |
108 | return m_pix ? m_pix : _unkPix; | 108 | return m_pix ? m_pix : _unkPix; |
109 | } | 109 | } |
110 | } | 110 | } |
111 | inline void IconViewItem::setText( const QString& str ) { | 111 | inline void IconViewItem::setText( const QString& str ) { |
112 | QString text = QIconViewItem::text()+"\n"+str; | 112 | QString text = QIconViewItem::text()+"\n"+str; |
113 | m_noInfo = true; | 113 | m_noInfo = true; |
114 | QIconViewItem::setText( text ); | 114 | QIconViewItem::setText( text ); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | /* | 119 | /* |
120 | * Set up the GUI.. initialize the slave set up gui | 120 | * Set up the GUI.. initialize the slave set up gui |
121 | * and also load a dir | 121 | * and also load a dir |
122 | */ | 122 | */ |
123 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | 123 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
124 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) | 124 | : QVBox( wid ), m_cfg( cfg ), m_updatet( false ) |
125 | { | 125 | { |
126 | { | 126 | { |
127 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 127 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
128 | } | 128 | } |
129 | m_path = QDir::homeDirPath(); | 129 | m_path = QDir::homeDirPath(); |
130 | m_mode = 0; | 130 | m_mode = 0; |
131 | 131 | ||
132 | QHBox *hbox = new QHBox( this ); | 132 | QHBox *hbox = new QHBox( this ); |
133 | QLabel* lbl = new QLabel( hbox ); | 133 | QLabel* lbl = new QLabel( hbox ); |
134 | lbl->setText( tr("View as" ) ); | 134 | lbl->setText( tr("View as" ) ); |
135 | 135 | ||
136 | m_views = new QComboBox( hbox, "View As" ); | 136 | m_views = new QComboBox( hbox, "View As" ); |
137 | connect( m_views, SIGNAL(activated(int)), | 137 | connect( m_views, SIGNAL(activated(int)), |
138 | this, SLOT(slotViewChanged(int)) ); | 138 | this, SLOT(slotViewChanged(int)) ); |
139 | 139 | ||
140 | m_view= new QIconView( this ); | 140 | m_view= new QIconView( this ); |
141 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 141 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
142 | this, SLOT(slotClicked(QIconViewItem*)) ); | 142 | this, SLOT(slotClicked(QIconViewItem*)) ); |
143 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), | 143 | connect(m_view, SIGNAL(returnPressed(QIconViewItem*)), |
144 | this, SLOT(slotClicked(QIconViewItem*)) ); | 144 | this, SLOT(slotClicked(QIconViewItem*)) ); |
145 | 145 | ||
146 | m_view->setArrangement( QIconView::LeftToRight ); | 146 | m_view->setArrangement( QIconView::LeftToRight ); |
147 | m_view->setItemTextPos( QIconView::Right ); | 147 | m_view->setItemTextPos( QIconView::Right ); |
148 | 148 | ||
149 | int dw = QApplication::desktop()->width(); | 149 | int dw = QApplication::desktop()->width(); |
150 | int viewerWidth = dw-style().scrollBarExtent().width(); | 150 | int viewerWidth = dw-style().scrollBarExtent().width(); |
151 | m_view->setGridX( viewerWidth-3*m_view->spacing()); | 151 | m_view->setGridX( viewerWidth-3*m_view->spacing()); |
152 | m_view->setGridY( fontMetrics().height()*2+40 ); | 152 | m_view->setGridY( fontMetrics().height()*2+40 ); |
153 | 153 | ||
154 | 154 | ||
155 | initKeys(); | 155 | initKeys(); |
156 | 156 | ||
157 | loadViews(); | 157 | loadViews(); |
158 | slotViewChanged( m_views->currentItem() ); | 158 | slotViewChanged( m_views->currentItem() ); |
159 | } | 159 | } |
160 | 160 | ||
161 | /* | 161 | /* |
162 | * Unref the slave and save the keyboard manager | 162 | * Unref the slave and save the keyboard manager |
163 | */ | 163 | */ |
164 | PIconView::~PIconView() { | 164 | PIconView::~PIconView() { |
165 | { | 165 | { |
166 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 166 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
167 | } | 167 | } |
168 | m_viewManager->save(); | 168 | m_viewManager->save(); |
169 | delete m_viewManager; | 169 | delete m_viewManager; |
170 | } | 170 | } |
171 | 171 | ||
172 | Opie::Core::OKeyConfigManager* PIconView::manager() { | 172 | Opie::Core::OKeyConfigManager* PIconView::manager() { |
173 | return m_viewManager; | 173 | return m_viewManager; |
174 | } | 174 | } |
175 | 175 | ||
176 | 176 | ||
177 | /* | 177 | /* |
178 | * init the KeyBoard Shortcuts | 178 | * init the KeyBoard Shortcuts |
179 | * called from the c'tor | 179 | * called from the c'tor |
180 | */ | 180 | */ |
181 | void PIconView::initKeys() { | 181 | void PIconView::initKeys() { |
182 | Opie::Core::OKeyPair::List lst; | 182 | Opie::Core::OKeyPair::List lst; |
183 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 183 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
184 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 184 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
185 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 185 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
186 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 186 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
187 | lst.append( Opie::Core::OKeyPair::returnKey() ); | 187 | lst.append( Opie::Core::OKeyPair::returnKey() ); |
188 | 188 | ||
189 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | 189 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", |
190 | lst, false,this, "keyconfig name" ); | 190 | lst, false,this, "keyconfig name" ); |
191 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | 191 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", |
192 | Resource::loadPixmap("beam"), BeamItem, | 192 | Resource::loadPixmap("beam"), BeamItem, |
193 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), | 193 | Opie::Core::OKeyPair(Qt::Key_B, Qt::ShiftButton), |
194 | this, SLOT(slotBeam())) ); | 194 | this, SLOT(slotBeam())) ); |
195 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | 195 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", |
196 | Resource::loadPixmap("trash"), DeleteItem, | 196 | Resource::loadPixmap("trash"), DeleteItem, |
197 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), | 197 | Opie::Core::OKeyPair(Qt::Key_D, Qt::ShiftButton), |
198 | this, SLOT(slotTrash())) ); | 198 | this, SLOT(slotTrash())) ); |
199 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | 199 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", |
200 | Resource::loadPixmap("1to1"), ViewItem, | 200 | Resource::loadPixmap("1to1"), ViewItem, |
201 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), | 201 | Opie::Core::OKeyPair(Qt::Key_V, Qt::ShiftButton), |
202 | this, SLOT(slotShowImage()))); | 202 | this, SLOT(slotShowImage()))); |
203 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | 203 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", |
204 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, | 204 | Resource::loadPixmap("DocumentTypeWord"), InfoItem, |
205 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | 205 | Opie::Core::OKeyPair(Qt::Key_I, Qt::ShiftButton ), |
206 | this, SLOT(slotImageInfo()) ) ); | 206 | this, SLOT(slotImageInfo()) ) ); |
207 | m_viewManager->load(); | 207 | m_viewManager->load(); |
208 | m_viewManager->handleWidget( m_view ); | 208 | m_viewManager->handleWidget( m_view ); |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | /* | 212 | /* |
213 | * change one dir up | 213 | * change one dir up |
214 | */ | 214 | */ |
215 | void PIconView::slotDirUp() { | 215 | void PIconView::slotDirUp() { |
216 | QDir dir( m_path ); | 216 | QDir dir( m_path ); |
217 | dir.cdUp(); | 217 | dir.cdUp(); |
218 | slotChangeDir( dir.absPath() ); | 218 | slotChangeDir( dir.absPath() ); |
219 | } | 219 | } |
220 | 220 | ||
221 | /* | 221 | /* |
222 | * change the dir | 222 | * change the dir |
223 | */ | 223 | */ |
224 | void PIconView::slotChangeDir(const QString& path) { | 224 | void PIconView::slotChangeDir(const QString& path) { |
225 | if ( !currentView() ) | 225 | if ( !currentView() ) |
226 | return; | 226 | return; |
227 | 227 | ||
228 | PDirLister *lister = currentView()->dirLister(); | 228 | PDirLister *lister = currentView()->dirLister(); |
229 | if (!lister ) | 229 | if (!lister ) |
230 | return; | 230 | return; |
231 | 231 | ||
232 | /* | 232 | /* |
233 | * Say what we want and take what we get | 233 | * Say what we want and take what we get |
234 | */ | 234 | */ |
235 | lister->setStartPath( path ); | 235 | lister->setStartPath( path ); |
236 | m_path = lister->currentPath(); | 236 | m_path = lister->currentPath(); |
237 | 237 | ||
238 | m_view->viewport()->setUpdatesEnabled( false ); | 238 | m_view->viewport()->setUpdatesEnabled( false ); |
239 | m_view->clear(); | 239 | m_view->clear(); |
240 | 240 | ||
241 | /* | 241 | /* |
242 | * add files and folders | 242 | * add files and folders |
243 | */ | 243 | */ |
244 | addFolders( lister->folders() ); | 244 | addFolders( lister->folders() ); |
245 | addFiles( lister->files() ); | 245 | addFiles( lister->files() ); |
246 | m_view->viewport()->setUpdatesEnabled( true ); | 246 | m_view->viewport()->setUpdatesEnabled( true ); |
247 | 247 | ||
248 | // Also invalidate the cache. We can't cancel the operations anyway | 248 | // Also invalidate the cache. We can't cancel the operations anyway |
249 | g_stringPix.clear(); | 249 | g_stringPix.clear(); |
250 | g_stringInf.clear(); | 250 | g_stringInf.clear(); |
251 | 251 | ||
252 | // looks ugly | 252 | // looks ugly |
253 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 253 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
254 | } | 254 | } |
255 | 255 | ||
256 | /** | 256 | /** |
257 | * get the current file name | 257 | * get the current file name |
258 | * @param isDir see if this is a dir or real file | 258 | * @param isDir see if this is a dir or real file |
259 | */ | 259 | */ |
260 | QString PIconView::currentFileName(bool &isDir)const { | 260 | QString PIconView::currentFileName(bool &isDir)const { |
261 | isDir = false; | 261 | isDir = false; |
262 | QIconViewItem* _it = m_view->currentItem(); | 262 | QIconViewItem* _it = m_view->currentItem(); |
263 | if ( !_it ) | 263 | if ( !_it ) |
264 | return QString::null; | 264 | return QString::null; |
265 | 265 | ||
266 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 266 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
267 | isDir = it->isDir(); | 267 | isDir = it->isDir(); |
268 | return it->path(); | 268 | return it->path(); |
269 | } | 269 | } |
270 | 270 | ||
271 | QString PIconView::nextFileName(bool &isDir)const | ||
272 | { | ||
273 | isDir = false; | ||
274 | QIconViewItem* _it1 = m_view->currentItem(); | ||
275 | if ( !_it1 ) | ||
276 | return QString::null; | ||
277 | QIconViewItem* _it = _it1->nextItem(); | ||
278 | if ( !_it ) | ||
279 | return QString::null; | ||
280 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | ||
281 | isDir = it->isDir(); | ||
282 | m_view->setCurrentItem(_it); | ||
283 | return it->path(); | ||
284 | } | ||
285 | |||
286 | QString PIconView::prevFileName(bool &isDir)const{ | ||
287 | isDir = false; | ||
288 | QIconViewItem* _it = m_view->currentItem(); | ||
289 | if ( !_it ) | ||
290 | return QString::null; | ||
291 | _it = _it->prevItem(); | ||
292 | if ( !_it ) | ||
293 | return QString::null; | ||
294 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | ||
295 | isDir = it->isDir(); | ||
296 | m_view->setCurrentItem(_it); | ||
297 | return it->path(); | ||
298 | } | ||
299 | |||
271 | void PIconView::slotTrash() { | 300 | void PIconView::slotTrash() { |
272 | bool isDir; | 301 | bool isDir; |
273 | QString pa = currentFileName( isDir ); | 302 | QString pa = currentFileName( isDir ); |
274 | if ( isDir && pa.isEmpty() ) | 303 | if ( isDir && pa.isEmpty() ) |
275 | return; | 304 | return; |
276 | 305 | ||
277 | if (!QPEMessageBox::confirmDelete( this, | 306 | if (!QPEMessageBox::confirmDelete( this, |
278 | tr("Delete Image" ), | 307 | tr("Delete Image" ), |
279 | tr("the Image %1" ).arg(pa))) | 308 | tr("the Image %1" ).arg(pa))) |
280 | return | 309 | return |
281 | 310 | ||
282 | 311 | ||
283 | currentView()->dirLister()->deleteImage( pa ); | 312 | currentView()->dirLister()->deleteImage( pa ); |
284 | delete m_view->currentItem(); | 313 | delete m_view->currentItem(); |
285 | } | 314 | } |
286 | 315 | ||
287 | /* | 316 | /* |
288 | * see what views are available | 317 | * see what views are available |
289 | */ | 318 | */ |
290 | void PIconView::loadViews() { | 319 | void PIconView::loadViews() { |
291 | ViewMap::Iterator it; | 320 | ViewMap::Iterator it; |
292 | ViewMap* map = viewMap(); | 321 | ViewMap* map = viewMap(); |
293 | for ( it = map->begin(); it != map->end(); ++it ) | 322 | for ( it = map->begin(); it != map->end(); ++it ) |
294 | m_views->insertItem( QObject::tr(it.key() ) ); | 323 | m_views->insertItem( QObject::tr(it.key() ) ); |
295 | } | 324 | } |
296 | 325 | ||
297 | void PIconView::resetView() { | 326 | void PIconView::resetView() { |
298 | slotViewChanged(m_views->currentItem()); | 327 | slotViewChanged(m_views->currentItem()); |
299 | } | 328 | } |
300 | 329 | ||
301 | /* | 330 | /* |
302 | *swicth view reloadDir and connect signals | 331 | *swicth view reloadDir and connect signals |
303 | */ | 332 | */ |
304 | void PIconView::slotViewChanged( int i) { | 333 | void PIconView::slotViewChanged( int i) { |
305 | if (!m_views->count() ) { | 334 | if (!m_views->count() ) { |
306 | setCurrentView( 0l); | 335 | setCurrentView( 0l); |
307 | return; | 336 | return; |
308 | } | 337 | } |
309 | 338 | ||
310 | PDirView* cur = currentView(); | 339 | PDirView* cur = currentView(); |
311 | delete cur; | 340 | delete cur; |
312 | QString str = m_views->text(i); | 341 | QString str = m_views->text(i); |
313 | cur = (*(*viewMap())[str])(*m_cfg); | 342 | cur = (*(*viewMap())[str])(*m_cfg); |
314 | setCurrentView( cur ); | 343 | setCurrentView( cur ); |
315 | 344 | ||
316 | /* connect to the signals of the lister */ | 345 | /* connect to the signals of the lister */ |
317 | PDirLister* lis = cur->dirLister(); | 346 | PDirLister* lis = cur->dirLister(); |
318 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 347 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
319 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 348 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
320 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 349 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
321 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 350 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
322 | connect(lis, SIGNAL(sig_start()), | 351 | connect(lis, SIGNAL(sig_start()), |
323 | this, SLOT(slotStart())); | 352 | this, SLOT(slotStart())); |
324 | connect(lis, SIGNAL(sig_end()) , | 353 | connect(lis, SIGNAL(sig_end()) , |
325 | this, SLOT(slotEnd()) ); | 354 | this, SLOT(slotEnd()) ); |
326 | 355 | ||
327 | 356 | ||
328 | /* reload now */ | 357 | /* reload now */ |
329 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 358 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
330 | } | 359 | } |
331 | 360 | ||
332 | 361 | ||
333 | void PIconView::slotReloadDir() { | 362 | void PIconView::slotReloadDir() { |
334 | slotChangeDir( m_path ); | 363 | slotChangeDir( m_path ); |
335 | } | 364 | } |
336 | 365 | ||
337 | 366 | ||
338 | /* | 367 | /* |
339 | * add files and folders | 368 | * add files and folders |
340 | */ | 369 | */ |
341 | void PIconView::addFolders( const QStringList& lst) { | 370 | void PIconView::addFolders( const QStringList& lst) { |
342 | QStringList::ConstIterator it; | 371 | QStringList::ConstIterator it; |
343 | 372 | ||
344 | for(it=lst.begin(); it != lst.end(); ++it ) | 373 | for(it=lst.begin(); it != lst.end(); ++it ) |
345 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 374 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
346 | 375 | ||
347 | 376 | ||
348 | } | 377 | } |
349 | 378 | ||
350 | void PIconView::addFiles( const QStringList& lst) { | 379 | void PIconView::addFiles( const QStringList& lst) { |
351 | QStringList::ConstIterator it; | 380 | QStringList::ConstIterator it; |
352 | for (it=lst.begin(); it!= lst.end(); ++it ) | 381 | for (it=lst.begin(); it!= lst.end(); ++it ) |
353 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | 382 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); |
354 | 383 | ||
355 | } | 384 | } |
356 | 385 | ||
357 | /* | 386 | /* |
358 | * user clicked on the item. Change dir or view | 387 | * user clicked on the item. Change dir or view |
359 | */ | 388 | */ |
360 | void PIconView::slotClicked(QIconViewItem* _it) { | 389 | void PIconView::slotClicked(QIconViewItem* _it) { |
361 | if(!_it ) | 390 | if(!_it ) |
362 | return; | 391 | return; |
363 | 392 | ||
364 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 393 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
365 | if( it->isDir() ) | 394 | if( it->isDir() ) |
366 | slotChangeDir( it->path() ); | 395 | slotChangeDir( it->path() ); |
367 | else // view image | 396 | else // view image |
368 | slotShowImage(); | 397 | slotShowImage(); |
369 | } | 398 | } |
370 | 399 | ||
371 | /* | 400 | /* |
372 | * got thumb info add to the cache if items is visible | 401 | * got thumb info add to the cache if items is visible |
373 | * we later need update after processing of slave is done | 402 | * we later need update after processing of slave is done |
374 | */ | 403 | */ |
375 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 404 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
376 | IconViewItem* item = g_stringInf[_path]; | 405 | IconViewItem* item = g_stringInf[_path]; |
377 | if (!item ) | 406 | if (!item ) |
378 | return; | 407 | return; |
379 | 408 | ||
380 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 409 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
381 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 410 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
382 | m_updatet = true; | 411 | m_updatet = true; |
383 | 412 | ||
384 | item->setText( str ); | 413 | item->setText( str ); |
385 | g_stringInf.remove( _path ); | 414 | g_stringInf.remove( _path ); |
386 | } | 415 | } |
387 | 416 | ||
388 | /* | 417 | /* |
389 | * got thumbnail and see if it is visible so we need to update later | 418 | * got thumbnail and see if it is visible so we need to update later |
390 | */ | 419 | */ |
391 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 420 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
392 | IconViewItem* item = g_stringPix[_path]; | 421 | IconViewItem* item = g_stringPix[_path]; |
393 | if (!item ) | 422 | if (!item ) |
394 | return; | 423 | return; |
395 | 424 | ||
396 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 425 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
397 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 426 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
398 | m_updatet = true; | 427 | m_updatet = true; |
399 | 428 | ||
400 | if (pix.width()>0) | 429 | if (pix.width()>0) |
401 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 430 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
402 | 431 | ||
403 | 432 | ||
404 | g_stringPix.remove( _path ); | 433 | g_stringPix.remove( _path ); |
405 | } | 434 | } |
406 | 435 | ||
407 | 436 | ||
408 | /* | 437 | /* |
409 | * FIXME rename | 438 | * FIXME rename |
410 | */ | 439 | */ |
411 | void PIconView::slotRename() { | 440 | void PIconView::slotRename() { |
412 | 441 | ||
413 | } | 442 | } |
414 | 443 | ||
415 | 444 | ||
416 | /* | 445 | /* |
417 | * BEAM the current file | 446 | * BEAM the current file |
418 | */ | 447 | */ |
419 | void PIconView::slotBeam() { | 448 | void PIconView::slotBeam() { |
420 | bool isDir; | 449 | bool isDir; |
421 | QString pa = currentFileName( isDir ); | 450 | QString pa = currentFileName( isDir ); |
422 | if ( isDir && pa.isEmpty() ) | 451 | if ( isDir && pa.isEmpty() ) |
423 | return; | 452 | return; |
424 | 453 | ||
425 | Ir* ir = new Ir( this ); | 454 | Ir* ir = new Ir( this ); |
426 | connect( ir, SIGNAL(done(Ir*)), | 455 | connect( ir, SIGNAL(done(Ir*)), |
427 | this, SLOT(slotBeamDone(Ir*))); | 456 | this, SLOT(slotBeamDone(Ir*))); |
428 | ir->send(pa, tr( "Image" ) ); | 457 | ir->send(pa, tr( "Image" ) ); |
429 | } | 458 | } |
430 | 459 | ||
431 | /* | 460 | /* |
432 | * BEAM done clean up | 461 | * BEAM done clean up |
433 | */ | 462 | */ |
434 | void PIconView::slotBeamDone( Ir* ir) { | 463 | void PIconView::slotBeamDone( Ir* ir) { |
435 | delete ir; | 464 | delete ir; |
436 | } | 465 | } |
437 | 466 | ||
438 | void PIconView::slotStart() { | 467 | void PIconView::slotStart() { |
439 | m_view->viewport()->setUpdatesEnabled( false ); | 468 | m_view->viewport()->setUpdatesEnabled( false ); |
440 | } | 469 | } |
441 | 470 | ||
442 | void PIconView::slotEnd() { | 471 | void PIconView::slotEnd() { |
443 | if ( m_updatet ) | 472 | if ( m_updatet ) |
444 | m_view->arrangeItemsInGrid( ); | 473 | m_view->arrangeItemsInGrid( ); |
445 | m_view->viewport()->setUpdatesEnabled( true ); | 474 | m_view->viewport()->setUpdatesEnabled( true ); |
446 | m_updatet = false; | 475 | m_updatet = false; |
447 | } | 476 | } |
448 | 477 | ||
478 | void PIconView::slotShowNext() | ||
479 | { | ||
480 | bool isDir = false; | ||
481 | QString name = nextFileName(isDir); | ||
482 | if (isDir) return; | ||
483 | if (name.isEmpty()) return; | ||
484 | odebug << "Show next: " << name << oendl; | ||
485 | slotShowImage(name); | ||
486 | } | ||
487 | |||
488 | void PIconView::slotShowPrev() | ||
489 | { | ||
490 | bool isDir = false; | ||
491 | QString name = prevFileName(isDir); | ||
492 | if (isDir) return; | ||
493 | if (name.isEmpty()) return; | ||
494 | slotShowImage(name); | ||
495 | } | ||
496 | |||
449 | void PIconView::slotShowImage() | 497 | void PIconView::slotShowImage() |
450 | { | 498 | { |
451 | bool isDir = false; | 499 | bool isDir = false; |
452 | QString name = currentFileName(isDir); | 500 | QString name = currentFileName(isDir); |
453 | if (isDir) return; | 501 | if (isDir) return; |
454 | 502 | ||
455 | slotShowImage( name ); | 503 | slotShowImage( name ); |
456 | } | 504 | } |
457 | void PIconView::slotShowImage( const QString& name) { | 505 | void PIconView::slotShowImage( const QString& name) { |
458 | emit sig_display( name ); | 506 | emit sig_display( name ); |
459 | } | 507 | } |
460 | void PIconView::slotImageInfo() { | 508 | void PIconView::slotImageInfo() { |
461 | bool isDir = false; | 509 | bool isDir = false; |
462 | QString name = currentFileName(isDir); | 510 | QString name = currentFileName(isDir); |
463 | if (isDir) return; | 511 | if (isDir) return; |
464 | 512 | ||
465 | slotImageInfo( name ); | 513 | slotImageInfo( name ); |
466 | } | 514 | } |
467 | 515 | ||
468 | void PIconView::slotImageInfo( const QString& name) { | 516 | void PIconView::slotImageInfo( const QString& name) { |
469 | emit sig_showInfo( name ); | 517 | emit sig_showInfo( name ); |
470 | } | 518 | } |
471 | 519 | ||
472 | 520 | ||
473 | void PIconView::slotChangeMode( int mode ) { | 521 | void PIconView::slotChangeMode( int mode ) { |
474 | if ( mode >= 1 && mode <= 3 ) | 522 | if ( mode >= 1 && mode <= 3 ) |
475 | m_mode = mode; | 523 | m_mode = mode; |
476 | 524 | ||
477 | QIconView::ItemTextPos pos; | 525 | QIconView::ItemTextPos pos; |
478 | switch( m_mode ) { | 526 | switch( m_mode ) { |
479 | case 2: | 527 | case 2: |
480 | pos = QIconView::Bottom; | 528 | pos = QIconView::Bottom; |
481 | break; | 529 | break; |
482 | case 3: | 530 | case 3: |
483 | case 1: | 531 | case 1: |
484 | default: | 532 | default: |
485 | pos = QIconView::Right; | 533 | pos = QIconView::Right; |
486 | break; | 534 | break; |
487 | } | 535 | } |
488 | m_view->setItemTextPos( pos ); | 536 | m_view->setItemTextPos( pos ); |
489 | 537 | ||
490 | calculateGrid(); | 538 | calculateGrid(); |
491 | slotReloadDir(); | 539 | slotReloadDir(); |
492 | } | 540 | } |
493 | 541 | ||
494 | 542 | ||
495 | void PIconView::resizeEvent( QResizeEvent* re ) { | 543 | void PIconView::resizeEvent( QResizeEvent* re ) { |
496 | QVBox::resizeEvent( re ); | 544 | QVBox::resizeEvent( re ); |
497 | calculateGrid(); | 545 | calculateGrid(); |
498 | } | 546 | } |
499 | 547 | ||
500 | 548 | ||
501 | void PIconView::calculateGrid() { | 549 | void PIconView::calculateGrid() { |
502 | 550 | ||
503 | } | 551 | } |
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index 903c4fd..14ad168 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h | |||
@@ -1,89 +1,95 @@ | |||
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_ICON_VIEW_H | 6 | #ifndef PHUNK_ICON_VIEW_H |
7 | #define PHUNK_ICON_VIEW_H | 7 | #define PHUNK_ICON_VIEW_H |
8 | 8 | ||
9 | #include <qvbox.h> | 9 | #include <qvbox.h> |
10 | 10 | ||
11 | 11 | ||
12 | class QIconView; | 12 | class QIconView; |
13 | class QIconViewItem; | 13 | class QIconViewItem; |
14 | class QComboBox; | 14 | class QComboBox; |
15 | class PIconViewItem; | 15 | class PIconViewItem; |
16 | class PDirLister; | 16 | class PDirLister; |
17 | class Ir; | 17 | class Ir; |
18 | 18 | ||
19 | namespace Opie { | 19 | namespace Opie { |
20 | namespace Core{ | 20 | namespace Core{ |
21 | class OConfig; | 21 | class OConfig; |
22 | class OKeyConfigManager; | 22 | class OKeyConfigManager; |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | class PIconView : public QVBox { | 26 | class PIconView : public QVBox { |
27 | Q_OBJECT | 27 | Q_OBJECT |
28 | friend class PIconViewItem; | 28 | friend class PIconViewItem; |
29 | enum ActionIds { | 29 | enum ActionIds { |
30 | BeamItem, DeleteItem, ViewItem, InfoItem | 30 | BeamItem, DeleteItem, ViewItem, InfoItem |
31 | }; | 31 | }; |
32 | public: | 32 | public: |
33 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); | 33 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); |
34 | ~PIconView(); | 34 | ~PIconView(); |
35 | void resetView(); | 35 | void resetView(); |
36 | Opie::Core::OKeyConfigManager* manager(); | 36 | Opie::Core::OKeyConfigManager* manager(); |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | void sig_showInfo( const QString& ); | 39 | void sig_showInfo( const QString& ); |
40 | void sig_display( const QString& ); | 40 | void sig_display( const QString& ); |
41 | 41 | ||
42 | public slots: | ||
43 | virtual void slotShowNext(); | ||
44 | virtual void slotShowPrev(); | ||
45 | |||
42 | protected: | 46 | protected: |
43 | void resizeEvent( QResizeEvent* ); | 47 | void resizeEvent( QResizeEvent* ); |
44 | 48 | ||
45 | private: | 49 | private: |
46 | void initKeys(); | 50 | void initKeys(); |
47 | QString currentFileName(bool &isDir)const; | 51 | QString currentFileName(bool &isDir)const; |
52 | QString nextFileName(bool &isDir)const; | ||
53 | QString prevFileName(bool &isDir)const; | ||
48 | void loadViews(); | 54 | void loadViews(); |
49 | void calculateGrid(); | 55 | void calculateGrid(); |
50 | 56 | ||
51 | private slots: | 57 | private slots: |
52 | void slotDirUp(); | 58 | void slotDirUp(); |
53 | void slotChangeDir(const QString&); | 59 | void slotChangeDir(const QString&); |
54 | void slotTrash(); | 60 | void slotTrash(); |
55 | void slotViewChanged( int ); | 61 | void slotViewChanged( int ); |
56 | void slotReloadDir(); | 62 | void slotReloadDir(); |
57 | void slotRename(); | 63 | void slotRename(); |
58 | void slotBeam(); | 64 | void slotBeam(); |
59 | void slotBeamDone( Ir* ); | 65 | void slotBeamDone( Ir* ); |
60 | 66 | ||
61 | void slotShowImage(); | 67 | void slotShowImage(); |
62 | void slotShowImage( const QString& ); | 68 | void slotShowImage( const QString& ); |
63 | void slotImageInfo(); | 69 | void slotImageInfo(); |
64 | void slotImageInfo( const QString& ); | 70 | void slotImageInfo( const QString& ); |
65 | 71 | ||
66 | void slotStart(); | 72 | void slotStart(); |
67 | void slotEnd(); | 73 | void slotEnd(); |
68 | 74 | ||
69 | /* for performance reasons make it inline in the future */ | 75 | /* for performance reasons make it inline in the future */ |
70 | void addFolders( const QStringList& ); | 76 | void addFolders( const QStringList& ); |
71 | void addFiles( const QStringList& ); | 77 | void addFiles( const QStringList& ); |
72 | void slotClicked(QIconViewItem* ); | 78 | void slotClicked(QIconViewItem* ); |
73 | 79 | ||
74 | /**/ | 80 | /**/ |
75 | void slotThumbInfo(const QString&, const QString&); | 81 | void slotThumbInfo(const QString&, const QString&); |
76 | void slotThumbNail(const QString&, const QPixmap&); | 82 | void slotThumbNail(const QString&, const QPixmap&); |
77 | 83 | ||
78 | void slotChangeMode( int ); | 84 | void slotChangeMode( int ); |
79 | private: | 85 | private: |
80 | Opie::Core::OKeyConfigManager *m_viewManager; | 86 | Opie::Core::OKeyConfigManager *m_viewManager; |
81 | Opie::Core::OConfig *m_cfg; | 87 | Opie::Core::OConfig *m_cfg; |
82 | QComboBox* m_views; | 88 | QComboBox* m_views; |
83 | QIconView* m_view; | 89 | QIconView* m_view; |
84 | QString m_path; | 90 | QString m_path; |
85 | bool m_updatet : 1; | 91 | bool m_updatet : 1; |
86 | int m_mode; | 92 | int m_mode; |
87 | }; | 93 | }; |
88 | 94 | ||
89 | #endif | 95 | #endif |
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp index db3ae74..aa2b9bc 100644 --- a/noncore/graphics/opie-eye/gui/imageview.cpp +++ b/noncore/graphics/opie-eye/gui/imageview.cpp | |||
@@ -1,60 +1,85 @@ | |||
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 | 8 | ||
9 | using namespace Opie::Core; | 9 | using namespace Opie::Core; |
10 | 10 | ||
11 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) | 11 | ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl ) |
12 | : Opie::MM::OImageScrollView(parent,name,fl) | 12 | : Opie::MM::OImageScrollView(parent,name,fl) |
13 | { | 13 | { |
14 | m_viewManager = 0; | 14 | m_viewManager = 0; |
15 | m_cfg = cfg; | 15 | m_cfg = cfg; |
16 | initKeys(); | 16 | initKeys(); |
17 | } | 17 | } |
18 | 18 | ||
19 | ImageView::~ImageView() | 19 | ImageView::~ImageView() |
20 | { | 20 | { |
21 | if (m_viewManager) { | 21 | if (m_viewManager) { |
22 | delete m_viewManager; | 22 | delete m_viewManager; |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | Opie::Core::OKeyConfigManager* ImageView::manager() | 26 | Opie::Core::OKeyConfigManager* ImageView::manager() |
27 | { | 27 | { |
28 | if (!m_viewManager) { | 28 | if (!m_viewManager) { |
29 | initKeys(); | 29 | initKeys(); |
30 | } | 30 | } |
31 | return m_viewManager; | 31 | return m_viewManager; |
32 | } | 32 | } |
33 | 33 | ||
34 | void ImageView::initKeys() | 34 | void ImageView::initKeys() |
35 | { | 35 | { |
36 | odebug << "init imageview keys" << oendl; | 36 | odebug << "init imageview keys" << oendl; |
37 | if (!m_cfg) { | 37 | if (!m_cfg) { |
38 | m_cfg = new Opie::Core::OConfig("phunkview"); | 38 | m_cfg = new Opie::Core::OConfig("phunkview"); |
39 | m_cfg->setGroup("image_view_keys" ); | 39 | m_cfg->setGroup("image_view_keys" ); |
40 | } | 40 | } |
41 | Opie::Core::OKeyPair::List lst; | 41 | Opie::Core::OKeyPair::List lst; |
42 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); | 42 | lst.append( Opie::Core::OKeyPair::upArrowKey() ); |
43 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); | 43 | lst.append( Opie::Core::OKeyPair::downArrowKey() ); |
44 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); | 44 | lst.append( Opie::Core::OKeyPair::leftArrowKey() ); |
45 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); | 45 | lst.append( Opie::Core::OKeyPair::rightArrowKey() ); |
46 | 46 | ||
47 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", | 47 | m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys", |
48 | lst, false,this, "image_view_keys" ); | 48 | lst, false,this, "image_view_keys" ); |
49 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", | 49 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo", |
50 | Resource::loadPixmap("1to1"), ViewInfo, | 50 | Resource::loadPixmap("1to1"), ViewInfo, |
51 | Opie::Core::OKeyPair(Qt::Key_I,Qt::ShiftButton), | 51 | Opie::Core::OKeyPair(Qt::Key_I,Qt::ShiftButton), |
52 | this, SLOT(slotShowImageInfo()))); | 52 | this, SLOT(slotShowImageInfo()))); |
53 | #if 0 | ||
54 | m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Next image"), "nextimage", | ||
55 | Resource::loadPixmap("next"), ViewInfo, | ||
56 | Opie::Core::OKeyPair(Qt::Key_N,0), | ||
57 | this, SLOT(slotDispNext()))); | ||
58 | #endif | ||
53 | m_viewManager->handleWidget( this ); | 59 | m_viewManager->handleWidget( this ); |
54 | m_viewManager->load(); | 60 | m_viewManager->load(); |
55 | } | 61 | } |
56 | 62 | ||
63 | void ImageView::keyReleaseEvent(QKeyEvent * e) | ||
64 | { | ||
65 | if (!e || e->state()!=0) { | ||
66 | return; | ||
67 | } | ||
68 | if (e->key()==Qt::Key_N) slotDispNext(); | ||
69 | if (e->key()==Qt::Key_P) slotDispPrev(); | ||
70 | } | ||
71 | |||
72 | void ImageView::slotDispNext() | ||
73 | { | ||
74 | emit dispNext(); | ||
75 | } | ||
76 | |||
77 | void ImageView::slotDispPrev() | ||
78 | { | ||
79 | emit dispPrev(); | ||
80 | } | ||
81 | |||
57 | void ImageView::slotShowImageInfo() | 82 | void ImageView::slotShowImageInfo() |
58 | { | 83 | { |
59 | emit dispImageInfo(m_lastName); | 84 | emit dispImageInfo(m_lastName); |
60 | } | 85 | } |
diff --git a/noncore/graphics/opie-eye/gui/imageview.h b/noncore/graphics/opie-eye/gui/imageview.h index 1790c4f..f467f00 100644 --- a/noncore/graphics/opie-eye/gui/imageview.h +++ b/noncore/graphics/opie-eye/gui/imageview.h | |||
@@ -1,36 +1,41 @@ | |||
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 | namespace Opie { | 6 | namespace Opie { |
7 | namespace Core { | 7 | namespace Core { |
8 | class OConfig; | 8 | class OConfig; |
9 | class OKeyConfigManager; | 9 | class OKeyConfigManager; |
10 | } | 10 | } |
11 | } | 11 | } |
12 | 12 | ||
13 | class ImageView:public Opie::MM::OImageScrollView | 13 | class ImageView:public Opie::MM::OImageScrollView |
14 | { | 14 | { |
15 | Q_OBJECT | 15 | Q_OBJECT |
16 | 16 | ||
17 | enum ActionIds { | 17 | enum ActionIds { |
18 | ViewInfo | 18 | ViewInfo |
19 | }; | 19 | }; |
20 | 20 | ||
21 | public: | 21 | public: |
22 | ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 ); | 22 | ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name = 0, WFlags fl = 0 ); |
23 | virtual ~ImageView(); | 23 | virtual ~ImageView(); |
24 | Opie::Core::OKeyConfigManager* manager(); | 24 | Opie::Core::OKeyConfigManager* manager(); |
25 | 25 | ||
26 | signals: | 26 | signals: |
27 | void dispImageInfo(const QString&); | 27 | void dispImageInfo(const QString&); |
28 | void dispNext(); | ||
29 | void dispPrev(); | ||
28 | 30 | ||
29 | protected: | 31 | protected: |
30 | Opie::Core::OConfig * m_cfg; | 32 | Opie::Core::OConfig * m_cfg; |
31 | Opie::Core::OKeyConfigManager*m_viewManager; | 33 | Opie::Core::OKeyConfigManager*m_viewManager; |
32 | void initKeys(); | 34 | void initKeys(); |
33 | protected slots: | 35 | protected slots: |
34 | virtual void slotShowImageInfo(); | 36 | virtual void slotShowImageInfo(); |
37 | virtual void slotDispNext(); | ||
38 | virtual void slotDispPrev(); | ||
39 | virtual void keyReleaseEvent(QKeyEvent * e); | ||
35 | }; | 40 | }; |
36 | #endif | 41 | #endif |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 09f562a..57be247 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -1,327 +1,329 @@ | |||
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/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | 26 | ||
27 | #include <qtoolbar.h> | 27 | #include <qtoolbar.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qdialog.h> | 30 | #include <qdialog.h> |
31 | #include <qmap.h> | 31 | #include <qmap.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | 33 | ||
34 | 34 | ||
35 | 35 | ||
36 | 36 | ||
37 | OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) | 37 | OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" ) |
38 | 38 | ||
39 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 39 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
40 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) | 40 | : QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 ) |
41 | { | 41 | { |
42 | setCaption( QObject::tr("Opie Eye Caramba" ) ); | 42 | setCaption( QObject::tr("Opie Eye Caramba" ) ); |
43 | m_cfg = new Opie::Core::OConfig("phunkview"); | 43 | m_cfg = new Opie::Core::OConfig("phunkview"); |
44 | m_cfg->setGroup("Zecke_view" ); | 44 | m_cfg->setGroup("Zecke_view" ); |
45 | // qDebug( "Process-wide OApplication object @ %0x", oApp ); | 45 | // qDebug( "Process-wide OApplication object @ %0x", oApp ); |
46 | /* | 46 | /* |
47 | * Initialize ToolBar and IconView | 47 | * Initialize ToolBar and IconView |
48 | * And Connect Them | 48 | * And Connect Them |
49 | */ | 49 | */ |
50 | QToolBar *bar = new QToolBar( this ); | 50 | QToolBar *bar = new QToolBar( this ); |
51 | bar->setHorizontalStretchable( true ); | 51 | bar->setHorizontalStretchable( true ); |
52 | setToolBarsMovable( false ); | 52 | setToolBarsMovable( false ); |
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 | connect(m_view, SIGNAL(sig_display(const QString&)), | 60 | connect(m_view, SIGNAL(sig_display(const QString&)), |
61 | this, SLOT(slotDisplay(const QString&))); | 61 | this, SLOT(slotDisplay(const QString&))); |
62 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), | 62 | connect(m_view, SIGNAL(sig_showInfo(const QString&)), |
63 | this, SLOT(slotShowInfo(const QString&)) ); | 63 | this, SLOT(slotShowInfo(const QString&)) ); |
64 | 64 | ||
65 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); | 65 | m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce); |
66 | 66 | ||
67 | QToolButton *btn = new QToolButton( bar ); | 67 | QToolButton *btn = new QToolButton( bar ); |
68 | btn->setIconSet( Resource::loadIconSet( "up" ) ); | 68 | btn->setIconSet( Resource::loadIconSet( "up" ) ); |
69 | connect( btn, SIGNAL(clicked()), | 69 | connect( btn, SIGNAL(clicked()), |
70 | m_view, SLOT(slotDirUp()) ); | 70 | m_view, SLOT(slotDirUp()) ); |
71 | 71 | ||
72 | btn = new PFileSystem( bar ); | 72 | btn = new PFileSystem( bar ); |
73 | connect( btn, SIGNAL( changeDir( const QString& ) ), | 73 | connect( btn, SIGNAL( changeDir( const QString& ) ), |
74 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 74 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
75 | 75 | ||
76 | btn = new QToolButton( bar ); | 76 | btn = new QToolButton( bar ); |
77 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); | 77 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); |
78 | connect( btn, SIGNAL(clicked()), | 78 | connect( btn, SIGNAL(clicked()), |
79 | m_view, SLOT(slotRename()) ); | 79 | m_view, SLOT(slotRename()) ); |
80 | 80 | ||
81 | if ( Ir::supported() ) { | 81 | if ( Ir::supported() ) { |
82 | btn = new QToolButton( bar ); | 82 | btn = new QToolButton( bar ); |
83 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); | 83 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); |
84 | connect( btn, SIGNAL(clicked()), | 84 | connect( btn, SIGNAL(clicked()), |
85 | m_view, SLOT(slotBeam()) ); | 85 | m_view, SLOT(slotBeam()) ); |
86 | } | 86 | } |
87 | 87 | ||
88 | btn = new QToolButton( bar ); | 88 | btn = new QToolButton( bar ); |
89 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); | 89 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); |
90 | connect( btn, SIGNAL(clicked() ), | 90 | connect( btn, SIGNAL(clicked() ), |
91 | m_view, SLOT(slotTrash() ) ); | 91 | m_view, SLOT(slotTrash() ) ); |
92 | 92 | ||
93 | 93 | ||
94 | btn = new ViewModeButton( bar ); | 94 | btn = new ViewModeButton( bar ); |
95 | connect( btn, SIGNAL(changeMode(int)), | 95 | connect( btn, SIGNAL(changeMode(int)), |
96 | m_view, SLOT(slotChangeMode(int))); | 96 | m_view, SLOT(slotChangeMode(int))); |
97 | 97 | ||
98 | btn = new QToolButton( bar ); | 98 | btn = new QToolButton( bar ); |
99 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); | 99 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); |
100 | connect( btn, SIGNAL(clicked() ), | 100 | connect( btn, SIGNAL(clicked() ), |
101 | this, SLOT(slotConfig() ) ); | 101 | this, SLOT(slotConfig() ) ); |
102 | 102 | ||
103 | rotateButton = new QToolButton(bar); | 103 | rotateButton = new QToolButton(bar); |
104 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); | 104 | rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) ); |
105 | rotateButton->setToggleButton(true); | 105 | rotateButton->setToggleButton(true); |
106 | 106 | ||
107 | odebug << "Mode = " << m_stack->mode() << oendl; | 107 | odebug << "Mode = " << m_stack->mode() << oendl; |
108 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { | 108 | if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) { |
109 | rotateButton->setOn(true); | 109 | rotateButton->setOn(true); |
110 | autoRotate = true; | 110 | autoRotate = true; |
111 | } else { | 111 | } else { |
112 | rotateButton->setOn(false); | 112 | rotateButton->setOn(false); |
113 | autoRotate = false; | 113 | autoRotate = false; |
114 | } | 114 | } |
115 | 115 | ||
116 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); | 116 | connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool))); |
117 | 117 | ||
118 | btn = new QToolButton(bar); | 118 | btn = new QToolButton(bar); |
119 | btn->setIconSet( Resource::loadIconSet( "1to1" ) ); | 119 | btn->setIconSet( Resource::loadIconSet( "1to1" ) ); |
120 | btn->setToggleButton(true); | 120 | btn->setToggleButton(true); |
121 | btn->setOn(false); | 121 | btn->setOn(false); |
122 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); | 122 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool))); |
123 | autoScale = true; | 123 | autoScale = true; |
124 | 124 | ||
125 | btn = new QToolButton(bar); | 125 | btn = new QToolButton(bar); |
126 | btn->setIconSet( Resource::loadIconSet( "mag" ) ); | 126 | btn->setIconSet( Resource::loadIconSet( "mag" ) ); |
127 | btn->setToggleButton(true); | 127 | btn->setToggleButton(true); |
128 | btn->setOn(true); | 128 | btn->setOn(true); |
129 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); | 129 | connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool))); |
130 | zoomerOn = true; | 130 | zoomerOn = true; |
131 | } | 131 | } |
132 | 132 | ||
133 | PMainWindow::~PMainWindow() { | 133 | PMainWindow::~PMainWindow() { |
134 | odebug << "Shutting down" << oendl; | 134 | odebug << "Shutting down" << oendl; |
135 | } | 135 | } |
136 | 136 | ||
137 | void PMainWindow::slotZoomerToggled(bool how) | 137 | void PMainWindow::slotZoomerToggled(bool how) |
138 | { | 138 | { |
139 | zoomerOn = how; | 139 | zoomerOn = how; |
140 | if (m_disp) { | 140 | if (m_disp) { |
141 | m_disp->setShowZoomer(zoomerOn); | 141 | m_disp->setShowZoomer(zoomerOn); |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | void PMainWindow::slotRotateToggled(bool how) | 145 | void PMainWindow::slotRotateToggled(bool how) |
146 | { | 146 | { |
147 | autoRotate = how; | 147 | autoRotate = how; |
148 | if (m_disp) { | 148 | if (m_disp) { |
149 | m_disp->setAutoRotate(how); | 149 | m_disp->setAutoRotate(how); |
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | void PMainWindow::slotScaleToggled(bool how) | 153 | void PMainWindow::slotScaleToggled(bool how) |
154 | { | 154 | { |
155 | autoScale = !how; | 155 | autoScale = !how; |
156 | if (m_disp) { | 156 | if (m_disp) { |
157 | m_disp->setAutoScale(autoScale); | 157 | m_disp->setAutoScale(autoScale); |
158 | } | 158 | } |
159 | if (!autoScale && autoRotate) { | 159 | if (!autoScale && autoRotate) { |
160 | rotateButton->setOn(false); | 160 | rotateButton->setOn(false); |
161 | } | 161 | } |
162 | rotateButton->setEnabled(!how); | 162 | rotateButton->setEnabled(!how); |
163 | } | 163 | } |
164 | 164 | ||
165 | void PMainWindow::slotConfig() { | 165 | void PMainWindow::slotConfig() { |
166 | /* | 166 | /* |
167 | * have a tab with the possible views | 167 | * have a tab with the possible views |
168 | * a tab for globals image cache size.. scaled loading | 168 | * a tab for globals image cache size.. scaled loading |
169 | * and one tab for the KeyConfigs | 169 | * and one tab for the KeyConfigs |
170 | */ | 170 | */ |
171 | QDialog dlg(this, 0, true); | 171 | QDialog dlg(this, 0, true); |
172 | dlg.setCaption( tr("Phunk View - Config" ) ); | 172 | dlg.setCaption( tr("Phunk View - Config" ) ); |
173 | 173 | ||
174 | QHBoxLayout *lay = new QHBoxLayout(&dlg); | 174 | QHBoxLayout *lay = new QHBoxLayout(&dlg); |
175 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); | 175 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); |
176 | lay->addWidget( wid ); | 176 | lay->addWidget( wid ); |
177 | ViewMap *vM = viewMap(); | 177 | ViewMap *vM = viewMap(); |
178 | ViewMap::Iterator _it = vM->begin(); | 178 | ViewMap::Iterator _it = vM->begin(); |
179 | QMap<PDirView*, QWidget*> lst; | 179 | QMap<PDirView*, QWidget*> lst; |
180 | 180 | ||
181 | for( ; _it != vM->end(); ++_it ) { | 181 | for( ; _it != vM->end(); ++_it ) { |
182 | PDirView *view = (_it.data())(*m_cfg); | 182 | PDirView *view = (_it.data())(*m_cfg); |
183 | PInterfaceInfo *inf = view->interfaceInfo(); | 183 | PInterfaceInfo *inf = view->interfaceInfo(); |
184 | QWidget *_wid = inf->configWidget( *m_cfg ); | 184 | QWidget *_wid = inf->configWidget( *m_cfg ); |
185 | _wid->reparent(wid, QPoint() ); | 185 | _wid->reparent(wid, QPoint() ); |
186 | lst.insert( view, _wid ); | 186 | lst.insert( view, _wid ); |
187 | wid->addTab( _wid, "fileopen", inf->name() ); | 187 | wid->addTab( _wid, "fileopen", inf->name() ); |
188 | } | 188 | } |
189 | 189 | ||
190 | /* | 190 | /* |
191 | * Add the KeyConfigWidget | 191 | * Add the KeyConfigWidget |
192 | */ | 192 | */ |
193 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); | 193 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); |
194 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | 194 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); |
195 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); | 195 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); |
196 | 196 | ||
197 | if ( !m_info ) { | 197 | if ( !m_info ) { |
198 | initInfo(); | 198 | initInfo(); |
199 | } | 199 | } |
200 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); | 200 | keyWid->insert( tr("Imageinfo Keyboard Actions"), m_info->manager() ); |
201 | 201 | ||
202 | if ( !m_disp ) { | 202 | if ( !m_disp ) { |
203 | initDisp(); | 203 | initDisp(); |
204 | } | 204 | } |
205 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); | 205 | keyWid->insert( tr("Imageview Keyboard Actions"), m_disp->manager() ); |
206 | 206 | ||
207 | keyWid->load(); | 207 | keyWid->load(); |
208 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); | 208 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); |
209 | 209 | ||
210 | 210 | ||
211 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 211 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
212 | 212 | ||
213 | /* | 213 | /* |
214 | * clean up | 214 | * clean up |
215 | *apply changes | 215 | *apply changes |
216 | */ | 216 | */ |
217 | 217 | ||
218 | QMap<PDirView*, QWidget*>::Iterator it; | 218 | QMap<PDirView*, QWidget*>::Iterator it; |
219 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 219 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
220 | if ( act ) | 220 | if ( act ) |
221 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); | 221 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); |
222 | delete it.key(); | 222 | delete it.key(); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | if ( act ) { | 226 | if ( act ) { |
227 | m_view->resetView(); | 227 | m_view->resetView(); |
228 | keyWid->save(); | 228 | keyWid->save(); |
229 | m_disp->manager()->save(); | 229 | m_disp->manager()->save(); |
230 | m_info->manager()->save(); | 230 | m_info->manager()->save(); |
231 | m_view->manager()->save(); | 231 | m_view->manager()->save(); |
232 | } | 232 | } |
233 | delete keyWid; | 233 | delete keyWid; |
234 | } | 234 | } |
235 | 235 | ||
236 | /* | 236 | /* |
237 | * create a new image info component | 237 | * create a new image info component |
238 | * and detach the current one | 238 | * and detach the current one |
239 | * we will make the other delete on exit | 239 | * we will make the other delete on exit |
240 | */ | 240 | */ |
241 | template<class T> | 241 | template<class T> |
242 | void PMainWindow::initT( const char* name, T** ptr, int id) { | 242 | void PMainWindow::initT( const char* name, T** ptr, int id) { |
243 | if ( *ptr ) { | 243 | if ( *ptr ) { |
244 | (*ptr)->disconnect(this, SLOT(slotReturn())); | 244 | (*ptr)->disconnect(this, SLOT(slotReturn())); |
245 | (*ptr)->setDestructiveClose(); | 245 | (*ptr)->setDestructiveClose(); |
246 | m_stack->removeWidget( *ptr ); | 246 | m_stack->removeWidget( *ptr ); |
247 | } | 247 | } |
248 | *ptr = new T(m_cfg, m_stack, name ); | 248 | *ptr = new T(m_cfg, m_stack, name ); |
249 | m_stack->addWidget( *ptr, id ); | 249 | m_stack->addWidget( *ptr, id ); |
250 | 250 | ||
251 | connect(*ptr, SIGNAL(sig_return()), | 251 | connect(*ptr, SIGNAL(sig_return()), |
252 | this,SLOT(slotReturn())); | 252 | this,SLOT(slotReturn())); |
253 | 253 | ||
254 | } | 254 | } |
255 | void PMainWindow::initInfo() { | 255 | void PMainWindow::initInfo() { |
256 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); | 256 | initT<imageinfo>( "Image Info", &m_info, ImageInfo ); |
257 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); | 257 | connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&))); |
258 | } | 258 | } |
259 | void PMainWindow::initDisp() { | 259 | void PMainWindow::initDisp() { |
260 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); | 260 | initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay ); |
261 | if (m_disp) { | 261 | if (m_disp) { |
262 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { | 262 | if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) { |
263 | m_disp->setMinimumSize(QApplication::desktop()->size()/2); | 263 | m_disp->setMinimumSize(QApplication::desktop()->size()/2); |
264 | } | 264 | } |
265 | m_disp->setAutoScale(autoScale); | 265 | m_disp->setAutoScale(autoScale); |
266 | m_disp->setAutoRotate(autoRotate); | 266 | m_disp->setAutoRotate(autoRotate); |
267 | m_disp->setShowZoomer(zoomerOn); | 267 | m_disp->setShowZoomer(zoomerOn); |
268 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); | 268 | connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&))); |
269 | connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext())); | ||
270 | connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev())); | ||
269 | } | 271 | } |
270 | } | 272 | } |
271 | 273 | ||
272 | /** | 274 | /** |
273 | * With big Screen the plan could be to 'detach' the image | 275 | * With big Screen the plan could be to 'detach' the image |
274 | * window if visible and to create a ne wone | 276 | * window if visible and to create a ne wone |
275 | * init* already supports it but I make no use of it for | 277 | * init* already supports it but I make no use of it for |
276 | * now. We set filename and raise | 278 | * now. We set filename and raise |
277 | * | 279 | * |
278 | * ### FIXME and talk to alwin | 280 | * ### FIXME and talk to alwin |
279 | */ | 281 | */ |
280 | void PMainWindow::slotShowInfo( const QString& inf ) { | 282 | void PMainWindow::slotShowInfo( const QString& inf ) { |
281 | if ( !m_info ) { | 283 | if ( !m_info ) { |
282 | initInfo(); | 284 | initInfo(); |
283 | } | 285 | } |
284 | m_info->setPath( inf ); | 286 | m_info->setPath( inf ); |
285 | m_stack->raiseWidget( ImageInfo ); | 287 | m_stack->raiseWidget( ImageInfo ); |
286 | } | 288 | } |
287 | 289 | ||
288 | void PMainWindow::slotDisplay( const QString& inf ) { | 290 | void PMainWindow::slotDisplay( const QString& inf ) { |
289 | if ( !m_disp ) { | 291 | if ( !m_disp ) { |
290 | initDisp(); | 292 | initDisp(); |
291 | } | 293 | } |
292 | m_disp->setImage( inf ); | 294 | m_disp->setImage( inf ); |
293 | m_stack->raiseWidget( ImageDisplay ); | 295 | m_stack->raiseWidget( ImageDisplay ); |
294 | } | 296 | } |
295 | 297 | ||
296 | void PMainWindow::slotReturn() { | 298 | void PMainWindow::slotReturn() { |
297 | raiseIconView(); | 299 | raiseIconView(); |
298 | } | 300 | } |
299 | 301 | ||
300 | 302 | ||
301 | void PMainWindow::closeEvent( QCloseEvent* ev ) { | 303 | void PMainWindow::closeEvent( QCloseEvent* ev ) { |
302 | /* | 304 | /* |
303 | * return from view | 305 | * return from view |
304 | * or properly quit | 306 | * or properly quit |
305 | */ | 307 | */ |
306 | if ( m_stack->visibleWidget() == m_info || | 308 | if ( m_stack->visibleWidget() == m_info || |
307 | m_stack->visibleWidget() == m_disp ) { | 309 | m_stack->visibleWidget() == m_disp ) { |
308 | raiseIconView(); | 310 | raiseIconView(); |
309 | ev->ignore(); | 311 | ev->ignore(); |
310 | return; | 312 | return; |
311 | } | 313 | } |
312 | ev->accept(); | 314 | ev->accept(); |
313 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); | 315 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows())); |
314 | } | 316 | } |
315 | 317 | ||
316 | void PMainWindow::raiseIconView() { | 318 | void PMainWindow::raiseIconView() { |
317 | m_stack->raiseWidget( IconView ); | 319 | m_stack->raiseWidget( IconView ); |
318 | } | 320 | } |
319 | 321 | ||
320 | void PMainWindow::setDocument( const QString& showImg ) { | 322 | void PMainWindow::setDocument( const QString& showImg ) { |
321 | QString file = showImg; | 323 | QString file = showImg; |
322 | DocLnk lnk(showImg); | 324 | DocLnk lnk(showImg); |
323 | if (lnk.isValid() ) | 325 | if (lnk.isValid() ) |
324 | file = lnk.file(); | 326 | file = lnk.file(); |
325 | 327 | ||
326 | slotDisplay( file ); | 328 | slotDisplay( file ); |
327 | } | 329 | } |