Skip to content

Commit

Permalink
Merge pull request #2738 from Montellese/fix_videoscreen_settings
Browse files Browse the repository at this point in the history
settings: move dependency handling into CSettingsManager and fix videoscreen settings
  • Loading branch information
Montellese committed May 23, 2013
2 parents 95b23de + c3be62c commit 9ac3e4c
Show file tree
Hide file tree
Showing 34 changed files with 420 additions and 296 deletions.
6 changes: 5 additions & 1 deletion system/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,11 @@
<constraints>
<options>screens</options>
</constraints>
<control type="spinner" format="string" delayed="true" />
<control type="spinner" format="string" delayed="true">
<dependencies>
<dependency type="update" setting="videoscreen.screenmode" />
</dependencies>
</control>
</setting>
<setting id="videoscreen.resolution" type="integer" label="169" help="36352">
<level>0</level>
Expand Down
3 changes: 0 additions & 3 deletions xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,7 @@ bool CApplication::OnEvent(XBMC_Event& newEvent)
// when fullscreen, remain fullscreen and resize to the dimensions of the new screen
RESOLUTION newRes = (RESOLUTION) g_Windowing.DesktopResolution(g_Windowing.GetCurrentScreen());
if (newRes != g_graphicsContext.GetVideoResolution())
{
CDisplaySettings::Get().SetCurrentResolution(newRes, true);
g_graphicsContext.SetVideoResolution(newRes);
}
}
else
#endif
Expand Down
1 change: 1 addition & 0 deletions xbmc/GUIPassword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "profiles/dialogs/GUIDialogProfileSettings.h"
#include "Util.h"
#include "settings/MediaSourceSettings.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "guilib/GUIWindowManager.h"
#include "FileItem.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/LangInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "guilib/LocalizeStrings.h"
#include "pvr/PVRManager.h"
#include "settings/AdvancedSettings.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "utils/CharsetConverter.h"
#include "utils/log.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/addons/Skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "filesystem/File.h"
#include "filesystem/SpecialProtocol.h"
#include "guilib/WindowIDs.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "utils/URIUtils.h"
#include "utils/log.h"
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/AudioEngine/AEFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void CAEFactory::SettingOptionsAudioDevicesFillerGeneral(const CSetting *setting
firstDevice = sink->second;

#if defined(TARGET_DARWIN)
list.push_back(StringSettingOption(sink->first, sink->first));
list.push_back(std::make_pair(sink->first, sink->first));
#else
list.push_back(std::make_pair(sink->first, sink->second));
#endif
Expand Down
1 change: 1 addition & 0 deletions xbmc/epg/EpgContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Application.h"
#include "threads/SingleLock.h"
#include "settings/AdvancedSettings.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "dialogs/GUIDialogExtendedProgressBar.h"
#include "dialogs/GUIDialogProgress.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/guilib/GUIAudioManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "GUIAudioManager.h"
#include "Key.h"
#include "input/ButtonTranslator.h"
#include "settings/Setting.h"
#include "threads/SingleLock.h"
#include "utils/URIUtils.h"
#include "utils/XBMCTinyXML.h"
Expand Down
2 changes: 1 addition & 1 deletion xbmc/guilib/GraphicContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ApplicationMessenger.h"
#include "settings/AdvancedSettings.h"
#include "settings/DisplaySettings.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "cores/VideoRenderers/RenderManager.h"
#include "windowing/WindowingFactory.h"
Expand Down Expand Up @@ -857,7 +858,6 @@ bool CGraphicContext::ToggleFullScreenRoot ()
#endif
}

SetVideoResolution(newRes);
CDisplaySettings::Get().SetCurrentResolution(uiRes, true);

return m_bFullScreenRoot;
Expand Down
1 change: 1 addition & 0 deletions xbmc/input/SDLJoystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ButtonTranslator.h"
#include "peripherals/devices/PeripheralImon.h"
#include "settings/AdvancedSettings.h"
#include "settings/Setting.h"
#include "utils/log.h"

