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