aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2016-09-15 14:47:06 -0400
committerKen Moore <ken@pcbsd.org>2016-09-15 14:47:06 -0400
commit9f79342ab366a74a26b2957e88af265e90658025 (patch)
tree94d54361e9c92ae9b758686912236c933c4e360d /src-qt5
parentGet the Git clone functionality all functional. The last thing missing is a g... (diff)
downloadlumina-9f79342ab366a74a26b2957e88af265e90658025.tar.gz
lumina-9f79342ab366a74a26b2957e88af265e90658025.tar.bz2
lumina-9f79342ab366a74a26b2957e88af265e90658025.zip
Get the progress reporting all setup for the git clone. Now it is all set and ready for use!
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/gitCompat.cpp45
-rw-r--r--src-qt5/desktop-utils/lumina-fm/gitCompat.h4
-rw-r--r--src-qt5/desktop-utils/lumina-fm/gitWizard.cpp43
-rw-r--r--src-qt5/desktop-utils/lumina-fm/gitWizard.h24
-rw-r--r--src-qt5/desktop-utils/lumina-fm/gitWizard.ui16
5 files changed, 106 insertions, 26 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/gitCompat.cpp b/src-qt5/desktop-utils/lumina-fm/gitCompat.cpp
new file mode 100644
index 00000000..18e83e6a
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-fm/gitCompat.cpp
@@ -0,0 +1,45 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is the backend classe for interacting with the "git" utility
+//===========================================
+#include "gitCompat.h"
+#include <QApplication>
+
+#define TMPFILE QString("/tmp/.")
+GitProcess::GitProcess() : QProcess(){
+ this->setProcessChannelMode(QProcess::MergedChannels);
+ tmpfile.setFileName(TMPFILE +QString::number( (rand()%8999) + 1000 ));
+ //qDebug() << "Temporary File Name:" << tmpfile.fileName();
+ tmpfile.setParent(this);
+ connect(this, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(cleanup()) );
+ connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(printoutput()) );
+}
+
+GitProcess::~GitProcess(){
+ if(tmpfile.exists()){ tmpfile.remove(); } //ensure that password file never gets left behind
+}
+
+void GitProcess::setSSHPassword(QString pass){
+ //Save the password into the temporary file
+ if( tmpfile.open(QIODevice::WriteOnly) ){
+ QTextStream in(&tmpfile);
+ in << "#!/bin/sh"<<"\n";
+ in << "echo \""+pass+"\"" << "\n";
+ in << "rm "+tmpfile.fileName()+"\n"; //have the script clean itself up after running once
+ tmpfile.close();
+ }
+ tmpfile.setPermissions( QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner );
+ QApplication::processEvents();
+ QProcessEnvironment env = this->processEnvironment();
+ env.insert("SSH_ASKPASS", tmpfile.fileName());
+ env.insert("DISPLAY",":0"); //will not actually be used - the tmp file sends the password back instantly
+ this->setProcessEnvironment(env);
+}
+
+void GitProcess::cleanup(){
+ if(tmpfile.exists()){ tmpfile.remove(); } //ensure that password file never gets left behind
+}
diff --git a/src-qt5/desktop-utils/lumina-fm/gitCompat.h b/src-qt5/desktop-utils/lumina-fm/gitCompat.h
index a8b5bd1f..3e6cb15e 100644
--- a/src-qt5/desktop-utils/lumina-fm/gitCompat.h
+++ b/src-qt5/desktop-utils/lumina-fm/gitCompat.h
@@ -32,7 +32,7 @@ public:
private slots:
void cleanup();
- void printoutput(){ qDebug() << "Proc Output:" << this->readAllStandardOutput(); }
+ //void printoutput(){ qDebug() << "Proc Output:" << this->readAllStandardOutput(); }
protected:
virtual void setupChildProcess(){
@@ -77,7 +77,7 @@ public:
P->setWorkingDirectory(indir);
P->setProgram("git");
QStringList args;
- args << "clone";
+ args << "clone" << "--progress";
if(!branch.isEmpty()){ args << "-b" << branch; }
if(depth>0){ args << "--depth" << QString::number(depth); }
args << url;
diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp
index 8f0e6199..7edfc95f 100644
--- a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp
@@ -15,8 +15,9 @@
GitWizard::GitWizard(QWidget *parent) : QWizard(parent), ui(new Ui::GitWizard){
ui->setupUi(this); //load the designer form
+ proc = 0; //not initialized yet
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(pageChanged(int)) );
- connect(this, SIGNAL(finished(int)), this, SLOT(finished(int)) );
+ //connect(this, SIGNAL(finished(int)), this, SLOT(finished(int)) );
connect(ui->line_repo_org, SIGNAL(textChanged(const QString&)), this, SLOT(validateRepo()) );
connect(ui->line_repo_name, SIGNAL(textChanged(const QString&)), this, SLOT(validateRepo()) );
connect(ui->line_ssh_pass, SIGNAL(textChanged(const QString&)), this, SLOT(validateType()) );
@@ -31,7 +32,7 @@ GitWizard::GitWizard(QWidget *parent) : QWizard(parent), ui(new Ui::GitWizard){
}
GitWizard::~GitWizard(){
-
+ if(proc!=0){ proc->deleteLater(); }
}
//Input values;
@@ -54,8 +55,8 @@ QString GitWizard::assembleURL(){
return url;
}
-void GitWizard::showDownload(GitProcess *P){
- P->start(QIODevice::ReadOnly);
+/*void GitWizard::showDownload(GitProcess *P){
+
//P->closeWriteChannel();
//P->closeReadChannel(GitProcess::StandardOutput);
//P->closeReadChannel(GitProcess::StandardError);
@@ -64,7 +65,7 @@ void GitWizard::showDownload(GitProcess *P){
QApplication::processEvents();
}
P->deleteLater();
-}
+}*/
//================
// PRIVATE SLOTS
@@ -84,31 +85,22 @@ void GitWizard::pageChanged(int newpage){
//Clear any of the UI as needed
ui->line_user->clear(); ui->line_pass->clear(); ui->line_ssh_pass->clear();
validateType();
- }else{
- //qDebug() << "Unknown page!" << newpage;
- }
-}
-
-void GitWizard::finished(int res){
- //called when the "finish" button is clicked:
- // res==0: window closed (rejected state)
- // res==1: "finish" clicked (accepted state)
- //qDebug() << "Got Finished:" << res;
- if(res == QDialog::Accepted){
+ }else if(this->page(newpage)==ui->page_download){
qDebug() << "Run git clone";
QString url = assembleURL();
QString branch; if(ui->check_branch->isChecked()){ branch = ui->line_branch->text(); }
int depth = -1; if(ui->check_depth->isChecked()){ depth = ui->spin_depth->value(); }
- GitProcess *proc = GIT::setupClone(inDir, url, branch, depth);
+ proc = GIT::setupClone(inDir, url, branch, depth);
if(proc!=0){
+ connect(proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readProc()) );
+ connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(procFinished(int)) );
if(ui->radio_type_ssh->isChecked()){
proc->setSSHPassword(ui->line_ssh_pass->text());
}
- showDownload(proc);
+ proc->start(QIODevice::ReadOnly);
+ this->button(QWizard::FinishButton)->setEnabled(false);
}
}
-
- this->deleteLater();
}
//Page validation slots
@@ -133,5 +125,14 @@ void GitWizard::validateType(){
ui->line_branch->setVisible(ui->check_branch->isChecked());
//Update the button as needed
- this->button(QWizard::FinishButton)->setEnabled(ok);
+ this->button(QWizard::NextButton)->setEnabled(ok);
+}
+
+void GitWizard::readProc(){
+ ui->text_procOutput->append( proc->readAllStandardOutput() );
}
+
+void GitWizard::procFinished(int retcode){
+ this->button(QWizard::FinishButton)->setEnabled(true);
+}
+
diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.h b/src-qt5/desktop-utils/lumina-fm/gitWizard.h
index e68ac82d..4a6ec2bc 100644
--- a/src-qt5/desktop-utils/lumina-fm/gitWizard.h
+++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.h
@@ -11,6 +11,7 @@
#include <QWizard>
#include <QString>
+#include <QMessageBox>
#include "gitCompat.h"
@@ -30,18 +31,37 @@ public:
private:
Ui::GitWizard *ui;
QString inDir;
+ GitProcess *proc;
QString assembleURL();
- void showDownload(GitProcess *P);
+ //void showDownload(GitProcess *P);
private slots:
//Page Change slots
void pageChanged(int newpage); //called when the "next" button is clicked
- void finished(int); //called when the "finish" button is clicked
+ //void finished(int); //called when the "finish" button is clicked
//Page validation slots
void validateRepo(); //for page_repo
void validateType(); //for page_type
+
+ //process output
+ void readProc();
+ void procFinished(int retcode);
+
+protected:
+ void closeEvent(QCloseEvent *ev){
+ //Make sure the process is not running first
+ if(proc!=0 && proc->state()!=QProcess::NotRunning){
+ ev->ignore();
+ if(QMessageBox::Yes == QMessageBox::question(this, tr("Stop Download?"), tr("Kill the current download?") ) ){
+ proc->kill();
+ }
+ }else{
+ QWizard::closeEvent(ev);
+ this->deleteLater(); //we need to clean this up completely
+ }
+ }
};
#endif
diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.ui b/src-qt5/desktop-utils/lumina-fm/gitWizard.ui
index 86a5ccb1..0f5894b6 100644
--- a/src-qt5/desktop-utils/lumina-fm/gitWizard.ui
+++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.ui
@@ -16,6 +16,9 @@
<property name="wizardStyle">
<enum>QWizard::ModernStyle</enum>
</property>
+ <property name="options">
+ <set>QWizard::NoBackButtonOnLastPage|QWizard::NoBackButtonOnStartPage|QWizard::NoCancelButtonOnLastPage</set>
+ </property>
<widget class="QWizardPage" name="page_repo">
<property name="title">
<string>Welcome!</string>
@@ -226,7 +229,18 @@
</font>
</property>
<property name="text">
- <string>Click &quot;Finish&quot; to start downloading the repository</string>
+ <string>Click &quot;Next&quot; to start downloading the repository</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWizardPage" name="page_download">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QTextEdit" name="text_procOutput">
+ <property name="readOnly">
+ <bool>true</bool>
</property>
</widget>
</item>
bgstack15