-rw-r--r-- | noncore/graphics/opie-eye/gui/basesetup.cpp | 28 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/basesetup.h | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.cpp | 173 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/iconview.h | 3 | ||||
-rw-r--r-- | noncore/graphics/opie-eye/gui/mainwindow.cpp | 4 |
5 files changed, 168 insertions, 43 deletions
diff --git a/noncore/graphics/opie-eye/gui/basesetup.cpp b/noncore/graphics/opie-eye/gui/basesetup.cpp index 20dda5a..fdf3466 100644 --- a/noncore/graphics/opie-eye/gui/basesetup.cpp +++ b/noncore/graphics/opie-eye/gui/basesetup.cpp | |||
@@ -10,12 +10,13 @@ BaseSetup::BaseSetup(Opie::Core::OConfig *a_cfg,QWidget * parent, const char * n | |||
10 | { | 10 | { |
11 | setFrameStyle(Box|Raised); | 11 | setFrameStyle(Box|Raised); |
12 | m_cfg = a_cfg; | 12 | m_cfg = a_cfg; |
13 | m_MainLayout = new QVBoxLayout( this, 11, 6, "m_MainLayout"); | 13 | m_MainLayout = new QVBoxLayout( this, 11, 6, "m_MainLayout"); |
14 | 14 | ||
15 | m_SlidetimeLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_SlidetimeLayout"); | 15 | m_SlidetimeLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_SlidetimeLayout"); |
16 | m_IconsizeLayout = new QGridLayout( 0, 1, 1, 0, 6, "m_IconsizeLayout"); | ||
16 | 17 | ||
17 | m_SlideShowTime = new QSpinBox( this, "m_SlideShowTime" ); | 18 | m_SlideShowTime = new QSpinBox( this, "m_SlideShowTime" ); |
18 | m_SlideShowTime->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); | 19 | m_SlideShowTime->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); |
19 | m_SlideShowTime->setButtonSymbols( QSpinBox::PlusMinus ); | 20 | m_SlideShowTime->setButtonSymbols( QSpinBox::PlusMinus ); |
20 | m_SlideShowTime->setMaxValue( 60 ); | 21 | m_SlideShowTime->setMaxValue( 60 ); |
21 | m_SlideShowTime->setMinValue(0); | 22 | m_SlideShowTime->setMinValue(0); |
@@ -26,35 +27,54 @@ BaseSetup::BaseSetup(Opie::Core::OConfig *a_cfg,QWidget * parent, const char * n | |||
26 | 27 | ||
27 | m_SlidetimeLabel = new QLabel( this, "m_SlidetimeLabel" ); | 28 | m_SlidetimeLabel = new QLabel( this, "m_SlidetimeLabel" ); |
28 | m_SlidetimeLabel->setText(tr("Slideshow timeout:")); | 29 | m_SlidetimeLabel->setText(tr("Slideshow timeout:")); |
29 | m_SlidetimeLayout->addWidget( m_SlidetimeLabel, 0, 0 ); | 30 | m_SlidetimeLayout->addWidget( m_SlidetimeLabel, 0, 0 ); |
30 | m_MainLayout->addLayout( m_SlidetimeLayout ); | 31 | m_MainLayout->addLayout( m_SlidetimeLayout ); |
31 | 32 | ||
33 | m_Iconsize = new QSpinBox( this, "m_Iconsize" ); | ||
34 | m_Iconsize->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Fixed)); | ||
35 | m_Iconsize->setButtonSymbols( QSpinBox::PlusMinus ); | ||
36 | m_Iconsize->setMaxValue( 64 ); | ||
37 | m_Iconsize->setMinValue(12); | ||
38 | m_Iconsize->setValue( 32 ); | ||
39 | m_Iconsize->setSuffix(tr(" pixel")); | ||
40 | m_IconsizeLayout->addWidget( m_Iconsize, 0, 1 ); | ||
41 | m_IconsizeLabel = new QLabel( this, "m_IconsizeLabel" ); | ||
42 | m_IconsizeLabel->setText(tr("Size of thumbnails:")); | ||
43 | m_IconsizeLayout->addWidget( m_IconsizeLabel, 0, 0 ); | ||
44 | m_MainLayout->addLayout(m_IconsizeLayout); | ||
45 | |||
46 | |||
32 | #if 0 | 47 | #if 0 |
33 | m_ShowToolBar = new QCheckBox( this, "m_ShowToolBar" ); | 48 | m_ShowToolBar = new QCheckBox( this, "m_ShowToolBar" ); |
34 | m_ShowToolBar->setText(tr("Show toolbar on startup")); | 49 | m_ShowToolBar->setText(tr("Show toolbar on startup")); |
35 | m_MainLayout->addWidget( m_ShowToolBar ); | 50 | m_MainLayout->addWidget( m_ShowToolBar ); |
36 | #endif | 51 | #endif |
37 | m_SaveStateAuto = new QCheckBox( this, "m_SaveStateAuto" ); | 52 | m_SaveStateAuto = new QCheckBox( this, "m_SaveStateAuto" ); |
38 | m_SaveStateAuto->setText(tr("Save status of fullscreen/autorotate")); | 53 | m_SaveStateAuto->setText(tr("Save status of fullscreen/autorotate")); |
39 | m_MainLayout->addWidget( m_SaveStateAuto ); | 54 | m_MainLayout->addWidget( m_SaveStateAuto ); |
40 | 55 | ||
41 | spacer1 = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ); | 56 | spacer1 = new QSpacerItem( 20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding ); |
42 | m_MainLayout->addItem( spacer1 ); | 57 | m_MainLayout->addItem( spacer1 ); |
43 | 58 | ||
44 | int stime = m_cfg->readNumEntry("base_slideshowtimeout",2); | 59 | int stime = m_cfg->readNumEntry("slideshowtimeout",2); |
45 | if (stime<0) stime=2; | 60 | if (stime<0) stime=2; |
46 | if (stime>60) stime=60; | 61 | if (stime>60) stime=60; |
47 | m_SlideShowTime->setValue(stime); | 62 | m_SlideShowTime->setValue(stime); |
48 | m_SaveStateAuto->setChecked(m_cfg->readBoolEntry("base_savestatus",false)); | 63 | m_SaveStateAuto->setChecked(m_cfg->readBoolEntry("savestatus",true)); |
64 | stime = m_cfg->readNumEntry("iconsize", 32); | ||
65 | if (stime<12)stime = 12; | ||
66 | if (stime>64)stime = 64; | ||
67 | m_Iconsize->setValue(stime); | ||
49 | } | 68 | } |
50 | 69 | ||
51 | BaseSetup::~BaseSetup() | 70 | BaseSetup::~BaseSetup() |
52 | { | 71 | { |
53 | } | 72 | } |
54 | 73 | ||
55 | void BaseSetup::save_values() | 74 | void BaseSetup::save_values() |
56 | { | 75 | { |
57 | if (!m_cfg) return; | 76 | if (!m_cfg) return; |
58 | m_cfg->writeEntry("base_slideshowtimeout",m_SlideShowTime->value()); | 77 | m_cfg->writeEntry("slideshowtimeout",m_SlideShowTime->value()); |
59 | m_cfg->writeEntry("base_savestatus",m_SaveStateAuto->isChecked()); | 78 | m_cfg->writeEntry("savestatus",m_SaveStateAuto->isChecked()); |
79 | m_cfg->writeEntry("iconsize",m_Iconsize->value()); | ||
60 | } | 80 | } |
diff --git a/noncore/graphics/opie-eye/gui/basesetup.h b/noncore/graphics/opie-eye/gui/basesetup.h index c343f88..95929f2 100644 --- a/noncore/graphics/opie-eye/gui/basesetup.h +++ b/noncore/graphics/opie-eye/gui/basesetup.h | |||
@@ -27,9 +27,12 @@ protected: | |||
27 | QVBoxLayout * m_MainLayout; | 27 | QVBoxLayout * m_MainLayout; |
28 | QGridLayout * m_SlidetimeLayout; | 28 | QGridLayout * m_SlidetimeLayout; |
29 | QSpinBox * m_SlideShowTime; | 29 | QSpinBox * m_SlideShowTime; |
30 | QLabel * m_SlidetimeLabel; | 30 | QLabel * m_SlidetimeLabel; |
31 | QCheckBox *m_SaveStateAuto; | 31 | QCheckBox *m_SaveStateAuto; |
32 | QSpacerItem *spacer1; | 32 | QSpacerItem *spacer1; |
33 | QGridLayout * m_IconsizeLayout; | ||
34 | QSpinBox * m_Iconsize; | ||
35 | QLabel * m_IconsizeLabel; | ||
33 | }; | 36 | }; |
34 | 37 | ||
35 | #endif | 38 | #endif |
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp index eafff1d..c037d0d 100644 --- a/noncore/graphics/opie-eye/gui/iconview.cpp +++ b/noncore/graphics/opie-eye/gui/iconview.cpp | |||
@@ -38,16 +38,17 @@ using Opie::Core::OKeyConfigItem; | |||
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* _cpyPix = 0; | ||
44 | static QPixmap* _emptyPix = 0; | 45 | static QPixmap* _emptyPix = 0; |
45 | class IconViewItem : public QIconViewItem { | 46 | class IconViewItem : public QIconViewItem { |
46 | public: | 47 | public: |
47 | IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false); | 48 | IconViewItem( QIconView*, const QString& path, const QString& name,int a_iconsize, bool isDir = false); |
48 | QPixmap* pixmap()const; | 49 | QPixmap* pixmap()const; |
49 | QString path()const { return m_path; } | 50 | QString path()const { return m_path; } |
50 | bool isDir()const { return m_isDir; } | 51 | bool isDir()const { return m_isDir; } |
51 | void setText( const QString& ); | 52 | void setText( const QString& ); |
52 | bool textOnly()const{return m_textOnly;} | 53 | bool textOnly()const{return m_textOnly;} |
53 | void setTextOnly(bool how){m_textOnly=how;} | 54 | void setTextOnly(bool how){m_textOnly=how;} |
@@ -55,28 +56,30 @@ namespace { | |||
55 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); | 56 | virtual void setPixmap( const QPixmap & icon, bool recalc, bool redraw = TRUE ); |
56 | /* just for starting recalc of item rect! */ | 57 | /* just for starting recalc of item rect! */ |
57 | virtual void setPixmap( const QPixmap & icon); | 58 | virtual void setPixmap( const QPixmap & icon); |
58 | 59 | ||
59 | protected: | 60 | protected: |
60 | mutable QPixmap* m_pix; | 61 | mutable QPixmap* m_pix; |
62 | int m_iconsize; | ||
63 | void check_pix()const; | ||
61 | 64 | ||
62 | private: | 65 | private: |
63 | QString m_path; | 66 | QString m_path; |
64 | bool m_isDir : 1; | 67 | bool m_isDir : 1; |
65 | bool m_noInfo :1; | 68 | bool m_noInfo :1; |
66 | bool m_textOnly:1; | 69 | bool m_textOnly:1; |
67 | bool m_NameOnly:1; | 70 | bool m_NameOnly:1; |
68 | bool m_Pixset:1; | 71 | bool m_Pixset:1; |
69 | }; | 72 | }; |
70 | class TextViewItem : public IconViewItem { | 73 | class TextViewItem : public IconViewItem { |
71 | TextViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 74 | TextViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize , bool isDir = false); |
72 | QPixmap *pixmap()const; | 75 | QPixmap *pixmap()const; |
73 | void setText( const QString& ); | 76 | void setText( const QString& ); |
74 | }; | 77 | }; |
75 | class ThumbViewItem : public IconViewItem { | 78 | class ThumbViewItem : public IconViewItem { |
76 | ThumbViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false ); | 79 | ThumbViewItem( QIconView*, const QString& path, const QString& name, int a_iconsize, bool isDir = false ); |
77 | QPixmap *pixmap()const; | 80 | QPixmap *pixmap()const; |
78 | void setText( const QString& ); | 81 | void setText( const QString& ); |
79 | }; | 82 | }; |
80 | 83 | ||
81 | 84 | ||
82 | /* | 85 | /* |
@@ -84,20 +87,61 @@ namespace { | |||
84 | * we add it to the map | 87 | * we add it to the map |
85 | */ | 88 | */ |
86 | static QMap<QString, IconViewItem*> g_stringInf; | 89 | static QMap<QString, IconViewItem*> g_stringInf; |
87 | static QMap<QString, IconViewItem*> g_stringPix; | 90 | static QMap<QString, IconViewItem*> g_stringPix; |
88 | 91 | ||
89 | IconViewItem::IconViewItem( QIconView* view,const QString& path, | 92 | IconViewItem::IconViewItem( QIconView* view,const QString& path, |
90 | const QString& name, bool isDir ) | 93 | const QString& name, int a_iconsize, bool isDir) |
91 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), | 94 | : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), |
92 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) | 95 | m_noInfo( false ),m_textOnly(false),m_Pixset(false) |
93 | { | 96 | { |
94 | if ( isDir && !_dirPix ) | 97 | m_iconsize = a_iconsize; |
95 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | 98 | if ( isDir ) { |
96 | else if ( !isDir && !_unkPix ) | 99 | if (_dirPix && _dirPix->width()!=m_iconsize) { |
97 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | 100 | delete _dirPix; |
101 | _dirPix = 0; | ||
102 | } | ||
103 | if (!_dirPix ) { | ||
104 | _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); | ||
105 | } | ||
106 | } else { | ||
107 | if (!_unkPix ) { | ||
108 | _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); | ||
109 | } | ||
110 | } | ||
111 | check_pix(); | ||
112 | } | ||
113 | |||
114 | inline void IconViewItem::check_pix()const | ||
115 | { | ||
116 | if (_cpyPix && _cpyPix->width()!=m_iconsize) { | ||
117 | delete _cpyPix; | ||
118 | _cpyPix = 0; | ||
119 | } | ||
120 | if (_dirPix && _dirPix->width()>m_iconsize) { | ||
121 | QPixmap*Pix = new QPixmap(*_dirPix); | ||
122 | Pix->resize(m_iconsize,m_iconsize); | ||
123 | delete _dirPix; | ||
124 | _dirPix = Pix; | ||
125 | } | ||
126 | if (!_cpyPix && _unkPix) { | ||
127 | if (_unkPix->width()>=m_iconsize) { | ||
128 | _cpyPix = new QPixmap(*_unkPix); | ||
129 | if (_unkPix->width()>m_iconsize) | ||
130 | _cpyPix->resize(m_iconsize,m_iconsize); | ||
131 | } else { | ||
132 | _cpyPix = new QPixmap(m_iconsize,m_iconsize); | ||
133 | _cpyPix->fill(); | ||
134 | QPainter pa(_cpyPix); | ||
135 | int offset = (m_iconsize-_unkPix->width())/2; | ||
136 | int offy = (m_iconsize-_unkPix->height())/2; | ||
137 | if (offy<0) offy=0; | ||
138 | pa.drawPixmap(offset,offy,*_unkPix); | ||
139 | pa.end(); | ||
140 | } | ||
141 | } | ||
98 | } | 142 | } |
99 | 143 | ||
100 | inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) | 144 | inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) |
101 | { | 145 | { |
102 | m_Pixset = true; | 146 | m_Pixset = true; |
103 | calcRect(text()); | 147 | calcRect(text()); |
@@ -118,22 +162,23 @@ namespace { | |||
118 | return _emptyPix; | 162 | return _emptyPix; |
119 | } | 163 | } |
120 | if ( m_isDir ) | 164 | if ( m_isDir ) |
121 | return _dirPix; | 165 | return _dirPix; |
122 | else{ | 166 | else{ |
123 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { | 167 | if (!m_noInfo && !g_stringInf.contains( m_path ) ) { |
124 | currentView()->dirLister()->imageInfo( m_path ); | ||
125 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); | 168 | g_stringInf.insert( m_path, const_cast<IconViewItem*>(this)); |
169 | currentView()->dirLister()->imageInfo( m_path ); | ||
126 | } | 170 | } |
127 | 171 | ||
128 | m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 ); | 172 | m_pix = PPixmapCache::self()->cachedImage( m_path, m_iconsize, m_iconsize ); |
129 | if (!m_pix && !g_stringPix.contains( m_path )) { | 173 | if (!m_pix && !g_stringPix.contains( m_path )) { |
130 | currentView()->dirLister()->thumbNail( m_path, 64, 64 ); | 174 | check_pix(); |
131 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); | 175 | g_stringPix.insert( m_path, const_cast<IconViewItem*>(this)); |
176 | currentView()->dirLister()->thumbNail( m_path, m_iconsize, m_iconsize); | ||
132 | } | 177 | } |
133 | return m_pix ? m_pix : _unkPix; | 178 | return m_pix ? m_pix : _cpyPix; |
134 | } | 179 | } |
135 | } | 180 | } |
136 | inline void IconViewItem::setText( const QString& str ) { | 181 | inline void IconViewItem::setText( const QString& str ) { |
137 | QString text = QIconViewItem::text()+"\n"+str; | 182 | QString text = QIconViewItem::text()+"\n"+str; |
138 | m_noInfo = true; | 183 | m_noInfo = true; |
139 | QIconViewItem::setText( text ); | 184 | QIconViewItem::setText( text ); |
@@ -150,12 +195,13 @@ PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | |||
150 | { | 195 | { |
151 | { | 196 | { |
152 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 197 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
153 | } | 198 | } |
154 | m_path = QDir::homeDirPath(); | 199 | m_path = QDir::homeDirPath(); |
155 | m_mode = 0; | 200 | m_mode = 0; |
201 | m_iconsize = 32; | ||
156 | m_internalReset = false; | 202 | m_internalReset = false; |
157 | 203 | ||
158 | QHBox *hbox = new QHBox( this ); | 204 | QHBox *hbox = new QHBox( this ); |
159 | QLabel* lbl = new QLabel( hbox ); | 205 | QLabel* lbl = new QLabel( hbox ); |
160 | lbl->setText( tr("View as" ) ); | 206 | lbl->setText( tr("View as" ) ); |
161 | 207 | ||
@@ -172,12 +218,20 @@ PIconView::PIconView( QWidget* wid, Opie::Core::OConfig* cfg ) | |||
172 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); | 218 | m_mode = m_cfg->readNumEntry("ListViewMode", 1); |
173 | QString lastView = m_cfg->readEntry("LastView",""); | 219 | QString lastView = m_cfg->readEntry("LastView",""); |
174 | 220 | ||
175 | if (m_mode < 1 || m_mode>3) m_mode = 1; | 221 | if (m_mode < 1 || m_mode>3) m_mode = 1; |
176 | 222 | ||
177 | m_view->setItemTextPos( QIconView::Right ); | 223 | m_view->setItemTextPos( QIconView::Right ); |
224 | if (m_mode >1) { | ||
225 | m_view->setResizeMode(QIconView::Adjust); | ||
226 | } else { | ||
227 | m_view->setResizeMode(QIconView::Fixed); | ||
228 | } | ||
229 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | ||
230 | if (m_iconsize<12)m_iconsize = 12; | ||
231 | if (m_iconsize>64)m_iconsize = 64; | ||
178 | 232 | ||
179 | calculateGrid(); | 233 | calculateGrid(); |
180 | 234 | ||
181 | initKeys(); | 235 | initKeys(); |
182 | 236 | ||
183 | loadViews(); | 237 | loadViews(); |
@@ -277,23 +331,23 @@ void PIconView::slotChangeDir(const QString& path) { | |||
277 | lister->setStartPath( path ); | 331 | lister->setStartPath( path ); |
278 | m_path = lister->currentPath(); | 332 | m_path = lister->currentPath(); |
279 | 333 | ||
280 | m_view->viewport()->setUpdatesEnabled( false ); | 334 | m_view->viewport()->setUpdatesEnabled( false ); |
281 | m_view->clear(); | 335 | m_view->clear(); |
282 | 336 | ||
337 | // Also invalidate the cache. We can't cancel the operations anyway | ||
338 | g_stringPix.clear(); | ||
339 | g_stringInf.clear(); | ||
340 | |||
283 | /* | 341 | /* |
284 | * add files and folders | 342 | * add files and folders |
285 | */ | 343 | */ |
286 | addFolders( lister->folders() ); | 344 | addFolders( lister->folders() ); |
287 | addFiles( lister->files() ); | 345 | addFiles( lister->files() ); |
288 | m_view->viewport()->setUpdatesEnabled( true ); | 346 | m_view->viewport()->setUpdatesEnabled( true ); |
289 | 347 | ||
290 | // Also invalidate the cache. We can't cancel the operations anyway | ||
291 | g_stringPix.clear(); | ||
292 | g_stringInf.clear(); | ||
293 | |||
294 | // looks ugly | 348 | // looks ugly |
295 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); | 349 | static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) ); |
296 | } | 350 | } |
297 | 351 | ||
298 | /** | 352 | /** |
299 | * get the current file name | 353 | * get the current file name |
@@ -362,12 +416,22 @@ void PIconView::loadViews() { | |||
362 | for ( it = map->begin(); it != map->end(); ++it ) | 416 | for ( it = map->begin(); it != map->end(); ++it ) |
363 | m_views->insertItem( it.key() ); | 417 | m_views->insertItem( it.key() ); |
364 | } | 418 | } |
365 | 419 | ||
366 | void PIconView::resetView() { | 420 | void PIconView::resetView() { |
367 | m_internalReset = true; | 421 | m_internalReset = true; |
422 | // Also invalidate the cache. We can't cancel the operations anyway | ||
423 | g_stringPix.clear(); | ||
424 | g_stringInf.clear(); | ||
425 | if (m_mode>1) { | ||
426 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | ||
427 | if (m_iconsize<12)m_iconsize = 12; | ||
428 | if (m_iconsize>64)m_iconsize = 64; | ||
429 | } else { | ||
430 | m_iconsize = 64; | ||
431 | } | ||
368 | slotViewChanged(m_views->currentItem()); | 432 | slotViewChanged(m_views->currentItem()); |
369 | m_internalReset = false; | 433 | m_internalReset = false; |
370 | } | 434 | } |
371 | 435 | ||
372 | /* | 436 | /* |
373 | *swicth view reloadDir and connect signals | 437 | *swicth view reloadDir and connect signals |
@@ -410,14 +474,15 @@ void PIconView::slotViewChanged( int i) { | |||
410 | this, SLOT(slotEnd()) ); | 474 | this, SLOT(slotEnd()) ); |
411 | 475 | ||
412 | 476 | ||
413 | /* reload now with default Path | 477 | /* reload now with default Path |
414 | * but only if it isn't a reset like from setupdlg | 478 | * but only if it isn't a reset like from setupdlg |
415 | */ | 479 | */ |
416 | if (!m_internalReset) | 480 | if (!m_internalReset) { |
417 | m_path = lis->defaultPath(); | 481 | m_path = lis->defaultPath(); |
482 | } | ||
418 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); | 483 | QTimer::singleShot( 0, this, SLOT(slotReloadDir())); |
419 | } | 484 | } |
420 | 485 | ||
421 | 486 | ||
422 | void PIconView::slotReloadDir() { | 487 | void PIconView::slotReloadDir() { |
423 | slotChangeDir( m_path ); | 488 | slotChangeDir( m_path ); |
@@ -429,13 +494,13 @@ void PIconView::slotReloadDir() { | |||
429 | */ | 494 | */ |
430 | void PIconView::addFolders( const QStringList& lst) { | 495 | void PIconView::addFolders( const QStringList& lst) { |
431 | QStringList::ConstIterator it; | 496 | QStringList::ConstIterator it; |
432 | IconViewItem * _iv; | 497 | IconViewItem * _iv; |
433 | 498 | ||
434 | for(it=lst.begin(); it != lst.end(); ++it ) { | 499 | for(it=lst.begin(); it != lst.end(); ++it ) { |
435 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it), true ); | 500 | _iv = new IconViewItem( m_view, m_path+"/"+(*it), (*it),m_iconsize, true ); |
436 | if (m_mode==3) _iv->setTextOnly(true); | 501 | if (m_mode==3) _iv->setTextOnly(true); |
437 | } | 502 | } |
438 | } | 503 | } |
439 | 504 | ||
440 | void PIconView::addFiles( const QStringList& lst) { | 505 | void PIconView::addFiles( const QStringList& lst) { |
441 | QStringList::ConstIterator it; | 506 | QStringList::ConstIterator it; |
@@ -443,14 +508,14 @@ void PIconView::addFiles( const QStringList& lst) { | |||
443 | QPixmap*m_pix = 0; | 508 | QPixmap*m_pix = 0; |
444 | QString pre = ""; | 509 | QString pre = ""; |
445 | if (!m_path.isEmpty()) { | 510 | if (!m_path.isEmpty()) { |
446 | pre = m_path+"/"; | 511 | pre = m_path+"/"; |
447 | } | 512 | } |
448 | for (it=lst.begin(); it!= lst.end(); ++it ) { | 513 | for (it=lst.begin(); it!= lst.end(); ++it ) { |
449 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), 64, 64 ); | 514 | m_pix = PPixmapCache::self()->cachedImage( pre+(*it), m_iconsize, m_iconsize ); |
450 | _iv = new IconViewItem( m_view, pre+(*it), (*it) ); | 515 | _iv = new IconViewItem( m_view, pre+(*it), (*it),m_iconsize ); |
451 | if (m_mode==3) { | 516 | if (m_mode==3) { |
452 | _iv->setTextOnly(true); | 517 | _iv->setTextOnly(true); |
453 | _iv->setPixmap(QPixmap()); | 518 | _iv->setPixmap(QPixmap()); |
454 | 519 | ||
455 | 520 | ||
456 | 521 | ||
@@ -521,18 +586,33 @@ void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) { | |||
521 | 586 | ||
522 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), | 587 | if ( item->intersects(QRect( m_view->contentsX(),m_view->contentsY(), |
523 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) | 588 | m_view->contentsWidth(), m_view->contentsHeight() ) ) ) |
524 | m_updatet = true; | 589 | m_updatet = true; |
525 | 590 | ||
526 | if (pix.width()>0) { | 591 | if (pix.width()>0) { |
527 | PPixmapCache::self()->insertImage( _path, pix, 64, 64 ); | 592 | if (pix.width()<m_iconsize) { |
528 | item->setPixmap(pix,true); | 593 | QPixmap p(m_iconsize,m_iconsize); |
594 | p.fill(); | ||
595 | QPainter pa(&p); | ||
596 | int offset = (m_iconsize-pix.width())/2; | ||
597 | int offy = (m_iconsize-pix.height())/2; | ||
598 | if (offy<0) offy=0; | ||
599 | pa.drawPixmap(offset,offy,pix); | ||
600 | pa.end(); | ||
601 | PPixmapCache::self()->insertImage( _path, p, m_iconsize, m_iconsize ); | ||
602 | item->setPixmap(p,true); | ||
603 | } else { | ||
604 | PPixmapCache::self()->insertImage( _path, pix, m_iconsize, m_iconsize ); | ||
605 | item->setPixmap(pix,true); | ||
606 | } | ||
607 | |||
529 | } else { | 608 | } else { |
530 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), 64, 64 ); | 609 | PPixmapCache::self()->insertImage( _path, Resource::loadPixmap( "UnknownDocument" ), m_iconsize, m_iconsize ); |
531 | } | 610 | } |
532 | g_stringPix.remove( _path ); | 611 | g_stringPix.remove( _path ); |
612 | m_view->arrangeItemsInGrid(true); | ||
533 | } | 613 | } |
534 | 614 | ||
535 | 615 | ||
536 | /* | 616 | /* |
537 | * FIXME rename | 617 | * FIXME rename |
538 | */ | 618 | */ |
@@ -688,13 +768,13 @@ void PIconView::slotStartSlide() { | |||
688 | if (isDir) { | 768 | if (isDir) { |
689 | if (!slotShowFirst()) | 769 | if (!slotShowFirst()) |
690 | return; | 770 | return; |
691 | } else { | 771 | } else { |
692 | slotShowImage( name ); | 772 | slotShowImage( name ); |
693 | } | 773 | } |
694 | int t = m_cfg->readNumEntry("base_slideshowtimeout", 2); | 774 | int t = m_cfg->readNumEntry("slideshowtimeout", 2); |
695 | emit sig_startslide(t); | 775 | emit sig_startslide(t); |
696 | } | 776 | } |
697 | 777 | ||
698 | void PIconView::slotImageInfo() { | 778 | void PIconView::slotImageInfo() { |
699 | bool isDir = false; | 779 | bool isDir = false; |
700 | QString name = currentFileName(isDir); | 780 | QString name = currentFileName(isDir); |
@@ -707,32 +787,52 @@ void PIconView::slotImageInfo( const QString& name) { | |||
707 | QString r_name = lister->nameToFname(name); | 787 | QString r_name = lister->nameToFname(name); |
708 | emit sig_showInfo(r_name ); | 788 | emit sig_showInfo(r_name ); |
709 | } | 789 | } |
710 | 790 | ||
711 | 791 | ||
712 | void PIconView::slotChangeMode( int mode ) { | 792 | void PIconView::slotChangeMode( int mode ) { |
713 | if ( mode >= 1 && mode <= 3 ) | 793 | if ( mode >= 1 && mode <= 3 ) { |
714 | m_mode = mode; | 794 | m_mode = mode; |
795 | m_cfg->writeEntry("ListViewMode", m_mode); | ||
796 | /* performance! */ | ||
797 | m_view->clear(); | ||
798 | if (m_mode >1) { | ||
799 | m_view->setResizeMode(QIconView::Adjust); | ||
800 | } else { | ||
801 | m_view->setResizeMode(QIconView::Fixed); | ||
802 | } | ||
803 | if (m_mode==1) { | ||
804 | m_iconsize = 64; | ||
805 | } else { | ||
806 | m_iconsize = m_cfg->readNumEntry("iconsize", 32); | ||
807 | if (m_iconsize<12)m_iconsize = 12; | ||
808 | if (m_iconsize>64)m_iconsize = 64; | ||
809 | } | ||
715 | 810 | ||
716 | m_cfg->writeEntry("ListViewMode", m_mode); | 811 | calculateGrid(); |
717 | /* performance! */ | 812 | slotReloadDir(); |
718 | m_view->clear(); | 813 | } |
719 | calculateGrid(); | ||
720 | slotReloadDir(); | ||
721 | } | 814 | } |
722 | 815 | ||
723 | 816 | ||
724 | void PIconView::resizeEvent( QResizeEvent* re ) { | 817 | void PIconView::resizeEvent( QResizeEvent* re ) { |
818 | calculateGrid(re); | ||
725 | QVBox::resizeEvent( re ); | 819 | QVBox::resizeEvent( re ); |
726 | calculateGrid(); | 820 | //calculateGrid(); |
727 | } | 821 | } |
728 | 822 | ||
729 | 823 | ||
730 | void PIconView::calculateGrid() { | 824 | void PIconView::calculateGrid(QResizeEvent* re) |
731 | int dw = QApplication::desktop()->width(); | 825 | { |
732 | int viewerWidth = dw-style().scrollBarExtent().width(); | 826 | int viewerWidth; |
827 | if (re) { | ||
828 | viewerWidth=re->size().width(); | ||
829 | } else { | ||
830 | int dw = QApplication::desktop()->width(); | ||
831 | viewerWidth = dw-style().scrollBarExtent().width(); | ||
832 | } | ||
733 | 833 | ||
734 | QIconView::ItemTextPos pos; | 834 | QIconView::ItemTextPos pos; |
735 | switch( m_mode ) { | 835 | switch( m_mode ) { |
736 | case 2: | 836 | case 2: |
737 | pos = QIconView::Bottom; | 837 | pos = QIconView::Bottom; |
738 | break; | 838 | break; |
@@ -742,14 +842,14 @@ void PIconView::calculateGrid() { | |||
742 | pos = QIconView::Right; | 842 | pos = QIconView::Right; |
743 | break; | 843 | break; |
744 | } | 844 | } |
745 | m_view->setItemTextPos( pos ); | 845 | m_view->setItemTextPos( pos ); |
746 | switch (m_mode) { | 846 | switch (m_mode) { |
747 | case 2: | 847 | case 2: |
748 | m_view->setGridX(50); | 848 | m_view->setGridX(m_iconsize); |
749 | m_view->setGridY(20); | 849 | m_view->setGridY(-1); |
750 | PPixmapCache::self()->setMaxImages(40); | 850 | PPixmapCache::self()->setMaxImages(40); |
751 | break; | 851 | break; |
752 | case 3: | 852 | case 3: |
753 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); | 853 | m_view->setGridX( fontMetrics().width("testimage.jpg")+20); |
754 | m_view->setGridY(8); | 854 | m_view->setGridY(8); |
755 | PPixmapCache::self()->setMaxImages(2); | 855 | PPixmapCache::self()->setMaxImages(2); |
@@ -758,7 +858,8 @@ void PIconView::calculateGrid() { | |||
758 | default: | 858 | default: |
759 | m_view->setGridX( viewerWidth-3*m_view->spacing()); | 859 | m_view->setGridX( viewerWidth-3*m_view->spacing()); |
760 | m_view->setGridY( fontMetrics().height()*2+40 ); | 860 | m_view->setGridY( fontMetrics().height()*2+40 ); |
761 | PPixmapCache::self()->setMaxImages(20); | 861 | PPixmapCache::self()->setMaxImages(20); |
762 | break; | 862 | break; |
763 | } | 863 | } |
864 | m_view->setSpacing(10); | ||
764 | } | 865 | } |
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h index bea35c2..b018c51 100644 --- a/noncore/graphics/opie-eye/gui/iconview.h +++ b/noncore/graphics/opie-eye/gui/iconview.h | |||
@@ -52,13 +52,13 @@ protected: | |||
52 | private: | 52 | private: |
53 | void initKeys(); | 53 | void initKeys(); |
54 | QString currentFileName(bool &isDir)const; | 54 | QString currentFileName(bool &isDir)const; |
55 | QString nextFileName(bool &isDir)const; | 55 | QString nextFileName(bool &isDir)const; |
56 | QString prevFileName(bool &isDir)const; | 56 | QString prevFileName(bool &isDir)const; |
57 | void loadViews(); | 57 | void loadViews(); |
58 | void calculateGrid(); | 58 | void calculateGrid(QResizeEvent*e = 0); |
59 | 59 | ||
60 | private slots: | 60 | private slots: |
61 | void slotDirUp(); | 61 | void slotDirUp(); |
62 | void slotChangeDir(const QString&); | 62 | void slotChangeDir(const QString&); |
63 | void slotTrash(); | 63 | void slotTrash(); |
64 | void slotViewChanged( int ); | 64 | void slotViewChanged( int ); |
@@ -93,9 +93,10 @@ private: | |||
93 | QComboBox* m_views; | 93 | QComboBox* m_views; |
94 | QIconView* m_view; | 94 | QIconView* m_view; |
95 | QString m_path; | 95 | QString m_path; |
96 | bool m_updatet : 1; | 96 | bool m_updatet : 1; |
97 | int m_mode; | 97 | int m_mode; |
98 | bool m_internalReset:1; | 98 | bool m_internalReset:1; |
99 | int m_iconsize; | ||
99 | }; | 100 | }; |
100 | 101 | ||
101 | #endif | 102 | #endif |
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp index 30c9bf1..67eb277 100644 --- a/noncore/graphics/opie-eye/gui/mainwindow.cpp +++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp | |||
@@ -201,18 +201,18 @@ void PMainWindow::slotConfig() { | |||
201 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); | 201 | it.key()->interfaceInfo()->writeConfig(it.data(), *m_cfg); |
202 | delete it.key(); | 202 | delete it.key(); |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | if ( act ) { | 206 | if ( act ) { |
207 | m_view->resetView(); | ||
208 | keyWid->save(); | 207 | keyWid->save(); |
209 | m_disp->manager()->save(); | 208 | m_disp->manager()->save(); |
210 | m_info->manager()->save(); | 209 | m_info->manager()->save(); |
211 | m_view->manager()->save(); | 210 | m_view->manager()->save(); |
212 | bSetup->save_values(); | 211 | bSetup->save_values(); |
212 | m_view->resetView(); | ||
213 | readConfig(); | 213 | readConfig(); |
214 | } | 214 | } |
215 | delete keyWid; | 215 | delete keyWid; |
216 | 216 | ||
217 | m_stack->raiseWidget(w); | 217 | m_stack->raiseWidget(w); |
218 | if (remdisp) { | 218 | if (remdisp) { |
@@ -689,8 +689,8 @@ void PMainWindow::listviewselected(QAction*which) | |||
689 | } | 689 | } |
690 | emit changeListMode(val); | 690 | emit changeListMode(val); |
691 | } | 691 | } |
692 | 692 | ||
693 | void PMainWindow::readConfig() | 693 | void PMainWindow::readConfig() |
694 | { | 694 | { |
695 | autoSave =m_cfg->readBoolEntry("base_savestatus",true); | 695 | autoSave =m_cfg->readBoolEntry("savestatus",true); |
696 | } | 696 | } |