#include "PrognameDialog.h"
#include "MountieMemory.h"

PrognameDialog::PrognameDialog(QWidget * parent) : QDialog(parent) {
   ui.setupUi(this);
   ui.lineEdit->setText(MountieMemory::Get()->GetProgname());

   connect(ui.buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)),
           this, SLOT(ResetButtonPushed()));
   connect(ui.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)),
           this, SLOT(OKButtonPushed()));
   connect(ui.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)),
           this, SLOT(CancelButtonPushed()));
   connect(this, SIGNAL(accepted()), this, SLOT(Accepted()));
}

PrognameDialog::~PrognameDialog() {
   return;
}

void
PrognameDialog::BrowseButtonPushed() {
   // PUT CODE HERE - popup browser for existing file at /usr/bin dir
}

void
PrognameDialog::ResetButtonPushed() {
   ui.lineEdit->clear();
}

void
PrognameDialog::OKButtonPushed() {
   accept();
}

void
PrognameDialog::CancelButtonPushed() {
   reject();
}

void
PrognameDialog::Accepted() {
   MountieMemory::Get()->SaveProgname(ui.lineEdit->text());
}
