From 5cfc16e9f961055de7f673038c60a920b6cd7e3d Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Wed, 4 Mar 2020 23:17:03 +0100 Subject: [PATCH] UI: Call setWindowFlags before setupUi For some reason this has a noticeable performance improvement, presumably because Qt is notifying all the child widgets? --- UI/window-basic-about.cpp | 4 ++-- UI/window-basic-filters.cpp | 3 ++- UI/window-basic-interaction.cpp | 8 ++++---- UI/window-basic-settings.cpp | 4 ++-- UI/window-basic-transform.cpp | 4 ++-- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/UI/window-basic-about.cpp b/UI/window-basic-about.cpp index 73d9bdb2b..328fa3fc2 100644 --- a/UI/window-basic-about.cpp +++ b/UI/window-basic-about.cpp @@ -11,10 +11,10 @@ using namespace json11; OBSAbout::OBSAbout(QWidget *parent) : QDialog(parent), ui(new Ui::OBSAbout) { - ui->setupUi(this); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + ui->setupUi(this); + QString bitness; QString ver; diff --git a/UI/window-basic-filters.cpp b/UI/window-basic-filters.cpp index 2da2a68fa..e4ac0d5f0 100644 --- a/UI/window-basic-filters.cpp +++ b/UI/window-basic-filters.cpp @@ -54,6 +54,8 @@ OBSBasicFilters::OBSBasicFilters(QWidget *parent, OBSSource source_) { main = reinterpret_cast(parent); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + ui->setupUi(this); UpdateFilters(); @@ -64,7 +66,6 @@ OBSBasicFilters::OBSBasicFilters(QWidget *parent, OBSSource source_) const char *name = obs_source_get_name(source); setWindowTitle(QTStr("Basic.Filters.Title").arg(QT_UTF8(name))); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); #ifndef QT_NO_SHORTCUT ui->actionRemoveFilter->setShortcut( diff --git a/UI/window-basic-interaction.cpp b/UI/window-basic-interaction.cpp index 147aafa0a..f7383c9d7 100644 --- a/UI/window-basic-interaction.cpp +++ b/UI/window-basic-interaction.cpp @@ -44,6 +44,10 @@ OBSBasicInteraction::OBSBasicInteraction(QWidget *parent, OBSSource source_) int cy = (int)config_get_int(App()->GlobalConfig(), "InteractionWindow", "cy"); + Qt::WindowFlags flags = windowFlags(); + Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint; + setWindowFlags(flags & (~helpFlag)); + ui->setupUi(this); ui->preview->setMouseTracking(true); @@ -59,10 +63,6 @@ OBSBasicInteraction::OBSBasicInteraction(QWidget *parent, OBSSource source_) const char *name = obs_source_get_name(source); setWindowTitle(QTStr("Basic.InteractionWindow").arg(QT_UTF8(name))); - Qt::WindowFlags flags = windowFlags(); - Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint; - setWindowFlags(flags & (~helpFlag)); - auto addDrawCallback = [this]() { obs_display_add_draw_callback(ui->preview->GetDisplay(), OBSBasicInteraction::DrawPreview, diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index e73376c73..89d9e52d0 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -318,10 +318,10 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) EnableThreadedMessageBoxes(true); - ui->setupUi(this); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + ui->setupUi(this); + main->EnableOutputs(false); PopulateAACBitrates({ui->simpleOutputABitrate, ui->advOutTrack1Bitrate, diff --git a/UI/window-basic-transform.cpp b/UI/window-basic-transform.cpp index 7c1d61db1..eaf0594cd 100644 --- a/UI/window-basic-transform.cpp +++ b/UI/window-basic-transform.cpp @@ -42,10 +42,10 @@ void OBSBasicTransform::HookWidget(QWidget *widget, const char *signal, OBSBasicTransform::OBSBasicTransform(OBSBasic *parent) : QDialog(parent), ui(new Ui::OBSBasicTransform), main(parent) { - ui->setupUi(this); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + ui->setupUi(this); + HookWidget(ui->positionX, DSCROLL_CHANGED, SLOT(OnControlChanged())); HookWidget(ui->positionY, DSCROLL_CHANGED, SLOT(OnControlChanged())); HookWidget(ui->rotation, DSCROLL_CHANGED, SLOT(OnControlChanged()));