diff options
author | william <william.os4y@gmail.com> | 2015-03-20 08:02:04 +0100 |
---|---|---|
committer | william <william.os4y@gmail.com> | 2015-03-20 08:02:04 +0100 |
commit | d9ff9adac5b379cd9d96277dd48d0259b8545921 (patch) | |
tree | d7ba249ca026a1f1680df717caa5248d30a4b222 /lumina-fm | |
parent | Merge remote-tracking branch 'upstream/master' into fmNumbers (diff) | |
parent | Update some panel plugins so that they minimize empty space when only an icon... (diff) | |
download | lumina-d9ff9adac5b379cd9d96277dd48d0259b8545921.tar.gz lumina-d9ff9adac5b379cd9d96277dd48d0259b8545921.tar.bz2 lumina-d9ff9adac5b379cd9d96277dd48d0259b8545921.zip |
Merge remote-tracking branch 'upstream/master' into fmNumbers
Diffstat (limited to 'lumina-fm')
-rw-r--r-- | lumina-fm/BackgroundWorker.cpp | 15 | ||||
-rw-r--r-- | lumina-fm/MainUI.cpp | 48 | ||||
-rw-r--r-- | lumina-fm/MainUI.h | 2 | ||||
-rw-r--r-- | lumina-fm/MimeIconProvider.h | 10 |
4 files changed, 63 insertions, 12 deletions
diff --git a/lumina-fm/BackgroundWorker.cpp b/lumina-fm/BackgroundWorker.cpp index bbba8749..1438f71e 100644 --- a/lumina-fm/BackgroundWorker.cpp +++ b/lumina-fm/BackgroundWorker.cpp @@ -3,6 +3,8 @@ #include <LuminaXDG.h> #include <QMediaServiceSupportedFormatsInterface> #include <QImageReader> +#include <QDir> +#include <QFileInfo> BackgroundWorker::BackgroundWorker() : QObject(){ @@ -14,6 +16,9 @@ BackgroundWorker::~BackgroundWorker(){ void BackgroundWorker::startDirChecks(QString path){ QDir dir(path); + //Make sure to remove any symlinks or redundency in the path + if(dir.canonicalPath()!=path){ path = dir.canonicalPath(); dir.cd(path); } + qDebug() << "Starting Dir Checks:" << path; //First check for image files if(imgFilter.isEmpty()){ //Initial Run - load supported image extensions @@ -34,27 +39,30 @@ void BackgroundWorker::startDirChecks(QString path){ } QStringList files = dir.entryList(multiFilter, QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase); if(!files.isEmpty() && !multiFilter.isEmpty()){ emit MultimediaAvailable(files); } - + qDebug() << " - done with audio/multimedia checks"; //Now check for ZFS snapshots of the directory if(!QFileInfo(path).isWritable() ){ return; } //skip ZFS checks if can't restore to this dir cdir = path; QStringList snapDirs; QString baseSnapDir; bool found = false; + qDebug() << " - start searching for base snapshot directory"; if(cdir == path && QFile::exists(csnapdir) ){ //no need to re-search for it - just found it recently baseSnapDir= csnapdir; found=true; }else{ - while(dir.absolutePath()!="/" && !found){ + while(dir.canonicalPath()!="/" && !found){ if(dir.exists(".zfs/snapshot")){ baseSnapDir = dir.canonicalPath()+"/.zfs/snapshot"; found = true; }else{ dir.cdUp(); } } } + qDebug() << " - done with base snapshot directory"; cdir = path; csnapdir = baseSnapDir; //Now find the snapshots that contain this directory and save them if(found){ + qDebug() << " - start fetching snapshots"; QString reldir = path; reldir.remove(baseSnapDir.section("/.zfs/snapshot",0,0)); //convert to a relative path dir.cd(baseSnapDir); @@ -68,12 +76,13 @@ void BackgroundWorker::startDirChecks(QString path){ snapDirs[i] = QFileInfo(dir, snapDirs[i]+"/"+reldir).created().toString("yyyyMMddhhmmsszzz")+"::::"+snapDirs[i]; } } + qDebug() << " - done fetching snapshots"; snapDirs.sort(); //Sort the snapshots by time (newest last) and format them for(int i=0; i<snapDirs.length(); i++){ snapDirs[i] = dir.absolutePath()+"/"+snapDirs[i].section("::::",1,50)+"/"+reldir; } if(!snapDirs.isEmpty()){ emit SnapshotsAvailable(baseSnapDir, snapDirs); } - //qDebug() << "Found snapshots:" << snapDirs; + qDebug() << "Found snapshots"; } }
\ No newline at end of file diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index 9b7ebcc6..187922e1 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -173,7 +173,7 @@ void MainUI::setupIcons(){ ui->tool_act_paste->setIcon( LXDG::findIcon("edit-paste","") ); ui->tool_act_rename->setIcon( LXDG::findIcon("edit-rename","") ); ui->tool_act_rm->setIcon( LXDG::findIcon("edit-delete","") ); - ui->tool_act_fav->setIcon( LXDG::findIcon("quickopen","") ); + ui->tool_act_fav->setIcon( LXDG::findIcon("bookmark-toolbar","") ); //Multimedia Player page ui->tool_player_next->setIcon( LXDG::findIcon("media-skip-forward","") ); @@ -945,6 +945,7 @@ void MainUI::OpenContextMenu(const QPoint &pt){ contextMenu->addAction(LXDG::findIcon("run-build-configure",""), tr("Open With..."), this, SLOT(OpenItemWith()) ); } contextMenu->addAction(LXDG::findIcon("edit-rename",""), tr("Rename"), this, SLOT(RenameItem()) )->setEnabled(info.isWritable()); + contextMenu->addAction(LXDG::findIcon("document-encrypted",""), tr("View Checksums"), this, SLOT(ChecksumItems()) ); contextMenu->addSeparator(); } bool hasSelection = !getSelectedItems().isEmpty(); @@ -979,7 +980,17 @@ void MainUI::ItemSelectionChanged(){ } QString itname; if(sel.length()==1){ itname = sel[0].fileName(); } - ui->tool_act_fav->setEnabled(!itname.isEmpty() && !QFile::exists(favdir+itname) ); + bool ok = !itname.isEmpty() && (getCurrentDir()!=QDir::homePath()+"/Desktop"); + if(ok){ + if(QFile::exists(favdir+itname)){ + //Make sure this favorite does not already point to the current file + QFileInfo info(favdir+itname); + if(info.isSymLink() && info.exists()){ + ok = false; //still an active favorite - do not allow replacement + } + } + } + ui->tool_act_fav->setEnabled(ok); } //------------------------------- @@ -1293,17 +1304,17 @@ void MainUI::RemoveItem(){ if(!checkUserPerms()){ return; } //Get the selected items QStringList paths, names; - if(CItem.isEmpty()){ + //if(CItem.isEmpty()){ QFileInfoList sel = getSelectedItems(); for(int i=0; i<sel.length(); i++){ paths << sel[i].absoluteFilePath(); names << sel[i].fileName(); } if(sel.isEmpty()){ return; } //nothing selected - }else{ + /*}else{ paths << CItem; names << CItem.section("/",-1); - } + }*/ //Verify permanent removal of file/dir if(QMessageBox::Yes != QMessageBox::question(this, tr("Verify Removal"), tr("WARNING: This will permanently delete the file(s) from the system!")+"\n"+tr("Are you sure you want to continue?")+"\n\n"+names.join("\n"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){ return; //cancelled @@ -1371,6 +1382,7 @@ void MainUI::FavoriteItem(){ QString fname = CItem; QString fullpath = fname; fname = fname.section("/",-1); //turn this into just the file name + if(QFile::exists(favdir+fname)){ QFile::remove(favdir+fname); } //remove the stale link QFile::link(fullpath, favdir+fname); CItem.clear(); ItemSelectionChanged(); @@ -1470,8 +1482,30 @@ void MainUI::PasteItems(){ QApplication::clipboard()->setMimeData(dat); } } - ItemSelectionChanged(); - + ItemSelectionChanged(); +} + +void MainUI::ChecksumItems(){ + if(ui->stackedWidget->currentWidget()!=ui->page_browser){ return; } + QFileInfoList sel = getSelectedItems(); + if(sel.isEmpty()){ return; } + QStringList info, files; + for(int i=0; i<sel.length(); i++){ + files << sel[i].absoluteFilePath(); + } + qDebug() << "Run Checksums:" << files; + info = LOS::Checksums(files); + qDebug() << " - Info:" << info; + if(info.isEmpty() || (info.length() != files.length()) ){ return; } + for(int i=0; i<info.length(); i++){ + info[i] = QString("%2 \t(%1)").arg(files[i].section("/",-1), info[i]); + } + /*QMessageBox dlg(this); + dlg.setWindowFlags( Qt::Dialog ); + dlg.setWindowTitle( tr("File Checksums") ); + dlg.setInformativeText(info.join("\n")); + dlg.exec();*/ + QMessageBox::information(this, tr("File Checksums"), info.join("\n") ); } void MainUI::resizeEvent(QResizeEvent *event){ diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h index 40ef25ff..97cadf86 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -89,7 +89,6 @@ private: //Phonon Widgets for the multimedia player QMediaPlayer *mediaObj; QVideoWidget *videoDisplay; - //Phonon::AudioOutput *audioOut; QSlider *playerSlider; QString playerTTime; //total time - to prevent recalculation every tick @@ -219,6 +218,7 @@ private slots: void CutItems(); void CopyItems(); void PasteItems(); + void ChecksumItems(); signals: void DirChanged(QString path); diff --git a/lumina-fm/MimeIconProvider.h b/lumina-fm/MimeIconProvider.h index 344d6801..0c9ba98e 100644 --- a/lumina-fm/MimeIconProvider.h +++ b/lumina-fm/MimeIconProvider.h @@ -34,8 +34,16 @@ public: if(showthumbnails && (info.suffix().toLower()=="png" || info.suffix().toLower()=="jpg") ){ //make sure to only load small versions of the files into memory: could have hundreds of them... return QIcon( QPixmap(info.absoluteFilePath()).scaledToHeight(64) ); + }else if(info.fileName().endsWith(".desktop") ){ + bool ok = false; + XDGDesktop desk = LXDG::loadDesktopFile(info.absoluteFilePath(), ok); + if(ok){ + return LXDG::findIcon(desk.icon, "unknown"); + }else{ + return LXDG::findMimeIcon(info.fileName()); + } }else{ - return LXDG::findMimeIcon(info.suffix()); + return LXDG::findMimeIcon(info.fileName()); } }else{ return LXDG::findIcon("unknown",""); |