summaryrefslogtreecommitdiff
authoralwin <alwin>2004-11-07 19:37:17 (UTC)
committer alwin <alwin>2004-11-07 19:37:17 (UTC)
commit9218d2bf841e1f999475c86ba602dc1cd7e338f6 (patch) (unidiff)
treeeb02e9dc2d1d4e8188f2c7cf8260d81298352117
parentc7eb493b3c2efa871104b27b6abf487da94f33f6 (diff)
downloadopie-9218d2bf841e1f999475c86ba602dc1cd7e338f6.zip
opie-9218d2bf841e1f999475c86ba602dc1cd7e338f6.tar.gz
opie-9218d2bf841e1f999475c86ba602dc1cd7e338f6.tar.bz2
try to improve the icon scaling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index f173ecc..5472ead 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -81,74 +81,77 @@ namespace {
81 void setText( const QString& ); 81 void setText( const QString& );
82 }; 82 };
83 83
84 84
85/* 85/*
86 * If we request an Image or String 86 * If we request an Image or String
87 * we add it to the map 87 * we add it to the map
88 */ 88 */
89 static QMap<QString, IconViewItem*> g_stringInf; 89 static QMap<QString, IconViewItem*> g_stringInf;
90 static QMap<QString, IconViewItem*> g_stringPix; 90 static QMap<QString, IconViewItem*> g_stringPix;
91 91
92 IconViewItem::IconViewItem( QIconView* view,const QString& path, 92 IconViewItem::IconViewItem( QIconView* view,const QString& path,
93 const QString& name, int a_iconsize, bool isDir) 93 const QString& name, int a_iconsize, bool isDir)
94 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ), 94 : QIconViewItem( view, name ), m_path( path ), m_isDir( isDir ),
95 m_noInfo( false ),m_textOnly(false),m_Pixset(false) 95 m_noInfo( false ),m_textOnly(false),m_Pixset(false)
96 { 96 {
97 m_iconsize = a_iconsize; 97 m_iconsize = a_iconsize;
98 if ( isDir ) { 98 if ( isDir ) {
99 if (!_dirPix ) { 99 if (!_dirPix ) {
100 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser")); 100 _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
101 } 101 }
102 } else { 102 } else {
103 if (!_unkPix ) { 103 if (!_unkPix ) {
104 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) ); 104 _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
105 } 105 }
106 } 106 }
107 check_pix(); 107 check_pix();
108 } 108 }
109 109
110 inline void IconViewItem::check_pix()const 110 inline void IconViewItem::check_pix()const
111 { 111 {
112 if (_dirPix && _dirPix->width()>m_iconsize) { 112 if (_dirPix && _dirPix->width()>m_iconsize) {
113 QPixmap*Pix = new QPixmap(*_dirPix); 113 QImage Pix = _dirPix->convertToImage();
114 Pix->resize(m_iconsize,m_iconsize); 114 *_dirPix = Pix.smoothScale(m_iconsize,m_iconsize);
115 delete _dirPix;
116 _dirPix = Pix;
117 } 115 }
118 if (!_cpyPix && _unkPix) { 116 if (!_cpyPix && _unkPix) {
119 if (_unkPix->width()>=m_iconsize) { 117 if (_unkPix->width()>=m_iconsize) {
120 _cpyPix = new QPixmap(*_unkPix); 118 QImage Pix = _unkPix->convertToImage();
121 if (_unkPix->width()>m_iconsize) 119 _cpyPix = new QPixmap();
122 _cpyPix->resize(m_iconsize,m_iconsize); 120 if (_unkPix->width()>m_iconsize) {
121 *_cpyPix = Pix.smoothScale(m_iconsize,m_iconsize);
122 } else {
123 _cpyPix->convertFromImage(Pix);
124 }
125
123 } else { 126 } else {
124 _cpyPix = new QPixmap(m_iconsize,m_iconsize); 127 _cpyPix = new QPixmap(m_iconsize,m_iconsize);
125 _cpyPix->fill(); 128 _cpyPix->fill();
126 QPainter pa(_cpyPix); 129 QPainter pa(_cpyPix);
127 int offset = (m_iconsize-_unkPix->width())/2; 130 int offset = (m_iconsize-_unkPix->width())/2;
128 int offy = (m_iconsize-_unkPix->height())/2; 131 int offy = (m_iconsize-_unkPix->height())/2;
129 if (offy<0) offy=0; 132 if (offy<0) offy=0;
130 pa.drawPixmap(offset,offy,*_unkPix); 133 pa.drawPixmap(offset,offy,*_unkPix);
131 pa.end(); 134 pa.end();
132 } 135 }
133 } 136 }
134 } 137 }
135 138
136 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool ) 139 inline void IconViewItem::setPixmap( const QPixmap & , bool, bool )
137 { 140 {
138 m_Pixset = true; 141 m_Pixset = true;
139 calcRect(text()); 142 calcRect(text());
140 } 143 }
141 inline void IconViewItem::setPixmap( const QPixmap & ) 144 inline void IconViewItem::setPixmap( const QPixmap & )
142 { 145 {
143 m_Pixset = true; 146 m_Pixset = true;
144 calcRect(text()); 147 calcRect(text());
145 } 148 }
146 149
147 inline QPixmap* IconViewItem::pixmap()const { 150 inline QPixmap* IconViewItem::pixmap()const {
148// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y() 151// owarn << "Name is " << m_path.right( 15 ) << " rect is " << rect().x() << " " << rect().y()
149// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX() 152// << " " << rect().width() << " " << rect().height() << " | " << iconView()->contentsX()
150// << " " << iconView()->contentsY() << oendl; 153// << " " << iconView()->contentsY() << oendl;
151 154
152 if (textOnly()&&!m_isDir) { 155 if (textOnly()&&!m_isDir) {
153 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1); 156 if (!_emptyPix) _emptyPix = new QPixmap(0,0,1);
154 return _emptyPix; 157 return _emptyPix;