Skip to content

Commit

Permalink
code commenting and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
waltergallegog committed Jan 31, 2018
1 parent e7dbf5f commit adf6fe5
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 329 deletions.
2 changes: 1 addition & 1 deletion SEcubeWallet.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.2.1, 2018-01-31T04:34:51. -->
<!-- Written by QtCreator 4.2.1, 2018-01-31T20:54:53. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
59 changes: 35 additions & 24 deletions scr/addentry.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
#include "addentry.h"
#include "ui_addentry.h"

#define OK_BUTTON 0
#define UNUSED(expr) (void)(expr)

//Default constructor, called from add entry
AddEntry::AddEntry(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddEntry){

ui->setupUi(this);
ui->PassDoNot->setVisible(false);
ui->buttonBox->buttons()[0]->setEnabled(false);
ui->buttonBox->buttons()[0]->setEnabled(false); //Ok button initially disabled, as user has not entered any data
setWindowTitle( tr("Fillout the new entry") );
setModal( true );
setModal(true); //Modal, so user cannot access main window without first closing this one.
}

// Second constructor, called from eddit entry
AddEntry::AddEntry(QWidget *parent, QString EditUserIn, QString EditPassIn, QString EditDomIn ) :
QDialog(parent),
ui(new Ui::AddEntry)
{

ui->setupUi(this);
//Initialize fields with the data to edit
ui->InUser->setText(EditUserIn);
ui->InDomain->setText(EditDomIn);
ui->InPass->setText(EditPassIn);
ui->InPass2->setText(EditPassIn);

ui->PassDoNot->setVisible(false);
ui->buttonBox->buttons()[0]->setEnabled(false);
setWindowTitle( tr("Fillout the new entry") );
setModal( true );
ui->buttonBox->buttons()[OK_BUTTON]->setEnabled(false);
setWindowTitle( tr("Edit the entry") );
setModal(true);
}

AddEntry::~AddEntry(){
Expand All @@ -45,56 +50,62 @@ QString AddEntry::getPassword(){
return ui->InPass->text();
}


// Each time the user modifies one of the text fields, we check if all of them have data, so we can enable Ok button
void AddEntry::EnableOkButton(){
bool ok = !ui->InDomain->text().isEmpty()
&& !ui->InUser->text().isEmpty()
&& !ui->InPass->text().isEmpty()
&& !ui->InPass2->text().isEmpty();

ui->buttonBox->buttons()[0]->setEnabled(ok);
ui->buttonBox->buttons()[OK_BUTTON]->setEnabled(ok);
}

// If passwords are not equal, warning message
void AddEntry::PasswordWarning(){
if (ui->InPass->text() == ui->InPass2->text())
EqPass=true;
EqPass=true; // Flag, to allow ok button
else
EqPass=false;
ui->PassDoNot->setVisible(!EqPass);
}

// If the user wants to show the passwords, change EchoMode
void AddEntry::on_ShowPass_toggled(bool checked)
{
if (checked){
ui->InPass->setEchoMode(QLineEdit::Normal);
ui->InPass2->setEchoMode(QLineEdit::Normal);
}
else{
ui->InPass->setEchoMode(QLineEdit::Password);
ui->InPass2->setEchoMode(QLineEdit::Password);
}
}

void AddEntry::on_InUser_textChanged(const QString &arg1){
EnableOkButton();
UNUSED(arg1);
}

void AddEntry::on_InDomain_textChanged(const QString &arg1){
EnableOkButton();
UNUSED(arg1);
}

void AddEntry::on_InPass_textChanged(const QString &arg1){
EnableOkButton();
PasswordWarning();
UNUSED(arg1);
}

void AddEntry::on_InPass2_textChanged(const QString &arg1){
EnableOkButton();
PasswordWarning();
UNUSED(arg1);
}


void AddEntry::on_buttonBox_clicked(QAbstractButton *button){
void AddEntry::on_buttonBox_clicked(QAbstractButton* button){
if (EqPass)
this->accept();
}

void AddEntry::on_ShowPass_toggled(bool checked)
{
if (checked){
ui->InPass->setEchoMode(QLineEdit::Normal);
ui->InPass2->setEchoMode(QLineEdit::Normal);
}
else{
ui->InPass->setEchoMode(QLineEdit::Password);
ui->InPass2->setEchoMode(QLineEdit::Password);
}
this->accept(); //Only emith accept() when passwords are equal
UNUSED(button);
}
8 changes: 6 additions & 2 deletions scr/addentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ class AddEntry : public QDialog
Q_OBJECT

public:
// Constructor when calling from add
explicit AddEntry(QWidget *parent = 0);

//Constructor when calling from edit.
explicit AddEntry(QWidget *parent, QString EditUserIn, QString EditPassIn, QString EditDomIn);
~AddEntry();

~AddEntry();//Destructor

//Methods to access data from main.
QString getUser();
QString getDomain();
QString getPassword();
Expand All @@ -30,7 +35,6 @@ private slots:
void on_InPass_textChanged(const QString &arg1);
void on_InPass2_textChanged(const QString &arg1);
void on_buttonBox_clicked(QAbstractButton *button);

void on_ShowPass_toggled(bool checked);

private:
Expand Down
54 changes: 0 additions & 54 deletions scr/dbmanager.cpp

This file was deleted.

48 changes: 0 additions & 48 deletions scr/dbmanager.h

This file was deleted.

4 changes: 2 additions & 2 deletions scr/deleteconfirmation.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "deleteconfirmation.h"
#include "ui_deleteconfirmation.h"

//Nothing to see here, just a simple dialog, configuration is done in the UI editor.
DeleteConfirmation::DeleteConfirmation(QWidget *parent) :
QDialog(parent),
ui(new Ui::DeleteConfirmation)
Expand All @@ -11,7 +12,6 @@ DeleteConfirmation::DeleteConfirmation(QWidget *parent) :
setModal( true );
}

DeleteConfirmation::~DeleteConfirmation()
{
DeleteConfirmation::~DeleteConfirmation(){
delete ui;
}
Loading

0 comments on commit adf6fe5

Please sign in to comment.