Commit edabd67a6e716b312fcd0750a5faacf313685485
1 parent
49eda702
improved br::File boolean logic
Showing
2 changed files
with
16 additions
and
2 deletions
openbr/openbr_plugin.h
| ... | ... | @@ -239,6 +239,13 @@ struct BR_EXPORT File |
| 239 | 239 | return variant.value<T>(); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | + /*!< \brief Specialization for boolean type. */ | |
| 243 | + template <bool> | |
| 244 | + bool get(const QString &key) const | |
| 245 | + { | |
| 246 | + return getBool(key); | |
| 247 | + } | |
| 248 | + | |
| 242 | 249 | /*!< \brief Returns a value for the key, returning \em defaultValue if the key does not exist or can't be converted. */ |
| 243 | 250 | template <typename T> |
| 244 | 251 | T get(const QString &key, const T &defaultValue) const |
| ... | ... | @@ -250,6 +257,13 @@ struct BR_EXPORT File |
| 250 | 257 | } |
| 251 | 258 | |
| 252 | 259 | /*!< \brief Specialization for boolean type. */ |
| 260 | + template <bool> | |
| 261 | + bool get(const QString &key, const bool &defaultValue) const | |
| 262 | + { | |
| 263 | + return getBool(key, defaultValue); | |
| 264 | + } | |
| 265 | + | |
| 266 | + /*!< \brief Specialization for boolean type. */ | |
| 253 | 267 | bool getBool(const QString &key, bool defaultValue = false) const; |
| 254 | 268 | |
| 255 | 269 | /*!< \brief Specialization for list type. Returns a list of type T for the key, throwing an error if the key does not exist or if the value cannot be converted to the specified type. */ | ... | ... |
openbr/plugins/gallery.cpp
| ... | ... | @@ -99,12 +99,12 @@ class galGallery : public Gallery |
| 99 | 99 | void init() |
| 100 | 100 | { |
| 101 | 101 | gallery.setFileName(file); |
| 102 | - if (file.get<bool>("remove", false)) | |
| 102 | + if (file.get<bool>("remove")) | |
| 103 | 103 | gallery.remove(); |
| 104 | 104 | QtUtils::touchDir(gallery); |
| 105 | 105 | QFile::OpenMode mode = QFile::ReadWrite; |
| 106 | 106 | |
| 107 | - if (file.contains("append")) | |
| 107 | + if (file.get<bool>("append")) | |
| 108 | 108 | mode |= QFile::Append; |
| 109 | 109 | |
| 110 | 110 | if (!gallery.open(mode)) | ... | ... |