diff --git a/mainwindow.cpp b/mainwindow.cpp index 4f3e2cb0..6f728fd2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -35,6 +35,7 @@ MainWindow::~MainWindow() { delete ui; delete myButton; + delete pinMsgBox; } void MainWindow::on_actionExit_triggered() @@ -56,5 +57,22 @@ void MainWindow::on_newHostBtn_clicked() } else { // silently close, user canceled } - +} + +// this opens a non-blocking informative message telling the user to enter the given pin +// it is open-loop: if the user cancels, nothing happens +// it is expected that upon pairing completion, the ::closePinDialog function will be called. +void MainWindow::displayPinDialog(QString pin = tr("ERROR")) { + + pinMsgBox = new QMessageBox( this ); + pinMsgBox->setAttribute( Qt::WA_DeleteOnClose ); //makes sure the msgbox is deleted automatically when closed + pinMsgBox->setStandardButtons( QMessageBox::Ok ); + pinMsgBox->setText("Please enter the number " + pin + " on the GFE dialog on the computer."); + pinMsgBox->setInformativeText("This dialog will be dismissed once complete."); + pinMsgBox->open(); +} + +// to be called when the pairing is complete +void MainWindow::closePinDialog() { + pinMsgBox->close(); } diff --git a/mainwindow.h b/mainwindow.h index aa56fbb5..8edff78b 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -22,11 +22,13 @@ protected: private slots: void on_actionExit_triggered(); void on_newHostBtn_clicked(); + void displayPinDialog(QString pin); + void closePinDialog(); private: Ui::MainWindow *ui; QAbstractButton *myButton = nullptr; - QAbstractButton *newHostBtn = nullptr; + QMessageBox *pinMsgBox = nullptr; };