UI: Do not display threaded message boxes on startup

The message boxes that tell you that the browser is initializing or that
you're authenticating with twitch are annoying on startup.  It makes
sense to do it in the settings/autoconfig dialogs where you sort of need
to know what's going on while waiting for it to connect, but on startup
it's not really necessary and can be kind of annoying.
This commit is contained in:
jp9000 2019-02-20 17:33:29 -08:00
parent 0e4bef09f4
commit 01c78bffc5
9 changed files with 46 additions and 18 deletions

View File

@ -83,7 +83,7 @@ try {
5);
};
ExecuteFuncSafeBlockMsgBox(
ExecThreadedWithoutBlocking(
func,
QTStr("Auth.LoadingChannel.Title"),
QTStr("Auth.LoadingChannel.Text").arg(service()));
@ -126,7 +126,7 @@ try {
5);
};
ExecuteFuncSafeBlockMsgBox(
ExecThreadedWithoutBlocking(
func,
QTStr("Auth.LoadingChannel.Title"),
QTStr("Auth.LoadingChannel.Text").arg(service()));
@ -205,7 +205,7 @@ void MixerAuth::LoadUI()
if (!GetChannelInfo())
return;
OBSBasic::InitBrowserPanelSafeBlock(true);
OBSBasic::InitBrowserPanelSafeBlock();
OBSBasic *main = OBSBasic::Get();
std::string url;

View File

@ -34,7 +34,7 @@ OAuthLogin::OAuthLogin(QWidget *parent, const std::string &url, bool token)
Qt::WindowFlags helpFlag = Qt::WindowContextHelpButtonHint;
setWindowFlags(flags & (~helpFlag));
OBSBasic::InitBrowserPanelSafeBlock(true);
OBSBasic::InitBrowserPanelSafeBlock();
cefWidget = cef->create_widget(nullptr, url, panel_cookies);
if (!cefWidget) {
@ -216,7 +216,7 @@ try {
5);
};
ExecuteFuncSafeBlockMsgBox(
ExecThreadedWithoutBlocking(
func,
QTStr("Auth.Authing.Title"),
QTStr("Auth.Authing.Text").arg(service()));

View File

@ -90,7 +90,7 @@ try {
5);
};
ExecuteFuncSafeBlockMsgBox(
ExecThreadedWithoutBlocking(
func,
QTStr("Auth.LoadingChannel.Title"),
QTStr("Auth.LoadingChannel.Text").arg(service()));
@ -191,7 +191,7 @@ void TwitchAuth::LoadUI()
if (!GetChannelInfo())
return;
OBSBasic::InitBrowserPanelSafeBlock(true);
OBSBasic::InitBrowserPanelSafeBlock();
OBSBasic *main = OBSBasic::Get();
QCefWidget *browser;

View File

@ -263,3 +263,21 @@ void ExecuteFuncSafeBlockMsgBox(
dlg.exec();
thread->wait();
}
static bool enable_message_boxes = false;
void EnableThreadedMessageBoxes(bool enable)
{
enable_message_boxes = enable;
}
void ExecThreadedWithoutBlocking(
std::function<void()> func,
const QString &title,
const QString &text)
{
if (!enable_message_boxes)
ExecuteFuncSafeBlock(func);
else
ExecuteFuncSafeBlockMsgBox(func, title, text);
}

View File

@ -73,6 +73,14 @@ void ExecuteFuncSafeBlockMsgBox(
const QString &title,
const QString &text);
/* allows executing without message boxes if starting up, otherwise with a
* message box */
void EnableThreadedMessageBoxes(bool enable);
void ExecThreadedWithoutBlocking(
std::function<void()> func,
const QString &title,
const QString &text);
class SignalBlocker {
QWidget *widget;
bool blocked;

View File

@ -709,6 +709,8 @@ void AutoConfigStreamPage::UpdateCompleted()
AutoConfig::AutoConfig(QWidget *parent)
: QWizard(parent)
{
EnableThreadedMessageBoxes(true);
calldata_t cd = {0};
calldata_set_int(&cd, "seconds", 5);
@ -839,6 +841,7 @@ AutoConfig::~AutoConfig()
{
OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
main->EnableOutputs(true);
EnableThreadedMessageBoxes(false);
}
void AutoConfig::TestHardwareEncoding()

View File

@ -145,7 +145,7 @@ void DuplicateCurrentCookieProfile(ConfigFile &config)
#endif
}
void OBSBasic::InitBrowserPanelSafeBlock(bool showDialog)
void OBSBasic::InitBrowserPanelSafeBlock()
{
#ifdef BROWSER_AVAILABLE
if (!cef)
@ -155,15 +155,10 @@ void OBSBasic::InitBrowserPanelSafeBlock(bool showDialog)
return;
}
if (showDialog)
ExecuteFuncSafeBlockMsgBox(
[] {cef->wait_for_browser_init();},
QTStr("BrowserPanelInit.Title"),
QTStr("BrowserPanelInit.Text"));
else
ExecuteFuncSafeBlock(
[] {cef->wait_for_browser_init();});
ExecThreadedWithoutBlocking(
[] {cef->wait_for_browser_init();},
QTStr("BrowserPanelInit.Title"),
QTStr("BrowserPanelInit.Text"));
InitPanelCookieManager();
#else
UNUSED_PARAMETER(showDialog);

View File

@ -804,7 +804,7 @@ public:
virtual int GetProfilePath(char *path, size_t size, const char *file)
const override;
static void InitBrowserPanelSafeBlock(bool showDialog);
static void InitBrowserPanelSafeBlock();
private:
std::unique_ptr<Ui::OBSBasic> ui;

View File

@ -280,6 +280,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
{
string path;
EnableThreadedMessageBoxes(true);
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
@ -735,6 +737,8 @@ OBSBasicSettings::~OBSBasicSettings()
delete ui->filenameFormatting->completer();
main->EnableOutputs(true);
App()->EnableInFocusHotkeys(!disableHotkeysInFocus);
EnableThreadedMessageBoxes(false);
}
void OBSBasicSettings::SaveCombo(QComboBox *widget, const char *section,