]> git.sesse.net Git - nageru/commitdiff
Make it possible to call set_channel_name() for live and preview.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 19 Jul 2019 15:34:48 +0000 (17:34 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 19 Jul 2019 15:35:58 +0000 (17:35 +0200)
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
nageru/mainwindow.cpp
nageru/theme.cpp

index e6c2c582853a1bfe894e7df5dabc465104acbdc1..10d39cb97c7ff30fb4bdc94bdd3a6493bf63938b 100644 (file)
@@ -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<string> &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);
                });
index 73362229ce35e8efc70f9cf5dcfe4c25a6e73037..f2adbf240c94a6e42afe8a2238553075f7cfcc38 100644 (file)
@@ -252,6 +252,9 @@ MainWindow::MainWindow()
        connect(ui->me_live, &GLWidget::transition_names_updated, this, &MainWindow::set_transition_names);
        qRegisterMetaType<Mixer::Output>("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<string> 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());
        }
index ce3d2d6d55c917f6fdc0afba77c1cec348428ca2..c6cf4515805ad83be506f783d26df92b30ebc103 100644 (file)
@@ -1295,6 +1295,10 @@ int Nageru_set_supports_wb(lua_State *L)
 Theme::Theme(const string &filename, const vector<string> &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<mutex> 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);