From 5caf1c18bb4f686c140cb58bd1f7bf50fb783c43 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 3 Feb 2015 17:17:17 +0100 Subject: Consistent code formatting --- src/pwgui/pwgui.cpp | 76 +++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) (limited to 'src/pwgui/pwgui.cpp') diff --git a/src/pwgui/pwgui.cpp b/src/pwgui/pwgui.cpp index b9473aa..193341b 100644 --- a/src/pwgui/pwgui.cpp +++ b/src/pwgui/pwgui.cpp @@ -9,67 +9,69 @@ // ____________________________________________________________________________ PwGui::PwGui(int pfd, char *user, QWidget *parent) : - QMainWindow(parent), - ui(new Ui::PwGui), - pipefd(pfd) + QMainWindow(parent), + ui(new Ui::PwGui), + pipefd(pfd) { - // Initialize UI - initializeUI(user); - connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(on_accept())); - connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(on_reject())); + // Initialize UI + initializeUI(user); + connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(on_accept())); + connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(on_reject())); } // ____________________________________________________________________________ PwGui::~PwGui() { - delete ui; + delete ui; } // ____________________________________________________________________________ void PwGui::initializeUI(char *user) { - ui->setupUi(this); + ui->setupUi(this); - // Prefill username - if (user != NULL) { - ui->lineEditUser->setText(QString::fromUtf8(user)); - } + // Prefill username + if (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); + // Protect password from being seen + ui->lineEditPass->setEchoMode(QLineEdit::Password); + ui->lineEditPass->setInputMethodHints(ui->lineEditPass->inputMethodHints() | Qt::ImhNoAutoUppercase); - /* Main Window properties */ + /* 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 ); - this->show(); - this->showNormal(); - this->raise(); - this->activateWindow(); + // 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 ); + this->show(); + this->showNormal(); + this->raise(); + this->activateWindow(); } // ____________________________________________________________________________ void PwGui::on_accept() { - char buffer[BUFLEN + 1]; - int len = snprintf(buffer, BUFLEN, "%s%c%s%c", ui->lineEditUser->text().toUtf8().constData(), 0, ui->lineEditPass->text().toUtf8().constData(), 0); - if (len > BUFLEN) len = BUFLEN; - buffer[len] = '\0'; - ::write(pipefd, buffer, len); - ::close(pipefd); - // Quit with code 0 - QCoreApplication::instance()->exit(0); + char buffer[BUFLEN + 1]; + int len = snprintf(buffer, BUFLEN, "%s%c%s%c", ui->lineEditUser->text().toUtf8().constData(), 0, ui->lineEditPass->text().toUtf8().constData(), 0); + if (len > BUFLEN) { + len = BUFLEN; + } + buffer[len] = '\0'; + ::write(pipefd, buffer, len); + ::close(pipefd); + // Quit with code 0 + QCoreApplication::instance()->exit(0); } // ____________________________________________________________________________ void PwGui::on_reject() { - // Quit with code 1 - QCoreApplication::instance()->exit(1); + // Quit with code 1 + QCoreApplication::instance()->exit(1); } -- cgit v1.2.3-55-g7522