author | zecke <zecke> | 2004-04-02 13:34:44 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-02 13:34:44 (UTC) |
commit | 96105800596dfbd6b828ef47dd7774769f1e3ef3 (patch) (unidiff) | |
tree | e8862c0d4f8cc6fb3a90da0856857cd21010ba8b | |
parent | 02696a8b22d86f74a4f123edcd24bfa32dd00441 (diff) | |
download | opie-96105800596dfbd6b828ef47dd7774769f1e3ef3.zip opie-96105800596dfbd6b828ef47dd7774769f1e3ef3.tar.gz opie-96105800596dfbd6b828ef47dd7774769f1e3ef3.tar.bz2 |
-Use OConfig
-Use OKeyConfigManager/Widget for Keyboard short cuts
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 63 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 26 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 64 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.h | 13 |
4 files changed, 139 insertions, 27 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index 74a8d0f..b3f0006 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -1,319 +1,378 @@ | |||
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 | 9 | ||
10 | #include <iface/dirview.h> | 10 | #include <iface/dirview.h> |
11 | #include <iface/dirlister.h> | 11 | #include <iface/dirlister.h> |
12 | 12 | ||
13 | #include <qpe/config.h> | 13 | #include <opie2/oconfig.h> |
14 | #include <opie2/okeyconfigwidget.h> | ||
15 | |||
14 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
15 | #include <qpe/qpemessagebox.h> | 17 | #include <qpe/qpemessagebox.h> |
16 | #include <qpe/ir.h> | 18 | #include <qpe/ir.h> |
17 | #include <qpe/qcopenvelope_qws.h> | 19 | #include <qpe/qcopenvelope_qws.h> |
18 | 20 | ||
21 | |||
19 | #include <qiconview.h> | 22 | #include <qiconview.h> |
20 | #include <qlabel.h> | 23 | #include <qlabel.h> |
21 | #include <qhbox.h> | 24 | #include <qhbox.h> |
22 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
23 | #include <qdir.h> | 26 | #include <qdir.h> |
24 | #include <qapplication.h> | 27 | #include <qapplication.h> |
25 | #include <qmainwindow.h> | 28 | #include <qmainwindow.h> |
26 | #include <qtimer.h> | 29 | #include <qtimer.h> |
27 | #include <qstyle.h> | 30 | #include <qstyle.h> |
28 | 31 | ||
29 | 32 | ||
33 | using Opie::Ui::OKeyConfigItem; | ||
30 | 34 | ||
31 | namespace { | 35 | namespace { |
32 | QPixmap* _dirPix = 0; | 36 | QPixmap* _dirPix = 0; |
33 | QPixmap* _unkPix = 0; | 37 | QPixmap* _unkPix = 0; |
34 | class IconViewItem : public QIconViewItem { | 38 | class IconViewItem : public QIconViewItem { |
35 | public: | 39 | public: |
36 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 40 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); |
37 | QPixmap* pixmap()const; | 41 | QPixmap* pixmap()const; |
38 | QString path()const { return m_path; } | 42 | QString path()const { return m_path; } |
39 | bool isDir()const { return m_isDir; } | 43 | bool isDir()const { return m_isDir; } |
40 | void setText( const QString& ); | 44 | void setText( const QString& ); |
41 | void reCalc(); | 45 | void reCalc(); |
42 | private: | 46 | private: |
43 | mutable QPixmap* m_pix; | 47 | mutable QPixmap* m_pix; |
44 | QString m_path; | 48 | QString m_path; |
45 | bool m_isDir : 1; | 49 | bool m_isDir : 1; |
46 | bool m_noInfo :1; | 50 | bool m_noInfo :1; |
47 | }; | 51 | }; |
48 | 52 | ||
49 | 53 | ||
50 | /* | 54 | /* |
51 | * If we request an Image or String | 55 | * If we request an Image or String |
52 | * we add it to the map | 56 | * we add it to the map |
53 | */ | 57 | */ |
54 | QMap<QString, IconViewItem*> g_stringInf; | 58 | QMap<QString, IconViewItem*> g_stringInf; |
55 | QMap<QString, IconViewItem*> g_stringPix; | 59 | QMap<QString, IconViewItem*> g_stringPix; |
56 | 60 | ||
57 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 61 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
58 | const QString& name, bool isDir ) | 62 | const QString& name, bool isDir ) |
59 | : QIconViewItem( view ), m_path( path ), m_isDir( isDir ), | 63 | : QIconViewItem( view ), m_path( path ), m_isDir( isDir ), |
60 | m_noInfo( false ) | 64 | m_noInfo( false ) |
61 | { | 65 | { |
62 | QIconViewItem::setText( name ); | 66 | QIconViewItem::setText( name ); |
63 | if ( isDir && !_dirPix ) | 67 | if ( isDir && !_dirPix ) |
64 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 68 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); |
65 | else if ( !isDir && !_unkPix ) | 69 | else if ( !isDir && !_unkPix ) |
66 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 70 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); |
67 | } | 71 | } |
68 | inline QPixmap* IconViewItem::pixmap()const { | 72 | inline QPixmap* IconViewItem::pixmap()const { |
69 | if ( m_isDir ) | 73 | if ( m_isDir ) |
70 | return _dirPix; | 74 | return _dirPix; |
71 | else{ | 75 | else{ |
72 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 76 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
73 | currentView()->dirLister()->imageInfo( m_path ); | 77 | currentView()->dirLister()->imageInfo( m_path ); |
74 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 78 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
75 | } | 79 | } |
76 | 80 | ||
77 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 81 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); |
78 | if ( !m_pix && !g_stringPix.contains( m_path )) { | 82 | if ( !m_pix && !g_stringPix.contains( m_path )) { |
79 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 83 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); |
80 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 84 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
81 | } | 85 | } |
82 | return m_pix ? m_pix : _unkPix; | 86 | return m_pix ? m_pix : _unkPix; |
83 | } | 87 | } |
84 | } | 88 | } |
85 | inline void IconViewItem::setText( const QString& str ) { | 89 | inline void IconViewItem::setText( const QString& str ) { |
86 | QString text = QIconViewItem::text()+"\n"+str; | 90 | QString text = QIconViewItem::text()+"\n"+str; |
87 | m_noInfo = true; | 91 | m_noInfo = true; |
88 | QIconViewItem::setText( text ); | 92 | QIconViewItem::setText( text ); |
89 | reCalc(); | 93 | reCalc(); |
90 | } | 94 | } |
91 | 95 | ||
92 | inline void IconViewItem::reCalc() | 96 | inline void IconViewItem::reCalc() |
93 | { | 97 | { |
94 | calcRect(); | 98 | calcRect(); |
95 | } | 99 | } |
96 | } | 100 | } |
97 | 101 | ||
98 | 102 | ||
99 | PIconView::PIconView( QWidget* wid, Config* cfg ) | 103 | PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) |
100 | : QVBox( wid ), m_cfg( cfg ) | 104 | : QVBox( wid ), m_cfg( cfg ) |
101 | { | 105 | { |
102 | { | 106 | { |
103 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 107 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
104 | } | 108 | } |
105 | m_path = QDir::homeDirPath(); | 109 | m_path = QDir::homeDirPath(); |
106 | 110 | ||
107 | QHBox *hbox = new QHBox( this ); | 111 | QHBox *hbox = new QHBox( this ); |
108 | QLabel* lbl = new QLabel( hbox ); | 112 | QLabel* lbl = new QLabel( hbox ); |
109 | lbl->setText( tr("View as" ) ); | 113 | lbl->setText( tr("View as" ) ); |
110 | 114 | ||
111 | m_views = new QComboBox( hbox, "View As" ); | 115 | m_views = new QComboBox( hbox, "View As" ); |
112 | connect( m_views, SIGNAL(activated(int)), | 116 | connect( m_views, SIGNAL(activated(int)), |
113 | this, SLOT(slotViewChanged(int)) ); | 117 | this, SLOT(slotViewChanged(int)) ); |
114 | 118 | ||
115 | m_view= new QIconView( this ); | 119 | m_view= new QIconView( this ); |
116 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), | 120 | connect(m_view, SIGNAL(clicked(QIconViewItem*) ), |
117 | this, SLOT(slotClicked(QIconViewItem*)) ); | 121 | this, SLOT(slotClicked(QIconViewItem*)) ); |
118 | 122 | ||
119 | m_view->setArrangement( QIconView::LeftToRight ); | 123 | m_view->setArrangement( QIconView::LeftToRight ); |
120 | m_view->setItemTextPos( QIconView::Right ); | 124 | m_view->setItemTextPos( QIconView::Right ); |
121 | m_view->setResizeMode(QIconView::Adjust); | 125 | m_view->setResizeMode(QIconView::Adjust); |
122 | 126 | ||
123 | int dw = QApplication::desktop()->width(); | 127 | int dw = QApplication::desktop()->width(); |
124 | int viewerWidth = dw-style().scrollBarExtent().width(); | 128 | int viewerWidth = dw-style().scrollBarExtent().width(); |
125 | m_view->setGridX( viewerWidth-2*m_view->spacing() ); | 129 | m_view->setGridX( viewerWidth-2*m_view->spacing() ); |
126 | m_view->setGridY( fontMetrics().height()*2+40 ); | 130 | m_view->setGridY( fontMetrics().height()*2+40 ); |
131 | |||
132 | |||
133 | initKeys(); | ||
134 | |||
127 | loadViews(); | 135 | loadViews(); |
128 | slotViewChanged( m_views->currentItem() ); | 136 | slotViewChanged( m_views->currentItem() ); |
129 | } | 137 | } |
130 | 138 | ||
131 | PIconView::~PIconView() { | 139 | PIconView::~PIconView() { |
132 | { | 140 | { |
133 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 141 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
134 | } | 142 | } |
143 | m_viewManager->save(); | ||
144 | delete m_viewManager; | ||
145 | } | ||
146 | |||
147 | Opie::Ui::OKeyConfigManager* PIconView::manager() { | ||
148 | return m_viewManager; | ||
149 | } | ||
150 | |||
151 | void PIconView::initKeys() { | ||
152 | Opie::Ui::OKeyPair::List lst; | ||
153 | lst.append( Opie::Ui::OKeyPair::upArrowKey() ); | ||
154 | lst.append( Opie::Ui::OKeyPair::downArrowKey() ); | ||
155 | lst.append( Opie::Ui::OKeyPair::leftArrowKey() ); | ||
156 | lst.append( Opie::Ui::OKeyPair::rightArrowKey() ); | ||
157 | lst.append( Opie::Ui::OKeyPair::returnKey() ); | ||
158 | |||
159 | m_viewManager = new Opie::Ui::OKeyConfigManager(m_cfg, "View-KeyBoard-Config", | ||
160 | lst, false,this, "keyconfig name" ); | ||
161 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Beam Current Item") , "beam", | ||
162 | QString::fromLatin1("beam"), BeamItem, | ||
163 | Opie::Ui::OKeyPair(Qt::Key_B, Qt::ShiftButton), | ||
164 | this, SLOT(slotBeam())) ); | ||
165 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Delete Current Item"), "delete", | ||
166 | QString::fromLatin1("trash"), DeleteItem, | ||
167 | Opie::Ui::OKeyPair(Qt::Key_D, Qt::ShiftButton), | ||
168 | this, SLOT(slotTrash())) ); | ||
169 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("View Current Item"), "view", | ||
170 | QString::fromLatin1("1to1"), ViewItem, | ||
171 | Opie::Ui::OKeyPair(Qt::Key_V, Qt::ShiftButton), | ||
172 | this, SLOT(slotShowImage()))); | ||
173 | m_viewManager->addKeyConfig( OKeyConfigItem(tr("Show Image Info") , "info", | ||
174 | QString::fromLatin1("DocumentTypeWord"), InfoItem, | ||
175 | Opie::Ui::OKeyPair(Qt::Key_I, Qt::ShiftButton ), | ||
176 | this, SLOT(slotImageInfo()) ) ); | ||
177 | m_viewManager->load(); | ||
178 | m_viewManager->handleWidget( m_view ); | ||
135 | } | 179 | } |
136 | 180 | ||
137 | void PIconView::slotDirUp() { | 181 | void PIconView::slotDirUp() { |
138 | QDir dir( m_path ); | 182 | QDir dir( m_path ); |
139 | dir.cdUp(); | 183 | dir.cdUp(); |
140 | slotChangeDir( dir.absPath() ); | 184 | slotChangeDir( dir.absPath() ); |
141 | 185 | ||
142 | } | 186 | } |
143 | 187 | ||
144 | void PIconView::slotChangeDir(const QString& path) { | 188 | void PIconView::slotChangeDir(const QString& path) { |
145 | if ( !currentView() ) | 189 | if ( !currentView() ) |
146 | return; | 190 | return; |
147 | 191 | ||
148 | PDirLister *lister = currentView()->dirLister(); | 192 | PDirLister *lister = currentView()->dirLister(); |
149 | if (!lister ) | 193 | if (!lister ) |
150 | return; | 194 | return; |
151 | 195 | ||
152 | lister->setStartPath( path ); | 196 | lister->setStartPath( path ); |
153 | m_path = lister->currentPath(); | 197 | m_path = lister->currentPath(); |
154 | 198 | ||
199 | m_view->setUpdatesEnabled( false ); | ||
155 | m_view->clear(); | 200 | m_view->clear(); |
156 | addFolders( lister->folders() ); | 201 | addFolders( lister->folders() ); |
157 | addFiles( lister->files() ); | 202 | addFiles( lister->files() ); |
203 | m_view->setUpdatesEnabled( true ); | ||
158 | 204 | ||
159 | // Also invalidate the cache. We can't cancel the operations anyway | 205 | // Also invalidate the cache. We can't cancel the operations anyway |
160 | g_stringPix.clear(); | 206 | g_stringPix.clear(); |
161 | g_stringInf.clear(); | 207 | g_stringInf.clear(); |
162 | 208 | ||
163 | // looks ugly | 209 | // looks ugly |
164 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 210 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
165 | } | 211 | } |
166 | 212 | ||
167 | QString PIconView::currentFileName(bool &isDir)const { | 213 | QString PIconView::currentFileName(bool &isDir)const { |
168 | isDir = false; | 214 | isDir = false; |
169 | QIconViewItem* _it = m_view->currentItem(); | 215 | QIconViewItem* _it = m_view->currentItem(); |
170 | if ( !_it ) | 216 | if ( !_it ) |
171 | return QString::null; | 217 | return QString::null; |
172 | 218 | ||
173 | IconViewItem* it = static_cast<IconViewItem*>( _it ); | 219 | IconViewItem* it = static_cast<IconViewItem*>( _it ); |
174 | isDir = it->isDir(); | 220 | isDir = it->isDir(); |
175 | return it->path(); | 221 | return it->path(); |
176 | } | 222 | } |
177 | 223 | ||
178 | void PIconView::slotTrash() { | 224 | void PIconView::slotTrash() { |
179 | bool isDir; | 225 | bool isDir; |
180 | QString pa = currentFileName( isDir ); | 226 | QString pa = currentFileName( isDir ); |
181 | if ( isDir && pa.isEmpty() ) | 227 | if ( isDir && pa.isEmpty() ) |
182 | return; | 228 | return; |
183 | 229 | ||
184 | if (!QPEMessageBox::confirmDelete( this, | 230 | if (!QPEMessageBox::confirmDelete( this, |
185 | tr("Delete Image" ), | 231 | tr("Delete Image" ), |
186 | tr("the Image %1" ).arg(pa))) | 232 | tr("the Image %1" ).arg(pa))) |
187 | return | 233 | return |
188 | 234 | ||
189 | 235 | ||
190 | currentView()->dirLister()->deleteImage( pa ); | 236 | currentView()->dirLister()->deleteImage( pa ); |
191 | delete m_view->currentItem(); | 237 | delete m_view->currentItem(); |
192 | } | 238 | } |
193 | void PIconView::loadViews() { | 239 | void PIconView::loadViews() { |
194 | ViewMap::Iterator it; | 240 | ViewMap::Iterator it; |
195 | ViewMap* map = viewMap(); | 241 | ViewMap* map = viewMap(); |
196 | for ( it = map->begin(); it != map->end(); ++it ) | 242 | for ( it = map->begin(); it != map->end(); ++it ) |
197 | m_views->insertItem( QObject::tr(it.key() ) ); | 243 | m_views->insertItem( QObject::tr(it.key() ) ); |
198 | } | 244 | } |
199 | 245 | ||
200 | void PIconView::resetView() { | 246 | void PIconView::resetView() { |
201 | slotViewChanged(m_views->currentItem()); | 247 | slotViewChanged(m_views->currentItem()); |
202 | } | 248 | } |
203 | 249 | ||
204 | void PIconView::slotViewChanged( int i) { | 250 | void PIconView::slotViewChanged( int i) { |
205 | if (!m_views->count() ) { | 251 | if (!m_views->count() ) { |
206 | setCurrentView( 0l); | 252 | setCurrentView( 0l); |
207 | return; | 253 | return; |
208 | } | 254 | } |
209 | 255 | ||
210 | PDirView* cur = currentView(); | 256 | PDirView* cur = currentView(); |
211 | delete cur; | 257 | delete cur; |
212 | QString str = m_views->text(i); | 258 | QString str = m_views->text(i); |
213 | cur = (*(*viewMap())[str])(*m_cfg); | 259 | cur = (*(*viewMap())[str])(*m_cfg); |
214 | setCurrentView( cur ); | 260 | setCurrentView( cur ); |
215 | 261 | ||
216 | /* connect to the signals of the lister */ | 262 | /* connect to the signals of the lister */ |
217 | PDirLister* lis = cur->dirLister(); | 263 | PDirLister* lis = cur->dirLister(); |
218 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), | 264 | connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )), |
219 | this, SLOT( slotThumbInfo(const QString&, const QString&))); | 265 | this, SLOT( slotThumbInfo(const QString&, const QString&))); |
220 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), | 266 | connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)), |
221 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); | 267 | this, SLOT(slotThumbNail(const QString&, const QPixmap&))); |
222 | connect(lis, SIGNAL(sig_start()), | 268 | connect(lis, SIGNAL(sig_start()), |
223 | this, SLOT(slotStart())); | 269 | this, SLOT(slotStart())); |
224 | connect(lis, SIGNAL(sig_end()) , | 270 | connect(lis, SIGNAL(sig_end()) , |
225 | this, SLOT(slotEnd()) ); | 271 | this, SLOT(slotEnd()) ); |
226 | 272 | ||
227 | 273 | ||
228 | /* reload now */ | 274 | /* reload now */ |
229 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 275 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
230 | } | 276 | } |
231 | 277 | ||
232 | 278 | ||
233 | void PIconView::slotReloadDir() { | 279 | void PIconView::slotReloadDir() { |
234 | slotChangeDir( m_path ); | 280 | slotChangeDir( m_path ); |
235 | } | 281 | } |
236 | 282 | ||
237 | 283 | ||
238 | void PIconView::addFolders( const QStringList& lst) { | 284 | void PIconView::addFolders( const QStringList& lst) { |
239 | QStringList::ConstIterator it; | 285 | QStringList::ConstIterator it; |
240 | 286 | ||
241 | for(it=lst.begin(); it != lst.end(); ++it ) { | 287 | for(it=lst.begin(); it != lst.end(); ++it ) { |
242 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 288 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); |
243 | } | 289 | } |
244 | 290 | ||
245 | } | 291 | } |
246 | 292 | ||
247 | void PIconView::addFiles( const QStringList& lst) { | 293 | void PIconView::addFiles( const QStringList& lst) { |
248 | QStringList::ConstIterator it; | 294 | QStringList::ConstIterator it; |
249 | for (it=lst.begin(); it!= lst.end(); ++it ) | 295 | for (it=lst.begin(); it!= lst.end(); ++it ) |
250 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); | 296 | (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) ); |
251 | 297 | ||
252 | } | 298 | } |
253 | 299 | ||
254 | void PIconView::slotClicked(QIconViewItem* _it) { | 300 | void PIconView::slotClicked(QIconViewItem* _it) { |
255 | if(!_it ) | 301 | if(!_it ) |
256 | return; | 302 | return; |
257 | 303 | ||
258 | IconViewItem* it = static_cast<IconViewItem*>(_it); | 304 | IconViewItem* it = static_cast<IconViewItem*>(_it); |
259 | if( it->isDir() ) | 305 | if( it->isDir() ) |
260 | slotChangeDir( it->path() ); | 306 | slotChangeDir( it->path() ); |
261 | else // view image | 307 | else // view image |
262 | ; | 308 | ; |
263 | } | 309 | } |
264 | 310 | ||
265 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { | 311 | void PIconView::slotThumbInfo( const QString& _path, const QString& str ) { |
266 | if ( g_stringInf.contains( _path ) ) { | 312 | if ( g_stringInf.contains( _path ) ) { |
267 | IconViewItem* item = g_stringInf[_path]; | 313 | IconViewItem* item = g_stringInf[_path]; |
268 | /* if set the view shows nonsens! | 314 | /* if set the view shows nonsens! |
269 | I dont know how to fix the format of displayed text :(*/ | 315 | I dont know how to fix the format of displayed text :(*/ |
270 | item->setText( str ); | 316 | item->setText( str ); |
271 | item->repaint(); | 317 | item->repaint(); |
272 | g_stringInf.remove( _path ); | 318 | g_stringInf.remove( _path ); |
273 | } | 319 | } |
274 | } | 320 | } |
275 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | 321 | void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { |
276 | if ( g_stringPix.contains( _path ) ) { | 322 | if ( g_stringPix.contains( _path ) ) { |
277 | IconViewItem* item = g_stringPix[_path]; | 323 | IconViewItem* item = g_stringPix[_path]; |
278 | 324 | ||
279 | if (pix.width()>0) { | 325 | if (pix.width()>0) { |
280 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 326 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); |
281 | /* required for a recalculated rectangle. otherwise the view show nonsense! */ | 327 | /* required for a recalculated rectangle. otherwise the view show nonsense! */ |
282 | item->reCalc(); | 328 | item->reCalc(); |
283 | } else { | 329 | } else { |
284 | PPixmapCache::self()->insertImage(_path,Resource::loadPixmap( "UnknownDocument" ),64,64 ); | 330 | PPixmapCache::self()->insertImage(_path,Resource::loadPixmap( "UnknownDocument" ),64,64 ); |
285 | } | 331 | } |
286 | item->repaint(); | 332 | item->repaint(); |
287 | g_stringPix.remove( _path ); | 333 | g_stringPix.remove( _path ); |
288 | } | 334 | } |
289 | } | 335 | } |
290 | 336 | ||
291 | 337 | ||
292 | void PIconView::slotRename() { | 338 | void PIconView::slotRename() { |
293 | 339 | ||
294 | } | 340 | } |
295 | 341 | ||
296 | void PIconView::slotBeam() { | 342 | void PIconView::slotBeam() { |
297 | bool isDir; | 343 | bool isDir; |
298 | QString pa = currentFileName( isDir ); | 344 | QString pa = currentFileName( isDir ); |
299 | if ( isDir && pa.isEmpty() ) | 345 | if ( isDir && pa.isEmpty() ) |
300 | return; | 346 | return; |
301 | 347 | ||
302 | Ir* ir = new Ir( this ); | 348 | Ir* ir = new Ir( this ); |
303 | connect( ir, SIGNAL(done(Ir*)), | 349 | connect( ir, SIGNAL(done(Ir*)), |
304 | this, SLOT(slotBeamDone(Ir*))); | 350 | this, SLOT(slotBeamDone(Ir*))); |
305 | ir->send(pa, tr( "Image" ) ); | 351 | ir->send(pa, tr( "Image" ) ); |
306 | 352 | ||
307 | } | 353 | } |
308 | 354 | ||
309 | void PIconView::slotBeamDone( Ir* ir) { | 355 | void PIconView::slotBeamDone( Ir* ir) { |
310 | delete ir; | 356 | delete ir; |
311 | } | 357 | } |
312 | 358 | ||
313 | void PIconView::slotStart() { | 359 | void PIconView::slotStart() { |
314 | m_view->setUpdatesEnabled( false ); | 360 | m_view->setUpdatesEnabled( false ); |
315 | } | 361 | } |
316 | 362 | ||
317 | void PIconView::slotEnd() { | 363 | void PIconView::slotEnd() { |
318 | m_view->setUpdatesEnabled( true ); | 364 | m_view->setUpdatesEnabled( true ); |
319 | } | 365 | } |
366 | |||
367 | void PIconView::slotShowImage() { | ||
368 | |||
369 | } | ||
370 | void PIconView::slotShowImage( const QString& ) { | ||
371 | |||
372 | } | ||
373 | void PIconView::slotImageInfo() { | ||
374 | |||
375 | } | ||
376 | void PIconView::slotImageInfo( const QString& ) { | ||
377 | |||
378 | } | ||
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index 439833a..0fba327 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h | |||
@@ -1,59 +1,79 @@ | |||
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 | #include <qpe/config.h> | ||
12 | 11 | ||
13 | class QIconView; | 12 | class QIconView; |
14 | class QIconViewItem; | 13 | class QIconViewItem; |
15 | class QComboBox; | 14 | class QComboBox; |
16 | class PIconViewItem; | 15 | class PIconViewItem; |
17 | class PDirLister; | 16 | class PDirLister; |
18 | class Ir; | 17 | class Ir; |
18 | |||
19 | namespace Opie { | ||
20 | namespace Core{ | ||
21 | class OConfig; | ||
22 | } | ||
23 | namespace Ui { | ||
24 | class OKeyConfigManager; | ||
25 | } | ||
26 | } | ||
27 | |||
19 | class PIconView : public QVBox { | 28 | class PIconView : public QVBox { |
20 | Q_OBJECT | 29 | Q_OBJECT |
21 | friend class PIconViewItem; | 30 | friend class PIconViewItem; |
31 | enum ActionIds { | ||
32 | BeamItem, DeleteItem, ViewItem, InfoItem | ||
33 | }; | ||
22 | public: | 34 | public: |
23 | PIconView( QWidget* wid, Config *cfg ); | 35 | PIconView( QWidget* wid, Opie::Core::OConfig *cfg ); |
24 | ~PIconView(); | 36 | ~PIconView(); |
25 | void resetView(); | 37 | void resetView(); |
38 | Opie::Ui::OKeyConfigManager* manager(); | ||
26 | 39 | ||
27 | private: | 40 | private: |
41 | void initKeys(); | ||
28 | QString currentFileName(bool &isDir)const; | 42 | QString currentFileName(bool &isDir)const; |
29 | void loadViews(); | 43 | void loadViews(); |
30 | 44 | ||
31 | private slots: | 45 | private slots: |
32 | void slotDirUp(); | 46 | void slotDirUp(); |
33 | void slotChangeDir(const QString&); | 47 | void slotChangeDir(const QString&); |
34 | void slotTrash(); | 48 | void slotTrash(); |
35 | void slotViewChanged( int ); | 49 | void slotViewChanged( int ); |
36 | void slotReloadDir(); | 50 | void slotReloadDir(); |
37 | void slotRename(); | 51 | void slotRename(); |
38 | void slotBeam(); | 52 | void slotBeam(); |
39 | void slotBeamDone( Ir* ); | 53 | void slotBeamDone( Ir* ); |
40 | 54 | ||
55 | void slotShowImage(); | ||
56 | void slotShowImage( const QString& ); | ||
57 | void slotImageInfo(); | ||
58 | void slotImageInfo( const QString& ); | ||
59 | |||
41 | void slotStart(); | 60 | void slotStart(); |
42 | void slotEnd(); | 61 | void slotEnd(); |
43 | 62 | ||
44 | /* for performance reasons make it inline in the future */ | 63 | /* for performance reasons make it inline in the future */ |
45 | void addFolders( const QStringList& ); | 64 | void addFolders( const QStringList& ); |
46 | void addFiles( const QStringList& ); | 65 | void addFiles( const QStringList& ); |
47 | void slotClicked(QIconViewItem* ); | 66 | void slotClicked(QIconViewItem* ); |
48 | 67 | ||
49 | /**/ | 68 | /**/ |
50 | void slotThumbInfo(const QString&, const QString&); | 69 | void slotThumbInfo(const QString&, const QString&); |
51 | void slotThumbNail(const QString&, const QPixmap&); | 70 | void slotThumbNail(const QString&, const QPixmap&); |
52 | private: | 71 | private: |
53 | Config *m_cfg; | 72 | Opie::Ui::OKeyConfigManager *m_viewManager; |
73 | Opie::Core::OConfig *m_cfg; | ||
54 | QComboBox* m_views; | 74 | QComboBox* m_views; |
55 | QIconView* m_view; | 75 | QIconView* m_view; |
56 | QString m_path; | 76 | QString m_path; |
57 | }; | 77 | }; |
58 | 78 | ||
59 | #endif | 79 | #endif |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index ea765d1..0314659 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -1,114 +1,138 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | #include "mainwindow.h" | ||
6 | |||
7 | #include "iconview.h" | ||
8 | #include "filesystem.h" | ||
9 | |||
10 | #include <iface/ifaceinfo.h> | ||
11 | #include <iface/dirview.h> | ||
12 | |||
13 | #include <opie2/oapplicationfactory.h> | ||
14 | #include <opie2/otabwidget.h> | ||
15 | #include <opie2/okeyconfigwidget.h> | ||
16 | |||
17 | |||
18 | #include <qpe/resource.h> | ||
19 | #include <qpe/config.h> | ||
20 | #include <qpe/ir.h> | ||
5 | 21 | ||
6 | #include <qtoolbar.h> | 22 | #include <qtoolbar.h> |
7 | #include <qtoolbutton.h> | 23 | #include <qtoolbutton.h> |
8 | #include <qlayout.h> | 24 | #include <qlayout.h> |
9 | #include <qdialog.h> | 25 | #include <qdialog.h> |
10 | #include <qmap.h> | 26 | #include <qmap.h> |
11 | 27 | ||
12 | #include <qpe/resource.h> | ||
13 | #include <qpe/config.h> | ||
14 | #include <qpe/ir.h> | ||
15 | 28 | ||
16 | #include <opie2/oapplicationfactory.h> | ||
17 | #include <opie2/otabwidget.h> | ||
18 | 29 | ||
19 | #include <iface/ifaceinfo.h> | ||
20 | #include <iface/dirview.h> | ||
21 | 30 | ||
22 | #include "iconview.h" | ||
23 | #include "filesystem.h" | ||
24 | |||
25 | #include "mainwindow.h" | ||
26 | 31 | ||
27 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) | 32 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<PMainWindow> ) |
28 | 33 | ||
29 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) | 34 | PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style) |
30 | : QMainWindow( wid, name, style ), m_cfg("phunkview") | 35 | : QMainWindow( wid, name, style ) |
31 | { | 36 | { |
32 | setCaption( QObject::tr("Opie Eye Caramba" ) ); | 37 | setCaption( QObject::tr("Opie Eye Caramba" ) ); |
33 | m_cfg.setGroup("Zecke_view" ); | 38 | m_cfg = new Opie::Core::OConfig("phunkview"); |
39 | m_cfg->setGroup("Zecke_view" ); | ||
40 | |||
41 | |||
34 | /* | 42 | /* |
35 | * Initialize ToolBar and IconView | 43 | * Initialize ToolBar and IconView |
36 | * And Connect Them | 44 | * And Connect Them |
37 | */ | 45 | */ |
38 | QToolBar *bar = new QToolBar( this ); | 46 | QToolBar *bar = new QToolBar( this ); |
39 | bar->setHorizontalStretchable( true ); | 47 | bar->setHorizontalStretchable( true ); |
40 | setToolBarsMovable( false ); | 48 | setToolBarsMovable( false ); |
41 | 49 | ||
42 | m_view = new PIconView( this, &m_cfg ); | 50 | m_view = new PIconView( this, m_cfg ); |
43 | setCentralWidget( m_view ); | 51 | setCentralWidget( m_view ); |
44 | 52 | ||
45 | QToolButton *btn = new QToolButton( bar ); | 53 | QToolButton *btn = new QToolButton( bar ); |
46 | btn->setIconSet( Resource::loadIconSet( "up" ) ); | 54 | btn->setIconSet( Resource::loadIconSet( "up" ) ); |
47 | connect( btn, SIGNAL(clicked()), | 55 | connect( btn, SIGNAL(clicked()), |
48 | m_view, SLOT(slotDirUp()) ); | 56 | m_view, SLOT(slotDirUp()) ); |
49 | 57 | ||
50 | btn = new PFileSystem( bar ); | 58 | btn = new PFileSystem( bar ); |
51 | connect( btn, SIGNAL( changeDir( const QString& ) ), | 59 | connect( btn, SIGNAL( changeDir( const QString& ) ), |
52 | m_view, SLOT(slotChangeDir( const QString& ) ) ); | 60 | m_view, SLOT(slotChangeDir( const QString& ) ) ); |
53 | 61 | ||
54 | btn = new QToolButton( bar ); | 62 | btn = new QToolButton( bar ); |
55 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); | 63 | btn->setIconSet( Resource::loadIconSet( "edit" ) ); |
56 | connect( btn, SIGNAL(clicked()), | 64 | connect( btn, SIGNAL(clicked()), |
57 | m_view, SLOT(slotRename()) ); | 65 | m_view, SLOT(slotRename()) ); |
58 | 66 | ||
59 | if ( Ir::supported() ) { | 67 | if ( Ir::supported() ) { |
60 | btn = new QToolButton( bar ); | 68 | btn = new QToolButton( bar ); |
61 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); | 69 | btn->setIconSet( Resource::loadIconSet( "beam" ) ); |
62 | connect( btn, SIGNAL(clicked()), | 70 | connect( btn, SIGNAL(clicked()), |
63 | m_view, SLOT(slotBeam()) ); | 71 | m_view, SLOT(slotBeam()) ); |
64 | } | 72 | } |
65 | 73 | ||
66 | btn = new QToolButton( bar ); | 74 | btn = new QToolButton( bar ); |
67 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); | 75 | btn->setIconSet( Resource::loadIconSet( "trash" ) ); |
68 | connect( btn, SIGNAL(clicked() ), | 76 | connect( btn, SIGNAL(clicked() ), |
69 | m_view, SLOT(slotTrash() ) ); | 77 | m_view, SLOT(slotTrash() ) ); |
70 | 78 | ||
71 | btn = new QToolButton( bar ); | 79 | btn = new QToolButton( bar ); |
72 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); | 80 | btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) ); |
73 | connect( btn, SIGNAL(clicked() ), | 81 | connect( btn, SIGNAL(clicked() ), |
74 | this, SLOT(slotConfig() ) ); | 82 | this, SLOT(slotConfig() ) ); |
75 | 83 | ||
76 | } | 84 | } |
77 | 85 | ||
78 | PMainWindow::~PMainWindow() { | 86 | PMainWindow::~PMainWindow() { |
79 | } | 87 | } |
80 | 88 | ||
81 | 89 | ||
82 | void PMainWindow::slotConfig() { | 90 | void PMainWindow::slotConfig() { |
91 | /* | ||
92 | * have a tab with the possible views | ||
93 | * a tab for globals image cache size.. scaled loading | ||
94 | * and one tab for the KeyConfigs | ||
95 | */ | ||
83 | QDialog dlg(this, 0, true); | 96 | QDialog dlg(this, 0, true); |
84 | dlg.setCaption( tr("Phunk View - Config" ) ); | 97 | dlg.setCaption( tr("Phunk View - Config" ) ); |
85 | 98 | ||
86 | QHBoxLayout *lay = new QHBoxLayout(&dlg); | 99 | QHBoxLayout *lay = new QHBoxLayout(&dlg); |
87 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); | 100 | Opie::Ui::OTabWidget *wid = new Opie::Ui::OTabWidget(&dlg ); |
88 | lay->addWidget( wid ); | 101 | lay->addWidget( wid ); |
89 | ViewMap *vM = viewMap(); | 102 | ViewMap *vM = viewMap(); |
90 | ViewMap::Iterator _it = vM->begin(); | 103 | ViewMap::Iterator _it = vM->begin(); |
91 | QMap<PDirView*, QWidget*> lst; | 104 | QMap<PDirView*, QWidget*> lst; |
92 | 105 | ||
93 | for( ; _it != vM->end(); ++_it ) { | 106 | for( ; _it != vM->end(); ++_it ) { |
94 | PDirView *view = (_it.data())(m_cfg); | 107 | PDirView *view = (_it.data())(*m_cfg); |
95 | PInterfaceInfo *inf = view->interfaceInfo(); | 108 | PInterfaceInfo *inf = view->interfaceInfo(); |
96 | QWidget *_wid = inf->configWidget( m_cfg ); | 109 | QWidget *_wid = inf->configWidget( *m_cfg ); |
97 | _wid->reparent(wid, QPoint() ); | 110 | _wid->reparent(wid, QPoint() ); |
98 | lst.insert( view, _wid ); | 111 | lst.insert( view, _wid ); |
99 | wid->addTab( _wid, QString::null, inf->name() ); | 112 | wid->addTab( _wid, QString::null, inf->name() ); |
100 | } | 113 | } |
101 | 114 | ||
102 | dlg.showMaximized(); | 115 | /* |
103 | bool act = ( dlg.exec() == QDialog::Accepted ); | 116 | * Add the KeyConfigWidget |
117 | */ | ||
118 | Opie::Ui::OKeyConfigWidget* keyWid = new Opie::Ui::OKeyConfigWidget( wid, "key config" ); | ||
119 | keyWid->setChangeMode( Opie::Ui::OKeyConfigWidget::Queue ); | ||
120 | keyWid->insert( tr("Browser Keyboard Actions"), m_view->manager() ); | ||
121 | keyWid->load(); | ||
122 | wid->addTab( keyWid, QString::fromLatin1("AppsIcon" ), tr("Keyboard Configuration") ); | ||
123 | |||
124 | |||
125 | bool act = ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | ||
104 | 126 | ||
105 | QMap<PDirView*, QWidget*>::Iterator it; | 127 | QMap<PDirView*, QWidget*>::Iterator it; |
106 | for ( it = lst.begin(); it != lst.end(); ++it ) { | 128 | for ( it = lst.begin(); it != lst.end(); ++it ) { |
107 | if ( act ) | 129 | if ( act ) |
108 | it.key()->interfaceInfo()->writeConfig(it.data(), m_cfg); | 130 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); |
109 | delete it.key(); | 131 | delete it.key(); |
110 | } | 132 | } |
111 | 133 | ||
112 | if ( act ) | 134 | if ( act ) { |
113 | m_view->resetView(); | 135 | m_view->resetView(); |
136 | keyWid->save(); | ||
137 | } | ||
114 | } | 138 | } |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h index 408fe32..317a51e 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.h +++ b/noncore/graphics/opie-eye/gui/mainwindow.h | |||
@@ -1,29 +1,38 @@ | |||
1 | /* | 1 | /* |
2 | * GPLv2 zecke@handhelds.org | 2 | * GPLv2 zecke@handhelds.org |
3 | * No WArranty... | 3 | * No WArranty... |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #ifndef PHUNK_MAIN_WINDOW_H | 6 | #ifndef PHUNK_MAIN_WINDOW_H |
7 | #define PHUNK_MAIN_WINDOW_H | 7 | #define PHUNK_MAIN_WINDOW_H |
8 | 8 | ||
9 | #include <opie2/oconfig.h> | ||
10 | |||
9 | #include <qmainwindow.h> | 11 | #include <qmainwindow.h> |
10 | 12 | ||
11 | #include <qpe/config.h> | 13 | |
14 | |||
15 | namespace Opie { | ||
16 | namespace Ui{ | ||
17 | class OKeyConfigManager; | ||
18 | } | ||
19 | } | ||
12 | 20 | ||
13 | class PIconView; | 21 | class PIconView; |
14 | class PMainWindow : public QMainWindow { | 22 | class PMainWindow : public QMainWindow { |
15 | Q_OBJECT | 23 | Q_OBJECT |
16 | public: | 24 | public: |
17 | static QString appName() { return QString::fromLatin1("opie-eye" ); } | 25 | static QString appName() { return QString::fromLatin1("opie-eye" ); } |
18 | PMainWindow(QWidget*, const char*, WFlags ); | 26 | PMainWindow(QWidget*, const char*, WFlags ); |
19 | ~PMainWindow(); | 27 | ~PMainWindow(); |
20 | 28 | ||
21 | private: | 29 | private: |
22 | Config m_cfg; | 30 | Opie::Core::OConfig *m_cfg; |
23 | PIconView* m_view; | 31 | PIconView* m_view; |
24 | 32 | ||
33 | |||
25 | private slots: | 34 | private slots: |
26 | void slotConfig(); | 35 | void slotConfig(); |
27 | }; | 36 | }; |
28 | 37 | ||
29 | #endif | 38 | #endif |