diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-06-23 17:16:35 +0300 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-06-23 17:16:35 +0300 |
commit | dd277842571ade5f78b33171648356a56fec400a (patch) | |
tree | e046e3d73a6bf8af173f34de59e1a20b96fd3504 /src/main.cpp | |
parent | enable smolblok (diff) | |
download | smolbote-dd277842571ade5f78b33171648356a56fec400a.tar.xz |
Fix compiler warnings in Configuration
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 149 |
1 files changed, 73 insertions, 76 deletions
diff --git a/src/main.cpp b/src/main.cpp index dad1f73..3976f53 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,7 +77,9 @@ int main(int argc, char **argv) return builtins::build(); // create and load configuration - spdlog::debug("Loading configuration {}", init_conf(args::get(cmd_config))); + auto conf = init_conf(args::get(cmd_config)); + conf.ptr->make_global(); + spdlog::debug("Loading configuration {}", conf.path); if(cmd_args) { const auto front = args::get(cmd_args).front(); @@ -87,92 +89,87 @@ int main(int argc, char **argv) } } - } catch(args::Help &) { - std::cout << parser; - return 0; - - } catch(args::Error &e) { - std::cerr << e.what() << std::endl; - std::cerr << parser; - return -1; - } - - // argc, argv, allowSecondary - Browser app(argc, argv); - // set this, otherwise the webview becomes black when using a stylesheet - app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); - - { - Configuration conf; - - if(conf.value<bool>("usebreakpad").value()) { - CrashHandler::Context ctx( - conf.value<std::string>("path.crashdump").value(), - conf.value<std::string>("path.crashhandler").value()); - - if(CrashHandler::install_handler(ctx)) { - spdlog::info("Installed breakpad crash handler: {}", ctx.dumppath); - } else { - spdlog::warn("Failed to install breakpad crash handler: {}", ctx.dumppath); + // argc, argv, allowSecondary + Browser app(argc, argv); + // set this, otherwise the webview becomes black when using a stylesheet + app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true); + + { + if(conf.ptr->value<bool>("usebreakpad").value()) { + CrashHandler::Context ctx( + conf.ptr->value<std::string>("path.crashdump").value(), + conf.ptr->value<std::string>("path.crashhandler").value()); + + if(CrashHandler::install_handler(ctx)) { + spdlog::info("Installed breakpad crash handler: {}", ctx.dumppath); + } else { + spdlog::warn("Failed to install breakpad crash handler: {}", ctx.dumppath); + } } - } - // load plugins - for(const QString &path : Util::files(conf.value<QString>("plugins.path").value(), { "*.so", "*.dll" })) { - if(app.loadPlugin(path)) { - spdlog::debug("Loaded plugin [{}]", qUtf8Printable(path)); - } else { - spdlog::warn("Failed loading plugin [{}]", qUtf8Printable(path)); + // load plugins + for(const QString &path : Util::files(conf.ptr->value<QString>("plugins.path").value(), { "*.so", "*.dll" })) { + if(app.loadPlugin(path)) { + spdlog::debug("Loaded plugin [{}]", qUtf8Printable(path)); + } else { + spdlog::warn("Failed loading plugin [{}]", qUtf8Printable(path)); + } } } - } - const auto profile = []() { - Configuration c; - return c.value<QString>("profile.default").value(); - }(); + const auto profile = conf.ptr->value<QString>("profile.default").value(); - QStringList urls; - for(const auto &u : args::get(cmd_args)) { - urls.append(QString::fromStdString(u)); - } - if(urls.isEmpty()) { - urls.append(QString()); - } + QStringList urls; + for(const auto &u : args::get(cmd_args)) { + urls.append(QString::fromStdString(u)); + } + 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()); - }); - } + // 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()); + { + 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()); + 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 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(); + return app.exec(); + + } catch(args::Help &) { + std::cout << parser; + return 0; + + } catch(args::Error &e) { + std::cerr << e.what() << std::endl; + std::cerr << parser; + return -1; + } } |