mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 23:31:59 +08:00
CLI option for single instance only with prusaslicer:// url
This commit is contained in:
parent
c93631a504
commit
e6313aa5e0
@ -5664,6 +5664,10 @@ CLIMiscConfigDef::CLIMiscConfigDef()
|
|||||||
"or an existing PrusaSlicer window is activated. "
|
"or an existing PrusaSlicer window is activated. "
|
||||||
"Overrides the \"single_instance\" configuration value from application preferences.");
|
"Overrides the \"single_instance\" configuration value from application preferences.");
|
||||||
|
|
||||||
|
def = this->add("single_instance_on_url", coBool);
|
||||||
|
def->label = L("Single instance mode for prusaslicer url");
|
||||||
|
def->tooltip = L("Works as single_instance but only if prusaslicer url is present.");
|
||||||
|
|
||||||
def = this->add("datadir", coString);
|
def = this->add("datadir", coString);
|
||||||
def->label = L("Data directory");
|
def->label = L("Data directory");
|
||||||
def->tooltip = L("Load and store settings at the given directory. This is useful for maintaining different profiles or including configurations from a network storage.");
|
def->tooltip = L("Load and store settings at the given directory. This is useful for maintaining different profiles or including configurations from a network storage.");
|
||||||
|
@ -69,18 +69,29 @@ namespace instance_check_internal
|
|||||||
//if (argc < 2)
|
//if (argc < 2)
|
||||||
// return ret;
|
// return ret;
|
||||||
std::vector<std::string> arguments { argv[0] };
|
std::vector<std::string> arguments { argv[0] };
|
||||||
|
bool send_if_url = false;
|
||||||
|
bool has_url = false;
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
const std::string token = argv[i];
|
const std::string token = argv[i];
|
||||||
|
if (token.find("prusaslicer://") == 0) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "url found: " << token;
|
||||||
|
has_url = true;
|
||||||
|
}
|
||||||
// Processing of boolean command line arguments shall match DynamicConfig::read_cli().
|
// Processing of boolean command line arguments shall match DynamicConfig::read_cli().
|
||||||
if (token == "--single-instance")
|
if (token == "--single-instance")
|
||||||
ret.should_send = true;
|
ret.should_send = true;
|
||||||
else if (token == "--no-single-instance")
|
else if (token == "--no-single-instance")
|
||||||
ret.should_send = false;
|
ret.should_send = false;
|
||||||
|
else if (token == "--single-instance-on-url")
|
||||||
|
send_if_url = true;
|
||||||
else
|
else
|
||||||
arguments.emplace_back(token);
|
arguments.emplace_back(token);
|
||||||
}
|
}
|
||||||
|
if (send_if_url && has_url) {
|
||||||
|
ret.should_send = true;
|
||||||
|
}
|
||||||
ret.cl_string = escape_strings_cstyle(arguments);
|
ret.cl_string = escape_strings_cstyle(arguments);
|
||||||
BOOST_LOG_TRIVIAL(debug) << "single instance: " <<
|
BOOST_LOG_TRIVIAL(info) << "single instance: " <<
|
||||||
(ret.should_send.has_value() ? (*ret.should_send ? "true" : "false") : "undefined") <<
|
(ret.should_send.has_value() ? (*ret.should_send ? "true" : "false") : "undefined") <<
|
||||||
". other params: " << ret.cl_string;
|
". other params: " << ret.cl_string;
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user