#include <math.h>
Expand Down
1 change: 0 additions & 1 deletion xbmc/interfaces/Builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ int CBuiltins::Execute(const CStdString& execString)
if (g_graphicsContext.IsValidResolution(res))
{
CDisplaySettings::Get().SetCurrentResolution(res, true);
g_graphicsContext.SetVideoResolution(res);
g_application.ReloadSkin();
}
}
Expand Down
1 change: 1 addition & 0 deletions xbmc/linux/LinuxTimezone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "Util.h"
#include "XBDateTime.h"
#include "settings/Setting.h"
#include "settings/Settings.h"

using namespace std;
Expand Down
1 change: 1 addition & 0 deletions xbmc/network/NetworkServices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#endif

#include "settings/AdvancedSettings.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "utils/log.h"
#include "utils/RssManager.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/osx/XBMCHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "dialogs/GUIDialogYesNo.h"
#include "utils/log.h"
#include "system.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "utils/SystemInfo.h"

Expand Down
2 changes: 1 addition & 1 deletion xbmc/peripherals/dialogs/GUIDialogPeripheralSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void CGUIDialogPeripheralSettings::CreateSettings()
{
m_intTextSettings.insert(make_pair(CStdString(intSetting->GetId()), intSetting->GetValue()));
vector<pair<int, int> > entries;
SettingOptions::const_iterator entriesItr = intSetting->GetOptions().begin();
StaticIntegerSettingOptions::const_iterator entriesItr = intSetting->GetOptions().begin();
while (entriesItr != intSetting->GetOptions().end())
{
entries.push_back(make_pair(entriesItr->first, entriesItr->second));
Expand Down
1 change: 1 addition & 0 deletions xbmc/powermanagement/PowerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Application.h"
#include "cores/AudioEngine/AEFactory.h"
#include "input/KeyboardStat.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "windowing/WindowingFactory.h"
#include "utils/log.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/pvr/PVRManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "music/tags/MusicInfoTag.h"
#include "settings/AdvancedSettings.h"
#include "settings/MediaSettings.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "threads/SingleLock.h"
#include "windows/GUIWindowPVR.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/pvr/channels/PVRChannelGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/

#include "settings/AdvancedSettings.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "guilib/GUIWindowManager.h"
#include "dialogs/GUIDialogYesNo.h"
Expand Down
1 change: 1 addition & 0 deletions xbmc/settings/AdvancedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "utils/LangCodeExpander.h"
#include "LangInfo.h"
#include "profiles/ProfilesManager.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "utils/StringUtils.h"
#include "utils/SystemInfo.h"
Expand Down
52 changes: 37 additions & 15 deletions xbmc/settings/DisplaySettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "guilib/gui3d.h"
#include "guilib/LocalizeStrings.h"
#include "settings/AdvancedSettings.h"
#include "settings/Setting.h"
#include "settings/Settings.h"
#include "threads/SingleLock.h"
#include "utils/log.h"
Expand Down Expand Up @@ -204,6 +205,7 @@ bool CDisplaySettings::OnSettingChanging(const CSetting *setting)
if (m_ignoreSettingChanging.find(make_pair(settingId, true)) == m_ignoreSettingChanging.end())
{
RESOLUTION newRes = RES_DESKTOP;
DisplayMode oldDisplayMode = GetCurrentDisplayMode();
if (settingId == "videoscreen.resolution")
newRes = (RESOLUTION)((CSettingInt*)setting)->GetValue();
else if (settingId == "videoscreen.screen")
Expand All @@ -221,28 +223,30 @@ bool CDisplaySettings::OnSettingChanging(const CSetting *setting)
SetCurrentResolution(newRes, save);
g_graphicsContext.SetVideoResolution(newRes);

// check if this setting is temporarily blocked from showing the dialog
if (m_ignoreSettingChanging.find(make_pair(settingId, false)) == m_ignoreSettingChanging.end())
// check if the old or the new resolution was/is windowed
// in which case we don't show any prompt to the user
if (newRes != RES_WINDOW && oldDisplayMode != DM_WINDOWED)
{
bool cancelled = false;
if (!CGUIDialogYesNo::ShowAndGetInput(13110, 13111, 20022, 20022, -1, -1, cancelled, 10000))
// check if this setting is temporarily blocked from showing the dialog
if (newRes != RES_WINDOW &&
m_ignoreSettingChanging.find(make_pair(settingId, false)) == m_ignoreSettingChanging.end())
{
// we need to ignore the next OnSettingChanging() call for
// the same setting which is executed to broadcast that
// changing the setting has failed
m_ignoreSettingChanging.insert(make_pair(settingId, false));
return false;
bool cancelled = false;
if (!CGUIDialogYesNo::ShowAndGetInput(13110, 13111, 20022, 20022, -1, -1, cancelled, 10000))
{
// we need to ignore the next OnSettingChanging() call for
// the same setting which is executed to broadcast that
// changing the setting has failed
m_ignoreSettingChanging.insert(make_pair(settingId, false));
return false;
}
}
else
m_ignoreSettingChanging.erase(make_pair(settingId, false));
}
else
m_ignoreSettingChanging.erase(make_pair(settingId, false));

if (settingId == "videoscreen.screen")
{
m_ignoreSettingChanging.insert(make_pair("videoscreen.resolution", true));
if (CSettings::Get().GetSetting("videoscreen.screenmode")->IsVisible())
m_ignoreSettingChanging.insert(make_pair("videoscreen.screenmode", true));
}
}
else
m_ignoreSettingChanging.erase(make_pair(settingId, true));
Expand Down Expand Up @@ -412,6 +416,14 @@ void CDisplaySettings::UpdateCalibrations()
}
}

