UI: Restart program when audio/locale changed

master
Clayton Groeneveld 2020-02-16 15:15:33 -06:00
parent fd244a6896
commit e0135823ce
6 changed files with 48 additions and 4 deletions

View File

@ -1013,4 +1013,8 @@ Importer.AutomaticCollectionText="OBS can automatically find importable scene co
OBSStudio="OBS Studio" OBSStudio="OBS Studio"
OBSClassic="OBS Classic" OBSClassic="OBS Classic"
Streamlabs="Streamlabs" Streamlabs="Streamlabs"
XSplitBroadcaster="XSplit Broadcaster" XSplitBroadcaster="XSplit Broadcaster"
# OBS restart
Restart="Restart"
NeedsRestart="OBS Studio needs to be restarted. Do you want to restart now?"

View File

@ -34,6 +34,7 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QProxyStyle> #include <QProxyStyle>
#include <QScreen> #include <QScreen>
#include <QProcess>
#include "qt-wrappers.hpp" #include "qt-wrappers.hpp"
#include "obs-app.hpp" #include "obs-app.hpp"
@ -83,6 +84,8 @@ string opt_starting_scene;
bool remuxAfterRecord = false; bool remuxAfterRecord = false;
string remuxFilename; string remuxFilename;
bool restart = false;
// GPU hint exports for AMD/NVIDIA laptops // GPU hint exports for AMD/NVIDIA laptops
#ifdef _MSC_VER #ifdef _MSC_VER
extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 1; extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 1;
@ -1806,7 +1809,7 @@ static int run_program(fstream &logFile, int argc, char *argv[])
} }
if (cancel_launch) if (cancel_launch)
return 0; ret = 0;
if (!created_log) { if (!created_log) {
create_log_file(logFile); create_log_file(logFile);
@ -1844,17 +1847,21 @@ static int run_program(fstream &logFile, int argc, char *argv[])
} }
if (!program.OBSInit()) if (!program.OBSInit())
return 0; ret = 0;
prof.Stop(); prof.Stop();
return program.exec(); ret = program.exec();
} catch (const char *error) { } catch (const char *error) {
blog(LOG_ERROR, "%s", error); blog(LOG_ERROR, "%s", error);
OBSErrorBox(nullptr, "%s", error); OBSErrorBox(nullptr, "%s", error);
} }
if (restart)
QProcess::startDetached(qApp->arguments()[0],
qApp->arguments());
return ret; return ret;
} }

View File

@ -230,3 +230,4 @@ extern bool opt_studio_mode;
extern bool opt_allow_opengl; extern bool opt_allow_opengl;
extern bool opt_always_on_top; extern bool opt_always_on_top;
extern std::string opt_starting_scene; extern std::string opt_starting_scene;
extern bool restart;

View File

@ -3882,6 +3882,7 @@ void OBSBasic::closeEvent(QCloseEvent *event)
if (button == QMessageBox::No) { if (button == QMessageBox::No) {
event->ignore(); event->ignore();
restart = false;
return; return;
} }
} }
@ -4012,6 +4013,16 @@ void OBSBasic::on_action_Settings_triggered()
SystemTray(false); SystemTray(false);
settings_already_executing = false; settings_already_executing = false;
if (restart) {
QMessageBox::StandardButton button = OBSMessageBox::question(
this, QTStr("Restart"), QTStr("NeedsRestart"));
if (button == QMessageBox::Yes)
close();
else
restart = false;
}
} }
void OBSBasic::on_actionAdvAudioProperties_triggered() void OBSBasic::on_actionAdvAudioProperties_triggered()

View File

@ -1248,6 +1248,11 @@ void OBSBasicSettings::LoadGeneralSettings()
ui->multiviewLayout->setCurrentIndex(config_get_int( ui->multiviewLayout->setCurrentIndex(config_get_int(
GetGlobalConfig(), "BasicWindow", "MultiviewLayout")); GetGlobalConfig(), "BasicWindow", "MultiviewLayout"));
prevLangIndex = ui->language->currentIndex();
if (obs_video_active())
ui->language->setEnabled(false);
loading = false; loading = false;
} }
@ -2121,6 +2126,11 @@ void OBSBasicSettings::LoadAudioDevices()
LoadListValues(ui->desktopAudioDevice2, outputs, 2); LoadListValues(ui->desktopAudioDevice2, outputs, 2);
obs_properties_destroy(output_props); obs_properties_destroy(output_props);
} }
if (obs_video_active()) {
ui->sampleRate->setEnabled(false);
ui->channelSetup->setEnabled(false);
}
} }
#define NBSP "\xC2\xA0" #define NBSP "\xC2\xA0"
@ -3514,6 +3524,15 @@ void OBSBasicSettings::SaveSettings()
blog(LOG_INFO, "Settings changed (%s)", changed.c_str()); blog(LOG_INFO, "Settings changed (%s)", changed.c_str());
blog(LOG_INFO, MINOR_SEPARATOR); blog(LOG_INFO, MINOR_SEPARATOR);
} }
bool langChanged = (ui->language->currentIndex() != prevLangIndex);
bool audioRestart = (ui->channelSetup->currentIndex() != channelIndex ||
ui->sampleRate->currentIndex() != sampleRateIndex);
if (langChanged || audioRestart)
restart = true;
else
restart = false;
} }
bool OBSBasicSettings::QueryChanges() bool OBSBasicSettings::QueryChanges()
@ -3535,6 +3554,7 @@ bool OBSBasicSettings::QueryChanges()
if (toggleAero) if (toggleAero)
SetAeroEnabled(!aeroWasDisabled); SetAeroEnabled(!aeroWasDisabled);
#endif #endif
restart = false;
} }
ClearChanged(); ClearChanged();

View File

@ -234,6 +234,7 @@ private:
void OnOAuthStreamKeyConnected(); void OnOAuthStreamKeyConnected();
void OnAuthConnected(); void OnAuthConnected();
QString lastService; QString lastService;
int prevLangIndex;
private slots: private slots:
void UpdateServerList(); void UpdateServerList();
void UpdateKeyLink(); void UpdateKeyLink();