2013-12-11 20:50:10 -08:00
|
|
|
/******************************************************************************
|
|
|
|
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-12-17 12:56:58 -08:00
|
|
|
#include <wx/msgdlg.h>
|
2013-12-28 20:51:18 -08:00
|
|
|
#include "window-basic-settings.hpp"
|
2013-12-29 03:40:53 -08:00
|
|
|
using namespace std;
|
2013-12-10 20:14:20 -08:00
|
|
|
|
2013-12-11 20:50:10 -08:00
|
|
|
OBSBasicSettings::OBSBasicSettings(wxWindow *parent)
|
|
|
|
: OBSBasicSettingsBase(parent)
|
|
|
|
{
|
2013-12-12 20:47:42 -08:00
|
|
|
unique_ptr<BasicSettingsData> data(CreateBasicGeneralSettings(this));
|
|
|
|
settings = move(data);
|
2013-12-11 20:50:10 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicSettings::PageChanged(wxListbookEvent &event)
|
|
|
|
{
|
2013-12-14 20:30:16 -08:00
|
|
|
wxWindow *curPage = settingsList->GetCurrentPage();
|
|
|
|
if (!curPage)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int id = curPage->GetId();
|
|
|
|
|
|
|
|
BasicSettingsData *ptr = NULL;
|
|
|
|
|
|
|
|
switch (id) {
|
|
|
|
case ID_SETTINGS_GENERAL:
|
|
|
|
ptr = CreateBasicGeneralSettings(this);
|
|
|
|
break;
|
|
|
|
case ID_SETTINGS_VIDEO:
|
|
|
|
ptr = CreateBasicVideoSettings(this);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
settings = move(unique_ptr<BasicSettingsData>(ptr));
|
2013-12-11 20:50:10 -08:00
|
|
|
}
|
|
|
|
|
2013-12-17 12:56:58 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-12-11 20:50:10 -08:00
|
|
|
void OBSBasicSettings::PageChanging(wxListbookEvent &event)
|
|
|
|
{
|
2013-12-17 12:56:58 -08:00
|
|
|
if (!ConfirmChanges())
|
|
|
|
event.Veto();
|
2013-12-11 20:50:10 -08:00
|
|
|
}
|
2013-12-13 22:11:23 -08:00
|
|
|
|
|
|
|
void OBSBasicSettings::OnClose(wxCloseEvent &event)
|
|
|
|
{
|
2013-12-17 12:56:58 -08:00
|
|
|
if (!ConfirmChanges())
|
|
|
|
event.Veto();
|
2013-12-16 07:06:30 -08:00
|
|
|
else
|
2013-12-17 12:56:58 -08:00
|
|
|
EndModal(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicSettings::OKClicked(wxCommandEvent &event)
|
|
|
|
{
|
2013-12-17 17:19:24 -08:00
|
|
|
if (settings && settings->DataChanged())
|
2013-12-17 12:56:58 -08:00
|
|
|
settings->Apply();
|
|
|
|
|
|
|
|
EndModal(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicSettings::CancelClicked(wxCommandEvent &event)
|
|
|
|
{
|
2013-12-17 16:07:40 -08:00
|
|
|
EndModal(0);
|
2013-12-17 12:56:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicSettings::ApplyClicked(wxCommandEvent &event)
|
|
|
|
{
|
2013-12-17 17:19:24 -08:00
|
|
|
if (settings && settings->DataChanged())
|
2013-12-17 12:56:58 -08:00
|
|
|
settings->Apply();
|
2013-12-13 22:11:23 -08:00
|
|
|
}
|