Skip to content

Commit

Permalink
[Fix] Global shortcuts were not working in settings dialog.
Browse files Browse the repository at this point in the history
git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@21765 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Sep 27, 2024
1 parent 6b51cc0 commit 3c9214e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 31 deletions.
2 changes: 1 addition & 1 deletion mptrack/DialogBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BOOL DialogBase::PreTranslateMessage(MSG *pMsg)
}


bool DialogBase::HandleGlobalKeyMessage(const MSG &msg) const
bool DialogBase::HandleGlobalKeyMessage(const MSG &msg)
{
// We handle keypresses before Windows has a chance to handle them (for alt etc..)
if(msg.message == WM_KEYDOWN || msg.message == WM_KEYUP || msg.message == WM_SYSKEYUP || msg.message == WM_SYSKEYDOWN)
Expand Down
3 changes: 1 addition & 2 deletions mptrack/DialogBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class DialogBase : public CDialog

BOOL PreTranslateMessage(MSG *pMsg) override;

protected:
bool HandleGlobalKeyMessage(const MSG &msg) const;
static bool HandleGlobalKeyMessage(const MSG &msg);
};

OPENMPT_NAMESPACE_END
76 changes: 48 additions & 28 deletions mptrack/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1949,49 +1949,69 @@ void CMainFrame::RefreshDlsBanks()
// CMainFrame message handlers


class CPropertySheetMPT : public CPropertySheet
{
using CPropertySheet::CPropertySheet;

BOOL PreTranslateMessage(MSG *pMsg) override
{
if(pMsg && DialogBase::HandleGlobalKeyMessage(*pMsg))
return TRUE;

return CPropertySheet::PreTranslateMessage(pMsg);
}
};


void CMainFrame::OnViewOptions()
{
if (m_bOptionsLocked)
return;

CPropertySheet dlg(_T("OpenMPT Setup"), this, m_nLastOptionsPage);
mpt::heap_value<COptionsGeneral> general;
mpt::heap_value<COptionsSoundcard> sounddlg(TrackerSettings::Instance().m_SoundDeviceIdentifier);
mpt::heap_value<COptionsSampleEditor> smpeditor;
mpt::heap_value<COptionsKeyboard> keyboard;
mpt::heap_value<COptionsColors> colors;
mpt::heap_value<COptionsMixer> mixerdlg;
mpt::heap_value<CMidiSetupDlg> mididlg(TrackerSettings::Instance().m_dwMidiSetup, TrackerSettings::Instance().GetCurrentMIDIDevice());
mpt::heap_value<PathConfigDlg> pathsdlg;
CPropertySheetMPT dlg(_T("OpenMPT Setup"), this, m_nLastOptionsPage);
struct Pages
{
COptionsGeneral general;
COptionsSoundcard sounddlg{TrackerSettings::Instance().m_SoundDeviceIdentifier};
COptionsSampleEditor smpeditor;
COptionsKeyboard keyboard;
COptionsColors colors;
COptionsMixer mixerdlg;
#if !defined(NO_REVERB) || !defined(NO_DSP) || !defined(NO_EQ) || !defined(NO_AGC)
COptionsPlayer dspdlg;
#endif
CMidiSetupDlg mididlg{TrackerSettings::Instance().m_dwMidiSetup, TrackerSettings::Instance().GetCurrentMIDIDevice()};
PathConfigDlg pathsdlg;
#if defined(MPT_ENABLE_UPDATE)
mpt::heap_value<CUpdateSetupDlg> updatedlg;
#endif // MPT_ENABLE_UPDATE
mpt::heap_value<COptionsAdvanced> advanced;
mpt::heap_value<COptionsWine> winedlg;
dlg.AddPage(&*general);
dlg.AddPage(&*sounddlg);
dlg.AddPage(&*mixerdlg);
CUpdateSetupDlg updatedlg;
#endif // MPT_ENABLE_UPDATE
COptionsAdvanced advanced;
COptionsWine winedlg;
};
mpt::heap_value<Pages> pages;
dlg.AddPage(&pages->general);
dlg.AddPage(&pages->sounddlg);
dlg.AddPage(&pages->mixerdlg);
#if !defined(NO_REVERB) || !defined(NO_DSP) || !defined(NO_EQ) || !defined(NO_AGC)
mpt::heap_value<COptionsPlayer> dspdlg;
dlg.AddPage(&*dspdlg);
dlg.AddPage(&pages->dspdlg);
#endif
dlg.AddPage(&*smpeditor);
dlg.AddPage(&*keyboard);
dlg.AddPage(&*colors);
dlg.AddPage(&*mididlg);
dlg.AddPage(&*pathsdlg);
dlg.AddPage(&pages->smpeditor);
dlg.AddPage(&pages->keyboard);
dlg.AddPage(&pages->colors);
dlg.AddPage(&pages->mididlg);
dlg.AddPage(&pages->pathsdlg);
#if defined(MPT_ENABLE_UPDATE)
dlg.AddPage(&*updatedlg);
dlg.AddPage(&pages->updatedlg);
#endif // MPT_ENABLE_UPDATE
dlg.AddPage(&*advanced);
dlg.AddPage(&pages->advanced);
if(mpt::OS::Windows::IsWine())
{
dlg.AddPage(&*winedlg);
dlg.AddPage(&pages->winedlg);
}
m_bOptionsLocked = true;
m_SoundCardOptionsDialog = &*sounddlg;
m_SoundCardOptionsDialog = &pages->sounddlg;
#if defined(MPT_ENABLE_UPDATE)
m_UpdateOptionsDialog = &*updatedlg;
m_UpdateOptionsDialog = &pages->updatedlg;
#endif // MPT_ENABLE_UPDATE
dlg.DoModal();
m_SoundCardOptionsDialog = nullptr;
Expand Down

0 comments on commit 3c9214e

Please sign in to comment.