std::wstring Hotkeys::ActionString(HotkeyInfo &selection) { HotkeyInfo::HotkeyActions action = (HotkeyInfo::HotkeyActions) selection.action; if (action < 0) { /* Selection has no action */ return L""; } /* Set to the default string (action with no parameters) */ std::wstring actionStr = _translator->Translate( HotkeyInfo::ActionNames[action]); if (selection.HasArgs() == false) { /* We're done */ return actionStr; } if (selection.args[0] == L"") { /* Blank arg = no arg. */ return actionStr; } switch ((HotkeyInfo::HotkeyActions) selection.action) { case HotkeyInfo::IncreaseVolume: case HotkeyInfo::DecreaseVolume: case HotkeyInfo::SetVolume: actionStr = _translator->TranslateAndReplace( VolumeActionString(selection), selection.args[0]); break; case HotkeyInfo::EjectDrive: actionStr = _translator->Replace(_ejectActionStr, selection.args[0]); break; case HotkeyInfo::MediaKey: actionStr = _translator->Replace(_mediaActionStr, _translator->Translate(selection.args[0])); break; case HotkeyInfo::VirtualKey: actionStr = _translator->Replace(_vkActionStr, selection.args[0]); break; case HotkeyInfo::Run: actionStr = _translator->Replace(_runActionStr, selection.args[0]); break; } return actionStr; }
void ProcessHotkeys(HotkeyInfo &hki) { switch (hki.action) { case HotkeyInfo::IncreaseVolume: case HotkeyInfo::DecreaseVolume: case HotkeyInfo::SetVolume: case HotkeyInfo::Mute: case HotkeyInfo::VolumeSlider: if (vOSD) { vOSD->ProcessHotkeys(hki); } break; case HotkeyInfo::EjectDrive: case HotkeyInfo::EjectLatestDrive: if (eOSD) { eOSD->ProcessHotkeys(hki); } break; case HotkeyInfo::MediaKey: MediaKeys::ProcessHotkeys(hki); break; case HotkeyInfo::Run: if (hki.HasArgs()) { ShellExecute(NULL, L"open", hki.args[0].c_str(), NULL, NULL, SW_SHOWNORMAL); } break; case HotkeyInfo::Settings: ShellExecute(NULL, L"open", Settings::SettingsApp().c_str(), NULL, NULL, SW_SHOWNORMAL); break; case HotkeyInfo::Exit: SendMessage(mainWnd, WM_CLOSE, NULL, NULL); break; } }
void Hotkeys::VolumeArgControlStates(HotkeyInfo &selection) { _argLabel->Text(_amountVolArgStr); _argCheck->Text(_amountVolArgStr); _argCheck->Checked(selection.HasArgs()); _argEdit->Enabled(_argCheck->Checked()); _argEdit->Width(_argEdit->EmSize() * 6); _argEdit->PlaceRightOf(*_argCheck); _argEdit->X(_action->X()); _argCombo->Enabled(_argCheck->Checked()); _argCombo->AddItem(_unitsVolArgStr); _argCombo->AddItem(_percentVolArgStr); _argCombo->Select(0); _argCombo->PlaceRightOf(*_argEdit); _argCombo->Width(_action->Width() - (_argCombo->X() - _action->X())); if (selection.HasArg(0)) { _argEdit->Text(selection.args[0]); } if (selection.HasArg(1)) { _argCombo->Select(selection.ArgToInt(1)); } }
void Hotkeys::LoadAction(int index, HotkeyInfo &selection) { int action = selection.action; if (action < 0) { /* Selection has no action */ return; } /* First, set the action description */ _keyList->ItemText(index, 1, ActionString(selection)); /* Default visiblities */ bool showLabel = false; bool showCheck = false; bool showCombo = false; bool showEdit = false; bool showButton = false; switch ((HotkeyInfo::HotkeyActions) action) { case HotkeyInfo::IncreaseVolume: case HotkeyInfo::DecreaseVolume: VolumeArgControlStates(selection); showCheck = true; showCombo = true; showEdit = true; break; case HotkeyInfo::SetVolume: VolumeArgControlStates(selection); showLabel = true; showCombo = true; showEdit = true; break; case HotkeyInfo::EjectDrive: _argLabel->Text(_driveArgStr); _argCombo->Width(_argCombo->EmSize() * 6); for (int i = 0; i < 26; ++i) { wchar_t ch = (wchar_t) i + 65; _argCombo->AddItem(std::wstring(1, ch)); } if (selection.HasArgs()) { _argCombo->Select(selection.args[0]); } showLabel = true; showCombo = true; break; case HotkeyInfo::MediaKey: _argLabel->Text(_keyArgStr); for (std::wstring keys : HotkeyInfo::MediaKeyNames) { _argCombo->AddItem(_translator->Translate(keys)); } if (selection.HasArgs()) { _argCombo->Select(_translator->Translate(selection.args[0])); } showLabel = true; showCombo = true; break; case HotkeyInfo::VirtualKey: _argLabel->Text(_vkArgStr); if (selection.HasArgs()) { _argEdit->Text(selection.args[0]); } showLabel = true; showEdit = true; break; case HotkeyInfo::Run: _argLabel->Text(_pathArgStr); _argButton->Text(L"…"); _argButton->Width(_argButton->EmSize() * 3); _argEdit->PlaceRightOf(*_argLabel); _argEdit->X(_action->X()); _argEdit->Width(_keys->Width() - _argButton->Width() - _argEdit->EmSize()); _argButton->PlaceRightOf(*_argEdit); if (selection.HasArgs()) { _argEdit->Text(selection.args[0]); } showLabel = true; showEdit = true; showButton = true; break; } /* Update control visibility */ _argLabel->Visible(showLabel); _argCheck->Visible(showCheck); _argCombo->Visible(showCombo); _argEdit->Visible(showEdit); _argButton->Visible(showButton); if (_argCheck->Visible() == false) { /* Controls are only disabled for optional arguments (check box). * If _argCheck isn't visible, make sure everything is enabled. */ _argEdit->Enable(); _argCombo->Enable(); _argButton->Enable(); } }