From b5bbe741204885614de29499ca4c13e4775abb69 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 17 Dec 2013 13:56:58 -0700 Subject: [PATCH] add in code for OK/Cancel/Apply buttons in basic settings window --- build/data/obs-studio/locale/en.txt | 3 +- obs/settings-basic-video.cpp | 2 +- obs/window-settings-basic.cpp | 47 +++++++++++++++++++++++++++-- obs/window-settings-basic.hpp | 6 ++++ 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/build/data/obs-studio/locale/en.txt b/build/data/obs-studio/locale/en.txt index 4187c2700..511c55286 100644 --- a/build/data/obs-studio/locale/en.txt +++ b/build/data/obs-studio/locale/en.txt @@ -34,7 +34,7 @@ Settings.Outputs="Outputs" Settings.Video="Video" Settings.Video.Adapter="Video Adapter:" Settings.Video.BaseRes="Base Resolution:" -Settings.Video.DownscaleRes="Output Resolution:" +Settings.Video.OutputRes="Output Resolution:" Settings.Video.DownscaleFilter="Downscale Filter:" Settings.Video.DisableAeroWindows="Disable Aero (Windows only)" Settings.Video.FPS="FPS:" @@ -44,6 +44,7 @@ Settings.VIdeo.FPS.Fraction="Frame Interval (fraction)" Settings.Video.FPS.Nanoseconds="Frame Interval (nanoseconds)" Settings.Video.FPS.Numerator="Numerator:" Settings.Video.FPS.Denominator="Denominator:" +Settings.Video.Renderer="Renderer:" Settings.Video.InvalidResolution="Invalid base resolution value. Must be [width]x[height] (i.e. 1920x1080)" Settings.Audio="Audio" diff --git a/obs/settings-basic-video.cpp b/obs/settings-basic-video.cpp index 9a760b928..fa99be1e1 100644 --- a/obs/settings-basic-video.cpp +++ b/obs/settings-basic-video.cpp @@ -344,7 +344,6 @@ void BasicVideoData::SaveFPSData() } config_set_string(GetGlobalConfig(), "Video", "FPSType", type); - SaveOther(); SaveFPSCommon(); SaveFPSInteger(); SaveFPSFraction(); @@ -396,6 +395,7 @@ void BasicVideoData::Apply() config_set_uint(GetGlobalConfig(), "Video", "OutputCY", cy); } + SaveOther(); SaveFPSData(); } diff --git a/obs/window-settings-basic.cpp b/obs/window-settings-basic.cpp index 1a7c9035e..74b9145d2 100644 --- a/obs/window-settings-basic.cpp +++ b/obs/window-settings-basic.cpp @@ -15,6 +15,7 @@ along with this program. If not, see . ******************************************************************************/ +#include #include "window-settings-basic.hpp" OBSBasicSettings::OBSBasicSettings(wxWindow *parent) @@ -46,14 +47,54 @@ void OBSBasicSettings::PageChanged(wxListbookEvent &event) settings = move(unique_ptr(ptr)); } +bool OBSBasicSettings::ConfirmChanges() +{ + if (settings && settings->DataChanged()) { + int confirm = wxMessageBox(WXStr("Settings.Confirm"), + WXStr("Settings.ConfirmTitle"), + wxYES_NO | wxCANCEL); + + if (confirm == wxCANCEL) { + return false; + } else if (confirm == wxYES) { + settings->Apply(); + return true; + } + } + + return true; +} + void OBSBasicSettings::PageChanging(wxListbookEvent &event) { + if (!ConfirmChanges()) + event.Veto(); } void OBSBasicSettings::OnClose(wxCloseEvent &event) { - if(IsModal()) - EndModal(0); + if (!ConfirmChanges()) + event.Veto(); else - Destroy(); + EndModal(0); +} + +void OBSBasicSettings::OKClicked(wxCommandEvent &event) +{ + if (settings) + settings->Apply(); + + EndModal(0); +} + +void OBSBasicSettings::CancelClicked(wxCommandEvent &event) +{ + if (ConfirmChanges()) + EndModal(0); +} + +void OBSBasicSettings::ApplyClicked(wxCommandEvent &event) +{ + if (settings) + settings->Apply(); } diff --git a/obs/window-settings-basic.hpp b/obs/window-settings-basic.hpp index 1de35722a..d523473d5 100644 --- a/obs/window-settings-basic.hpp +++ b/obs/window-settings-basic.hpp @@ -31,6 +31,12 @@ protected: virtual void PageChanging(wxListbookEvent &event); virtual void OnClose(wxCloseEvent &event); + bool ConfirmChanges(); + + virtual void OKClicked(wxCommandEvent &event); + virtual void CancelClicked(wxCommandEvent &event); + virtual void ApplyClicked(wxCommandEvent &event); + public: OBSBasicSettings(wxWindow *parent); };