DisplayMode CDisplaySettings::GetCurrentDisplayMode() const
{
if (GetCurrentResolution() == RES_WINDOW)
return DM_WINDOWED;

return GetCurrentResolutionInfo().iScreen;
}

RESOLUTION CDisplaySettings::GetResolutionFromString(const std::string &strResolution)
{
if (strResolution == "DESKTOP")
Expand Down Expand Up @@ -570,6 +582,16 @@ void CDisplaySettings::SettingOptionsScreensFiller(const CSetting *setting, std:
int screen = CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP + idx).iScreen;
list.push_back(make_pair(StringUtils::Format(g_localizeStrings.Get(241), screen + 1), screen));
}

RESOLUTION res = CDisplaySettings::Get().GetDisplayResolution();

if (res == RES_WINDOW)
current = DM_WINDOWED;
else
{
RESOLUTION_INFO resInfo = CDisplaySettings::Get().GetResolutionInfo(res);
current = resInfo.iScreen;
}
}

void CDisplaySettings::SettingOptionsVerticalSyncsFiller(const CSetting *setting, std::vector< std::pair<std::string, int> > &list, int &current)
Expand Down
2 changes: 2 additions & 0 deletions xbmc/settings/DisplaySettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class CDisplaySettings : public ISettingCallback, public ISubSettings,
CDisplaySettings const& operator=(CDisplaySettings const&);
virtual ~CDisplaySettings();

DisplayMode GetCurrentDisplayMode() const;

static RESOLUTION GetResolutionFromString(const std::string &strResolution);
static std::string GetStringFromResolution(RESOLUTION resolution, float refreshrate = 0.0f);
static RESOLUTION GetResolutionForScreen();
Expand Down
11 changes: 11 additions & 0 deletions xbmc/settings/ISettingCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,15 @@ class ISettingCallback
\return True if the setting has been successfully updated otherwise false
*/
virtual bool OnSettingUpdate(CSetting* &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode) { return false; }

/*!
\brief The given property of the given setting has changed
This callback is triggered when a property (e.g. enabled or the list of
dynamic options) has changed.
\param setting The setting which has a changed property
\param propertyName The string representation of the changed property
*/
virtual void OnSettingPropertyChanged(const CSetting *setting, const char *propertyName) { }
};
Loading

0 comments on commit 9ac3e4c

Please sign in to comment.