From 21552196c529cdc4e7112d2f09a80ab81c71207a Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 24 Feb 2017 02:06:20 +0100 Subject: Settings class rework Using toml as format --- smolbote.qbs | 2 +- src/3rd-party/toml/LICENSE | 24 + src/3rd-party/toml/toml.h | 1958 +++++++++++++++++++++++++++++++++++++++++ src/browser.cpp | 21 +- src/browser.h | 5 + src/forms/blockerdialog.cpp | 5 +- src/forms/downloaddialog.cpp | 6 +- src/mainwindow.cpp | 27 +- src/settings.cpp | 80 +- src/settings.h | 25 +- src/widgets/webviewtabbar.cpp | 15 +- test/config.ini | 34 - test/config.toml | 36 + 13 files changed, 2129 insertions(+), 109 deletions(-) create mode 100644 src/3rd-party/toml/LICENSE create mode 100644 src/3rd-party/toml/toml.h delete mode 100644 test/config.ini create mode 100644 test/config.toml diff --git a/smolbote.qbs b/smolbote.qbs index 032a93e..31cb6b3 100644 --- a/smolbote.qbs +++ b/smolbote.qbs @@ -42,7 +42,7 @@ Project { // condition: qbs.targetOS.contains("windows") // } - cpp.includePaths: ['src'] + cpp.includePaths: ['src', 'src/3rd-party'] cpp.defines: { if(project.deprecatedWarnings) defines.push("QT_DEPRECATED_WARNINGS", "QT_DISABLE_DEPRECATED_BEFORE="+project.deprecatedBefore); diff --git a/src/3rd-party/toml/LICENSE b/src/3rd-party/toml/LICENSE new file mode 100644 index 0000000..1514196 --- /dev/null +++ b/src/3rd-party/toml/LICENSE @@ -0,0 +1,24 @@ +Copyright (c) 2014, MAYAH +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/src/3rd-party/toml/toml.h b/src/3rd-party/toml/toml.h new file mode 100644 index 0000000..ec8c489 --- /dev/null +++ b/src/3rd-party/toml/toml.h @@ -0,0 +1,1958 @@ +#ifndef TINYTOML_H_ +#define TINYTOML_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace toml { + +// ---------------------------------------------------------------------- +// Declarations + +class Value; +typedef std::chrono::system_clock::time_point Time; +typedef std::vector Array; +typedef std::map Table; + +namespace internal { +template struct call_traits_value { + typedef T return_type; +}; +template struct call_traits_ref { + typedef const T& return_type; +}; +} // namespace internal + +template struct call_traits; +template<> struct call_traits : public internal::call_traits_value {}; +template<> struct call_traits : public internal::call_traits_value {}; +template<> struct call_traits : public internal::call_traits_value {}; +template<> struct call_traits : public internal::call_traits_value {}; +template<> struct call_traits : public internal::call_traits_ref {}; +template<> struct call_traits