mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 13:20:03 +00:00 
			
		
		
		
	Merge pull request #5381 from zhaowenlan1779/swkbd-another-fix
applets/swkbd: Properly handle button_text
This commit is contained in:
		
						commit
						e6ad0d390e
					
				
					 3 changed files with 18 additions and 38 deletions
				
			
		|  | @ -34,33 +34,21 @@ QtKeyboardDialog::QtKeyboardDialog(QWidget* parent, QtKeyboard* keyboard_) | ||||||
|     // Initialize buttons
 |     // Initialize buttons
 | ||||||
|     switch (config.button_config) { |     switch (config.button_config) { | ||||||
|     case ButtonConfig::Triple: |     case ButtonConfig::Triple: | ||||||
|         buttons->addButton(config.has_custom_button_text |         buttons->addButton(config.button_text[1].empty() | ||||||
|                                ? QString::fromStdString(config.button_text[2]) |                                ? tr(SWKBD_BUTTON_FORGOT) | ||||||
|                                : tr(SWKBD_BUTTON_OKAY), |                                : QString::fromStdString(config.button_text[1]), | ||||||
|                            QDialogButtonBox::ButtonRole::AcceptRole); |  | ||||||
|         buttons->addButton(config.has_custom_button_text |  | ||||||
|                                ? QString::fromStdString(config.button_text[1]) |  | ||||||
|                                : tr(SWKBD_BUTTON_FORGOT), |  | ||||||
|                            QDialogButtonBox::ButtonRole::HelpRole); |                            QDialogButtonBox::ButtonRole::HelpRole); | ||||||
|         buttons->addButton(config.has_custom_button_text |         [[fallthrough]]; | ||||||
|                                ? QString::fromStdString(config.button_text[0]) |  | ||||||
|                                : tr(SWKBD_BUTTON_CANCEL), |  | ||||||
|                            QDialogButtonBox::ButtonRole::RejectRole); |  | ||||||
|         break; |  | ||||||
|     case ButtonConfig::Dual: |     case ButtonConfig::Dual: | ||||||
|         buttons->addButton(config.has_custom_button_text |         buttons->addButton(config.button_text[0].empty() | ||||||
|                                ? QString::fromStdString(config.button_text[2]) |                                ? tr(SWKBD_BUTTON_CANCEL) | ||||||
|                                : tr(SWKBD_BUTTON_OKAY), |                                : QString::fromStdString(config.button_text[0]), | ||||||
|                            QDialogButtonBox::ButtonRole::AcceptRole); |  | ||||||
|         buttons->addButton(config.has_custom_button_text |  | ||||||
|                                ? QString::fromStdString(config.button_text[0]) |  | ||||||
|                                : tr(SWKBD_BUTTON_CANCEL), |  | ||||||
|                            QDialogButtonBox::ButtonRole::RejectRole); |                            QDialogButtonBox::ButtonRole::RejectRole); | ||||||
|         break; |         [[fallthrough]]; | ||||||
|     case ButtonConfig::Single: |     case ButtonConfig::Single: | ||||||
|         buttons->addButton(config.has_custom_button_text |         buttons->addButton(config.button_text[2].empty() | ||||||
|                                ? QString::fromStdString(config.button_text[2]) |                                ? tr(SWKBD_BUTTON_OKAY) | ||||||
|                                : tr(SWKBD_BUTTON_OKAY), |                                : QString::fromStdString(config.button_text[2]), | ||||||
|                            QDialogButtonBox::ButtonRole::AcceptRole); |                            QDialogButtonBox::ButtonRole::AcceptRole); | ||||||
|         break; |         break; | ||||||
|     case ButtonConfig::None: |     case ButtonConfig::None: | ||||||
|  |  | ||||||
|  | @ -43,7 +43,6 @@ struct KeyboardConfig { | ||||||
|     u16 max_text_length;       /// Maximum number of letters allowed if its a text input
 |     u16 max_text_length;       /// Maximum number of letters allowed if its a text input
 | ||||||
|     u16 max_digits;            /// Maximum number of numbers allowed if its a number input
 |     u16 max_digits;            /// Maximum number of numbers allowed if its a number input
 | ||||||
|     std::string hint_text;     /// Displayed in the field as a hint before
 |     std::string hint_text;     /// Displayed in the field as a hint before
 | ||||||
|     bool has_custom_button_text; /// If true, use the button_text instead
 |  | ||||||
|     std::vector<std::string> button_text; /// Contains the button text that the caller provides
 |     std::vector<std::string> button_text; /// Contains the button text that the caller provides
 | ||||||
|     struct Filters { |     struct Filters { | ||||||
|         bool prevent_digit;     /// Limit maximum digit count to max_digits
 |         bool prevent_digit;     /// Limit maximum digit count to max_digits
 | ||||||
|  |  | ||||||
|  | @ -194,16 +194,9 @@ Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig( | ||||||
|     frontend_config.max_text_length = config.max_text_length; |     frontend_config.max_text_length = config.max_text_length; | ||||||
|     frontend_config.max_digits = config.max_digits; |     frontend_config.max_digits = config.max_digits; | ||||||
|     frontend_config.hint_text = Common::UTF16BufferToUTF8(config.hint_text); |     frontend_config.hint_text = Common::UTF16BufferToUTF8(config.hint_text); | ||||||
|     frontend_config.has_custom_button_text = |  | ||||||
|         !std::all_of(config.button_text.begin(), config.button_text.end(), |  | ||||||
|                      [](std::array<u16, HLE::Applets::MAX_BUTTON_TEXT_LEN + 1> x) { |  | ||||||
|                          return std::all_of(x.begin(), x.end(), [](u16 x) { return x == 0; }); |  | ||||||
|                      }); |  | ||||||
|     if (frontend_config.has_custom_button_text) { |  | ||||||
|     for (const auto& text : config.button_text) { |     for (const auto& text : config.button_text) { | ||||||
|         frontend_config.button_text.push_back(Common::UTF16BufferToUTF8(text)); |         frontend_config.button_text.push_back(Common::UTF16BufferToUTF8(text)); | ||||||
|     } |     } | ||||||
|     } |  | ||||||
|     frontend_config.filters.prevent_digit = |     frontend_config.filters.prevent_digit = | ||||||
|         static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::Digits); |         static_cast<bool>(config.filter_flags & SoftwareKeyboardFilter::Digits); | ||||||
|     frontend_config.filters.prevent_at = |     frontend_config.filters.prevent_at = | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue