From a60a2c892c08f6fab3a1e6b7cf4343cad8689058 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 19 Jul 2019 17:34:48 +0200 Subject: [PATCH] Make it possible to call set_channel_name() for live and preview. The use case for this is if you want to copy the channel name to preview or similar. Does not affect the legacy channel_name() callback (it is still guaranteed never to get 0 or 1). Probably doesn't affect the analyzer; I haven't tested. --- nageru/glwidget.cpp | 6 +++--- nageru/mainwindow.cpp | 9 ++++++++- nageru/theme.cpp | 10 ++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/nageru/glwidget.cpp b/nageru/glwidget.cpp index e6c2c58..10d39cb 100644 --- a/nageru/glwidget.cpp +++ b/nageru/glwidget.cpp @@ -96,15 +96,15 @@ void GLWidget::initializeGL() global_mixer->add_frame_ready_callback(output, this, [this]{ QMetaObject::invokeMethod(this, "update", Qt::AutoConnection); }); + global_mixer->set_name_updated_callback(output, [this](const string &name){ + emit name_updated(output, name); + }); if (output == Mixer::OUTPUT_LIVE) { global_mixer->set_transition_names_updated_callback(output, [this](const vector &names){ emit transition_names_updated(names); }); } if (output >= Mixer::OUTPUT_INPUT0) { - global_mixer->set_name_updated_callback(output, [this](const string &name){ - emit name_updated(output, name); - }); global_mixer->set_color_updated_callback(output, [this](const string &color){ emit color_updated(output, color); }); diff --git a/nageru/mainwindow.cpp b/nageru/mainwindow.cpp index 7336222..f2adbf2 100644 --- a/nageru/mainwindow.cpp +++ b/nageru/mainwindow.cpp @@ -252,6 +252,9 @@ MainWindow::MainWindow() connect(ui->me_live, &GLWidget::transition_names_updated, this, &MainWindow::set_transition_names); qRegisterMetaType("Mixer::Output"); + connect(ui->me_live, &GLWidget::name_updated, this, &MainWindow::update_channel_name); + connect(ui->me_preview, &GLWidget::name_updated, this, &MainWindow::update_channel_name); + // Hook up the prev/next buttons on the audio views. connect(ui->compact_prev_page, &QAbstractButton::clicked, this, &MainWindow::prev_page); connect(ui->compact_next_page, &QAbstractButton::clicked, this, &MainWindow::next_page); @@ -1503,7 +1506,11 @@ void MainWindow::set_transition_names(vector transition_names) void MainWindow::update_channel_name(Mixer::Output output, const string &name) { - if (output >= Mixer::OUTPUT_INPUT0) { + if (output == Mixer::OUTPUT_LIVE) { + ui->label_live->setText(name.c_str()); + } else if (output == Mixer::OUTPUT_PREVIEW) { + ui->label_preview->setText(name.c_str()); + } else if (output >= Mixer::OUTPUT_INPUT0) { unsigned channel = output - Mixer::OUTPUT_INPUT0; previews[channel]->label->setText(name.c_str()); } diff --git a/nageru/theme.cpp b/nageru/theme.cpp index ce3d2d6..c6cf451 100644 --- a/nageru/theme.cpp +++ b/nageru/theme.cpp @@ -1295,6 +1295,10 @@ int Nageru_set_supports_wb(lua_State *L) Theme::Theme(const string &filename, const vector &search_dirs, ResourcePool *resource_pool, unsigned num_cards) : resource_pool(resource_pool), num_cards(num_cards), signal_to_card_mapping(global_flags.default_stream_mapping) { + // Defaults. + channel_names[0] = "Live"; + channel_names[1] = "Preview"; + L = luaL_newstate(); luaL_openlibs(L); @@ -1569,6 +1573,12 @@ string Theme::get_channel_name(unsigned channel) { lock_guard lock(m); + // We never ask the legacy channel_name() about live and preview. + // The defaults are set in our constructor. + if (channel == 0 || channel == 1) { + return channel_names[channel]; + } + lua_getglobal(L, "channel_name"); if (lua_isnil(L, -1)) { lua_pop(L, 1); -- 2.39.2