From eea17de71ca7198bb3e463b730c534090496fc7c Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 18 Nov 2016 10:36:46 -0500 Subject: Add a couple new features to lumina-archiver: 1) Add the ability to extract only the selected item from an archive 2) Add better status reporting on archive interactions Changelog=yes --- src-qt5/desktop-utils/lumina-archiver/MainUI.cpp | 30 +++++++++++++++++-- src-qt5/desktop-utils/lumina-archiver/MainUI.h | 3 +- src-qt5/desktop-utils/lumina-archiver/MainUI.ui | 34 ++++++++++++++++++++++ .../desktop-utils/lumina-archiver/TarBackend.cpp | 22 +++++++++----- src-qt5/desktop-utils/lumina-archiver/TarBackend.h | 4 +-- 5 files changed, 80 insertions(+), 13 deletions(-) (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp index 9710045c..71fb6db1 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp @@ -18,7 +18,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ this->setWindowTitle(tr("Archive Manager")); BACKEND = new Backend(this); connect(BACKEND, SIGNAL(ProcessStarting()), this, SLOT(ProcStarting()) ); - connect(BACKEND, SIGNAL(ProcessFinished()), this, SLOT(ProcFinished()) ); + connect(BACKEND, SIGNAL(ProcessFinished(bool, QString)), this, SLOT(ProcFinished(bool, QString)) ); connect(BACKEND, SIGNAL(ProgressUpdate(int, QString)), this, SLOT(ProcUpdate(int, QString)) ); //Add a spacer between toolbar items @@ -33,10 +33,12 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->actionAdd_File, SIGNAL(triggered()), this, SLOT(addFiles()) ); connect(ui->actionRemove_File, SIGNAL(triggered()), this, SLOT(remFiles()) ); connect(ui->actionExtract_All, SIGNAL(triggered()), this, SLOT(extractFiles()) ); + connect(ui->actionExtract_Sel, SIGNAL(triggered()), this, SLOT(extractSelection()) ); connect(ui->actionAdd_Dirs, SIGNAL(triggered()), this, SLOT(addDirs()) ); connect(ui->tree_contents, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(ViewFile(QTreeWidgetItem*)) ); ui->progressBar->setVisible(false); ui->label_progress->setVisible(false); + ui->label_progress_icon->setVisible(false); ui->actionAdd_File->setEnabled(false); ui->actionRemove_File->setEnabled(false); ui->actionExtract_All->setEnabled(false); @@ -64,6 +66,7 @@ void MainUI::loadIcons(){ ui->actionAdd_Dirs->setIcon( LXDG::findIcon("archive-insert-directory","") ); ui->actionRemove_File->setIcon( LXDG::findIcon("archive-remove","") ); ui->actionExtract_All->setIcon( LXDG::findIcon("archive-extract","") ); + ui->actionExtract_Sel->setIcon( LXDG::findIcon("archive-extract","") ); } //=================== @@ -158,24 +161,28 @@ void MainUI::NewArchive(){ if(QFile::exists(file)){ if( !QFile::remove(file) ){ QMessageBox::warning(this, tr("Error"), QString(tr("Could not overwrite file:"))+"\n"+file); } } + ui->label_progress->setText(""); //just clear it (this action is instant) BACKEND->loadFile(file); } void MainUI::OpenArchive(){ QString file = QFileDialog::getOpenFileName(this, tr("Open Archive"), QDir::homePath(), OpenFileTypes() ); if(file.isEmpty()){ return; } + ui->label_progress->setText(tr("Opening Archive")); BACKEND->loadFile(file); } void MainUI::addFiles(){ QStringList files = QFileDialog::getOpenFileNames(this, tr("Add to Archive"), QDir::homePath() ); if(files.isEmpty()){ return; } + ui->label_progress->setText(tr("Adding Items")); BACKEND->startAdd(files); } void MainUI::addDirs(){ QString dirs = QFileDialog::getExistingDirectory(this, tr("Add to Archive"), QDir::homePath() ); if(dirs.isEmpty()){ return; } + ui->label_progress->setText(tr("Adding Items")); BACKEND->startAdd(QStringList() << dirs); } @@ -186,17 +193,29 @@ void MainUI::remFiles(){ items << sel[i]->whatsThis(0); } items.removeDuplicates(); + ui->label_progress->setText(tr("Removing Items")); BACKEND->startRemove(items); } void MainUI::extractFiles(){ QString dir = QFileDialog::getExistingDirectory(this, tr("Extract Into Directory"), QDir::homePath() ); if(dir.isEmpty()){ return; } + ui->label_progress->setText(tr("Extracting...")); BACKEND->startExtract(dir, true); } +void MainUI::extractSelection(){ + if(ui->tree_contents->currentItem()==0){ return; } + QString sel = ui->tree_contents->currentItem()->whatsThis(0); + QString dir = QFileDialog::getExistingDirectory(this, tr("Extract Into Directory"), QDir::homePath() ); + if(dir.isEmpty()){ return; } + ui->label_progress->setText(tr("Extracting...")); + BACKEND->startExtract(dir, true, sel); +} + void MainUI::ViewFile(QTreeWidgetItem *it){ if(it->childCount()>0){ return; } //directory - not viewable + ui->label_progress->setText(tr("Extracting...")); BACKEND->startViewFile(it->whatsThis(0)); } @@ -242,16 +261,21 @@ void MainUI::ProcStarting(){ ui->progressBar->setValue(0); ui->progressBar->setVisible(true); ui->label_progress->setVisible(true); + ui->label_progress_icon->setVisible(false); ui->tree_contents->setEnabled(false); ui->label_archive->setText(BACKEND->currentFile()); } -void MainUI::ProcFinished(){ +void MainUI::ProcFinished(bool success, QString msg){ ui->progressBar->setRange(0,0); ui->progressBar->setValue(0); ui->progressBar->setVisible(false); - ui->label_progress->setVisible(false); + ui->label_progress->setText(msg); + ui->label_progress->setVisible(!msg.isEmpty()); ui->tree_contents->setEnabled(true); + ui->label_progress_icon->setVisible(!msg.isEmpty()); + if(success){ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-complete","").pixmap(32,32) );} + else{ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-attention","").pixmap(32,32) );} if(ui->label_archive->text()!=BACKEND->currentFile()){ ui->label_archive->setText(BACKEND->currentFile()); this->setWindowTitle(BACKEND->currentFile().section("/",-1)); diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.h b/src-qt5/desktop-utils/lumina-archiver/MainUI.h index 09207aa3..bb462a7d 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.h +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.h @@ -44,13 +44,14 @@ private slots: void addDirs(); void remFiles(); void extractFiles(); + void extractSelection(); void ViewFile(QTreeWidgetItem *it); void UpdateTree(); //Backend Handling void ProcStarting(); - void ProcFinished(); + void ProcFinished(bool, QString); void ProcUpdate(int percent, QString txt); }; diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.ui b/src-qt5/desktop-utils/lumina-archiver/MainUI.ui index 8c2b2836..1aff2e4f 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.ui @@ -56,6 +56,31 @@ + + + + + 0 + 0 + + + + + 32 + 32 + + + + + 32 + 32 + + + + + + + @@ -68,6 +93,9 @@ + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -101,6 +129,7 @@ + @@ -183,6 +212,11 @@ Add directory to archive + + + Extract Selection + + diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index 4dee247b..de3ef49b 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -32,7 +32,7 @@ void Backend::loadFile(QString path){ flags.clear(); flags << "-f" << filepath; //add the actual archive path if(QFile::exists(path)){ startList(); } - else{ contents.clear(); emit ProcessFinished(); } + else{ contents.clear(); emit ProcessFinished(true, ""); } } bool Backend::canModify(){ @@ -115,11 +115,13 @@ void Backend::startRemove(QStringList paths){ PROC.start("tar", args); } -void Backend::startExtract(QString path, bool overwrite){ +void Backend::startExtract(QString path, bool overwrite, QString file){ QStringList args; args << "-x"; if(!overwrite){ args << "-k"; } - args << flags << "-C" << path; + args << flags; + if(!file.isEmpty()){ args << "--include" << file << "--strip-components" << QString::number(file.count("/")); } + args << "-C" << path; STARTING=true; //qDebug() << "Starting command:" << "tar" << args; PROC.start("tar", args); @@ -174,17 +176,19 @@ void Backend::startList(){ // PRIVATE SLOTS //=============== void Backend::procFinished(int retcode, QProcess::ExitStatus){ + static QString result; processData(); qDebug() << "Process Finished:" << PROC.arguments() << retcode; LIST = STARTING = false; if(PROC.arguments().contains("-tv")){ if(retcode!=0){ contents.clear(); } //could not read archive - emit ProcessFinished(); + emit ProcessFinished(true,result); + result.clear(); }else{ bool needupdate = true; QStringList args = PROC.arguments(); if(args.contains("-x") && retcode==0){ - needupdate=false; + needupdate=false; if(args.contains("--include")){ //Need to find the full path to the extracted file QString path = args.last() +"/"+ args[ args.indexOf("--include")+1].section("/",-1); @@ -201,8 +205,10 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){ QFile::remove(tmpfilepath); } } + if(args.contains("-x")){ result = tr("Extraction Finished"); } + else if(args.contains("-c")){ result = tr("Modification Finished"); } if(needupdate){ startList(); } - else{ emit ProcessFinished(); } + else{ emit ProcessFinished(retcode==0, result); result.clear(); } } } @@ -213,7 +219,9 @@ void Backend::processData(){ if(read.endsWith("\n")){ data.clear(); } else{ data = read.section("\n",-1); read = read.section("\n",0,-2); } QStringList lines = read.split("\n",QString::SkipEmptyParts); + QString info; if(LIST){ parseLines(lines); } + else if(!lines.isEmpty()){ info = lines.last(); } //qDebug() << lines; - emit ProgressUpdate(-1, ""); + emit ProgressUpdate(-1, info); } diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h index f12aae63..c1e47454 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h @@ -33,7 +33,7 @@ public: //Modification routines void startAdd(QStringList paths); void startRemove(QStringList paths); - void startExtract(QString path, bool overwrite); //path to dir + void startExtract(QString path, bool overwrite, QString file=""); //path to dir, overwrite, optional file to extract (everything otherwise) void startViewFile(QString path); @@ -58,7 +58,7 @@ signals: void FileLoaded(); void ProcessStarting(); void ProgressUpdate(int, QString); //percentage, text - void ProcessFinished(); + void ProcessFinished(bool, QString); //success, text }; #endif -- cgit From dfcd09c7824548001260bc18dcae711c50f63de3 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 18 Nov 2016 12:37:01 -0500 Subject: Fix up the detection of links within an archive - and show them appropriately within the UI --- src-qt5/desktop-utils/lumina-archiver/MainUI.cpp | 61 +++++++++++++++------- .../desktop-utils/lumina-archiver/TarBackend.cpp | 25 +++++++-- src-qt5/desktop-utils/lumina-archiver/TarBackend.h | 3 ++ 3 files changed, 66 insertions(+), 23 deletions(-) (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp index 71fb6db1..9d41374c 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp @@ -44,7 +44,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->actionExtract_All->setEnabled(false); ui->actionAdd_Dirs->setEnabled(false); loadIcons(); - ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size") << tr("Compressed")+" " ); + ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size")+" " ); } MainUI::~MainUI(){ @@ -53,7 +53,11 @@ MainUI::~MainUI(){ void MainUI::LoadArguments(QStringList args){ for(int i=0; iloadFile(args[i]); break;} + if(QFile::exists(args[i])){ + ui->label_progress->setText(tr("Opening Archive...")); + BACKEND->loadFile(args[i]); + break; + } } } @@ -75,17 +79,16 @@ void MainUI::loadIcons(){ QTreeWidgetItem* MainUI::findItem(QString path, QTreeWidgetItem *start){ if(start==0){ for(int i=0; itree_contents->topLevelItemCount(); i++){ - QString itpath = ui->tree_contents->topLevelItem(i)->whatsThis(0); - if(itpath == path){ return ui->tree_contents->topLevelItem(i); } - else if(path.startsWith(itpath+"/")){ return findItem(path, ui->tree_contents->topLevelItem(i)); } + if(ui->tree_contents->topLevelItem(i)->whatsThis(0) == path){ return ui->tree_contents->topLevelItem(i); } + else if(path.startsWith(ui->tree_contents->topLevelItem(i)->whatsThis(0)+"/")){ return findItem(path, ui->tree_contents->topLevelItem(i)); } } }else{ for(int i=0; ichildCount(); i++){ - QString itpath = start->child(i)->whatsThis(0); - if(itpath == path){ return start->child(i); } - else if(path.startsWith(itpath+"/")){ return findItem(path, start->child(i)); } + if(start->child(i)->whatsThis(0) == path){ return start->child(i); } + else if(path.startsWith(start->child(i)->whatsThis(0)+"/")){ return findItem(path, start->child(i)); } } } + //qDebug() << "Could not find item:" << path; return 0; //nothing found } @@ -168,21 +171,21 @@ void MainUI::NewArchive(){ void MainUI::OpenArchive(){ QString file = QFileDialog::getOpenFileName(this, tr("Open Archive"), QDir::homePath(), OpenFileTypes() ); if(file.isEmpty()){ return; } - ui->label_progress->setText(tr("Opening Archive")); + ui->label_progress->setText(tr("Opening Archive...")); BACKEND->loadFile(file); } void MainUI::addFiles(){ QStringList files = QFileDialog::getOpenFileNames(this, tr("Add to Archive"), QDir::homePath() ); if(files.isEmpty()){ return; } - ui->label_progress->setText(tr("Adding Items")); + ui->label_progress->setText(tr("Adding Items...")); BACKEND->startAdd(files); } void MainUI::addDirs(){ QString dirs = QFileDialog::getExistingDirectory(this, tr("Add to Archive"), QDir::homePath() ); if(dirs.isEmpty()){ return; } - ui->label_progress->setText(tr("Adding Items")); + ui->label_progress->setText(tr("Adding Items...")); BACKEND->startAdd(QStringList() << dirs); } @@ -193,7 +196,7 @@ void MainUI::remFiles(){ items << sel[i]->whatsThis(0); } items.removeDuplicates(); - ui->label_progress->setText(tr("Removing Items")); + ui->label_progress->setText(tr("Removing Items...")); BACKEND->startRemove(items); } @@ -220,20 +223,30 @@ void MainUI::ViewFile(QTreeWidgetItem *it){ } void MainUI::UpdateTree(){ - ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size") << tr("Compressed")+" " ); + this->setEnabled(false); + ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size")+" " ); QStringList files = BACKEND->heirarchy(); files.sort(); //Remove any entries for file no longer in the archive bool changed = cleanItems(files); - qDebug() << "Found Files:" << files; + //qDebug() << "Found Files:" << files; for(int i=0; isize(files[i])) << LUtils::BytesToDisplaySize(BACKEND->csize(files[i])) ); + QTreeWidgetItem *it = new QTreeWidgetItem(); + it->setText(0, files[i].section("/",-1) ); + if(!BACKEND->isLink(files[i])){ + it->setText(1, LXDG::findAppMimeForFile(files[i].section("/",-1), false) ); + it->setText(2, LUtils::BytesToDisplaySize( BACKEND->size(files[i])) ); + }else{ + it->setText(1, QString(tr("Link To: %1")).arg(BACKEND->linkTo(files[i]) ) ); + } it->setWhatsThis(0, files[i]); if(BACKEND->isDir(files[i])){ it->setIcon(0, LXDG::findIcon("folder","")); it->setText(1,""); //clear the mimetype + }else if(BACKEND->isLink(files[i])){ + it->setIcon(0, LXDG::findIcon("emblem-symbolic-link","") ); }else{ it->setIcon(0, LXDG::findMimeIcon(files[i].section("/",-1)) ); } @@ -245,14 +258,23 @@ void MainUI::UpdateTree(){ else{ parent->addChild(it); } }else{ ui->tree_contents->addTopLevelItem(it); + QApplication::processEvents(); } changed = true; } - int wid = 0; + if(changed){ - for(int i=3; i>0; i--){ui->tree_contents->resizeColumnToContents(i); wid+= ui->tree_contents->columnWidth(i); } + int wid = ui->tree_contents->fontMetrics().width("W")*5; + ui->tree_contents->setColumnWidth(2, wid); + for(int i=1; i<2; i++){ui->tree_contents->resizeColumnToContents(i); QApplication::processEvents(); wid+= ui->tree_contents->columnWidth(i); } + //qDebug() << "Set column 0 width:" << wid << ui->tree_contents->viewport()->width(); ui->tree_contents->setColumnWidth(0, ui->tree_contents->viewport()->width()-wid); } + ui->tree_contents->sortItems(0, Qt::AscendingOrder); //sort by name + ui->tree_contents->sortItems(1,Qt::AscendingOrder); //sort by mimetype (put dirs first - still organized by name) + + this->setEnabled(true); + ui->tree_contents->setEnabled(true); } //Backend Handling @@ -260,19 +282,19 @@ void MainUI::ProcStarting(){ ui->progressBar->setRange(0,0); ui->progressBar->setValue(0); ui->progressBar->setVisible(true); - ui->label_progress->setVisible(true); + ui->label_progress->setVisible(!ui->label_progress->text().isEmpty()); ui->label_progress_icon->setVisible(false); ui->tree_contents->setEnabled(false); ui->label_archive->setText(BACKEND->currentFile()); } void MainUI::ProcFinished(bool success, QString msg){ + UpdateTree(); ui->progressBar->setRange(0,0); ui->progressBar->setValue(0); ui->progressBar->setVisible(false); ui->label_progress->setText(msg); ui->label_progress->setVisible(!msg.isEmpty()); - ui->tree_contents->setEnabled(true); ui->label_progress_icon->setVisible(!msg.isEmpty()); if(success){ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-complete","").pixmap(32,32) );} else{ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-attention","").pixmap(32,32) );} @@ -289,7 +311,6 @@ void MainUI::ProcFinished(bool success, QString msg){ ui->actionRemove_File->setEnabled(canmodify && info.exists()); ui->actionExtract_All->setEnabled(info.exists()); ui->actionAdd_Dirs->setEnabled(canmodify); - UpdateTree(); } void MainUI::ProcUpdate(int percent, QString txt){ diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index de3ef49b..919a6813 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -75,6 +75,16 @@ bool Backend::isDir(QString file){ return contents.value(file)[0].startsWith("d"); } +bool Backend::isLink(QString file){ + if(!contents.contains(file)){ return false; } + return contents.value(file)[0].startsWith("l"); +} + +QString Backend::linkTo(QString file){ + if(!contents.contains(file)){ return ""; } + return contents.value(file)[2]; +} + //Modification routines void Backend::startAdd(QStringList paths){ //NOTE: All the "paths" have to have the same parent directory @@ -153,14 +163,23 @@ void Backend::parseLines(QStringList lines){ QString file = info[1]; QString perms = ""; if(file.endsWith("/")){ perms = "d"; file.chop(1); } - contents.insert(file, QStringList() << perms << "-1" ); //Save the [perms, size ] + contents.insert(file, QStringList() << perms << "-1" <<""); //Save the [perms, size, linkto ] } else if(info.length()<9){ continue; } //invalid line //TAR Archive parsing while(info.length()>9){ info[8] = info[8]+" "+info[9]; info.removeAt(9); } //Filename has spaces in it QString file = info[8]; if(file.endsWith("/")){ file.chop(1); } - contents.insert(file, QStringList() << info[0] << info[4] ); //Save the [perms, size ] + QString linkto; + //See if this file has the "link to" or "->" notation + if(file.contains(" -> ")){ linkto = file.section(" -> ",1,-1); file = file.section(" -> ",0,0); } + else if(file.contains(" link to ")){ + //Special case - alternate form of a link within a tar archive (not reflected in perms) + linkto = file.section(" link to ",1,-1); + file = file.section(" link to ",0,0); + if(info[0].startsWith("-")){ info[0].replace(0,1,"l"); } + } + contents.insert(file, QStringList() << info[0] << info[4] << linkto); //Save the [perms, size, linkto ] } } @@ -178,7 +197,7 @@ void Backend::startList(){ void Backend::procFinished(int retcode, QProcess::ExitStatus){ static QString result; processData(); - qDebug() << "Process Finished:" << PROC.arguments() << retcode; + //qDebug() << "Process Finished:" << PROC.arguments() << retcode; LIST = STARTING = false; if(PROC.arguments().contains("-tv")){ if(retcode!=0){ contents.clear(); } //could not read archive diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h index c1e47454..47bc0bb6 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h @@ -29,6 +29,8 @@ public: double size(QString file); double csize(QString file); bool isDir(QString file); + bool isLink(QString file); + QString linkTo(QString file); //Modification routines void startAdd(QStringList paths); @@ -37,6 +39,7 @@ public: void startViewFile(QString path); + //Special process public slots: private: -- cgit From d5a55a057d3fc180a3a07e76362b6830b6d2c5f4 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 18 Nov 2016 12:40:50 -0500 Subject: Add a new dialog UI form (not integrated yet) for a front-end to "dd"ing ISO/IMG files to a USB stick. --- src-qt5/desktop-utils/lumina-archiver/isoDialog.ui | 151 +++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 src-qt5/desktop-utils/lumina-archiver/isoDialog.ui (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-archiver/isoDialog.ui b/src-qt5/desktop-utils/lumina-archiver/isoDialog.ui new file mode 100644 index 00000000..99ba31fb --- /dev/null +++ b/src-qt5/desktop-utils/lumina-archiver/isoDialog.ui @@ -0,0 +1,151 @@ + + + isoDialog + + + + 0 + 0 + 305 + 179 + + + + Burn ISO/IMG to device + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Transfer Rate + + + + + + + + + + 0 + 0 + + + + 1 + + + 1023 + + + + + + + + + + + + USB Device + + + + + + + Wipe all extra space on device (conv = sync) + + + true + + + + + + + + + + + + Refresh Device List + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Cancel + + + + + + + Start + + + + + + + + + + -- cgit From 151062b99e29e18dbc614bf66582f908c864a96a Mon Sep 17 00:00:00 2001 From: q5sys Date: Sun, 20 Nov 2016 01:50:36 -0500 Subject: Revert "search clear function on ESC press" This reverts commit b9840ef585385fece513e24e4cea193d35328dc0, reversing changes made to cb5524f6fd5186414c11339375bebd3b808b4857. --- src-qt5/desktop-utils/lumina-archiver/MainUI.cpp | 83 +++-------- src-qt5/desktop-utils/lumina-archiver/MainUI.h | 3 +- src-qt5/desktop-utils/lumina-archiver/MainUI.ui | 34 ----- .../desktop-utils/lumina-archiver/TarBackend.cpp | 47 ++----- src-qt5/desktop-utils/lumina-archiver/TarBackend.h | 7 +- src-qt5/desktop-utils/lumina-archiver/isoDialog.ui | 151 --------------------- 6 files changed, 32 insertions(+), 293 deletions(-) delete mode 100644 src-qt5/desktop-utils/lumina-archiver/isoDialog.ui (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp index 9d41374c..9710045c 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp @@ -18,7 +18,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ this->setWindowTitle(tr("Archive Manager")); BACKEND = new Backend(this); connect(BACKEND, SIGNAL(ProcessStarting()), this, SLOT(ProcStarting()) ); - connect(BACKEND, SIGNAL(ProcessFinished(bool, QString)), this, SLOT(ProcFinished(bool, QString)) ); + connect(BACKEND, SIGNAL(ProcessFinished()), this, SLOT(ProcFinished()) ); connect(BACKEND, SIGNAL(ProgressUpdate(int, QString)), this, SLOT(ProcUpdate(int, QString)) ); //Add a spacer between toolbar items @@ -33,18 +33,16 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->actionAdd_File, SIGNAL(triggered()), this, SLOT(addFiles()) ); connect(ui->actionRemove_File, SIGNAL(triggered()), this, SLOT(remFiles()) ); connect(ui->actionExtract_All, SIGNAL(triggered()), this, SLOT(extractFiles()) ); - connect(ui->actionExtract_Sel, SIGNAL(triggered()), this, SLOT(extractSelection()) ); connect(ui->actionAdd_Dirs, SIGNAL(triggered()), this, SLOT(addDirs()) ); connect(ui->tree_contents, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(ViewFile(QTreeWidgetItem*)) ); ui->progressBar->setVisible(false); ui->label_progress->setVisible(false); - ui->label_progress_icon->setVisible(false); ui->actionAdd_File->setEnabled(false); ui->actionRemove_File->setEnabled(false); ui->actionExtract_All->setEnabled(false); ui->actionAdd_Dirs->setEnabled(false); loadIcons(); - ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size")+" " ); + ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size") << tr("Compressed")+" " ); } MainUI::~MainUI(){ @@ -53,11 +51,7 @@ MainUI::~MainUI(){ void MainUI::LoadArguments(QStringList args){ for(int i=0; ilabel_progress->setText(tr("Opening Archive...")); - BACKEND->loadFile(args[i]); - break; - } + if(QFile::exists(args[i])){ BACKEND->loadFile(args[i]); break;} } } @@ -70,7 +64,6 @@ void MainUI::loadIcons(){ ui->actionAdd_Dirs->setIcon( LXDG::findIcon("archive-insert-directory","") ); ui->actionRemove_File->setIcon( LXDG::findIcon("archive-remove","") ); ui->actionExtract_All->setIcon( LXDG::findIcon("archive-extract","") ); - ui->actionExtract_Sel->setIcon( LXDG::findIcon("archive-extract","") ); } //=================== @@ -79,16 +72,17 @@ void MainUI::loadIcons(){ QTreeWidgetItem* MainUI::findItem(QString path, QTreeWidgetItem *start){ if(start==0){ for(int i=0; itree_contents->topLevelItemCount(); i++){ - if(ui->tree_contents->topLevelItem(i)->whatsThis(0) == path){ return ui->tree_contents->topLevelItem(i); } - else if(path.startsWith(ui->tree_contents->topLevelItem(i)->whatsThis(0)+"/")){ return findItem(path, ui->tree_contents->topLevelItem(i)); } + QString itpath = ui->tree_contents->topLevelItem(i)->whatsThis(0); + if(itpath == path){ return ui->tree_contents->topLevelItem(i); } + else if(path.startsWith(itpath+"/")){ return findItem(path, ui->tree_contents->topLevelItem(i)); } } }else{ for(int i=0; ichildCount(); i++){ - if(start->child(i)->whatsThis(0) == path){ return start->child(i); } - else if(path.startsWith(start->child(i)->whatsThis(0)+"/")){ return findItem(path, start->child(i)); } + QString itpath = start->child(i)->whatsThis(0); + if(itpath == path){ return start->child(i); } + else if(path.startsWith(itpath+"/")){ return findItem(path, start->child(i)); } } } - //qDebug() << "Could not find item:" << path; return 0; //nothing found } @@ -164,28 +158,24 @@ void MainUI::NewArchive(){ if(QFile::exists(file)){ if( !QFile::remove(file) ){ QMessageBox::warning(this, tr("Error"), QString(tr("Could not overwrite file:"))+"\n"+file); } } - ui->label_progress->setText(""); //just clear it (this action is instant) BACKEND->loadFile(file); } void MainUI::OpenArchive(){ QString file = QFileDialog::getOpenFileName(this, tr("Open Archive"), QDir::homePath(), OpenFileTypes() ); if(file.isEmpty()){ return; } - ui->label_progress->setText(tr("Opening Archive...")); BACKEND->loadFile(file); } void MainUI::addFiles(){ QStringList files = QFileDialog::getOpenFileNames(this, tr("Add to Archive"), QDir::homePath() ); if(files.isEmpty()){ return; } - ui->label_progress->setText(tr("Adding Items...")); BACKEND->startAdd(files); } void MainUI::addDirs(){ QString dirs = QFileDialog::getExistingDirectory(this, tr("Add to Archive"), QDir::homePath() ); if(dirs.isEmpty()){ return; } - ui->label_progress->setText(tr("Adding Items...")); BACKEND->startAdd(QStringList() << dirs); } @@ -196,57 +186,35 @@ void MainUI::remFiles(){ items << sel[i]->whatsThis(0); } items.removeDuplicates(); - ui->label_progress->setText(tr("Removing Items...")); BACKEND->startRemove(items); } void MainUI::extractFiles(){ QString dir = QFileDialog::getExistingDirectory(this, tr("Extract Into Directory"), QDir::homePath() ); if(dir.isEmpty()){ return; } - ui->label_progress->setText(tr("Extracting...")); BACKEND->startExtract(dir, true); } -void MainUI::extractSelection(){ - if(ui->tree_contents->currentItem()==0){ return; } - QString sel = ui->tree_contents->currentItem()->whatsThis(0); - QString dir = QFileDialog::getExistingDirectory(this, tr("Extract Into Directory"), QDir::homePath() ); - if(dir.isEmpty()){ return; } - ui->label_progress->setText(tr("Extracting...")); - BACKEND->startExtract(dir, true, sel); -} - void MainUI::ViewFile(QTreeWidgetItem *it){ if(it->childCount()>0){ return; } //directory - not viewable - ui->label_progress->setText(tr("Extracting...")); BACKEND->startViewFile(it->whatsThis(0)); } void MainUI::UpdateTree(){ - this->setEnabled(false); - ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size")+" " ); + ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size") << tr("Compressed")+" " ); QStringList files = BACKEND->heirarchy(); files.sort(); //Remove any entries for file no longer in the archive bool changed = cleanItems(files); - //qDebug() << "Found Files:" << files; + qDebug() << "Found Files:" << files; for(int i=0; isetText(0, files[i].section("/",-1) ); - if(!BACKEND->isLink(files[i])){ - it->setText(1, LXDG::findAppMimeForFile(files[i].section("/",-1), false) ); - it->setText(2, LUtils::BytesToDisplaySize( BACKEND->size(files[i])) ); - }else{ - it->setText(1, QString(tr("Link To: %1")).arg(BACKEND->linkTo(files[i]) ) ); - } + QTreeWidgetItem *it = new QTreeWidgetItem( QStringList() << files[i].section("/",-1) << mime << LUtils::BytesToDisplaySize( BACKEND->size(files[i])) << LUtils::BytesToDisplaySize(BACKEND->csize(files[i])) ); it->setWhatsThis(0, files[i]); if(BACKEND->isDir(files[i])){ it->setIcon(0, LXDG::findIcon("folder","")); it->setText(1,""); //clear the mimetype - }else if(BACKEND->isLink(files[i])){ - it->setIcon(0, LXDG::findIcon("emblem-symbolic-link","") ); }else{ it->setIcon(0, LXDG::findMimeIcon(files[i].section("/",-1)) ); } @@ -258,23 +226,14 @@ void MainUI::UpdateTree(){ else{ parent->addChild(it); } }else{ ui->tree_contents->addTopLevelItem(it); - QApplication::processEvents(); } changed = true; } - + int wid = 0; if(changed){ - int wid = ui->tree_contents->fontMetrics().width("W")*5; - ui->tree_contents->setColumnWidth(2, wid); - for(int i=1; i<2; i++){ui->tree_contents->resizeColumnToContents(i); QApplication::processEvents(); wid+= ui->tree_contents->columnWidth(i); } - //qDebug() << "Set column 0 width:" << wid << ui->tree_contents->viewport()->width(); + for(int i=3; i>0; i--){ui->tree_contents->resizeColumnToContents(i); wid+= ui->tree_contents->columnWidth(i); } ui->tree_contents->setColumnWidth(0, ui->tree_contents->viewport()->width()-wid); } - ui->tree_contents->sortItems(0, Qt::AscendingOrder); //sort by name - ui->tree_contents->sortItems(1,Qt::AscendingOrder); //sort by mimetype (put dirs first - still organized by name) - - this->setEnabled(true); - ui->tree_contents->setEnabled(true); } //Backend Handling @@ -282,22 +241,17 @@ void MainUI::ProcStarting(){ ui->progressBar->setRange(0,0); ui->progressBar->setValue(0); ui->progressBar->setVisible(true); - ui->label_progress->setVisible(!ui->label_progress->text().isEmpty()); - ui->label_progress_icon->setVisible(false); + ui->label_progress->setVisible(true); ui->tree_contents->setEnabled(false); ui->label_archive->setText(BACKEND->currentFile()); } -void MainUI::ProcFinished(bool success, QString msg){ - UpdateTree(); +void MainUI::ProcFinished(){ ui->progressBar->setRange(0,0); ui->progressBar->setValue(0); ui->progressBar->setVisible(false); - ui->label_progress->setText(msg); - ui->label_progress->setVisible(!msg.isEmpty()); - ui->label_progress_icon->setVisible(!msg.isEmpty()); - if(success){ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-complete","").pixmap(32,32) );} - else{ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-attention","").pixmap(32,32) );} + ui->label_progress->setVisible(false); + ui->tree_contents->setEnabled(true); if(ui->label_archive->text()!=BACKEND->currentFile()){ ui->label_archive->setText(BACKEND->currentFile()); this->setWindowTitle(BACKEND->currentFile().section("/",-1)); @@ -311,6 +265,7 @@ void MainUI::ProcFinished(bool success, QString msg){ ui->actionRemove_File->setEnabled(canmodify && info.exists()); ui->actionExtract_All->setEnabled(info.exists()); ui->actionAdd_Dirs->setEnabled(canmodify); + UpdateTree(); } void MainUI::ProcUpdate(int percent, QString txt){ diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.h b/src-qt5/desktop-utils/lumina-archiver/MainUI.h index bb462a7d..09207aa3 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.h +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.h @@ -44,14 +44,13 @@ private slots: void addDirs(); void remFiles(); void extractFiles(); - void extractSelection(); void ViewFile(QTreeWidgetItem *it); void UpdateTree(); //Backend Handling void ProcStarting(); - void ProcFinished(bool, QString); + void ProcFinished(); void ProcUpdate(int percent, QString txt); }; diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.ui b/src-qt5/desktop-utils/lumina-archiver/MainUI.ui index 1aff2e4f..8c2b2836 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.ui @@ -56,31 +56,6 @@ - - - - - 0 - 0 - - - - - 32 - 32 - - - - - 32 - 32 - - - - - - - @@ -93,9 +68,6 @@ - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - @@ -129,7 +101,6 @@ - @@ -212,11 +183,6 @@ Add directory to archive - - - Extract Selection - - diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index 919a6813..4dee247b 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -32,7 +32,7 @@ void Backend::loadFile(QString path){ flags.clear(); flags << "-f" << filepath; //add the actual archive path if(QFile::exists(path)){ startList(); } - else{ contents.clear(); emit ProcessFinished(true, ""); } + else{ contents.clear(); emit ProcessFinished(); } } bool Backend::canModify(){ @@ -75,16 +75,6 @@ bool Backend::isDir(QString file){ return contents.value(file)[0].startsWith("d"); } -bool Backend::isLink(QString file){ - if(!contents.contains(file)){ return false; } - return contents.value(file)[0].startsWith("l"); -} - -QString Backend::linkTo(QString file){ - if(!contents.contains(file)){ return ""; } - return contents.value(file)[2]; -} - //Modification routines void Backend::startAdd(QStringList paths){ //NOTE: All the "paths" have to have the same parent directory @@ -125,13 +115,11 @@ void Backend::startRemove(QStringList paths){ PROC.start("tar", args); } -void Backend::startExtract(QString path, bool overwrite, QString file){ +void Backend::startExtract(QString path, bool overwrite){ QStringList args; args << "-x"; if(!overwrite){ args << "-k"; } - args << flags; - if(!file.isEmpty()){ args << "--include" << file << "--strip-components" << QString::number(file.count("/")); } - args << "-C" << path; + args << flags << "-C" << path; STARTING=true; //qDebug() << "Starting command:" << "tar" << args; PROC.start("tar", args); @@ -163,23 +151,14 @@ void Backend::parseLines(QStringList lines){ QString file = info[1]; QString perms = ""; if(file.endsWith("/")){ perms = "d"; file.chop(1); } - contents.insert(file, QStringList() << perms << "-1" <<""); //Save the [perms, size, linkto ] + contents.insert(file, QStringList() << perms << "-1" ); //Save the [perms, size ] } else if(info.length()<9){ continue; } //invalid line //TAR Archive parsing while(info.length()>9){ info[8] = info[8]+" "+info[9]; info.removeAt(9); } //Filename has spaces in it QString file = info[8]; if(file.endsWith("/")){ file.chop(1); } - QString linkto; - //See if this file has the "link to" or "->" notation - if(file.contains(" -> ")){ linkto = file.section(" -> ",1,-1); file = file.section(" -> ",0,0); } - else if(file.contains(" link to ")){ - //Special case - alternate form of a link within a tar archive (not reflected in perms) - linkto = file.section(" link to ",1,-1); - file = file.section(" link to ",0,0); - if(info[0].startsWith("-")){ info[0].replace(0,1,"l"); } - } - contents.insert(file, QStringList() << info[0] << info[4] << linkto); //Save the [perms, size, linkto ] + contents.insert(file, QStringList() << info[0] << info[4] ); //Save the [perms, size ] } } @@ -195,19 +174,17 @@ void Backend::startList(){ // PRIVATE SLOTS //=============== void Backend::procFinished(int retcode, QProcess::ExitStatus){ - static QString result; processData(); - //qDebug() << "Process Finished:" << PROC.arguments() << retcode; + qDebug() << "Process Finished:" << PROC.arguments() << retcode; LIST = STARTING = false; if(PROC.arguments().contains("-tv")){ if(retcode!=0){ contents.clear(); } //could not read archive - emit ProcessFinished(true,result); - result.clear(); + emit ProcessFinished(); }else{ bool needupdate = true; QStringList args = PROC.arguments(); if(args.contains("-x") && retcode==0){ - needupdate=false; + needupdate=false; if(args.contains("--include")){ //Need to find the full path to the extracted file QString path = args.last() +"/"+ args[ args.indexOf("--include")+1].section("/",-1); @@ -224,10 +201,8 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){ QFile::remove(tmpfilepath); } } - if(args.contains("-x")){ result = tr("Extraction Finished"); } - else if(args.contains("-c")){ result = tr("Modification Finished"); } if(needupdate){ startList(); } - else{ emit ProcessFinished(retcode==0, result); result.clear(); } + else{ emit ProcessFinished(); } } } @@ -238,9 +213,7 @@ void Backend::processData(){ if(read.endsWith("\n")){ data.clear(); } else{ data = read.section("\n",-1); read = read.section("\n",0,-2); } QStringList lines = read.split("\n",QString::SkipEmptyParts); - QString info; if(LIST){ parseLines(lines); } - else if(!lines.isEmpty()){ info = lines.last(); } //qDebug() << lines; - emit ProgressUpdate(-1, info); + emit ProgressUpdate(-1, ""); } diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h index 47bc0bb6..f12aae63 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h @@ -29,17 +29,14 @@ public: double size(QString file); double csize(QString file); bool isDir(QString file); - bool isLink(QString file); - QString linkTo(QString file); //Modification routines void startAdd(QStringList paths); void startRemove(QStringList paths); - void startExtract(QString path, bool overwrite, QString file=""); //path to dir, overwrite, optional file to extract (everything otherwise) + void startExtract(QString path, bool overwrite); //path to dir void startViewFile(QString path); - //Special process public slots: private: @@ -61,7 +58,7 @@ signals: void FileLoaded(); void ProcessStarting(); void ProgressUpdate(int, QString); //percentage, text - void ProcessFinished(bool, QString); //success, text + void ProcessFinished(); }; #endif diff --git a/src-qt5/desktop-utils/lumina-archiver/isoDialog.ui b/src-qt5/desktop-utils/lumina-archiver/isoDialog.ui deleted file mode 100644 index 99ba31fb..00000000 --- a/src-qt5/desktop-utils/lumina-archiver/isoDialog.ui +++ /dev/null @@ -1,151 +0,0 @@ - - - isoDialog - - - - 0 - 0 - 305 - 179 - - - - Burn ISO/IMG to device - - - - - - - 75 - true - - - - TextLabel - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Transfer Rate - - - - - - - - - - 0 - 0 - - - - 1 - - - 1023 - - - - - - - - - - - - USB Device - - - - - - - Wipe all extra space on device (conv = sync) - - - true - - - - - - - - - - - - Refresh Device List - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Cancel - - - - - - - Start - - - - - - - - - - -- cgit From c79aa5623796f62aa67b2c37367e28710b0f05d2 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Sun, 20 Nov 2016 13:22:08 -0500 Subject: Revert "Revert "search clear function on ESC press"" This reverts commit 151062b99e29e18dbc614bf66582f908c864a96a. --- src-qt5/desktop-utils/lumina-archiver/MainUI.cpp | 83 ++++++++--- src-qt5/desktop-utils/lumina-archiver/MainUI.h | 3 +- src-qt5/desktop-utils/lumina-archiver/MainUI.ui | 34 +++++ .../desktop-utils/lumina-archiver/TarBackend.cpp | 47 +++++-- src-qt5/desktop-utils/lumina-archiver/TarBackend.h | 7 +- src-qt5/desktop-utils/lumina-archiver/isoDialog.ui | 151 +++++++++++++++++++++ 6 files changed, 293 insertions(+), 32 deletions(-) create mode 100644 src-qt5/desktop-utils/lumina-archiver/isoDialog.ui (limited to 'src-qt5/desktop-utils') diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp index 9710045c..9d41374c 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp @@ -18,7 +18,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ this->setWindowTitle(tr("Archive Manager")); BACKEND = new Backend(this); connect(BACKEND, SIGNAL(ProcessStarting()), this, SLOT(ProcStarting()) ); - connect(BACKEND, SIGNAL(ProcessFinished()), this, SLOT(ProcFinished()) ); + connect(BACKEND, SIGNAL(ProcessFinished(bool, QString)), this, SLOT(ProcFinished(bool, QString)) ); connect(BACKEND, SIGNAL(ProgressUpdate(int, QString)), this, SLOT(ProcUpdate(int, QString)) ); //Add a spacer between toolbar items @@ -33,16 +33,18 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->actionAdd_File, SIGNAL(triggered()), this, SLOT(addFiles()) ); connect(ui->actionRemove_File, SIGNAL(triggered()), this, SLOT(remFiles()) ); connect(ui->actionExtract_All, SIGNAL(triggered()), this, SLOT(extractFiles()) ); + connect(ui->actionExtract_Sel, SIGNAL(triggered()), this, SLOT(extractSelection()) ); connect(ui->actionAdd_Dirs, SIGNAL(triggered()), this, SLOT(addDirs()) ); connect(ui->tree_contents, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(ViewFile(QTreeWidgetItem*)) ); ui->progressBar->setVisible(false); ui->label_progress->setVisible(false); + ui->label_progress_icon->setVisible(false); ui->actionAdd_File->setEnabled(false); ui->actionRemove_File->setEnabled(false); ui->actionExtract_All->setEnabled(false); ui->actionAdd_Dirs->setEnabled(false); loadIcons(); - ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size") << tr("Compressed")+" " ); + ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size")+" " ); } MainUI::~MainUI(){ @@ -51,7 +53,11 @@ MainUI::~MainUI(){ void MainUI::LoadArguments(QStringList args){ for(int i=0; iloadFile(args[i]); break;} + if(QFile::exists(args[i])){ + ui->label_progress->setText(tr("Opening Archive...")); + BACKEND->loadFile(args[i]); + break; + } } } @@ -64,6 +70,7 @@ void MainUI::loadIcons(){ ui->actionAdd_Dirs->setIcon( LXDG::findIcon("archive-insert-directory","") ); ui->actionRemove_File->setIcon( LXDG::findIcon("archive-remove","") ); ui->actionExtract_All->setIcon( LXDG::findIcon("archive-extract","") ); + ui->actionExtract_Sel->setIcon( LXDG::findIcon("archive-extract","") ); } //=================== @@ -72,17 +79,16 @@ void MainUI::loadIcons(){ QTreeWidgetItem* MainUI::findItem(QString path, QTreeWidgetItem *start){ if(start==0){ for(int i=0; itree_contents->topLevelItemCount(); i++){ - QString itpath = ui->tree_contents->topLevelItem(i)->whatsThis(0); - if(itpath == path){ return ui->tree_contents->topLevelItem(i); } - else if(path.startsWith(itpath+"/")){ return findItem(path, ui->tree_contents->topLevelItem(i)); } + if(ui->tree_contents->topLevelItem(i)->whatsThis(0) == path){ return ui->tree_contents->topLevelItem(i); } + else if(path.startsWith(ui->tree_contents->topLevelItem(i)->whatsThis(0)+"/")){ return findItem(path, ui->tree_contents->topLevelItem(i)); } } }else{ for(int i=0; ichildCount(); i++){ - QString itpath = start->child(i)->whatsThis(0); - if(itpath == path){ return start->child(i); } - else if(path.startsWith(itpath+"/")){ return findItem(path, start->child(i)); } + if(start->child(i)->whatsThis(0) == path){ return start->child(i); } + else if(path.startsWith(start->child(i)->whatsThis(0)+"/")){ return findItem(path, start->child(i)); } } } + //qDebug() << "Could not find item:" << path; return 0; //nothing found } @@ -158,24 +164,28 @@ void MainUI::NewArchive(){ if(QFile::exists(file)){ if( !QFile::remove(file) ){ QMessageBox::warning(this, tr("Error"), QString(tr("Could not overwrite file:"))+"\n"+file); } } + ui->label_progress->setText(""); //just clear it (this action is instant) BACKEND->loadFile(file); } void MainUI::OpenArchive(){ QString file = QFileDialog::getOpenFileName(this, tr("Open Archive"), QDir::homePath(), OpenFileTypes() ); if(file.isEmpty()){ return; } + ui->label_progress->setText(tr("Opening Archive...")); BACKEND->loadFile(file); } void MainUI::addFiles(){ QStringList files = QFileDialog::getOpenFileNames(this, tr("Add to Archive"), QDir::homePath() ); if(files.isEmpty()){ return; } + ui->label_progress->setText(tr("Adding Items...")); BACKEND->startAdd(files); } void MainUI::addDirs(){ QString dirs = QFileDialog::getExistingDirectory(this, tr("Add to Archive"), QDir::homePath() ); if(dirs.isEmpty()){ return; } + ui->label_progress->setText(tr("Adding Items...")); BACKEND->startAdd(QStringList() << dirs); } @@ -186,35 +196,57 @@ void MainUI::remFiles(){ items << sel[i]->whatsThis(0); } items.removeDuplicates(); + ui->label_progress->setText(tr("Removing Items...")); BACKEND->startRemove(items); } void MainUI::extractFiles(){ QString dir = QFileDialog::getExistingDirectory(this, tr("Extract Into Directory"), QDir::homePath() ); if(dir.isEmpty()){ return; } + ui->label_progress->setText(tr("Extracting...")); BACKEND->startExtract(dir, true); } +void MainUI::extractSelection(){ + if(ui->tree_contents->currentItem()==0){ return; } + QString sel = ui->tree_contents->currentItem()->whatsThis(0); + QString dir = QFileDialog::getExistingDirectory(this, tr("Extract Into Directory"), QDir::homePath() ); + if(dir.isEmpty()){ return; } + ui->label_progress->setText(tr("Extracting...")); + BACKEND->startExtract(dir, true, sel); +} + void MainUI::ViewFile(QTreeWidgetItem *it){ if(it->childCount()>0){ return; } //directory - not viewable + ui->label_progress->setText(tr("Extracting...")); BACKEND->startViewFile(it->whatsThis(0)); } void MainUI::UpdateTree(){ - ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size") << tr("Compressed")+" " ); + this->setEnabled(false); + ui->tree_contents->setHeaderLabels( QStringList() << tr("File") << tr("MimeType") << tr("Size")+" " ); QStringList files = BACKEND->heirarchy(); files.sort(); //Remove any entries for file no longer in the archive bool changed = cleanItems(files); - qDebug() << "Found Files:" << files; + //qDebug() << "Found Files:" << files; for(int i=0; isize(files[i])) << LUtils::BytesToDisplaySize(BACKEND->csize(files[i])) ); + QTreeWidgetItem *it = new QTreeWidgetItem(); + it->setText(0, files[i].section("/",-1) ); + if(!BACKEND->isLink(files[i])){ + it->setText(1, LXDG::findAppMimeForFile(files[i].section("/",-1), false) ); + it->setText(2, LUtils::BytesToDisplaySize( BACKEND->size(files[i])) ); + }else{ + it->setText(1, QString(tr("Link To: %1")).arg(BACKEND->linkTo(files[i]) ) ); + } it->setWhatsThis(0, files[i]); if(BACKEND->isDir(files[i])){ it->setIcon(0, LXDG::findIcon("folder","")); it->setText(1,""); //clear the mimetype + }else if(BACKEND->isLink(files[i])){ + it->setIcon(0, LXDG::findIcon("emblem-symbolic-link","") ); }else{ it->setIcon(0, LXDG::findMimeIcon(files[i].section("/",-1)) ); } @@ -226,14 +258,23 @@ void MainUI::UpdateTree(){ else{ parent->addChild(it); } }else{ ui->tree_contents->addTopLevelItem(it); + QApplication::processEvents(); } changed = true; } - int wid = 0; + if(changed){ - for(int i=3; i>0; i--){ui->tree_contents->resizeColumnToContents(i); wid+= ui->tree_contents->columnWidth(i); } + int wid = ui->tree_contents->fontMetrics().width("W")*5; + ui->tree_contents->setColumnWidth(2, wid); + for(int i=1; i<2; i++){ui->tree_contents->resizeColumnToContents(i); QApplication::processEvents(); wid+= ui->tree_contents->columnWidth(i); } + //qDebug() << "Set column 0 width:" << wid << ui->tree_contents->viewport()->width(); ui->tree_contents->setColumnWidth(0, ui->tree_contents->viewport()->width()-wid); } + ui->tree_contents->sortItems(0, Qt::AscendingOrder); //sort by name + ui->tree_contents->sortItems(1,Qt::AscendingOrder); //sort by mimetype (put dirs first - still organized by name) + + this->setEnabled(true); + ui->tree_contents->setEnabled(true); } //Backend Handling @@ -241,17 +282,22 @@ void MainUI::ProcStarting(){ ui->progressBar->setRange(0,0); ui->progressBar->setValue(0); ui->progressBar->setVisible(true); - ui->label_progress->setVisible(true); + ui->label_progress->setVisible(!ui->label_progress->text().isEmpty()); + ui->label_progress_icon->setVisible(false); ui->tree_contents->setEnabled(false); ui->label_archive->setText(BACKEND->currentFile()); } -void MainUI::ProcFinished(){ +void MainUI::ProcFinished(bool success, QString msg){ + UpdateTree(); ui->progressBar->setRange(0,0); ui->progressBar->setValue(0); ui->progressBar->setVisible(false); - ui->label_progress->setVisible(false); - ui->tree_contents->setEnabled(true); + ui->label_progress->setText(msg); + ui->label_progress->setVisible(!msg.isEmpty()); + ui->label_progress_icon->setVisible(!msg.isEmpty()); + if(success){ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-complete","").pixmap(32,32) );} + else{ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-attention","").pixmap(32,32) );} if(ui->label_archive->text()!=BACKEND->currentFile()){ ui->label_archive->setText(BACKEND->currentFile()); this->setWindowTitle(BACKEND->currentFile().section("/",-1)); @@ -265,7 +311,6 @@ void MainUI::ProcFinished(){ ui->actionRemove_File->setEnabled(canmodify && info.exists()); ui->actionExtract_All->setEnabled(info.exists()); ui->actionAdd_Dirs->setEnabled(canmodify); - UpdateTree(); } void MainUI::ProcUpdate(int percent, QString txt){ diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.h b/src-qt5/desktop-utils/lumina-archiver/MainUI.h index 09207aa3..bb462a7d 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.h +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.h @@ -44,13 +44,14 @@ private slots: void addDirs(); void remFiles(); void extractFiles(); + void extractSelection(); void ViewFile(QTreeWidgetItem *it); void UpdateTree(); //Backend Handling void ProcStarting(); - void ProcFinished(); + void ProcFinished(bool, QString); void ProcUpdate(int percent, QString txt); }; diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.ui b/src-qt5/desktop-utils/lumina-archiver/MainUI.ui index 8c2b2836..1aff2e4f 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.ui @@ -56,6 +56,31 @@ + + + + + 0 + 0 + + + + + 32 + 32 + + + + + 32 + 32 + + + + + + + @@ -68,6 +93,9 @@ + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + @@ -101,6 +129,7 @@ + @@ -183,6 +212,11 @@ Add directory to archive + + + Extract Selection + + diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index 4dee247b..919a6813 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -32,7 +32,7 @@ void Backend::loadFile(QString path){ flags.clear(); flags << "-f" << filepath; //add the actual archive path if(QFile::exists(path)){ startList(); } - else{ contents.clear(); emit ProcessFinished(); } + else{ contents.clear(); emit ProcessFinished(true, ""); } } bool Backend::canModify(){ @@ -75,6 +75,16 @@ bool Backend::isDir(QString file){ return contents.value(file)[0].startsWith("d"); } +bool Backend::isLink(QString file){ + if(!contents.contains(file)){ return false; } + return contents.value(file)[0].startsWith("l"); +} + +QString Backend::linkTo(QString file){ + if(!contents.contains(file)){ return ""; } + return contents.value(file)[2]; +} + //Modification routines void Backend::startAdd(QStringList paths){ //NOTE: All the "paths" have to have the same parent directory @@ -115,11 +125,13 @@ void Backend::startRemove(QStringList paths){ PROC.start("tar", args); } -void Backend::startExtract(QString path, bool overwrite){ +void Backend::startExtract(QString path, bool overwrite, QString file){ QStringList args; args << "-x"; if(!overwrite){ args << "-k"; } - args << flags << "-C" << path; + args << flags; + if(!file.isEmpty()){ args << "--include" << file << "--strip-components" << QString::number(file.count("/")); } + args << "-C" << path; STARTING=true; //qDebug() << "Starting command:" << "tar" << args; PROC.start("tar", args); @@ -151,14 +163,23 @@ void Backend::parseLines(QStringList lines){ QString file = info[1]; QString perms = ""; if(file.endsWith("/")){ perms = "d"; file.chop(1); } - contents.insert(file, QStringList() << perms << "-1" ); //Save the [perms, size ] + contents.insert(file, QStringList() << perms << "-1" <<""); //Save the [perms, size, linkto ] } else if(info.length()<9){ continue; } //invalid line //TAR Archive parsing while(info.length()>9){ info[8] = info[8]+" "+info[9]; info.removeAt(9); } //Filename has spaces in it QString file = info[8]; if(file.endsWith("/")){ file.chop(1); } - contents.insert(file, QStringList() << info[0] << info[4] ); //Save the [perms, size ] + QString linkto; + //See if this file has the "link to" or "->" notation + if(file.contains(" -> ")){ linkto = file.section(" -> ",1,-1); file = file.section(" -> ",0,0); } + else if(file.contains(" link to ")){ + //Special case - alternate form of a link within a tar archive (not reflected in perms) + linkto = file.section(" link to ",1,-1); + file = file.section(" link to ",0,0); + if(info[0].startsWith("-")){ info[0].replace(0,1,"l"); } + } + contents.insert(file, QStringList() << info[0] << info[4] << linkto); //Save the [perms, size, linkto ] } } @@ -174,17 +195,19 @@ void Backend::startList(){ // PRIVATE SLOTS //=============== void Backend::procFinished(int retcode, QProcess::ExitStatus){ + static QString result; processData(); - qDebug() << "Process Finished:" << PROC.arguments() << retcode; + //qDebug() << "Process Finished:" << PROC.arguments() << retcode; LIST = STARTING = false; if(PROC.arguments().contains("-tv")){ if(retcode!=0){ contents.clear(); } //could not read archive - emit ProcessFinished(); + emit ProcessFinished(true,result); + result.clear(); }else{ bool needupdate = true; QStringList args = PROC.arguments(); if(args.contains("-x") && retcode==0){ - needupdate=false; + needupdate=false; if(args.contains("--include")){ //Need to find the full path to the extracted file QString path = args.last() +"/"+ args[ args.indexOf("--include")+1].section("/",-1); @@ -201,8 +224,10 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){ QFile::remove(tmpfilepath); } } + if(args.contains("-x")){ result = tr("Extraction Finished"); } + else if(args.contains("-c")){ result = tr("Modification Finished"); } if(needupdate){ startList(); } - else{ emit ProcessFinished(); } + else{ emit ProcessFinished(retcode==0, result); result.clear(); } } } @@ -213,7 +238,9 @@ void Backend::processData(){ if(read.endsWith("\n")){ data.clear(); } else{ data = read.section("\n",-1); read = read.section("\n",0,-2); } QStringList lines = read.split("\n",QString::SkipEmptyParts); + QString info; if(LIST){ parseLines(lines); } + else if(!lines.isEmpty()){ info = lines.last(); } //qDebug() << lines; - emit ProgressUpdate(-1, ""); + emit ProgressUpdate(-1, info); } diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h index f12aae63..47bc0bb6 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h @@ -29,14 +29,17 @@ public: double size(QString file); double csize(QString file); bool isDir(QString file); + bool isLink(QString file); + QString linkTo(QString file); //Modification routines void startAdd(QStringList paths); void startRemove(QStringList paths); - void startExtract(QString path, bool overwrite); //path to dir + void startExtract(QString path, bool overwrite, QString file=""); //path to dir, overwrite, optional file to extract (everything otherwise) void startViewFile(QString path); + //Special process public slots: private: @@ -58,7 +61,7 @@ signals: void FileLoaded(); void ProcessStarting(); void ProgressUpdate(int, QString); //percentage, text - void ProcessFinished(); + void ProcessFinished(bool, QString); //success, text }; #endif diff --git a/src-qt5/desktop-utils/lumina-archiver/isoDialog.ui b/src-qt5/desktop-utils/lumina-archiver/isoDialog.ui new file mode 100644 index 00000000..99ba31fb --- /dev/null +++ b/src-qt5/desktop-utils/lumina-archiver/isoDialog.ui @@ -0,0 +1,151 @@ + + + isoDialog + + + + 0 + 0 + 305 + 179 + + + + Burn ISO/IMG to device + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Transfer Rate + + + + + + + + + + 0 + 0 + + + + 1 + + + 1023 + + + + + + + + + + + + USB Device + + + + + + + Wipe all extra space on device (conv = sync) + + + true + + + + + + + + + + + + Refresh Device List + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Cancel + + + + + + + Start + + + + + + + + + + -- cgit