Skip to content

Commit

Permalink
qt5+: Pass single StandardButtons arg. to QMessageBox funcs [4/4]
Browse files Browse the repository at this point in the history
Invoking `QMessageBox` functions with separate `button0`, `button1`, ...
arguments was deprecated in Qt 4; all button specifications are now
passed within a single `QMessageBox::StandardButtons` argument.

This commit takes care of the last such instance, where buttons were
passed this time as `QString`.  This requires calling `addButton()` for
each one, as well as replacing the following `switch` with an `if`,
since the return type of `clickedButton()` is a (non-constant) pointer.
(For the record, since we are using custom buttons, the return value of
`exec()` is now an opaque value.)
  • Loading branch information
fbriere committed Nov 19, 2024
1 parent 031b552 commit a87fbaa
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/gui/selectprofileform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int SelectProfileForm::execForm()
"Before you can use Twinkle, you must create a user "\
"profile.<br>Click OK to create a profile.</html>"));

int newProfileMethod = QMessageBox::question(this, PRODUCT_NAME, tr(
QMessageBox mb(QMessageBox::Question, PRODUCT_NAME, tr(
"<html>"\
"You can use the profile editor to create a profile. "\
"With the profile editor you can change many settings "\
Expand All @@ -121,23 +121,29 @@ int SelectProfileForm::execForm()
"calls to regular and cell phones and send SMS messages.<br><br>")
#endif
+ tr("Choose what method you wish to use.</html>"),
tr("&Wizard"), tr("&Profile editor")
QMessageBox::NoButton, this);
QPushButton *wizardButton = mb.addButton(
tr("&Wizard"),
QMessageBox::AcceptRole);
QPushButton *editorButton = mb.addButton(
tr("&Profile editor"),
QMessageBox::AcceptRole);
#ifdef WITH_DIAMONDCARD
, tr("&Diamondcard")
QPushButton *diamondCardButton = mb.addButton(
tr("&Diamondcard"),
QMessageBox::AcceptRole);
#endif
);
mb.exec();

switch (newProfileMethod) {
case 0:
if (mb.clickedButton() == wizardButton) {
wizardProfile(true);
break;
case 1:
} else if (mb.clickedButton() == editorButton) {
newProfile(true);
break;
case 2:
#ifdef WITH_DIAMONDCARD
} else if (mb.clickedButton() == diamondCardButton) {
diamondcardProfile(true);
break;
default:
#endif
} else {
return QDialog::Rejected;
}

Expand Down

0 comments on commit a87fbaa

Please sign in to comment.