UI: Update Projectors title on source name change
This commit is contained in:
parent
76af4ff36d
commit
372640ff35
@ -2204,6 +2204,8 @@ void OBSBasic::RenameSources(OBSSource source, QString newName,
|
||||
volumes[i]->SetName(newName);
|
||||
}
|
||||
|
||||
OBSProjector::RenameProjector(prevName, newName);
|
||||
|
||||
SaveProject();
|
||||
|
||||
obs_scene_t *scene = obs_scene_from_source(source);
|
||||
@ -5538,9 +5540,7 @@ void OBSBasic::OpenSourceWindow()
|
||||
return;
|
||||
|
||||
OBSSource source = obs_sceneitem_get_source(item);
|
||||
QString text = QString::fromUtf8(obs_source_get_name(source));
|
||||
QString title = QTStr("SourceWindow") + " - " + text;
|
||||
|
||||
QString title = QString::fromUtf8(obs_source_get_name(source));
|
||||
OpenProjector(obs_sceneitem_get_source(item), monitor, title);
|
||||
}
|
||||
|
||||
@ -5559,9 +5559,7 @@ void OBSBasic::OpenSceneWindow()
|
||||
return;
|
||||
|
||||
OBSSource source = obs_scene_get_source(scene);
|
||||
QString text = QString::fromUtf8(obs_source_get_name(source));
|
||||
QString title = QTStr("SceneWindow") + " - " + text;
|
||||
|
||||
QString title = QString::fromUtf8(obs_source_get_name(source));
|
||||
OpenProjector(obs_scene_get_source(scene), monitor, title);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QMenu>
|
||||
#include <QScreen>
|
||||
#include "obs-app.hpp"
|
||||
#include "window-basic-main.hpp"
|
||||
#include "display-helpers.hpp"
|
||||
#include "qt-wrappers.hpp"
|
||||
@ -13,6 +14,7 @@
|
||||
#define VERTICAL_LEFT 2
|
||||
#define VERTICAL_RIGHT 3
|
||||
|
||||
static QList<OBSProjector *> windowedProjectors;
|
||||
static QList<OBSProjector *> multiviewProjectors;
|
||||
static bool updatingMultiview = false;
|
||||
static int multiviewLayout = HORIZONTAL_TOP;
|
||||
@ -89,6 +91,9 @@ OBSProjector::~OBSProjector()
|
||||
if (type == ProjectorType::Multiview)
|
||||
multiviewProjectors.removeAll(this);
|
||||
|
||||
if (isWindow)
|
||||
windowedProjectors.removeAll(this);
|
||||
|
||||
App()->DecrementSleepInhibition();
|
||||
}
|
||||
|
||||
@ -135,6 +140,10 @@ static OBSSource CreateLabel(const char *name, size_t h)
|
||||
void OBSProjector::Init(int monitor, bool window, QString title,
|
||||
ProjectorType type_)
|
||||
{
|
||||
savedMonitor = monitor;
|
||||
isWindow = window;
|
||||
type = type_;
|
||||
|
||||
bool alwaysOnTop = config_get_bool(GetGlobalConfig(),
|
||||
"BasicWindow", "ProjectorAlwaysOnTop");
|
||||
if (alwaysOnTop && !window)
|
||||
@ -143,7 +152,8 @@ void OBSProjector::Init(int monitor, bool window, QString title,
|
||||
show();
|
||||
|
||||
if (window) {
|
||||
setWindowTitle(title);
|
||||
UpdateProjectorTitle(title);
|
||||
windowedProjectors.push_back(this);
|
||||
} else {
|
||||
QScreen *screen = QGuiApplication::screens()[monitor];
|
||||
setGeometry(screen->geometry());
|
||||
@ -159,10 +169,6 @@ void OBSProjector::Init(int monitor, bool window, QString title,
|
||||
if (source)
|
||||
obs_source_inc_showing(source);
|
||||
|
||||
savedMonitor = monitor;
|
||||
isWindow = window;
|
||||
type = type_;
|
||||
|
||||
if (type == ProjectorType::Multiview) {
|
||||
obs_enter_graphics();
|
||||
gs_render_start(true);
|
||||
@ -852,6 +858,26 @@ void OBSProjector::UpdateMultiview()
|
||||
multiviewLayout = HORIZONTAL_TOP;
|
||||
}
|
||||
|
||||
void OBSProjector::UpdateProjectorTitle(QString name)
|
||||
{
|
||||
projectorTitle = name;
|
||||
|
||||
QString title = nullptr;
|
||||
switch (type) {
|
||||
case ProjectorType::Scene:
|
||||
title = QTStr("SceneWindow") + " - " + name;
|
||||
break;
|
||||
case ProjectorType::Source:
|
||||
title = QTStr("SourceWindow") + " - " + name;
|
||||
break;
|
||||
default:
|
||||
title = name;
|
||||
break;
|
||||
}
|
||||
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
OBSSource OBSProjector::GetSource()
|
||||
{
|
||||
return source;
|
||||
@ -880,3 +906,10 @@ void OBSProjector::UpdateMultiviewProjectors()
|
||||
updatingMultiview = false;
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
void OBSProjector::RenameProjector(QString oldName, QString newName)
|
||||
{
|
||||
for (auto &projector : windowedProjectors)
|
||||
if (projector->projectorTitle == oldName)
|
||||
projector->UpdateProjectorTitle(newName);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ private:
|
||||
|
||||
int savedMonitor = 0;
|
||||
bool isWindow = false;
|
||||
QString projectorTitle;
|
||||
ProjectorType type = ProjectorType::Source;
|
||||
OBSWeakSource multiviewScenes[8];
|
||||
OBSSource multiviewLabels[10];
|
||||
@ -42,6 +43,7 @@ private:
|
||||
bool ready = false;
|
||||
|
||||
void UpdateMultiview();
|
||||
void UpdateProjectorTitle(QString name);
|
||||
|
||||
private slots:
|
||||
void EscapeTriggered();
|
||||
@ -57,4 +59,5 @@ public:
|
||||
ProjectorType GetProjectorType();
|
||||
int GetMonitor();
|
||||
static void UpdateMultiviewProjectors();
|
||||
static void RenameProjector(QString oldName, QString newName);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user