ladybird/Userland/Libraries/LibGUI/Shortcut.cpp
Linus Groh 57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00

47 lines
1.2 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, Geordie Hall <me@geordiehall.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <LibGUI/Shortcut.h>
namespace GUI {
DeprecatedString Shortcut::to_deprecated_string() const
{
Vector<DeprecatedString, 8> parts;
if (m_modifiers & Mod_Ctrl)
parts.append("Ctrl");
if (m_modifiers & Mod_Shift)
parts.append("Shift");
if (m_modifiers & Mod_Alt)
parts.append("Alt");
if (m_modifiers & Mod_AltGr)
parts.append("AltGr");
if (m_modifiers & Mod_Super)
parts.append("Super");
if (m_type == Type::Keyboard) {
if (auto* key_name = key_code_to_string(m_keyboard_key))
parts.append(key_name);
else
parts.append("(Invalid)");
} else {
if (m_mouse_button != MouseButton::None)
parts.append(DeprecatedString::formatted("Mouse {}", mouse_button_to_string(m_mouse_button)));
else
parts.append("(Invalid)");
}
StringBuilder builder;
builder.join('+', parts);
return builder.to_deprecated_string();
}
}