From 70f6a4b5593391da169d794661cd0b38ff6f8105 Mon Sep 17 00:00:00 2001 From: Exeldro Date: Mon, 11 Mar 2024 07:44:24 +0100 Subject: [PATCH] fix building on OBS master --- audio-monitor-dock.cpp | 33 ++++++++++++++++++++------------- audio-monitor-dock.hpp | 3 ++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/audio-monitor-dock.cpp b/audio-monitor-dock.cpp index ba87a1d..58f6c3e 100644 --- a/audio-monitor-dock.cpp +++ b/audio-monitor-dock.cpp @@ -22,11 +22,27 @@ MODULE_EXPORT void load_audio_monitor_dock() const auto main_window = static_cast(obs_frontend_get_main_window()); obs_frontend_push_ui_translation(obs_module_get_string); - obs_frontend_add_dock(new AudioMonitorDock(main_window)); + +#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(30, 0, 0) + obs_frontend_add_dock_by_id("AudioMonitorDock", + obs_module_text("AudioMonitor"), + new AudioMonitorDock(main_window)); +#else + const auto dock = new QDockWidget(main_window); + dock->setObjectName("AudioMonitorDock"); + dock->setWindowTitle( + QString::fromUtf8(obs_module_text("AudioMonitor"))); + dock->setWidget(new AudioMonitorDock(main_window)); + dock->setFeatures(QDockWidget::DockWidgetMovable | + QDockWidget::DockWidgetFloatable); + dock->setFloating(true); + dock->hide(); + obs_frontend_add_dock(dock); +#endif obs_frontend_pop_ui_translation(); } -AudioMonitorDock::AudioMonitorDock(QWidget *parent) : QDockWidget(parent) +AudioMonitorDock::AudioMonitorDock(QWidget *parent) : QStackedWidget(parent) { mainLayout = new QGridLayout; @@ -81,12 +97,6 @@ AudioMonitorDock::AudioMonitorDock(QWidget *parent) : QDockWidget(parent) QSizePolicy::Expanding); mainLayout->addWidget(control, 1, 1); } - setFeatures(DockWidgetClosable | DockWidgetMovable | - DockWidgetFloatable); - setWindowTitle(QT_UTF8(obs_module_text("AudioMonitor"))); - setObjectName("AudioMonitorDock"); - setFloating(true); - hide(); signal_handler_connect_global(obs_get_signal_handler(), OBSSignal, this); @@ -106,9 +116,8 @@ AudioMonitorDock::AudioMonitorDock(QWidget *parent) : QDockWidget(parent) scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); scrollArea->setWidgetResizable(true); - auto *stackedMixerArea = new QStackedWidget; - stackedMixerArea->setObjectName(QStringLiteral("stackedMixerArea")); - stackedMixerArea->addWidget(scrollArea); + setObjectName(QStringLiteral("stackedMixerArea")); + addWidget(scrollArea); auto *config = new QPushButton(this); config->setProperty("themeID", "configIconSmall"); @@ -124,8 +133,6 @@ AudioMonitorDock::AudioMonitorDock(QWidget *parent) : QDockWidget(parent) dockWidgetContents->setLayout(mainLayout); scrollArea->setWidget(dockWidgetContents); - - setWidget(stackedMixerArea); } AudioMonitorDock::~AudioMonitorDock() diff --git a/audio-monitor-dock.hpp b/audio-monitor-dock.hpp index 5663cc5..e1e170d 100644 --- a/audio-monitor-dock.hpp +++ b/audio-monitor-dock.hpp @@ -2,13 +2,14 @@ #include #include #include +#include #include "obs.h" #include "audio-control.hpp" #include "audio-monitor-filter.h" #include -class AudioMonitorDock : public QDockWidget { +class AudioMonitorDock : public QStackedWidget { Q_OBJECT private: