Change Windows Modifier Name to Win for Windows and Super for Linux/BSD

This commit is contained in:
Gabriel Rauter 2016-03-01 23:52:36 +01:00
parent e22332144a
commit cb92b781eb
4 changed files with 15 additions and 6 deletions

View File

@ -15,7 +15,7 @@
<check text="Alt" id="alt" />
<check text="Shift" id="shift" />
<check text="Space" id="space" />
<check text="Windows" id="windows" />
<check text="Win" id="win" />
</hbox>
<label text="Assigned to:" />

View File

@ -95,7 +95,7 @@ SelectAccelerator::SelectAccelerator(const ui::Accelerator& accel, KeyContext ke
ctrl()->Click.connect(base::Bind<void>(&SelectAccelerator::onModifierChange, this, kKeyCtrlModifier, ctrl()));
shift()->Click.connect(base::Bind<void>(&SelectAccelerator::onModifierChange, this, kKeyShiftModifier, shift()));
space()->Click.connect(base::Bind<void>(&SelectAccelerator::onModifierChange, this, kKeySpaceModifier, space()));
windows()->Click.connect(base::Bind<void>(&SelectAccelerator::onModifierChange, this, kKeyWinModifier, windows()));
win()->Click.connect(base::Bind<void>(&SelectAccelerator::onModifierChange, this, kKeyWinModifier, win()));
m_keyField->AccelChange.connect(&SelectAccelerator::onAccelChange, this);
clearButton()->Click.connect(base::Bind<void>(&SelectAccelerator::onClear, this));
@ -157,10 +157,13 @@ void SelectAccelerator::updateModifiers()
shift()->setSelected(m_accel.modifiers() & kKeyShiftModifier ? true: false);
space()->setSelected(m_accel.modifiers() & kKeySpaceModifier ? true: false);
#if __APPLE__
windows()->setVisible(false);
win()->setVisible(false);
cmd()->setSelected(m_accel.modifiers() & kKeyCmdModifier ? true: false);
#else
windows()->setSelected(m_accel.modifiers() & kKeyWinModifier ? true: false);
#if __linux__
win()->setText(winKeyName);
#endif
win()->setSelected(m_accel.modifiers() & kKeyWinModifier ? true: false);
cmd()->setVisible(false);
#endif
}

View File

@ -91,7 +91,7 @@ Accelerator::Accelerator(const std::string& str)
else if (tok == "cmd") {
m_modifiers = (KeyModifiers)((int)m_modifiers | (int)kKeyCmdModifier);
}
else if (tok == "windows") {
else if (tok == base::string_to_lower(winKeyName)) {
m_modifiers = (KeyModifiers)((int)m_modifiers | (int)kKeyWinModifier);
}
@ -352,7 +352,7 @@ std::string Accelerator::toString() const
if (m_modifiers & kKeyAltModifier) buf += "Alt+";
if (m_modifiers & kKeyShiftModifier) buf += "Shift+";
if (m_modifiers & kKeySpaceModifier) buf += "Space+";
if (m_modifiers & kKeyWinModifier) buf += "Windows+";
if (m_modifiers & kKeyWinModifier) { buf += winKeyName; buf += "+"; }
// Key
if (m_unicodeChar) {

View File

@ -15,6 +15,12 @@
namespace ui {
#ifdef _WIN32
const std::string winKeyName = "Win";
#else
const std::string winKeyName = "Super";
#endif
class Accelerator {
public:
Accelerator();