aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-archiver
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-06-22 04:55:42 -0400
committerKen Moore <ken@ixsystems.com>2017-06-22 04:55:42 -0400
commit60b24de5be126f387e5bd4ea654c36e7f0bdd0d4 (patch)
tree9e9bd4b7865f46b0deae7619be296c8994fb8660 /src-qt5/desktop-utils/lumina-archiver
parentOops - forgot to add the new test.xml file to the last commit. (diff)
parentStart a large update to LuminaRandR info retrieval routine. (diff)
downloadlumina-60b24de5be126f387e5bd4ea654c36e7f0bdd0d4.tar.gz
lumina-60b24de5be126f387e5bd4ea654c36e7f0bdd0d4.tar.bz2
lumina-60b24de5be126f387e5bd4ea654c36e7f0bdd0d4.zip
Merge branch 'master' of github.com:trueos/lumina
Diffstat (limited to 'src-qt5/desktop-utils/lumina-archiver')
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/MainUI.cpp47
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp30
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/TarBackend.h4
3 files changed, 22 insertions, 59 deletions
diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp
index 43020309..9b77a477 100644
--- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp
@@ -52,7 +52,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
ui->action_Open->setShortcut(tr("CTRL+O"));
ui->action_Quit->setShortcut(tr("CTRL+Q"));
ui->actionExtract_All->setShortcut(tr("CTRL+E"));
-
+
ui->progressBar->setVisible(false);
ui->label_progress->setVisible(false);
ui->label_progress_icon->setVisible(false);
@@ -75,39 +75,13 @@ void MainUI::LoadArguments(QStringList args){
for(int i=0; i<args.length(); i++){
if(args[i]=="--burn-img"){ burnIMG = true; continue; }
if(args[i]=="--ax"){ autoExtract = true; continue; }
- /*i++;
- QFileInfo filename(args[i]);
- QDir filedir = filename.canonicalPath();
- QString newdir = filename.completeBaseName();
- filedir.mkpath(newdir);
- dir = newdir;
- qDebug() << "MAINUI - archivefile = " << args[i];
- qDebug() << "MAINUI - filedir = " << filedir;
- qDebug() << "MAINUI - newdir = " << newdir;
- qDebug() << "MAINUI - dir = " << dir;
- BACKEND->loadFile(args[i]);
- qDebug () << "MAINUI - File should have loaded";
- //add in a delay in case i'm hitting a race condition
- QTime waitTime= QTime::currentTime().addSecs(2);
- while (QTime::currentTime() < waitTime)
- QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
- //things should have settled, now trigger extraction
- if(autoExtract){
- ui->label_progress->setText(tr("Extracting..."));
- autoextractFiles();
- qDebug () << "MAINUI - Extraction should have started";
- }
- //now quit
- //QCoreApplication::quit();
- return;
- }*/
if(QFile::exists(args[i])){
ui->label_progress->setText(tr("Opening Archive..."));
- if(autoExtract){
- connect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(autoextractFiles()) );
+ if(autoExtract){
+ connect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(autoextractFiles()) );
connect(BACKEND, SIGNAL(ExtractSuccessful()), this, SLOT(close()) );
}
- BACKEND->loadFile(args[i]);
+ BACKEND->loadFile(args[i]);
ui->actionUSB_Image->setEnabled(args[i].simplified().endsWith(".img"));
if(burnIMG){ BurnImgToUSB(); } //Go ahead and launch the burn dialog right away
break;
@@ -140,10 +114,9 @@ QTreeWidgetItem* MainUI::findItem(QString path, QTreeWidgetItem *start){
}else{
for(int i=0; i<start->childCount(); 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)); }
+ 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
}
@@ -272,18 +245,11 @@ void MainUI::extractFiles(){
}
void MainUI::autoextractFiles(){
- disconnect(BACKEND, SIGNAL(fileLoaded()), this, SLOT(autoextractFiles()) );
+ disconnect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(autoextractFiles()) );
QString dir = BACKEND->currentFile().section("/",0,-2); //parent directory of the archive
- //QFileDialog::getExistingDirectory(this, tr("Extract Into Directory"), QDir::homePath() );
if(dir.isEmpty()){ return; }
- //add in a delay in case i'm hitting a race condition
- /*qDebug() << "void MainUI::autoextractFiles() has started";
- QTime waitTime= QTime::currentTime().addSecs(2);
- while (QTime::currentTime() < waitTime)
- QCoreApplication::processEvents(QEventLoop::AllEvents, 100);*/
ui->label_progress->setText(tr("Extracting..."));
BACKEND->startExtract(dir, true);
-// QApplication::quit();
}
void MainUI::extractSelection(){
@@ -312,7 +278,6 @@ void MainUI::UpdateTree(){
files.sort();
//Remove any entries for file no longer in the archive
bool changed = cleanItems(files);
- //qDebug() << "Found Files:" << files;
for(int i=0; i<files.length(); i++){
if(0 != findItem(files[i]) ){ continue; } //already in the tree widget
QString mime = LXDG::findAppMimeForFile(files[i].section("/",-1), false); //first match only
diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
index 226da9f1..c0d3b03e 100644
--- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
+++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
@@ -30,14 +30,11 @@ void Backend::loadFile(QString path){
qDebug() << "void Backend::loadFile(QString path) has started";
qDebug() << "Loading Archive:" << path;
filepath = path;
- //qDebug () << "BACKEND LOAD- " << "path = " << path;
- //qDebug () << "BACKEND LOAD- " << "filepath = " << filepath;
tmpfilepath = filepath.section("/",0,-2)+"/"+".tmp_larchiver_"+filepath.section("/",-1);
flags.clear();
flags << "-f" << filepath; //add the actual archive path
if(QFile::exists(path)){ startList(); qDebug () << "BACKEND LOAD startList has started";}
else{ contents.clear(); emit ProcessFinished(true, ""); }
- //qDebug () << "BACKEND LOAD COMPLETE";
}
bool Backend::canModify(){
@@ -108,8 +105,8 @@ void Backend::startAdd(QStringList paths){
args << paths;
if(QFile::exists(filepath)){ //append to existing
args.replaceInStrings(filepath, tmpfilepath);
- args<< "@"+filepath;
- }
+ args<< "@"+filepath;
+ }
STARTING=true;
PROC.start("tar", args);
}
@@ -120,21 +117,17 @@ void Backend::startRemove(QStringList paths){
QStringList args;
args << "-c" << "-a";
args << flags;
- args.replaceInStrings(filepath, tmpfilepath);
+ args.replaceInStrings(filepath, tmpfilepath);
//Add the include rules for all the files we want to keep (no exclude option in "tar")
for(int i=0; i<paths.length(); i++){
args << "--exclude" << paths[i];
}
- args<< "@"+filepath;
+ args<< "@"+filepath;
STARTING=true;
PROC.start("tar", args);
}
void Backend::startExtract(QString path, bool overwrite, QString file){
- qDebug () << "BACKEND startExtract -" << "void Backend::startExtract(QString path, bool overwrite, QString file) has started";
- qDebug () << "BACKEND startExtract -" << "path = " << path;
- qDebug () << "BACKEND startExtract -" << "overwrite =" << overwrite ;
- qDebug () << "BACKEND startExtract -" << "file =" << file;
startExtract(path, overwrite, QStringList() << file); //overload for multi-file function
}
@@ -179,7 +172,7 @@ void Backend::parseLines(QStringList lines){
if(info.startsWith("x ") && filepath.endsWith(".zip")){
//ZIP archives do not have all the extra information - just filenames
while(info.length()>2){ info[1]=info[1]+" "+info[2]; }
- QString file = info[1];
+ 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 ]
@@ -187,7 +180,7 @@ void Backend::parseLines(QStringList lines){
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];
+ QString file = info[8];
if(file.endsWith("/")){ file.chop(1); }
QString linkto;
//See if this file has the "link to" or "->" notation
@@ -241,9 +234,14 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){
QProcess::startDetached("xdg-open \""+path+"\"");
}else{
//Multi-file extract - open the dir instead
- QProcess::startDetached("xdg-open \""+ args.last()+"\""); //just extracted to a dir - open it now
+ QString dir = args.last();
+ //Check to see if tar extracted into a new subdir it just created
+ if(QFile::exists(dir+"/"+filepath.section("/",-1).section(".",0,0) ) ){
+ dir = dir+"/"+filepath.section("/",-1).section(".",0,0);
+ }
+ QProcess::startDetached("xdg-open \""+ dir+"\""); //just extracted to a dir - open it now
}
-
+
}else if(args.contains("-c") && QFile::exists(tmpfilepath)){
if(retcode==0){
QFile::remove(filepath);
@@ -260,7 +258,7 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){
}
void Backend::processData(){
- //Read the process
+ //Read the process
static QString data;
QString read = data+PROC.readAllStandardOutput();
if(read.endsWith("\n")){ data.clear(); }
diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h
index 271efa42..3eb4eb53 100644
--- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h
+++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h
@@ -37,10 +37,10 @@ public:
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, QStringList files);
-
+
void startViewFile(QString path);
- //Special process
+ //Special process
public slots:
private:
bgstack15