From 01452936bdab960bbb8a3a1fea36cabc196e5982 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 4 Aug 2017 15:50:41 +0200 Subject: Implemented --default-config --- README.md | 4 ++-- src/main.cpp | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dca7b23..bcdf137 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ _yet another Qt browser_ The aim is to create a small, fast and clean web browser. * minimal - just a browser, not a platform -* configurable - settings file in plain sight and plain text +* configurable - settings in plain sight and plain text ### What's up with the name?! It's a small boat. @@ -13,6 +13,6 @@ It's a small boat. ### Sounds dumb, how do I use it? You make it yourself after taking a cursory glance at BUILDING.md. -### Reporting bugs, or throwing code into the pot +### Reporting bugs, or throwing code into the bucket Use the facilities present at the repository. For more information, glance at CONTRIBUTING.md. diff --git a/src/main.cpp b/src/main.cpp index 960c11c..789a3e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,11 +18,25 @@ ** ******************************************************************************/ +#include #include "browser.h" #include "mainwindow.h" #include #include +/** + * @brief printPoiToml Print the built-in config (if any) + * @param output std::ostream to print to + */ +void printPoiToml(std::ostream &output) +{ + QFile conf(":/poi.toml"); + if(conf.open(QIODevice::ReadOnly)) { + output << conf.readAll().toStdString() << std::endl; + conf.close(); + } +} + int main(int argc, char *argv[]) { // @@ -40,7 +54,7 @@ int main(int argc, char *argv[]) QCommandLineOption configOption(QStringList() << "c" << "config", "Set configuration file.", "PATH"); parser.addOption(configOption); - QCommandLineOption defaultConfigOption(QStringList() << "default-config", "Print default configuration"); + QCommandLineOption defaultConfigOption(QStringList() << "default-config", "Print default configuration."); parser.addOption(defaultConfigOption); QCommandLineOption profileOption(QStringList() << "p" << "profile", "Use this profile.", "PROFILE"); @@ -62,6 +76,11 @@ int main(int argc, char *argv[]) parser.process(app); + if(parser.isSet(defaultConfigOption)) { + printPoiToml(std::cout); + return 0; + } + app.setWindowIcon(QIcon(QLatin1String(":/icon.svg"))); // This lets the web view automatically scale on high-dpi displays. app.setAttribute(Qt::AA_EnableHighDpiScaling); -- cgit v1.2.1