applets/swkbd: Properly handle button_text

I'm not sure why we decided to have a boolean here, but apparently that wasn't the correct behaviour. According to HW tests, the Software Keyboard simply displays the default text when the button text provided is empty (**not necessarily all zero**). For example, if you set a text for one of the buttons and leave others empty, the button you set will have your text, while others will have their default texts. Removed the boolean and updated frontend code to make it correct.
This commit is contained in:
zhupengfei 2020-05-31 09:40:12 +08:00
parent 7dc472a3a7
commit 190a053987
No known key found for this signature in database
GPG key ID: DD129E108BD09378
3 changed files with 18 additions and 38 deletions

View file

@ -34,33 +34,21 @@ QtKeyboardDialog::QtKeyboardDialog(QWidget* parent, QtKeyboard* keyboard_)
// Initialize buttons
switch (config.button_config) {
case ButtonConfig::Triple:
buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[2])
: tr(SWKBD_BUTTON_OKAY),
QDialogButtonBox::ButtonRole::AcceptRole);
buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[1])
: tr(SWKBD_BUTTON_FORGOT),
buttons->addButton(config.button_text[1].empty()
? tr(SWKBD_BUTTON_FORGOT)
: QString::fromStdString(config.button_text[1]),
QDialogButtonBox::ButtonRole::HelpRole);
buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[0])
: tr(SWKBD_BUTTON_CANCEL),
QDialogButtonBox::ButtonRole::RejectRole);
break;
// fallthrough
case ButtonConfig::Dual:
buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[2])
: tr(SWKBD_BUTTON_OKAY),
QDialogButtonBox::ButtonRole::AcceptRole);
buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[0])
: tr(SWKBD_BUTTON_CANCEL),
buttons->addButton(config.button_text[0].empty()
? tr(SWKBD_BUTTON_CANCEL)
: QString::fromStdString(config.button_text[0]),
QDialogButtonBox::ButtonRole::RejectRole);
break;
// fallthrough
case ButtonConfig::Single:
buttons->addButton(config.has_custom_button_text
? QString::fromStdString(config.button_text[2])
: tr(SWKBD_BUTTON_OKAY),
buttons->addButton(config.button_text[2].empty()
? tr(SWKBD_BUTTON_OKAY)
: QString::fromStdString(config.button_text[2]),
QDialogButtonBox::ButtonRole::AcceptRole);
break;
case ButtonConfig::None: