aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/MainUI.cpp75
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/MainUI.h17
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp5
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/TarBackend.h2
4 files changed, 59 insertions, 40 deletions
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; 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{
+ 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){
+ 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]; }
+ connect(BACKEND, SIGNAL(FileLoaded()), this, SLOT(autoArchiveFiles()) );
+ connect(BACKEND, SIGNAL(ArchivalSuccessful()), 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(){
@@ -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
diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.h b/src-qt5/desktop-utils/lumina-archiver/MainUI.h
index a2687895..a16d5862 100644
--- a/src-qt5/desktop-utils/lumina-archiver/MainUI.h
+++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.h
@@ -10,6 +10,7 @@
#include <QMainWindow>
#include <QString>
#include <QTreeWidgetItem>
+#include <QTimer>
#include "TarBackend.h"
@@ -24,20 +25,20 @@ public:
~MainUI();
void LoadArguments(QStringList);
- void loadIcons();
- //QStringList aaFileList;
+ void loadIcons();
private:
Ui::MainUI *ui;
Backend *BACKEND;
- bool auto_extract_close;
+ QStringList aaFileList;
+ QTimer *delayClose;
QTreeWidgetItem* findItem(QString path, QTreeWidgetItem *start = 0);
bool cleanItems(QStringList list, QTreeWidgetItem *start = 0); //returns true if anything gets cleaned
//Functions for setting the valid file extensions ("tar" limitations)
QString CreateFileTypes();
- QString OpenFileTypes();
+ QString OpenFileTypes();
private slots:
void NewArchive();
@@ -45,14 +46,14 @@ private slots:
void addFiles();
void addDirs();
void remFiles();
- void extractFiles();
- void autoextractFiles();
- //void autoArchiveFiles(QStringList aaFileList);
+ void extractFiles();
+ void autoextractFiles();
+ void autoArchiveFiles();
void extractSelection();
void ViewFile(QTreeWidgetItem *it);
void UpdateTree();
- void BurnImgToUSB();
+ void BurnImgToUSB();
//Backend Handling
void ProcStarting();
diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
index e0b802a4..f110624b 100644
--- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
+++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp
@@ -36,7 +36,7 @@ void Backend::loadFile(QString path){
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, ""); }
+ else{ contents.clear(); emit FileLoaded(); emit ProcessFinished(true, ""); }
}
bool Backend::canModify(){
@@ -262,8 +262,7 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){
}
}
if(args.contains("-x")){ result = tr("Extraction Finished"); emit ExtractSuccessful(); }
- //if(args.contains("-aa")){ result = tr("Archival Finished"); emit ArchivalSuccessful(); }
- else if(args.contains("-c")){ result = tr("Modification Finished"); }
+ else if(args.contains("-c")){ result = tr("Modification Finished"); emit ArchivalSuccessful(); }
if(needupdate){ startList(); }
else{ emit ProcessFinished(retcode==0, result); result.clear(); }
}
diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h
index d86ecf7c..183cb610 100644
--- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h
+++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h
@@ -64,7 +64,7 @@ signals:
void ProcessStarting();
void ProgressUpdate(int, QString); //percentage, text
void ProcessFinished(bool, QString); //success, text
- //void ArchivalSuccessful();
+ void ArchivalSuccessful();
};
#endif
bgstack15