summaryrefslogtreecommitdiffstats
path: root/src/pwgui/pwgui.cpp
blob: 448cee8d4a06063097607034c8db4ecfc4f4be8e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "pwgui.h"
#include "ui_pwgui.h"
#include <QMessageBox>
#include <QTimer>
#include <QDesktopWidget>

// ____________________________________________________________________________
PwGui::PwGui(int pfd, QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::PwGui),
    pipefd(pfd)
{
  // Initialize UI
  initializeUI();
}

// ____________________________________________________________________________
PwGui::~PwGui()
{
  delete ui;
}

// ____________________________________________________________________________
void PwGui::initializeUI()
{
  ui->setupUi(this);

  /*
  // Prefill username
  if (this->user != NULL) {
    ui->lineEditUser->setText(QString::fromUtf8(user));
  }
  */

  // Protect password from being seen
  ui->lineEditPass->setEchoMode(QLineEdit::Password);
  ui->lineEditPass->setInputMethodHints(ui->lineEditPass->inputMethodHints() | Qt::ImhNoAutoUppercase);

  /*  Main Window properties  */

  // Disable close button
  this->setWindowFlags((this->windowFlags() & ~Qt::WindowCloseButtonHint) | Qt::WindowStaysOnTopHint);
  // center dialog on screen center
  QRect desktopRect = QApplication::desktop()->screenGeometry(this);
  this->move( desktopRect.width()/2-this->width()/2,
              desktopRect.height()/2-this->height()/2);
}

/*
void PwGui::on_buttonCancel_clicked()
{
  // Quit with code 1
  QCoreApplication::instance()->exit(1);
}
*/

// ____________________________________________________________________________
void PwGui::on_checkStatusTimer()
{
  static int retries = 0;
  if (++retries > 20) {
    QCoreApplication::instance()->quit();
  }
}