aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-archiver
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/desktop-utils/lumina-archiver')
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/MainUI.cpp98
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/MainUI.h19
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp5
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/TarBackend.h2
-rw-r--r--src-qt5/desktop-utils/lumina-archiver/main.cpp2
5 files changed, 80 insertions, 46 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
diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.h b/src-qt5/desktop-utils/lumina-archiver/MainUI.h
index a2687895..1a9d287c 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,21 @@ public:
~MainUI();
void LoadArguments(QStringList);
- void loadIcons();
- //QStringList aaFileList;
+ void loadIcons();
private:
Ui::MainUI *ui;
Backend *BACKEND;
- bool auto_extract_close;
+ QStringList aaFileList, sxList;
+ QString sxPath, sxFile;
+ 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 +47,15 @@ private slots:
void addFiles();
void addDirs();
void remFiles();
- void extractFiles();
- void autoextractFiles();
- //void autoArchiveFiles(QStringList aaFileList);
+ void extractFiles();
+ void autoextractFiles();
+ void autoArchiveFiles();
+ void simpleExtractFiles();
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
diff --git a/src-qt5/desktop-utils/lumina-archiver/main.cpp b/src-qt5/desktop-utils/lumina-archiver/main.cpp
index 40cd7967..01e7bda1 100644
--- a/src-qt5/desktop-utils/lumina-archiver/main.cpp
+++ b/src-qt5/desktop-utils/lumina-archiver/main.cpp
@@ -15,7 +15,7 @@
int main(int argc, char *argv[]) {
LTHEME::LoadCustomEnvSettings();
QApplication a(argc, argv);
- a.setAttribute(Qt::AA_UseHighDpiPixmaps);
+ a.setAttribute(Qt::AA_UseHighDpiPixmaps);
LUtils::LoadTranslation(&a, "l-archiver");
//Now go ahead and setup the app
QStringList args;
bgstack15