ui/updater: Apply workaround for OBS Studio checking for modals

In order to work around a bug in the OBS Studio UI code, we have to swap our modal status right before showing and right after hiding, so that the OBS Studio tray menu continuous working correctly. This is a bit of a weird solution, but it does work as expected.

Related: https://github.com/obsproject/obs-studio/issues/3518
This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2020-09-30 02:20:16 +02:00 committed by Xaymar
parent 4ed1f3d481
commit 3dbf9c9dbc
3 changed files with 29 additions and 9 deletions

View file

@ -103,9 +103,16 @@ void streamfx::ui::updater_dialog::show(streamfx::update_info current, streamfx:
_update_url = QUrl(QString::fromStdString(update.url));
this->setModal(true);
QDialog::show();
}
void streamfx::ui::updater_dialog::hide()
{
this->setModal(false);
QDialog::hide();
}
void streamfx::ui::updater_dialog::on_ok()
{
QDesktopServices::openUrl(_update_url);
@ -122,14 +129,6 @@ streamfx::ui::updater::updater(QMenu* menu)
// Create dialog.
_dialog = new updater_dialog();
// Create GitHub message box.
_gdpr = new QMessageBox(reinterpret_cast<QWidget*>(obs_frontend_get_main_window()));
_gdpr->setWindowTitle(QString::fromUtf8(D_TRANSLATE(D_I18N_GITHUBPERMISSION_TITLE)));
_gdpr->setTextFormat(Qt::TextFormat::RichText);
_gdpr->setText(QString::fromUtf8(D_TRANSLATE(D_I18N_GITHUBPERMISSION_TEXT)));
_gdpr->setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
connect(_gdpr, &QMessageBox::buttonClicked, this, &streamfx::ui::updater::on_gdpr_button);
{ // Create the necessary menu entries.
menu->addSeparator();
@ -179,6 +178,7 @@ streamfx::ui::updater::updater(QMenu* menu)
if (_updater->gdpr()) {
_updater->refresh();
} else {
create_gdpr_box();
_gdpr->exec();
}
}
@ -243,6 +243,7 @@ void streamfx::ui::updater::on_gdpr_button(QAbstractButton* btn)
void streamfx::ui::updater::on_cfu_triggered(bool)
{
if (!_updater->gdpr()) {
create_gdpr_box();
_gdpr->exec();
} else {
emit check_active(true);
@ -287,3 +288,19 @@ void streamfx::ui::updater::on_check_active(bool active)
_channel_stable->setEnabled(!active);
_channel_menu->setEnabled(!active);
}
void streamfx::ui::updater::create_gdpr_box()
{
if (_gdpr) {
_gdpr->deleteLater();
_gdpr = nullptr;
}
// Create GitHub message box.
_gdpr = new QMessageBox(reinterpret_cast<QWidget*>(obs_frontend_get_main_window()));
_gdpr->setWindowTitle(QString::fromUtf8(D_TRANSLATE(D_I18N_GITHUBPERMISSION_TITLE)));
_gdpr->setTextFormat(Qt::TextFormat::RichText);
_gdpr->setText(QString::fromUtf8(D_TRANSLATE(D_I18N_GITHUBPERMISSION_TEXT)));
_gdpr->setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
connect(_gdpr, &QMessageBox::buttonClicked, this, &streamfx::ui::updater::on_gdpr_button);
}

View file

@ -54,6 +54,7 @@ namespace streamfx::ui {
~updater_dialog();
void show(streamfx::update_info current, streamfx::update_info update);
void hide();
public slots:
; // Needed by some linters.
@ -83,6 +84,8 @@ namespace streamfx::ui {
updater(QMenu* menu);
~updater();
void create_gdpr_box();
void on_updater_automation_changed(streamfx::updater&, bool);
void on_updater_channel_changed(streamfx::updater&, streamfx::update_channel);
void on_updater_refreshed(streamfx::updater&);

View file

@ -41,7 +41,7 @@ QWidget[objectName=&quot;ok&quot;]:hover {
}</string>
</property>
<property name="modal">
<bool>true</bool>
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">