aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-08-24 19:49:21 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-08-24 20:03:38 +0200
commitb8ea8aa986ff88e82658523ac8d40756ab871984 (patch)
tree5cf1b6dcbd86ffe6e26814c8225b7f05c7407c05 /src/main.cpp
parentDownloads: prevent download widget width from exceeding download list width (diff)
downloadsmolbote-b8ea8aa986ff88e82658523ac8d40756ab871984.tar.xz
MainWindow: fix load session action
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/main.cpp b/src/main.cpp
index d7bcee0..405210f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -115,7 +115,7 @@ int main(int argc, char **argv)
}
// command line arguments
- bool ignoreSecondary = config->exists("no-remote");
+ bool isStandalone = config->exists("no-remote");
auto arguments = config->value<std::vector<std::string>>("args");
auto session = config->value<QString>("browser.session");
auto profile = config->value<QString>("profile.default");
@@ -138,34 +138,32 @@ int main(int argc, char **argv)
}
}
- //
- if(!ignoreSecondary) {
+ // if app is primary, create new sessions from received messages
+ if(app.isPrimary() && !isStandalone) {
QObject::connect(&app, &Browser::receivedMessage, &app, [&app](quint32 instanceId, QByteArray message) {
auto doc = QJsonDocument::fromJson(message);
app.createSession(doc.object());
});
}
- if(app.isPrimary()) {
- app.createSession(Session::toJsonObject(profile.value(), urls));
- } else if(ignoreSecondary) {
- // app is not primary (= secondary), and --ignore-secondary is set
- return -1;
- } else if(session) {
- QFile sessionJson(session.value());
- if(sessionJson.open(QIODevice::ReadOnly | QIODevice::Text)) {
- app.sendMessage(sessionJson.readAll());
- sessionJson.close();
- qDebug("session data sent");
- return EXIT_SUCCESS;
+ {
+ QJsonObject sessionData;
+ if(session) {
+ QFile sessionJson(session.value());
+ if(sessionJson.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ sessionData = QJsonDocument::fromJson(sessionJson.readAll()).object();
+ sessionJson.close();
+ }
+ } else {
+ sessionData = Session::toJsonObject(profile.value(), urls);
+ }
+
+ if(app.isPrimary() || isStandalone) {
+ app.createSession(sessionData);
} else {
- qWarning("Could not open session [%s].", qUtf8Printable(sessionJson.fileName()));
+ // app is secondary and not standalone
+ return app.sendMessage(QJsonDocument(sessionData).toJson());
}
- } else {
- auto message = Session::toJsonObject(profile.value(), urls);
- qDebug("sending message: %s", app.sendMessage(QJsonDocument(message).toJson()) ? "okay" : "failed");
- qDebug("message>>>\n%s", qUtf8Printable(QJsonDocument(message).toJson()));
- return EXIT_SUCCESS;
}
return app.exec();