mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 12:15:30 +02:00
Move screen naming to UI library, and improve naming
This commit is contained in:
parent
de36c716c8
commit
1cf3756c84
5 changed files with 86 additions and 10 deletions
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "LightingModel.h"
|
#include "LightingModel.h"
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include "ScreenName.h"
|
||||||
|
|
||||||
|
|
||||||
RenderScriptingInterface* RenderScriptingInterface::getInstance() {
|
RenderScriptingInterface* RenderScriptingInterface::getInstance() {
|
||||||
|
@ -24,6 +25,7 @@ RenderScriptingInterface::RenderScriptingInterface() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderScriptingInterface::loadSettings() {
|
void RenderScriptingInterface::loadSettings() {
|
||||||
_renderSettingLock.withReadLock([&] {
|
_renderSettingLock.withReadLock([&] {
|
||||||
_renderMethod = (_renderMethodSetting.get());
|
_renderMethod = (_renderMethodSetting.get());
|
||||||
|
@ -208,7 +210,7 @@ QStringList RenderScriptingInterface::getScreens() const {
|
||||||
QStringList screens;
|
QStringList screens;
|
||||||
|
|
||||||
for(QScreen *screen : qApp->screens()) {
|
for(QScreen *screen : qApp->screens()) {
|
||||||
screens << getNameForScreen(screen);
|
screens << ScreenName::getNameForScreen(screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
return screens;
|
return screens;
|
||||||
|
|
|
@ -74,9 +74,6 @@ public:
|
||||||
// Need to be called on start up to re-initialize the runtime to the saved setting states
|
// Need to be called on start up to re-initialize the runtime to the saved setting states
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
static QString getNameForScreen(QScreen *screen) {
|
|
||||||
return screen->model() + " (" + screen->name() + ", " + screen->serialNumber() + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/*@jsdoc
|
/*@jsdoc
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <ui-plugins/PluginContainer.h>
|
#include <ui-plugins/PluginContainer.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
#include "SettingHandle.h"
|
#include "SettingHandle.h"
|
||||||
|
#include "ScreenName.h"
|
||||||
|
|
||||||
|
|
||||||
const QString Basic2DWindowOpenGLDisplayPlugin::NAME("Desktop");
|
const QString Basic2DWindowOpenGLDisplayPlugin::NAME("Desktop");
|
||||||
|
@ -167,17 +168,12 @@ bool Basic2DWindowOpenGLDisplayPlugin::isThrottled() const {
|
||||||
return _isThrottled;
|
return _isThrottled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static QString getNameForScreen(QScreen *screen) {
|
|
||||||
return screen->model() + " (" + screen->name() + ", " + screen->serialNumber() + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
QScreen* Basic2DWindowOpenGLDisplayPlugin::getFullscreenTarget() {
|
QScreen* Basic2DWindowOpenGLDisplayPlugin::getFullscreenTarget() {
|
||||||
Setting::Handle<QString> _fullScreenScreenSetting { "fullScreenScreen", "" };
|
Setting::Handle<QString> _fullScreenScreenSetting { "fullScreenScreen", "" };
|
||||||
QString selectedModel = _fullScreenScreenSetting.get();
|
QString selectedModel = _fullScreenScreenSetting.get();
|
||||||
|
|
||||||
for(QScreen *screen : qApp->screens()) {
|
for(QScreen *screen : qApp->screens()) {
|
||||||
if (getNameForScreen(screen) == selectedModel) {
|
if (ScreenName::getNameForScreen(screen) == selectedModel) {
|
||||||
return screen;
|
return screen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
49
libraries/ui/src/ScreenName.cpp
Normal file
49
libraries/ui/src/ScreenName.cpp
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
//
|
||||||
|
// Created by Dale Glass on 7/01/2023
|
||||||
|
// Copyright 2022 Overte e.V.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ScreenName.h"
|
||||||
|
|
||||||
|
QString ScreenName::getNameForScreen(QScreen *screen) {
|
||||||
|
// The data provided by QScreen isn't as convenient as it could be.
|
||||||
|
// So far testing shows:
|
||||||
|
//
|
||||||
|
// Windows:
|
||||||
|
// model() returns an empty string
|
||||||
|
// name() returns something like \\.\DISPLAY1
|
||||||
|
//
|
||||||
|
// Linux:
|
||||||
|
// model() returns a name, like "LG Ultra HD/525000"
|
||||||
|
// name() returns the output's name, like "HDMI1"
|
||||||
|
|
||||||
|
// So we try to assemble something unique and readable from all the possibilities.
|
||||||
|
|
||||||
|
QString ret;
|
||||||
|
bool addParens = false;
|
||||||
|
|
||||||
|
ret.append(screen->manufacturer());
|
||||||
|
|
||||||
|
if (!ret.isEmpty()) {
|
||||||
|
ret.append(" - ");
|
||||||
|
}
|
||||||
|
ret.append(screen->model());
|
||||||
|
|
||||||
|
addParens = !ret.isEmpty();
|
||||||
|
|
||||||
|
if(addParens) {
|
||||||
|
ret.append(" (");
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.append(screen->name().replace(QString("\\\\.\\"), QString("")));
|
||||||
|
|
||||||
|
|
||||||
|
if(addParens) {
|
||||||
|
ret.append(")");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
32
libraries/ui/src/ScreenName.h
Normal file
32
libraries/ui/src/ScreenName.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
//
|
||||||
|
// Created by Dale Glass on 7/01/2023
|
||||||
|
// Copyright 2022 Overte e.V.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <QScreen>
|
||||||
|
#include <QString>
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Screen naming
|
||||||
|
*
|
||||||
|
* This class exists because display-plugins and interface need to share the same,
|
||||||
|
* fairly involved rule for converting QScreen data to user-facing text.
|
||||||
|
*/
|
||||||
|
class ScreenName {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Get a descriptive name for a screen
|
||||||
|
*
|
||||||
|
* This is used in the graphics settings, to name monitors. This function tries to generate
|
||||||
|
* human friendly and unique, even if two identical monitors are present.
|
||||||
|
*
|
||||||
|
* @param screen Screen to provide a name for
|
||||||
|
* @return QString Descriptive name for the screen
|
||||||
|
*/
|
||||||
|
static QString getNameForScreen(QScreen *screen);
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in a new issue