mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #4675
anthony.bilinski (1): feat(login): Add command line argument to open login screen
This commit is contained in:
commit
ce0c102011
24
src/main.cpp
24
src/main.cpp
|
@ -191,8 +191,10 @@ int main(int argc, char* argv[])
|
|||
parser.addVersionOption();
|
||||
parser.addPositionalArgument("uri", QObject::tr("Tox URI to parse"));
|
||||
parser.addOption(
|
||||
QCommandLineOption("p", QObject::tr("Starts new instance and loads specified profile."),
|
||||
QCommandLineOption(QStringList() << "p" << "profile", QObject::tr("Starts new instance and loads specified profile."),
|
||||
QObject::tr("profile")));
|
||||
parser.addOption(
|
||||
QCommandLineOption(QStringList() << "l" << "login", QObject::tr("Starts new instance and opens the login screen.")));
|
||||
parser.process(*a);
|
||||
|
||||
uint32_t profileId = Settings::getInstance().getCurrentProfileId();
|
||||
|
@ -265,16 +267,22 @@ int main(int argc, char* argv[])
|
|||
ipc.registerEventHandler("activate", &toxActivateEventHandler);
|
||||
|
||||
uint32_t ipcDest = 0;
|
||||
bool doIpc = true;
|
||||
QString eventType, firstParam;
|
||||
if (parser.isSet("p")) {
|
||||
profileName = parser.value("p");
|
||||
if (!Profile::exists(profileName)) {
|
||||
qCritical() << "-p profile" << profileName + ".tox"
|
||||
<< "doesn't exist";
|
||||
return EXIT_FAILURE;
|
||||
qWarning() << "-p profile" << profileName + ".tox"
|
||||
<< "doesn't exist, opening login screen";
|
||||
doIpc = false;
|
||||
autoLogin = false;
|
||||
} else {
|
||||
ipcDest = Settings::makeProfileId(profileName);
|
||||
autoLogin = true;
|
||||
}
|
||||
ipcDest = Settings::makeProfileId(profileName);
|
||||
autoLogin = true;
|
||||
} else if (parser.isSet("l")) {
|
||||
doIpc = false;
|
||||
autoLogin = false;
|
||||
} else {
|
||||
profileName = Settings::getInstance().getCurrentProfile();
|
||||
}
|
||||
|
@ -296,13 +304,13 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (!ipc.isCurrentOwner()) {
|
||||
if (doIpc && !ipc.isCurrentOwner()) {
|
||||
time_t event = ipc.postEvent(eventType, firstParam.toUtf8(), ipcDest);
|
||||
// If someone else processed it, we're done here, no need to actually start qTox
|
||||
if (ipc.waitUntilAccepted(event, 2)) {
|
||||
if (eventType == "activate") {
|
||||
qDebug() << "Another qTox instance is already running. If you want to start a second "
|
||||
"instance, please start with a profile (qtox -p <profile name>).";
|
||||
"instance, please open login screen (qtox -l) or start with a profile (qtox -p <profile name>).";
|
||||
} else {
|
||||
qDebug() << "Event" << eventType << "was handled by other client.";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user