History

Add an option to choose which screen to use for full screen mode

Dale Glass committed 3 years ago

Commit 88849881 parent 4fff6344 files · +200 −17Browse files

Showing the changes to interface/src/scripting/RenderScriptingInterface.cpp (1 of 4 files). Show all

Unified · Split

interface/src/scripting/RenderScriptingInterface.cpp+46−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
8#include "RenderScriptingInterface.h"8#include "RenderScriptingInterface.h"
9 9
10#include "LightingModel.h"10#include "LightingModel.h"
11#include <QScreen>
11 12
12 13
13RenderScriptingInterface* RenderScriptingInterface::getInstance() {14RenderScriptingInterface* RenderScriptingInterface::getInstance() {
@@ -31,7 +32,17 @@ void RenderScriptingInterface::loadSettings() { · 17 unmodified lines
31 //_antialiasingMode = (_antialiasingModeSetting.get());32 //_antialiasingMode = (_antialiasingModeSetting.get());
32 _antialiasingMode = static_cast<AntialiasingConfig::Mode>(_antialiasingModeSetting.get());33 _antialiasingMode = static_cast<AntialiasingConfig::Mode>(_antialiasingModeSetting.get());
33 _viewportResolutionScale = (_viewportResolutionScaleSetting.get());34 _viewportResolutionScale = (_viewportResolutionScaleSetting.get());
35 _fullScreenScreen = (_fullScreenScreenSetting.get());
34 });36 });
37
38 // If full screen screen is not initialized, or set to an invalid value,
39 // set to the first screen.
40 auto screens = getScreens();
41 if (std::find(screens.begin(), screens.end(), _fullScreenScreen) == screens.end()) {
42 setFullScreenScreen(screens.first());
43 }
44
45
35 forceRenderMethod((RenderMethod)_renderMethod);46 forceRenderMethod((RenderMethod)_renderMethod);
36 forceShadowsEnabled(_shadowsEnabled);47 forceShadowsEnabled(_shadowsEnabled);
37 forceAmbientOcclusionEnabled(_ambientOcclusionEnabled);48 forceAmbientOcclusionEnabled(_ambientOcclusionEnabled);
@@ -193,6 +204,41 @@ void RenderScriptingInterface::setViewportResolutionScale(float scale) { · 155 unmodified lines
193 }204 }
194}205}
195 206
207QStringList RenderScriptingInterface::getScreens() const {
208 QStringList screens;
209
210 for(QScreen *screen : qApp->screens()) {
211 screens << screen->model();
212 }
213
214 return screens;
215}
216
217bool RenderScriptingInterface::setFullScreenScreen(QString name) {
218 auto screens = getScreens();
219
220 if (std::find(screens.begin(), screens.end(), name) == screens.end()) {
221 // Screens can come and go and don't have a stable opaque ID, so we
222 // go by model here. For multiple screens with the same model we get names
223 // that include a serial number, so it works.
224 return false;
225 }
226
227 _renderSettingLock.withWriteLock([&] {
228 _fullScreenScreen = name;
229 _fullScreenScreenSetting.set(name);
230 });
231
232 emit settingsChanged();
233
234 return true;
235}
236
237QString RenderScriptingInterface::getFullScreenScreen() const {
238 return _fullScreenScreen;
239}
240
241
196void RenderScriptingInterface::forceViewportResolutionScale(float scale) {242void RenderScriptingInterface::forceViewportResolutionScale(float scale) {
197 // just not negative values or zero243 // just not negative values or zero
198 if (scale <= 0.f) {244 if (scale <= 0.f) {