diff options
-rw-r--r-- | src-qt5/desktop-utils/lumina-archiver/MainUI.cpp | 30 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-archiver/MainUI.h | 3 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-archiver/MainUI.ui | 34 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp | 22 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-archiver/TarBackend.h | 4 |
5 files changed, 80 insertions, 13 deletions
diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp index 9710045c..71fb6db1 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.cpp @@ -18,7 +18,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ this->setWindowTitle(tr("Archive Manager")); BACKEND = new Backend(this); connect(BACKEND, SIGNAL(ProcessStarting()), this, SLOT(ProcStarting()) ); - connect(BACKEND, SIGNAL(ProcessFinished()), this, SLOT(ProcFinished()) ); + connect(BACKEND, SIGNAL(ProcessFinished(bool, QString)), this, SLOT(ProcFinished(bool, QString)) ); connect(BACKEND, SIGNAL(ProgressUpdate(int, QString)), this, SLOT(ProcUpdate(int, QString)) ); //Add a spacer between toolbar items @@ -33,10 +33,12 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ connect(ui->actionAdd_File, SIGNAL(triggered()), this, SLOT(addFiles()) ); connect(ui->actionRemove_File, SIGNAL(triggered()), this, SLOT(remFiles()) ); connect(ui->actionExtract_All, SIGNAL(triggered()), this, SLOT(extractFiles()) ); + connect(ui->actionExtract_Sel, SIGNAL(triggered()), this, SLOT(extractSelection()) ); connect(ui->actionAdd_Dirs, SIGNAL(triggered()), this, SLOT(addDirs()) ); connect(ui->tree_contents, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(ViewFile(QTreeWidgetItem*)) ); ui->progressBar->setVisible(false); ui->label_progress->setVisible(false); + ui->label_progress_icon->setVisible(false); ui->actionAdd_File->setEnabled(false); ui->actionRemove_File->setEnabled(false); ui->actionExtract_All->setEnabled(false); @@ -64,6 +66,7 @@ void MainUI::loadIcons(){ ui->actionAdd_Dirs->setIcon( LXDG::findIcon("archive-insert-directory","") ); ui->actionRemove_File->setIcon( LXDG::findIcon("archive-remove","") ); ui->actionExtract_All->setIcon( LXDG::findIcon("archive-extract","") ); + ui->actionExtract_Sel->setIcon( LXDG::findIcon("archive-extract","") ); } //=================== @@ -158,24 +161,28 @@ void MainUI::NewArchive(){ if(QFile::exists(file)){ if( !QFile::remove(file) ){ QMessageBox::warning(this, tr("Error"), QString(tr("Could not overwrite file:"))+"\n"+file); } } + ui->label_progress->setText(""); //just clear it (this action is instant) BACKEND->loadFile(file); } void MainUI::OpenArchive(){ QString file = QFileDialog::getOpenFileName(this, tr("Open Archive"), QDir::homePath(), OpenFileTypes() ); if(file.isEmpty()){ return; } + ui->label_progress->setText(tr("Opening Archive")); BACKEND->loadFile(file); } void MainUI::addFiles(){ QStringList files = QFileDialog::getOpenFileNames(this, tr("Add to Archive"), QDir::homePath() ); if(files.isEmpty()){ return; } + ui->label_progress->setText(tr("Adding Items")); BACKEND->startAdd(files); } void MainUI::addDirs(){ QString dirs = QFileDialog::getExistingDirectory(this, tr("Add to Archive"), QDir::homePath() ); if(dirs.isEmpty()){ return; } + ui->label_progress->setText(tr("Adding Items")); BACKEND->startAdd(QStringList() << dirs); } @@ -186,17 +193,29 @@ void MainUI::remFiles(){ items << sel[i]->whatsThis(0); } items.removeDuplicates(); + ui->label_progress->setText(tr("Removing Items")); BACKEND->startRemove(items); } void MainUI::extractFiles(){ QString dir = QFileDialog::getExistingDirectory(this, tr("Extract Into Directory"), QDir::homePath() ); if(dir.isEmpty()){ return; } + ui->label_progress->setText(tr("Extracting...")); BACKEND->startExtract(dir, true); } +void MainUI::extractSelection(){ + if(ui->tree_contents->currentItem()==0){ return; } + QString sel = ui->tree_contents->currentItem()->whatsThis(0); + QString dir = QFileDialog::getExistingDirectory(this, tr("Extract Into Directory"), QDir::homePath() ); + if(dir.isEmpty()){ return; } + ui->label_progress->setText(tr("Extracting...")); + BACKEND->startExtract(dir, true, sel); +} + void MainUI::ViewFile(QTreeWidgetItem *it){ if(it->childCount()>0){ return; } //directory - not viewable + ui->label_progress->setText(tr("Extracting...")); BACKEND->startViewFile(it->whatsThis(0)); } @@ -242,16 +261,21 @@ void MainUI::ProcStarting(){ ui->progressBar->setValue(0); ui->progressBar->setVisible(true); ui->label_progress->setVisible(true); + ui->label_progress_icon->setVisible(false); ui->tree_contents->setEnabled(false); ui->label_archive->setText(BACKEND->currentFile()); } -void MainUI::ProcFinished(){ +void MainUI::ProcFinished(bool success, QString msg){ ui->progressBar->setRange(0,0); ui->progressBar->setValue(0); ui->progressBar->setVisible(false); - ui->label_progress->setVisible(false); + ui->label_progress->setText(msg); + ui->label_progress->setVisible(!msg.isEmpty()); ui->tree_contents->setEnabled(true); + 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)); diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.h b/src-qt5/desktop-utils/lumina-archiver/MainUI.h index 09207aa3..bb462a7d 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.h +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.h @@ -44,13 +44,14 @@ private slots: void addDirs(); void remFiles(); void extractFiles(); + void extractSelection(); void ViewFile(QTreeWidgetItem *it); void UpdateTree(); //Backend Handling void ProcStarting(); - void ProcFinished(); + void ProcFinished(bool, QString); void ProcUpdate(int percent, QString txt); }; diff --git a/src-qt5/desktop-utils/lumina-archiver/MainUI.ui b/src-qt5/desktop-utils/lumina-archiver/MainUI.ui index 8c2b2836..1aff2e4f 100644 --- a/src-qt5/desktop-utils/lumina-archiver/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-archiver/MainUI.ui @@ -57,6 +57,31 @@ <item> <layout class="QHBoxLayout" name="horizontalLayout_2"> <item> + <widget class="QLabel" name="label_progress_icon"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="text"> + <string notr="true"/> + </property> + </widget> + </item> + <item> <widget class="QProgressBar" name="progressBar"> <property name="value"> <number>24</number> @@ -68,6 +93,9 @@ <property name="text"> <string notr="true"/> </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> </widget> </item> </layout> @@ -101,6 +129,7 @@ <addaction name="actionRemove_File"/> <addaction name="separator"/> <addaction name="actionExtract_All"/> + <addaction name="actionExtract_Sel"/> </widget> <addaction name="menuFile"/> <addaction name="menuEdit"/> @@ -183,6 +212,11 @@ <string>Add directory to archive</string> </property> </action> + <action name="actionExtract_Sel"> + <property name="text"> + <string>Extract Selection</string> + </property> + </action> </widget> <resources/> <connections/> diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index 4dee247b..de3ef49b 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -32,7 +32,7 @@ void Backend::loadFile(QString path){ flags.clear(); flags << "-f" << filepath; //add the actual archive path if(QFile::exists(path)){ startList(); } - else{ contents.clear(); emit ProcessFinished(); } + else{ contents.clear(); emit ProcessFinished(true, ""); } } bool Backend::canModify(){ @@ -115,11 +115,13 @@ void Backend::startRemove(QStringList paths){ PROC.start("tar", args); } -void Backend::startExtract(QString path, bool overwrite){ +void Backend::startExtract(QString path, bool overwrite, QString file){ QStringList args; args << "-x"; if(!overwrite){ args << "-k"; } - args << flags << "-C" << path; + args << flags; + if(!file.isEmpty()){ args << "--include" << file << "--strip-components" << QString::number(file.count("/")); } + args << "-C" << path; STARTING=true; //qDebug() << "Starting command:" << "tar" << args; PROC.start("tar", args); @@ -174,17 +176,19 @@ void Backend::startList(){ // PRIVATE SLOTS //=============== void Backend::procFinished(int retcode, QProcess::ExitStatus){ + static QString result; processData(); qDebug() << "Process Finished:" << PROC.arguments() << retcode; LIST = STARTING = false; if(PROC.arguments().contains("-tv")){ if(retcode!=0){ contents.clear(); } //could not read archive - emit ProcessFinished(); + emit ProcessFinished(true,result); + result.clear(); }else{ bool needupdate = true; QStringList args = PROC.arguments(); if(args.contains("-x") && retcode==0){ - needupdate=false; + needupdate=false; if(args.contains("--include")){ //Need to find the full path to the extracted file QString path = args.last() +"/"+ args[ args.indexOf("--include")+1].section("/",-1); @@ -201,8 +205,10 @@ void Backend::procFinished(int retcode, QProcess::ExitStatus){ QFile::remove(tmpfilepath); } } + if(args.contains("-x")){ result = tr("Extraction Finished"); } + else if(args.contains("-c")){ result = tr("Modification Finished"); } if(needupdate){ startList(); } - else{ emit ProcessFinished(); } + else{ emit ProcessFinished(retcode==0, result); result.clear(); } } } @@ -213,7 +219,9 @@ void Backend::processData(){ if(read.endsWith("\n")){ data.clear(); } else{ data = read.section("\n",-1); read = read.section("\n",0,-2); } QStringList lines = read.split("\n",QString::SkipEmptyParts); + QString info; if(LIST){ parseLines(lines); } + else if(!lines.isEmpty()){ info = lines.last(); } //qDebug() << lines; - emit ProgressUpdate(-1, ""); + emit ProgressUpdate(-1, info); } diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h index f12aae63..c1e47454 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.h +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.h @@ -33,7 +33,7 @@ public: //Modification routines void startAdd(QStringList paths); void startRemove(QStringList paths); - void startExtract(QString path, bool overwrite); //path to dir + void startExtract(QString path, bool overwrite, QString file=""); //path to dir, overwrite, optional file to extract (everything otherwise) void startViewFile(QString path); @@ -58,7 +58,7 @@ signals: void FileLoaded(); void ProcessStarting(); void ProgressUpdate(int, QString); //percentage, text - void ProcessFinished(); + void ProcessFinished(bool, QString); //success, text }; #endif |