From 74870600fa54a48d4c1ce4b19861a9b0ce027fee Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 22 Mar 2020 14:59:04 +0200 Subject: lib/configuration improvements Configuration changes: - Configuration::value return type is now [[nodiscard]] - Configuration::value is now a generic template that only works with the exact types of the underlying std::variant - Add Configuration::value for standard library types compatible with the types of std::variant - Add Configuration::shortcut<> placeholder, and QAction and QKeySequence specializations as a convenient way to set up shortcuts - Deprecate setShortcut - Add Configuration::read_file convenience member that takes file path as parameter Format changes: - Configuration files can now have sections, specified as [section name]. Section names are prepended to keys. Section names cannot be nested. - Configuration files can now have @@include directives, causing another file to be read as well. The included file is not treated as nested into a section, and will overwrite values previously set. Others: - add some tests for libconfiguration. QAction/QKeySequence require a QApplication be set up, so the test application may require running xorg/wayland. old coverage: lines: 15.6% (960 out of 6172) branches: 9.9% (1187 out of 12012) new coverage: lines: 17.1% (1067 out of 6254) branches: 11.0% (1388 out of 12644) --- lib/configuration/qt_specialization.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/configuration/qt_specialization.h (limited to 'lib/configuration/qt_specialization.h') diff --git a/lib/configuration/qt_specialization.h b/lib/configuration/qt_specialization.h new file mode 100644 index 0000000..8aabf6b --- /dev/null +++ b/lib/configuration/qt_specialization.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +template <> +callable_when(unconsumed) [[nodiscard]] std::optional Configuration::value(const char *path) const; +template <> +callable_when(unconsumed) [[nodiscard]] std::optional Configuration::value(const char *path) const; + +template <> +callable_when(unconsumed) QAction &Configuration::shortcut(QAction &, const char *) const; +template <> +callable_when(unconsumed) QKeySequence &Configuration::shortcut(QKeySequence &, const char *) const; + +[[deprecated("Use Configuration::shortcut(name) instead")]] void setShortcut(QAction *action, const char *name); -- cgit v1.2.1