MCPcopy Create free account
hub / github.com/Neverous/efibooteditor / fromQKey

Method fromQKey

src/efikeysequence.cpp:106–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106EFIKey EFIKey::fromQKey(int key, Qt::KeyboardModifiers modifiers, const QString &text, bool *success)
107{
108 if(success)
109 *success = false;
110
111 EFIKey value;
112 if(key != Qt::Key_unknown)
113 {
114 if(auto code = std::find_if(efi_scan_codes.begin(), efi_scan_codes.end(), [&](const auto &row)
115 { return std::get<Qt::Key>(row) == key; });
116 code != efi_scan_codes.end())
117 {
118 value.scan_code = std::get<Qt::Key>(*code);
119 if(success)
120 *success = true;
121
122 return value;
123 }
124 }
125
126 value.scan_code = Qt::Key_unknown;
127 if(modifiers)
128 {
129 auto stripped = QKeySequence{key}.toString();
130 if(stripped.length() != 1)
131 return {};
132
133 if(!(modifiers & Qt::ShiftModifier) && Qt::Key_A <= key && key <= Qt::Key_Z)
134 stripped = stripped.toLower();
135
136 value.unicode_char = stripped[0];
137 if(success)
138 *success = true;
139
140 return value;
141 }
142
143 if(text.length() != 1)
144 return {};
145
146 value.unicode_char = text[0];
147 if(success)
148 *success = true;
149
150 return value;
151}
152
153EFIKeySequence::EFIKeySequence(const EFIBoot::efi_boot_key_data &key_data, const std::vector<EFIBoot::efi_input_key> &keys_)
154{

Callers

nothing calls this directly

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected