Skip to content

Commit

Permalink
start of streamlined wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
Anne Jan Brouwer committed May 18, 2015
1 parent b4649f6 commit 540c285
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
15 changes: 15 additions & 0 deletions dialog.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "dialog.h"
#include "ui_dialog.h"
#include <QDebug>
#include <QMessageBox>

/**
* @brief Dialog::Dialog
Expand Down Expand Up @@ -348,3 +350,16 @@ void Dialog::addGPGId(bool addGPGId)
{
ui->checkBoxAddGPGId->setChecked(addGPGId);
}

void Dialog::wizard()
{
// got GPG at-least ?
// TODO ^^

QString passStore = ui->storePath->text();
if(!QFile(passStore + ".gpg-id").exists()){
QMessageBox::critical(this, tr("Password store not initialised"),
tr("The folder %1 doesn't seem to be a password store or is not yet initialised.").arg(passStore));
}
// TODO REST
}
1 change: 1 addition & 0 deletions dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Dialog : public QDialog
bool hidePassword();
bool hideContent();
bool addGPGId();
void wizard();

private slots:
void on_radioButtonNative_clicked();
Expand Down
25 changes: 14 additions & 11 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ MainWindow::MainWindow(QWidget *parent) :
wrapperRunning = false;
execQueue = new QQueue<execQueueItem>;
ui->statusBar->showMessage(tr("Welcome to QtPass ") + VERSION, 2000);
firstRun = true;
}

/**
Expand Down Expand Up @@ -138,16 +139,6 @@ void MainWindow::checkConfig() {
}
passStore = Util::normalizeFolderPath(passStore);

if (!QFile(passStore).exists()) {
QMessageBox::critical(this, tr("Password store not initialised"),
tr("The folder %1 does not exist.").arg(passStore));
// TODO magic
} else if (!QFile(passStore + ".gpg-id").exists()) {
QMessageBox::critical(this, tr("Password store not initialised"),
tr("The folder %1 doesn't seem to be a password store or is not yet initialised.").arg(passStore));
// TODO wizard
}

passExecutable = settings.value("passExecutable").toString();
if (passExecutable == "") {
passExecutable = Util::findBinaryInPath("pass");
Expand All @@ -169,8 +160,10 @@ void MainWindow::checkConfig() {
webDavUser = settings.value("webDavUser").toString();
webDavPassword = settings.value("webDavPassword").toString();

if (passExecutable == "" && (gitExecutable == "" || gpgExecutable == "")) {
if (Util::checkConfig(passStore, passExecutable, gpgExecutable)) {
config();
} else {
firstRun = false;
}

// TODO: this needs to be before we try to access the store,
Expand Down Expand Up @@ -239,6 +232,7 @@ void MainWindow::config() {
d->hidePassword(hidePassword);
d->hideContent(hideContent);
d->addGPGId(addGPGId);
d->wizard(); // does shit

if (d->exec()) {
if (d->result() == QDialog::Accepted) {
Expand Down Expand Up @@ -269,8 +263,17 @@ void MainWindow::config() {
settings.setValue("addGPGId", addGPGId ? "true" : "false");

ui->treeView->setRootIndex(model.setRootPath(passStore));

if (firstRun && Util::checkConfig(passStore, passExecutable, gpgExecutable)) {
config(); // loop !!
}
}

} else if (firstRun) {
// close(); // not strong enough since not opened yet ;)
exit(0);
}
firstRun = false;
}

/**
Expand Down
1 change: 1 addition & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private slots:
bool wrapperRunning;
QStringList env;
QQueue<execQueueItem> *execQueue;
bool firstRun;
void updateText();
void executePass(QString, QString = QString());
void executeWrapper(QString, QString, QString = QString());
Expand Down
5 changes: 5 additions & 0 deletions util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@ QString Util::findBinaryInPath(QString binary)

return ret;
}

bool Util::checkConfig(QString passStore, QString passExecutable, QString gpgExecutable)
{
return !QFile(passStore).exists() || (!QFile(passExecutable).exists() && !QFile(gpgExecutable).exists());
}
1 change: 1 addition & 0 deletions util.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Util
static QString findBinaryInPath(QString);
static QString findPasswordStore();
static QString normalizeFolderPath(QString);
static bool checkConfig(QString, QString, QString);

private:
static void initialiseEnvironment();
Expand Down

0 comments on commit 540c285

Please sign in to comment.