Merge pull request #758 from cg2121/command-line-args

UI: Add more command line options
master
Jim 2017-01-29 19:42:37 -08:00 committed by GitHub
commit ce46ffa82e
3 changed files with 64 additions and 3 deletions

View File

@ -52,6 +52,8 @@
#include <signal.h>
#endif
#include <iostream>
using namespace std;
static log_handler_t def_log_handler;
@ -64,6 +66,9 @@ static bool log_verbose = false;
static bool unfiltered_log = false;
bool opt_start_streaming = false;
bool opt_start_recording = false;
bool opt_studio_mode = false;
bool opt_start_replaybuffer = false;
bool opt_minimize_tray = false;
string opt_starting_collection;
string opt_starting_profile;
string opt_starting_scene;
@ -1766,6 +1771,9 @@ int main(int argc, char *argv[])
} else if (arg_is(argv[i], "--startrecording", nullptr)) {
opt_start_recording = true;
} else if (arg_is(argv[i], "--startreplaybuffer", nullptr)) {
opt_start_replaybuffer = true;
} else if (arg_is(argv[i], "--collection", nullptr)) {
if (++i < argc) opt_starting_collection = argv[i];
@ -1774,6 +1782,42 @@ int main(int argc, char *argv[])
} else if (arg_is(argv[i], "--scene", nullptr)) {
if (++i < argc) opt_starting_scene = argv[i];
} else if (arg_is(argv[i], "--minimize-to-tray", nullptr)) {
opt_minimize_tray = true;
} else if (arg_is(argv[i], "--studio-mode", nullptr)) {
opt_studio_mode = true;
} else if (arg_is(argv[i], "--help", "-h")) {
std::cout <<
"--help, -h: Get list of available commands.\n\n" <<
"--startstreaming: Automatically start streaming.\n" <<
"--startrecording: Automatically start recording.\n" <<
"--startreplaybuffer: Start replay buffer.\n\n" <<
"--collection <string>: Use specific scene collection."
<< "\n" <<
"--profile <string>: Use specific profile.\n" <<
"--scene <string>: Start with specific scene.\n\n" <<
"--studio-mode: Enable studio mode.\n" <<
"--minimize-to-tray: Minimize to system tray.\n" <<
"--portable, -p: Use portable mode.\n\n" <<
"--verbose: Make log more verbose.\n" <<
"--unfiltered_log: Make log unfiltered.\n\n" <<
"--version, -V: Get current version.\n";
exit(0);
} else if (arg_is(argv[i], "--version", "-V")) {
std::cout << "OBS Studio - " <<
App()->GetVersionString() << "\n";
exit(0);
} else {
std::cout <<
"Invalid arguments. Use --help or -h to get " <<
"a list of available command line arguments.\n";
exit(0);
}
}

View File

@ -178,4 +178,7 @@ static inline int GetProfilePath(char *path, size_t size, const char *file)
extern bool opt_start_streaming;
extern bool opt_start_recording;
extern bool opt_start_replaybuffer;
extern bool opt_minimize_tray;
extern bool opt_studio_mode;
extern std::string opt_starting_scene;

View File

@ -789,6 +789,12 @@ retryScene:
opt_start_recording = false;
}
if (opt_start_replaybuffer) {
QMetaObject::invokeMethod(this, "StartReplayBuffer",
Qt::QueuedConnection);
opt_start_replaybuffer = false;
}
LogScenes();
disableSaving--;
@ -1248,8 +1254,14 @@ void OBSBasic::OBSInit()
"BasicWindow", "SwapScenesMode");
editPropertiesMode = config_get_bool(App()->GlobalConfig(),
"BasicWindow", "EditPropertiesMode");
SetPreviewProgramMode(config_get_bool(App()->GlobalConfig(),
"BasicWindow", "PreviewProgramMode"));
if (!opt_studio_mode) {
SetPreviewProgramMode(config_get_bool(App()->GlobalConfig(),
"BasicWindow", "PreviewProgramMode"));
} else {
SetPreviewProgramMode(true);
opt_studio_mode = false;
}
#define SET_VISIBILITY(name, control) \
do { \
@ -5215,12 +5227,14 @@ void OBSBasic::SystemTray(bool firstStarted)
if (!sysTrayWhenStarted && !sysTrayEnabled) {
trayIcon->hide();
} else if (sysTrayWhenStarted && sysTrayEnabled) {
} else if ((sysTrayWhenStarted && sysTrayEnabled)
|| opt_minimize_tray) {
trayIcon->show();
if (firstStarted) {
QTimer::singleShot(50, this, SLOT(hide()));
EnablePreviewDisplay(false);
setVisible(false);
opt_minimize_tray = false;
}
} else if (sysTrayEnabled) {
trayIcon->show();