From d731985427420c462d845b4279b14238e5527cae Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 4 Oct 2017 09:51:31 -0400 Subject: Finish up the auto archive/extract within lumina-archiver (with JT) --- src-qt5/desktop-utils/lumina-archiver/MainUI.cpp | 75 +++++++++++++++--------- 1 file changed, 47 insertions(+), 28 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-archiver/MainUI.cpp') diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp index 9d220824..215fc64e 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp @@ -20,7 +20,11 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); - auto_extract_close = false; + delayClose = new QTimer(this); + delayClose->setInterval(500); + delayClose->setSingleShot(true); + connect(delayClose, SIGNAL(timeout()), this, SLOT(close()) ); + QString title = tr("Archive Manager"); if( getuid()==0){ title.append(" ("+tr("Admin Mode")+")"); } this->setWindowTitle(title); @@ -70,33 +74,34 @@ MainUI::~MainUI(){ } void MainUI::LoadArguments(QStringList args){ - bool burnIMG = false; - bool autoExtract = false; - //bool autoArchive = false; + int action = -1; // 0: burnIMG, 1: autoExtract, 2: autoArchive + QStringList files; for(int i=0; ilabel_progress->setText(tr("Opening Archive...")); - if(autoExtract){ - connect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(autoextractFiles()) ); - connect(BACKEND, SIGNAL(ExtractSuccessful()), this, SLOT(close()) ); - } - 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; + if(args[i].startsWith("--") ){ + if(action>=0){ break; } + else if(args[i]=="--burn-img"){ action = 0; continue; } + else if(args[i]=="--ax"){ action = 1; continue; } + else if(args[i]=="--aa"){ action = 2; continue; } + }else{ + files << args[i]; } - //if(autoArchive){ - //get rest of arguments - //for(int i=1; ilabel_progress->setText(tr("Opening Archive...")); + if(action==1){ + connect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(autoextractFiles()) ); + connect(BACKEND, SIGNAL(ExtractSuccessful()), delayClose, SLOT(start()) ); + }else if(action==2){ + aaFileList.clear(); + for(int j=1; jloadFile(files[0]); + ui->actionUSB_Image->setEnabled(files[0].simplified().endsWith(".img")); + if(action==0){ BurnImgToUSB(); } //Go ahead and launch the burn dialog right away + } void MainUI::loadIcons(){ @@ -258,13 +263,27 @@ void MainUI::autoextractFiles(){ disconnect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(autoextractFiles()) ); QString dir = BACKEND->currentFile().section("/",0,-2); //parent directory of the archive if(dir.isEmpty()){ return; } + QDir tmp(dir); + QString name = BACKEND->currentFile().section("/",-1).section(".",0,0); + if(QFile::exists(dir+"/"+name)){ + int num = 1; + while( QFile::exists(dir+"/"+name+"_"+QString::number(num))){ num++; } + name = name+"_"+QString::number(num); + } + if(tmp.mkdir(name) ){ + dir.append("/"+name); //created sub directory + } ui->label_progress->setText(tr("Extracting...")); BACKEND->startExtract(dir, true); } -/* -void MainUI::autoArchiveFiles(aaFileList){ -*/ + +void MainUI::autoArchiveFiles(){ + qDebug() << "Auto Archive Files:" << aaFileList; + ui->label_progress->setText(tr("Adding Items...")); + BACKEND->startAdd(aaFileList); +} + void MainUI::extractSelection(){ if(ui->tree_contents->currentItem()==0){ return; } //nothing selected -- cgit