mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-01-16 02:08:35 -05:00
UI: Add intro startup page (windows)
Allows the ability to show a web page via CEF to the users on startup to present and announce new features.
This commit is contained in:
@@ -68,8 +68,19 @@
|
||||
#include <QScreen>
|
||||
#include <QWindow>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <browser-panel.hpp>
|
||||
#endif
|
||||
|
||||
#include <json11.hpp>
|
||||
|
||||
using namespace json11;
|
||||
using namespace std;
|
||||
|
||||
#ifdef _WIN32
|
||||
static CREATE_BROWSER_WIDGET_PROC create_browser_widget = nullptr;
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename OBSRef>
|
||||
@@ -1429,6 +1440,10 @@ void OBSBasic::OBSInit()
|
||||
blog(LOG_INFO, "---------------------------------");
|
||||
obs_post_load_modules();
|
||||
|
||||
#ifdef _WIN32
|
||||
create_browser_widget = obs_browser_init_panel();
|
||||
#endif
|
||||
|
||||
CheckForSimpleModeX264Fallback();
|
||||
|
||||
blog(LOG_INFO, STARTUP_SEPARATOR);
|
||||
@@ -1649,6 +1664,21 @@ void OBSBasic::OnFirstLoad()
|
||||
{
|
||||
if (api)
|
||||
api->on_event(OBS_FRONTEND_EVENT_FINISHED_LOADING);
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Attempt to load init screen if available */
|
||||
if (create_browser_widget) {
|
||||
WhatsNewInfoThread *wnit = new WhatsNewInfoThread();
|
||||
if (wnit) {
|
||||
connect(wnit, &WhatsNewInfoThread::Result,
|
||||
this, &OBSBasic::ReceivedIntroJson);
|
||||
}
|
||||
if (wnit) {
|
||||
introCheckThread = wnit;
|
||||
introCheckThread->start();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OBSBasic::DeferredLoad(const QString &file, int requeueCount)
|
||||
@@ -1666,6 +1696,93 @@ void OBSBasic::DeferredLoad(const QString &file, int requeueCount)
|
||||
OnFirstLoad();
|
||||
}
|
||||
|
||||
/* shows a "what's new" page on startup of new versions using CEF */
|
||||
void OBSBasic::ReceivedIntroJson(const QString &text)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::string err;
|
||||
Json json = Json::parse(QT_TO_UTF8(text), err);
|
||||
if (!err.empty())
|
||||
return;
|
||||
|
||||
std::string info_url;
|
||||
int info_increment = -1;
|
||||
|
||||
/* check to see if there's an info page for this version */
|
||||
const Json::array &items = json.array_items();
|
||||
for (const Json &item : items) {
|
||||
const std::string &version = item["version"].string_value();
|
||||
const std::string &url = item["url"].string_value();
|
||||
int increment = item["increment"].int_value();
|
||||
|
||||
int major = 0;
|
||||
int minor = 0;
|
||||
|
||||
sscanf(version.c_str(), "%d.%d", &major, &minor);
|
||||
if (major == LIBOBS_API_MAJOR_VER &&
|
||||
minor == LIBOBS_API_MINOR_VER) {
|
||||
info_url = url;
|
||||
info_increment = increment;
|
||||
}
|
||||
}
|
||||
|
||||
/* this version was not found, or no info for this version */
|
||||
if (info_increment == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t lastVersion = config_get_int(App()->GlobalConfig(), "General",
|
||||
"LastVersion");
|
||||
|
||||
int current_version_increment = -1;
|
||||
|
||||
if (lastVersion < LIBOBS_API_VER) {
|
||||
config_set_int(App()->GlobalConfig(), "General",
|
||||
"InfoIncrement", -1);
|
||||
} else {
|
||||
current_version_increment = config_get_int(
|
||||
App()->GlobalConfig(), "General",
|
||||
"InfoIncrement");
|
||||
}
|
||||
|
||||
if (info_increment <= current_version_increment) {
|
||||
return;
|
||||
}
|
||||
|
||||
config_set_int(App()->GlobalConfig(), "General",
|
||||
"InfoIncrement", info_increment);
|
||||
|
||||
QDialog dlg(this);
|
||||
dlg.setWindowTitle("What's New");
|
||||
dlg.resize(600, 600);
|
||||
|
||||
QCefWidget *cefWidget = create_browser_widget(nullptr, info_url);
|
||||
if (!cefWidget) {
|
||||
return;
|
||||
}
|
||||
|
||||
connect(cefWidget, SIGNAL(titleChanged(const QString &)),
|
||||
&dlg, SLOT(setWindowTitle(const QString &)));
|
||||
|
||||
QPushButton *close = new QPushButton(QTStr("Close"));
|
||||
connect(close, &QAbstractButton::clicked,
|
||||
&dlg, &QDialog::accept);
|
||||
|
||||
QHBoxLayout *bottomLayout = new QHBoxLayout();
|
||||
bottomLayout->addStretch();
|
||||
bottomLayout->addWidget(close);
|
||||
bottomLayout->addStretch();
|
||||
|
||||
QVBoxLayout *topLayout = new QVBoxLayout(&dlg);
|
||||
topLayout->addWidget(cefWidget);
|
||||
topLayout->addLayout(bottomLayout);
|
||||
|
||||
dlg.exec();
|
||||
#else
|
||||
UNUSED_PARAMETER(text);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OBSBasic::UpdateMultiviewProjectorMenu()
|
||||
{
|
||||
multiviewProjectorMenu->clear();
|
||||
@@ -3389,6 +3506,8 @@ void OBSBasic::closeEvent(QCloseEvent *event)
|
||||
|
||||
blog(LOG_INFO, SHUTDOWN_SEPARATOR);
|
||||
|
||||
if (introCheckThread)
|
||||
introCheckThread->wait();
|
||||
if (updateCheckThread)
|
||||
updateCheckThread->wait();
|
||||
if (logUploadThread)
|
||||
|
||||
Reference in New Issue
Block a user