aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2017-11-14 00:04:49 +0000
committerWeblate <noreply@weblate.org>2017-11-14 00:04:49 +0000
commitdc40a01ae695b47f87daff7ee08f3519d79b12ae (patch)
tree6e1d58f23d4537f8f501ba7e531f9ed90f269dda /src-qt5/desktop-utils/lumina-archiver/MainUI.cpp
parentTranslated using Weblate (German) (diff)
parentAdd a special rule for Ubuntu Linux: (diff)
downloadlumina-dc40a01ae695b47f87daff7ee08f3519d79b12ae.tar.gz
lumina-dc40a01ae695b47f87daff7ee08f3519d79b12ae.tar.bz2
lumina-dc40a01ae695b47f87daff7ee08f3519d79b12ae.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/desktop-utils/lumina-archiver/MainUI.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/MainUI.cpp98
1 files changed, 65 insertions, 33 deletions
diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp
index 9d220824..79c023dc 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,42 @@ 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; i<args.length(); i++){
- if(args[i]=="--burn-img"){ burnIMG = true; continue; }
- if(args[i]=="--ax"){ autoExtract = true; continue; }
- //if(args[i]=="--aa"){ autoArchive = true; continue; }
- if(QFile::exists(args[i])){
- ui->label_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 if(args[i]=="--sx"){ action = 3; continue; }
+ }else{
+ files << args[i];
}
- //if(autoArchive){
- //get rest of arguments
- //for(int i=1; i<args.length(); i++){
- // aaFileList << args[i];}
- // now launch autoarchive method with arg list
- // autoArchiveFiles(aaFileList);
- // connect(BACKEND, SIGNAL(ArchivalSuccessful()), this, SLOT(close()) );
- //}
}
+ if(files.isEmpty()){ return; }
+ //Now go through and do any actions as needed
+ ui->label_progress->setText(tr("Opening Archive..."));
+ if(action==1){
+ //qDebug() << "blah";
+ connect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(autoextractFiles()) );
+ connect(BACKEND, SIGNAL(ExtractSuccessful()), delayClose, SLOT(start()) );
+ }else if(action==2){
+ aaFileList.clear();
+ for(int j=1; j<files.length(); j++){ aaFileList << files[j]; }
+ qDebug() << "AA Files:" << aaFileList;
+ connect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(autoArchiveFiles()) );
+ connect(BACKEND, SIGNAL(ArchivalSuccessful()), delayClose, SLOT(start()) );
+ }else if(action==3 && files.length()==2){
+ sxFile = files[0];
+ sxPath = files[1];
+ connect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(simpleExtractFiles()) );
+ connect(BACKEND, SIGNAL(ExtractSuccessful()), delayClose, SLOT(start()) );
+ }
+ BACKEND->loadFile(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(){
@@ -255,16 +268,35 @@ void MainUI::extractFiles(){
}
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; }
- ui->label_progress->setText(tr("Extracting..."));
- BACKEND->startExtract(dir, true);
+ 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::simpleExtractFiles(){
+ disconnect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(autoextractFiles()) );
+ QString dir = sxPath;
+ ui->label_progress->setText(tr("Extracting..."));
+ BACKEND->startExtract(dir, true);
+}
+
+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
bgstack15