author | drw <drw> | 2005-03-02 19:32:43 (UTC) |
---|---|---|
committer | drw <drw> | 2005-03-02 19:32:43 (UTC) |
commit | 9f3e0913c7b01c1e14f907e756999b9d9bf9ceef (patch) (unidiff) | |
tree | c117c38bbbeb630adbe2f25025ff97dc02475a88 | |
parent | af157881a6265b1ea9e74d61853c2d3d865a6080 (diff) | |
download | opie-9f3e0913c7b01c1e14f907e756999b9d9bf9ceef.zip opie-9f3e0913c7b01c1e14f907e756999b9d9bf9ceef.tar.gz opie-9f3e0913c7b01c1e14f907e756999b9d9bf9ceef.tar.bz2 |
Scale icons approprtely
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 56e3282..fd81313 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -43,224 +43,224 @@ AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) | |||
43 | : QMainWindow( ) { | 43 | : QMainWindow( ) { |
44 | init(); | 44 | init(); |
45 | renameBox = 0; | 45 | renameBox = 0; |
46 | whichTab = 1; | 46 | whichTab = 1; |
47 | unknownXpm = Resource::loadImage("UnknownDocument").smoothScale(AppLnk::smallIconSize(),AppLnk::smallIconSize() ); | 47 | unknownXpm = Resource::loadImage("UnknownDocument").smoothScale(AppLnk::smallIconSize(),AppLnk::smallIconSize() ); |
48 | 48 | ||
49 | initConnections(); | 49 | initConnections(); |
50 | rePopulate(); | 50 | rePopulate(); |
51 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); | 51 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); |
52 | connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&))); | 52 | connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&))); |
53 | switchToLocalTab(); | 53 | switchToLocalTab(); |
54 | } | 54 | } |
55 | 55 | ||
56 | AdvancedFm::~AdvancedFm() { | 56 | AdvancedFm::~AdvancedFm() { |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
60 | void AdvancedFm::cleanUp() { | 60 | void AdvancedFm::cleanUp() { |
61 | QString sfile=QDir::homeDirPath(); | 61 | QString sfile=QDir::homeDirPath(); |
62 | if(sfile.right(1) != "/") | 62 | if(sfile.right(1) != "/") |
63 | sfile+="/._temp"; | 63 | sfile+="/._temp"; |
64 | else | 64 | else |
65 | sfile+="._temp"; | 65 | sfile+="._temp"; |
66 | QFile file( sfile); | 66 | QFile file( sfile); |
67 | if(file.exists()) | 67 | if(file.exists()) |
68 | file.remove(); | 68 | file.remove(); |
69 | } | 69 | } |
70 | 70 | ||
71 | void AdvancedFm::tabChanged(QWidget *wd) { | 71 | void AdvancedFm::tabChanged(QWidget *wd) { |
72 | if(wd == tab) { | 72 | if(wd == tab) { |
73 | whichTab = 1; | 73 | whichTab = 1; |
74 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 74 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
75 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 75 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
76 | // qDebug("tabchanged: LOCAL VIEW SHOWN"); | 76 | // qDebug("tabchanged: LOCAL VIEW SHOWN"); |
77 | } | 77 | } |
78 | 78 | ||
79 | else if(wd == tab_2) { | 79 | else if(wd == tab_2) { |
80 | whichTab = 2; | 80 | whichTab = 2; |
81 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 81 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
82 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 82 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
83 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); | 83 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); |
84 | } | 84 | } |
85 | qApp->processEvents(); | 85 | qApp->processEvents(); |
86 | QString path = CurrentDir()->canonicalPath(); | 86 | QString path = CurrentDir()->canonicalPath(); |
87 | 87 | ||
88 | chdir( path.latin1()); | 88 | chdir( path.latin1()); |
89 | currentPathCombo->lineEdit()->setText(path); | 89 | currentPathCombo->lineEdit()->setText(path); |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | void AdvancedFm::populateView() { | 93 | void AdvancedFm::populateView() { |
94 | 94 | ||
95 | QPixmap pm; | 95 | QPixmap pm; |
96 | QListView *thisView = CurrentView(); | 96 | QListView *thisView = CurrentView(); |
97 | QDir *thisDir = CurrentDir(); | 97 | QDir *thisDir = CurrentDir(); |
98 | QString path = thisDir->canonicalPath(); | 98 | QString path = thisDir->canonicalPath(); |
99 | 99 | ||
100 | thisView->clear(); | 100 | thisView->clear(); |
101 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 101 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
102 | thisDir->setMatchAllDirs(TRUE); | 102 | thisDir->setMatchAllDirs(TRUE); |
103 | thisDir->setNameFilter(filterStr); | 103 | thisDir->setNameFilter(filterStr); |
104 | QString fileL, fileS, fileDate; | 104 | QString fileL, fileS, fileDate; |
105 | 105 | ||
106 | QString fs = getFileSystemType((const QString &) path); | 106 | QString fs = getFileSystemType((const QString &) path); |
107 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 107 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
108 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | 108 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
109 | bool isDir = FALSE; | 109 | bool isDir = FALSE; |
110 | 110 | ||
111 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 111 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
112 | QFileInfoListIterator it(*list); | 112 | QFileInfoListIterator it(*list); |
113 | QFileInfo *fi; | 113 | QFileInfo *fi; |
114 | while ( (fi=it.current()) ) { | 114 | while ( (fi=it.current()) ) { |
115 | if (fi->isSymLink() ) { | 115 | if (fi->isSymLink() ) { |
116 | QString symLink = fi->readLink(); | 116 | QString symLink = fi->readLink(); |
117 | QFileInfo sym( symLink); | 117 | QFileInfo sym( symLink); |
118 | fileS.sprintf( "%10i", sym.size() ); | 118 | fileS.sprintf( "%10i", sym.size() ); |
119 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 119 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
120 | fileDate = sym.lastModified().toString(); | 120 | fileDate = sym.lastModified().toString(); |
121 | } else { | 121 | } else { |
122 | fileS.sprintf( "%10i", fi->size() ); | 122 | fileS.sprintf( "%10i", fi->size() ); |
123 | fileL = fi->fileName(); | 123 | fileL = fi->fileName(); |
124 | fileDate= fi->lastModified().toString(); | 124 | fileDate= fi->lastModified().toString(); |
125 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 125 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
126 | // if(fileL == "..") | 126 | // if(fileL == "..") |
127 | fileL += "/"; | 127 | fileL += "/"; |
128 | isDir=TRUE; | 128 | isDir=TRUE; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | QFileInfo fileInfo( path + "/" + fileL); | 131 | QFileInfo fileInfo( path + "/" + fileL); |
132 | 132 | ||
133 | if(fileL !="./" && fi->exists()) { | 133 | if(fileL !="./" && fi->exists()) { |
134 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 134 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
135 | 135 | ||
136 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 136 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
137 | 137 | ||
138 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 138 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
139 | pm = Resource::loadPixmap( "lockedfolder" ); | 139 | pm.convertFromImage( Resource::loadImage( "lockedfolder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
140 | else | 140 | else |
141 | pm= Resource::loadPixmap( "folder" ); | 141 | pm.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
142 | } | 142 | } |
143 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 143 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
144 | pm = Resource::loadPixmap( "exec"); | 144 | pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
145 | } | 145 | } |
146 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 146 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
147 | | fileInfo.permission( QFileInfo::ExeGroup) | 147 | | fileInfo.permission( QFileInfo::ExeGroup) |
148 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 148 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
149 | pm = Resource::loadPixmap( "exec"); | 149 | pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
150 | } | 150 | } |
151 | else if( !fi->isReadable() ) { | 151 | else if( !fi->isReadable() ) { |
152 | pm = Resource::loadPixmap( "locked" ); | 152 | pm.convertFromImage( Resource::loadImage( "locked" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
153 | } | 153 | } |
154 | else { //everything else goes by mimetype | 154 | else { //everything else goes by mimetype |
155 | MimeType mt(fi->filePath()); | 155 | MimeType mt(fi->filePath()); |
156 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 156 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
157 | if(pm.isNull()) { | 157 | if(pm.isNull()) { |
158 | pm = unknownXpm; | 158 | pm = unknownXpm; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 161 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
162 | // odebug << " overlay link image" << oendl; | 162 | // odebug << " overlay link image" << oendl; |
163 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | 163 | pm.convertFromImage( Resource::loadImage( "advancedfm/symlink" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); |
164 | // pm= Resource::loadPixmap( "folder" ); | 164 | // pm= Resource::loadPixmap( "folder" ); |
165 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 165 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
166 | // QPainter painter( &pm ); | 166 | // QPainter painter( &pm ); |
167 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 167 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
168 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 168 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
169 | } | 169 | } |
170 | item->setPixmap( 0,pm); | 170 | item->setPixmap( 0, pm ); |
171 | 171 | ||
172 | } | 172 | } |
173 | isDir=FALSE; | 173 | isDir=FALSE; |
174 | ++it; | 174 | ++it; |
175 | } | 175 | } |
176 | 176 | ||
177 | if( path.find("dev",0,TRUE) != -1) { | 177 | if( path.find("dev",0,TRUE) != -1) { |
178 | struct stat buf; | 178 | struct stat buf; |
179 | dev_t devT; | 179 | dev_t devT; |
180 | DIR *dir; | 180 | DIR *dir; |
181 | struct dirent *mydirent; | 181 | struct dirent *mydirent; |
182 | 182 | ||
183 | if((dir = opendir( path.latin1())) != NULL) | 183 | if((dir = opendir( path.latin1())) != NULL) |
184 | while ((mydirent = readdir(dir)) != NULL) { | 184 | while ((mydirent = readdir(dir)) != NULL) { |
185 | lstat( mydirent->d_name, &buf); | 185 | lstat( mydirent->d_name, &buf); |
186 | // odebug << mydirent->d_name << oendl; | 186 | // odebug << mydirent->d_name << oendl; |
187 | fileL.sprintf("%s", mydirent->d_name); | 187 | fileL.sprintf("%s", mydirent->d_name); |
188 | devT = buf.st_dev; | 188 | devT = buf.st_dev; |
189 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 189 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
190 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 190 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
191 | if( fileL.find(".") == -1 ) { | 191 | if( fileL.find(".") == -1 ) { |
192 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 192 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
193 | pm = unknownXpm; | 193 | pm = unknownXpm; |
194 | item->setPixmap( 0,pm); | 194 | item->setPixmap( 0,pm); |
195 | } | 195 | } |
196 | } | 196 | } |
197 | 197 | ||
198 | closedir(dir); | 198 | closedir(dir); |
199 | } | 199 | } |
200 | 200 | ||
201 | thisView->setSorting( 3,FALSE); | 201 | thisView->setSorting( 3,FALSE); |
202 | fillCombo( (const QString &) path ); | 202 | fillCombo( (const QString &) path ); |
203 | } | 203 | } |
204 | 204 | ||
205 | void AdvancedFm::rePopulate() { | 205 | void AdvancedFm::rePopulate() { |
206 | // qDebug("repopulate views"); | 206 | // qDebug("repopulate views"); |
207 | populateView(); | 207 | populateView(); |
208 | setOtherTabCurrent(); | 208 | setOtherTabCurrent(); |
209 | populateView(); | 209 | populateView(); |
210 | } | 210 | } |
211 | 211 | ||
212 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | 212 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { |
213 | if(selectedItem) { | 213 | if(selectedItem) { |
214 | QString strItem=selectedItem->text(0); | 214 | QString strItem=selectedItem->text(0); |
215 | // owarn << strItem << oendl; | 215 | // owarn << strItem << oendl; |
216 | QString strSize=selectedItem->text(1); | 216 | QString strSize=selectedItem->text(1); |
217 | strSize=strSize.stripWhiteSpace(); | 217 | strSize=strSize.stripWhiteSpace(); |
218 | bool isDirectory = false; | 218 | bool isDirectory = false; |
219 | QString strItem2; | 219 | QString strItem2; |
220 | 220 | ||
221 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink | 221 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink |
222 | strItem2 = dealWithSymName((const QString&)strItem); | 222 | strItem2 = dealWithSymName((const QString&)strItem); |
223 | if(QDir(strItem2).exists() ) | 223 | if(QDir(strItem2).exists() ) |
224 | strItem = strItem2; | 224 | strItem = strItem2; |
225 | } | 225 | } |
226 | 226 | ||
227 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 227 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
228 | 228 | ||
229 | if(QDir(strItem).exists()) | 229 | if(QDir(strItem).exists()) |
230 | isDirectory = true; | 230 | isDirectory = true; |
231 | } | 231 | } |
232 | 232 | ||
233 | if( isDirectory ) { | 233 | if( isDirectory ) { |
234 | CurrentDir()->cd( strItem, TRUE); | 234 | CurrentDir()->cd( strItem, TRUE); |
235 | populateView(); | 235 | populateView(); |
236 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 236 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
237 | } | 237 | } |
238 | chdir( strItem.latin1()); | 238 | chdir( strItem.latin1()); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 242 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
243 | Q_UNUSED(item); | 243 | Q_UNUSED(item); |
244 | switch (mouse) { | 244 | switch (mouse) { |
245 | case 1: | 245 | case 1: |
246 | { | 246 | { |
247 | if(renameBox != 0 ) { | 247 | if(renameBox != 0 ) { |
248 | cancelRename(); | 248 | cancelRename(); |
249 | } | 249 | } |
250 | } | 250 | } |
251 | break; | 251 | break; |
252 | // case 2: | 252 | // case 2: |
253 | // menuTimer.start( 50, TRUE ); | 253 | // menuTimer.start( 50, TRUE ); |
254 | // break; | 254 | // break; |
255 | }; | 255 | }; |
256 | } | 256 | } |
257 | 257 | ||
258 | 258 | ||
259 | void AdvancedFm::refreshCurrentTab() { | 259 | void AdvancedFm::refreshCurrentTab() { |
260 | populateView(); | 260 | populateView(); |
261 | // if ( TabWidget->currentWidget() == tab) { | 261 | // if ( TabWidget->currentWidget() == tab) { |
262 | } | 262 | } |
263 | 263 | ||
264 | void AdvancedFm::switchToLocalTab() { | 264 | void AdvancedFm::switchToLocalTab() { |
265 | TabWidget->setCurrentWidget(tab); | 265 | TabWidget->setCurrentWidget(tab); |
266 | Local_View->setFocus(); | 266 | Local_View->setFocus(); |