/* * This file is part of smolbote. It's copyrighted by the contributors recorded * in the version control history of the file, available from its original * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote * * SPDX-License-Identifier: GPL-3.0 */ #include "browser.h" #include "configuration.h" #include "session/sessiondialog.h" #include "session_json.hpp" #include "settings.h" #include #include #include #include #include int main(int argc, char **argv) { // change log pattern spdlog::set_pattern("[%^%l%$] [%P:%t] %v"); #ifdef QT_DEBUG spdlog::set_level(spdlog::level::debug); // Set global log level to debug #endif init_conf(""); // argc, argv, allowSecondary Browser app(argc, argv); // set this, otherwise the webview becomes black when using a stylesheet app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); QCommandLineParser parser; parser.addHelpOption(); parser.addPositionalArgument("url", "URLs to open"); parser.process(app); const auto profile = []() { Configuration c; return c.value("profile.default").value(); }(); QStringList urls = parser.positionalArguments(); if(urls.isEmpty()) { urls.append(QString()); } // if app is primary, create new sessions from received messages if(app.isPrimary() /*&& !cmd_noRemote*/) { QObject::connect(&app, &Browser::receivedMessage, &app, [&app](quint32 instanceId, QByteArray message) { Q_UNUSED(instanceId); JsonSession session(message); app.open(session.get()); }); } { const auto session = [&]() { /*if(cmd_session) { QFile sessionJson(QString::fromStdString(args::get(cmd_session))); if(sessionJson.open(QIODevice::ReadOnly | QIODevice::Text)) { return JsonSession(sessionJson.readAll()); } } if(cmd_pickSession) { SessionDialog dlg; if(const auto pick = dlg.pickSession()) { return JsonSession(pick.value()); } }*/ return JsonSession(profile, urls); }(); if(app.isPrimary() /*|| cmd_noRemote */) { app.open(session.get()); } else { // app is secondary and not standalone return app.sendMessage(session.serialize()); } } return app.exec(); }