Browse Source

UI: Add func to load browser/cookies, but show dialog

Adds a function for initializing browser and cookies in a separate
thread while, and while waiting for it to complete, show a dialog
stating that the browser is currently being loaded.  Allows the ability
to safely prevent the user from taking any action without actually
freezing up the UI thread.
jp9000 6 years ago
parent
commit
1b8bc55f6a
3 changed files with 31 additions and 0 deletions
  1. 4 0
      UI/data/locale/en-US.ini
  2. 25 0
      UI/window-basic-main-browser.cpp
  3. 2 0
      UI/window-basic-main.hpp

+ 4 - 0
UI/data/locale/en-US.ini

@@ -95,6 +95,10 @@ AlreadyRunning.LaunchAnyway="Launch Anyway"
 Copy.Filters="Copy Filters"
 Copy.Filters="Copy Filters"
 Paste.Filters="Paste Filters"
 Paste.Filters="Paste Filters"
 
 
+# browser initialization dialog
+BrowserPanelInit.Title="Initializing Browser.."
+BrowserPanelInit.Text="Initializing browser, please wait.."
+
 # bandwidth test
 # bandwidth test
 BandwidthTest.Region="Region"
 BandwidthTest.Region="Region"
 BandwidthTest.Region.US="United States"
 BandwidthTest.Region.US="United States"

+ 25 - 0
UI/window-basic-main-browser.cpp

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

+ 2 - 0
UI/window-basic-main.hpp

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