-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 27 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 29 |
2 files changed, 26 insertions, 30 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 979549d..828f5a1 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp @@ -1,71 +1,70 @@ /*************************************************************************** AdvancedFm.cpp ------------------- ** Created: Sat Mar 9 23:33:09 2002 copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #define DEVELOPERS_VERSION #include "advancedfm.h" #include <opie2/odebug.h> - +#include <opie2/oresource.h> #include <opie2/ostorageinfo.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/mimetype.h> #include <qpe/applnk.h> -#include <qpe/resource.h> #include <qpe/menubutton.h> #include <qcombobox.h> #include <qpopupmenu.h> #include <qlistview.h> #include <qmessagebox.h> #include <qlineedit.h> #include <sys/stat.h> #include <time.h> #include <dirent.h> #include <fcntl.h> #include <sys/vfs.h> #include <mntent.h> using namespace Opie::Ui; AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) : QMainWindow( ) { init(); renameBox = 0; whichTab = 1; - unknownXpm = Resource::loadImage("UnknownDocument").smoothScale(AppLnk::smallIconSize(),AppLnk::smallIconSize() ); + unknownXpm = Opie::Core::OResource::loadImage("UnknownDocument", Opie::Core::OResource::SmallIcon); initConnections(); rePopulate(); channel = new QCopChannel( "QPE/Application/advancedfm", this ); connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&))); switchToLocalTab(); } AdvancedFm::~AdvancedFm() { } void AdvancedFm::cleanUp() { QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") sfile+="/._temp"; else sfile+="._temp"; QFile file( sfile); if(file.exists()) file.remove(); } void AdvancedFm::tabChanged(QWidget *wd) { @@ -115,78 +114,73 @@ void AdvancedFm::populateView() { if (fi->isSymLink() ) { QString symLink = fi->readLink(); QFileInfo sym( symLink); fileS.sprintf( "%10i", sym.size() ); fileL = fi->fileName() +" -> " + sym.filePath().data(); fileDate = sym.lastModified().toString(); } else { fileS.sprintf( "%10i", fi->size() ); fileL = fi->fileName(); fileDate= fi->lastModified().toString(); if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { // if(fileL == "..") fileL += "/"; isDir=TRUE; } } QFileInfo fileInfo( path + "/" + fileL); if(fileL !="./" && fi->exists()) { item = new QListViewItem( thisView, fileL, fileS , fileDate); if(isDir || fileL.find("/",0,TRUE) != -1) { if( !QDir( fi->filePath() ).isReadable()) //is directory - pm.convertFromImage( Resource::loadImage( "lockedfolder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); + pm = Opie::Core::OResource::loadPixmap( "lockedfolder", Opie::Core::OResource::SmallIcon ); else - pm.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - } + pm = Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ); + } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { - pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); + pm = Opie::Core::OResource::loadPixmap( "exec", Opie::Core::OResource::SmallIcon ); } else if( (fileInfo.permission( QFileInfo::ExeUser) | fileInfo.permission( QFileInfo::ExeGroup) | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { - pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); + pm = Opie::Core::OResource::loadPixmap( "exec", Opie::Core::OResource::SmallIcon ); } else if( !fi->isReadable() ) { - pm.convertFromImage( Resource::loadImage( "locked" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); + pm = Opie::Core::OResource::loadPixmap( "locked", Opie::Core::OResource::SmallIcon ); } else { //everything else goes by mimetype MimeType mt(fi->filePath()); pm=mt.pixmap(); //sets the correct pixmap for mimetype if(pm.isNull()) { pm = unknownXpm; } } if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { // odebug << " overlay link image" << oendl; - pm.convertFromImage( Resource::loadImage( "advancedfm/symlink" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - // pm= Resource::loadPixmap( "folder" ); -// QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); -// QPainter painter( &pm ); -// painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); -// pm.setMask( pm.createHeuristicMask( FALSE ) ); + pm = Opie::Core::OResource::loadPixmap( "advancedfm/symlink", Opie::Core::OResource::SmallIcon ); } item->setPixmap( 0, pm ); } isDir=FALSE; ++it; } if( path.find("dev",0,TRUE) != -1) { struct stat buf; dev_t devT; DIR *dir; struct dirent *mydirent; if((dir = opendir( path.latin1())) != NULL) while ((mydirent = readdir(dir)) != NULL) { lstat( mydirent->d_name, &buf); // odebug << mydirent->d_name << oendl; fileL.sprintf("%s", mydirent->d_name); devT = buf.st_dev; fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); fileDate.sprintf("%s", ctime( &buf.st_mtime)); if( fileL.find(".") == -1 ) { item= new QListViewItem( thisView, fileL, fileS, fileDate); @@ -439,49 +433,50 @@ QString AdvancedFm::getDiskSpace( const QString &path) { } void AdvancedFm::showFileMenu() { QString curApp; curApp = CurrentView()->currentItem()->text(0); MimeType mt(curApp); const AppLnk* app = mt.application(); QFile fi(curApp); QPopupMenu *m = new QPopupMenu(0); QPopupMenu *n = new QPopupMenu(0); // QPopupMenu *o = new QPopupMenu(0); m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); if ( QFileInfo(fi).isDir()) { m->insertSeparator(); m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); } else { if (app) m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this m->insertItem(tr("Execute"),this,SLOT(runThis())); - m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); + m->insertItem( Opie::Core::OResource::loadPixmap( "txt", Opie::Core::OResource::SmallIcon ), + tr("Open as text"),this,SLOT(runText())); } m->insertItem(tr("Actions"),n); n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); n->insertSeparator(); n->insertItem(tr("Rename"),this,SLOT(renameIt())); n->insertItem(tr("Copy"),this,SLOT(copyTimer())); n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); n->insertItem(tr("Move"),this,SLOT(moveTimer())); n->insertSeparator(); n->insertItem(tr("Delete"),this,SLOT(doDelete())); m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); m->insertItem(tr("Run Command"),this,SLOT(runCommand())); m->insertItem(tr("File Info"),this,SLOT(fileStatus())); m->insertSeparator(); m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index b43d2ba..aa9db52 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp @@ -1,112 +1,113 @@ /*************************************************************************** advancedfmData.cpp ------------------- ** Created: Mon 09-23-2002 13:24:11 copyright : (C) 2002 by ljp email : ljp@llornkcor.com * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #include "advancedfm.h" /* OPIE */ #include <opie2/odebug.h> +#include <opie2/oresource.h> #include <qpe/applnk.h> #include <qpe/storage.h> #include <qpe/qpeapplication.h> -#include <qpe/resource.h> #include <qpe/menubutton.h> using namespace Opie::Core; using namespace Opie::Ui; /* QT */ #include <qlayout.h> #include <qhbox.h> #include <qmenubar.h> #include <qcombobox.h> #include <qtoolbutton.h> #include <qlineedit.h> #include <qlistview.h> /* STD */ #include <sys/utsname.h> void AdvancedFm::init() { b = false; setCaption( tr( "AdvancedFm" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setSpacing( 2); layout->setMargin( 0); // squeeze QMenuBar *menuBar = new QMenuBar(this); menuBar->setMargin( 0 ); // squeeze fileMenu = new QPopupMenu( this ); viewMenu = new QPopupMenu( this ); // customDirMenu = new QPopupMenu( this ); layout->addWidget( menuBar ); menuBar->insertItem( tr( "File" ), fileMenu); menuBar->insertItem( tr( "View" ), viewMenu); - QPixmap pm; + bool useBigIcon = qApp->desktop()->size().width() > 330; + cdUpButton = new QToolButton( 0,"cdUpButton"); - pm.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - cdUpButton->setPixmap( pm ); + cdUpButton->setUsesBigPixmap( useBigIcon ); + cdUpButton->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); cdUpButton->setAutoRaise( true ); menuBar->insertItem( cdUpButton ); qpeDirButton= new QToolButton( 0,"QPEButton"); - pm.convertFromImage( Resource::loadImage( "logo/opielogo" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - qpeDirButton->setPixmap( pm );//,"",this,"QPEButton"); + qpeDirButton->setUsesBigPixmap( useBigIcon ); + qpeDirButton->setPixmap( Opie::Core::OResource::loadPixmap( "logo/opielogo", Opie::Core::OResource::SmallIcon ) ); qpeDirButton->setAutoRaise( true ); menuBar->insertItem( qpeDirButton ); cfButton = new QToolButton( 0, "CFButton"); - pm.convertFromImage( Resource::loadImage( "cardmon/pcmcia" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - cfButton->setPixmap( pm ); + cfButton->setUsesBigPixmap( useBigIcon ); + cfButton->setPixmap( Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ) ); cfButton->setAutoRaise( true ); menuBar->insertItem( cfButton ); sdButton = new QToolButton( 0, "SDButton"); - pm.convertFromImage( Resource::loadImage( "advancedfm/sdcard" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - sdButton->setPixmap( pm ); + sdButton->setUsesBigPixmap( useBigIcon ); + sdButton->setPixmap( Opie::Core::OResource::loadPixmap( "advancedfm/sdcard", Opie::Core::OResource::SmallIcon ) ); sdButton->setAutoRaise( true ); menuBar->insertItem( sdButton ); docButton = new QToolButton( 0,"docsButton"); - pm.convertFromImage( Resource::loadImage( "DocsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - docButton->setPixmap( pm ); + docButton->setUsesBigPixmap( useBigIcon ); + docButton->setPixmap( Opie::Core::OResource::loadPixmap( "DocsIcon", Opie::Core::OResource::SmallIcon ) ); docButton->setAutoRaise( true ); menuBar->insertItem( docButton ); homeButton = new QToolButton( 0, "homeButton"); - pm.convertFromImage( Resource::loadImage( "home" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); - homeButton->setPixmap( pm ); + homeButton->setUsesBigPixmap( useBigIcon ); + homeButton->setPixmap( Opie::Core::OResource::loadPixmap( "home", Opie::Core::OResource::SmallIcon ) ); homeButton->setAutoRaise( true ); menuBar->insertItem( homeButton ); fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); fileMenu->insertSeparator(); fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); fileMenu->setCheckable(TRUE); viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab())); viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); viewMenu->insertItem( tr( "Refresh" ), this, SLOT( refreshCurrentTab())); // viewMenu->insertSeparator(); // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |