aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@pcbsd.org>2016-09-15 14:04:02 -0400
committerKen Moore <ken@pcbsd.org>2016-09-15 14:04:02 -0400
commit4e8537a11832f00b58334e805e2b9aede0fcd0ff (patch)
treee87b3b7bdb89088750551db51b79d4da090881ba /src-qt5/desktop-utils/lumina-fm/gitWizard.cpp
parentFix a couple compile errors in lumina-fm. (diff)
downloadlumina-4e8537a11832f00b58334e805e2b9aede0fcd0ff.tar.gz
lumina-4e8537a11832f00b58334e805e2b9aede0fcd0ff.tar.bz2
lumina-4e8537a11832f00b58334e805e2b9aede0fcd0ff.zip
Get the Git clone functionality all functional. The last thing missing is a graphical dialog showing the status of the download.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm/gitWizard.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-fm/gitWizard.cpp70
1 files changed, 62 insertions, 8 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp
index f6d6f3b3..8f0e6199 100644
--- a/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp
+++ b/src-qt5/desktop-utils/lumina-fm/gitWizard.cpp
@@ -11,11 +11,23 @@
#include "gitCompat.h"
#include <QDebug>
+#include <QThread>
GitWizard::GitWizard(QWidget *parent) : QWizard(parent), ui(new Ui::GitWizard){
ui->setupUi(this); //load the designer form
connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(pageChanged(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()) );
+ connect(ui->line_user, SIGNAL(textChanged(const QString&)), this, SLOT(validateType()) );
+ connect(ui->line_pass, SIGNAL(textChanged(const QString&)), this, SLOT(validateType()) );
+ connect(ui->radio_type_ssh, SIGNAL(clicked()), this, SLOT(validateType()) );
+ connect(ui->radio_type_login, SIGNAL(clicked()), this, SLOT(validateType()) );
+ connect(ui->radio_type_anon, SIGNAL(clicked()), this, SLOT(validateType()) );
+ connect(ui->check_depth, SIGNAL(clicked()), this, SLOT(validateType()) );
+ connect(ui->check_branch, SIGNAL(clicked()), this, SLOT(validateType()) );
+ validateRepo();
}
GitWizard::~GitWizard(){
@@ -31,12 +43,26 @@ void GitWizard::setWorkingDir(QString path){
// PRIVATE
// ============
QString GitWizard::assembleURL(){
+ QString repo = ui->line_repo_org->text()+"/"+ui->line_repo_name->text()+".git";
+ QString url;
+ if(ui->radio_type_ssh->isChecked()){ url = "git@github.com:"+repo; }
+ else if(ui->radio_type_anon->isChecked()){ url = "https://github.com/"+repo; }
+ else if(ui->radio_type_login->isChecked()){
+ url = "https://"+ui->line_user->text()+":"+ui->line_pass->text()+"@github.com/"+repo;
+ }
+ return url;
}
-void GitWizard::showDownload(QProcess *P){
-
-
+void GitWizard::showDownload(GitProcess *P){
+ P->start(QIODevice::ReadOnly);
+ //P->closeWriteChannel();
+ //P->closeReadChannel(GitProcess::StandardOutput);
+ //P->closeReadChannel(GitProcess::StandardError);
+ while(P->state()!=QProcess::NotRunning){
+ this->thread()->usleep(50000); //50 ms
+ QApplication::processEvents();
+ }
P->deleteLater();
}
@@ -46,18 +72,18 @@ void GitWizard::showDownload(QProcess *P){
void GitWizard::pageChanged(int newpage){
//called when the "next" button is clicked
if(this->page(newpage)==ui->page_repo){
-
+ validateRepo();
}else if(this->page(newpage)==ui->page_type){
//Need to adjust items on this page based on info on last page
ui->radio_type_anon->setEnabled( !ui->check_privaterepo->isChecked() );
- ui->radio_type_ssh->setEnabled( QFile::exists(QDir::homePath()+"/.ssh/id_rsa") );
+ ui->radio_type_ssh->setEnabled( QFile::exists(QDir::homePath()+"/.ssh/id_rsa") ); //TODO - Disable for now until SSH passphrases can be used properly
//Now set the preferred type of login based on which are available
if(ui->radio_type_ssh->isEnabled()){ ui->radio_type_ssh->setChecked(true); } //SSH is preferred if that is available
else if(ui->radio_type_anon->isEnabled()){ ui->radio_type_anon->setChecked(true); } //anonymous next since it is a public repo - no creds really needed
else{ ui->radio_type_login->setChecked(true); }
//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;
}
@@ -73,11 +99,39 @@ void GitWizard::finished(int res){
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(); }
- QProcess *proc = GIT::setupClone(inDir, url, branch, depth);
+ GitProcess *proc = GIT::setupClone(inDir, url, branch, depth);
if(proc!=0){
+ if(ui->radio_type_ssh->isChecked()){
+ proc->setSSHPassword(ui->line_ssh_pass->text());
+ }
showDownload(proc);
}
}
- //this->deleteLater();
+ this->deleteLater();
+}
+
+//Page validation slots
+void GitWizard::validateRepo(){
+ bool ok = !ui->line_repo_org->text().isEmpty() && !ui->line_repo_name->text().isEmpty();
+ this->button(QWizard::NextButton)->setEnabled(ok);
+}
+
+void GitWizard::validateType(){
+ bool ok = false;
+ //Check types first
+ if(ui->radio_type_login->isChecked()){ ok = !ui->line_user->text().isEmpty() && !ui->line_pass->text().isEmpty(); }
+ else{ ok = true; }
+ //Now check optional settings
+ if(ui->check_branch->isChecked()){ ok = ok && !ui->line_branch->text().isEmpty(); }
+ if(ui->check_branch->isChecked()){ ok = ok && !ui->line_branch->text().isEmpty(); }
+ //Now make interface boxes appear/disappear as needed
+ ui->line_ssh_pass->setVisible(ui->radio_type_ssh->isChecked());
+ ui->line_user->setVisible(ui->radio_type_login->isChecked());
+ ui->line_pass->setVisible(ui->radio_type_login->isChecked());
+ ui->spin_depth->setVisible(ui->check_depth->isChecked());
+ ui->line_branch->setVisible(ui->check_branch->isChecked());
+
+ //Update the button as needed
+ this->button(QWizard::FinishButton)->setEnabled(ok);
}
bgstack15