From 3e2450652b35f1461ebf3c652f2173b778ace05e Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Wed, 7 Jun 2017 07:22:51 -0400 Subject: Get the auto-extract functionality cleaned up with the signal/slots a bit. --- src-qt5/desktop-utils/lumina-archiver/MainUI.cpp | 17 ++++++++++------- src-qt5/desktop-utils/lumina-archiver/MainUI.h | 3 ++- src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp | 14 ++++++++------ src-qt5/desktop-utils/lumina-archiver/TarBackend.h | 1 + 4 files changed, 21 insertions(+), 14 deletions(-) (limited to 'src-qt5/desktop-utils/lumina-archiver') diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp index d812d924..43020309 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp @@ -20,6 +20,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ ui->setupUi(this); + auto_extract_close = false; QString title = tr("Archive Manager"); if( getuid()==0){ title.append(" ("+tr("Admin Mode")+")"); } this->setWindowTitle(title); @@ -102,11 +103,13 @@ void MainUI::LoadArguments(QStringList args){ }*/ 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]); ui->actionUSB_Image->setEnabled(args[i].simplified().endsWith(".img")); if(burnIMG){ BurnImgToUSB(); } //Go ahead and launch the burn dialog right away - //else if(autoExtract){ QTimer::singleShot(2000, this, SLOT(autoextractFiles())); } break; } } @@ -375,6 +378,11 @@ void MainUI::ProcStarting(){ } void MainUI::ProcFinished(bool success, QString msg){ + if(ui->label_archive->text()!=BACKEND->currentFile()){ + ui->label_archive->setText(BACKEND->currentFile()); + this->setWindowTitle(BACKEND->currentFile().section("/",-1)); + ui->tree_contents->clear(); + } UpdateTree(); ui->progressBar->setRange(0,0); ui->progressBar->setValue(0); @@ -384,11 +392,6 @@ void MainUI::ProcFinished(bool success, QString msg){ ui->label_progress_icon->setVisible(!msg.isEmpty()); if(success){ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-complete","").pixmap(32,32) );} else{ ui->label_progress_icon->setPixmap( LXDG::findIcon("task-attention","").pixmap(32,32) );} - if(ui->label_archive->text()!=BACKEND->currentFile()){ - ui->label_archive->setText(BACKEND->currentFile()); - this->setWindowTitle(BACKEND->currentFile().section("/",-1)); - ui->tree_contents->clear(); - } QFileInfo info(BACKEND->currentFile()); bool canmodify = info.isWritable(); if(!info.exists()){ canmodify = QFileInfo(BACKEND->currentFile().section("/",0,-2)).isWritable(); } diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.h b/src-qt5/desktop-utils/lumina-archiver/MainUI.h index e37ae1cb..61475fb2 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.h +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.h @@ -25,11 +25,12 @@ public: void LoadArguments(QStringList); void loadIcons(); - //QString newdir, dir; + private: Ui::MainUI *ui; Backend *BACKEND; + bool auto_extract_close; QTreeWidgetItem* findItem(QString path, QTreeWidgetItem *start = 0); bool cleanItems(QStringList list, QTreeWidgetItem *start = 0); //returns true if anything gets cleaned diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index ad88c8bf..226da9f1 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -30,14 +30,14 @@ 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; + //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"; + //qDebug () << "BACKEND LOAD COMPLETE"; } bool Backend::canModify(){ @@ -140,9 +140,9 @@ void Backend::startExtract(QString path, bool overwrite, QString file){ } void Backend::startExtract(QString path, bool overwrite, QStringList files){ - QStringList args; + QStringList args; //this is a new/empty list - no need for the check below (KPM) //remove --ax arg if its still lingering so its not passed to external process - for(int i=0; i