Skip to content

Commit 546a343

Browse files
committed
Add overload setValue(const ConfigKey& key, const QFlags<EnumType>& value)
1 parent 5e7366a commit 546a343

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/preferences/configobject.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ template <class ValueType> class ConfigObject {
164164
void setValue(const ConfigKey& key, const EnumType& value) {
165165
setValue<int>(key, static_cast<int>(value));
166166
};
167+
template<class EnumType>
168+
requires std::is_enum_v<EnumType>
169+
void setValue(const ConfigKey& key, const QFlags<EnumType>& value) {
170+
setValue<int>(key, value.toInt());
171+
}
167172

168173
// Returns the value for key, converted to ResultType. If key is not present
169174
// or the value cannot be converted to ResultType, returns ResultType().
@@ -187,6 +192,12 @@ template <class ValueType> class ConfigObject {
187192
// we need to take default_value as const ref otherwise the overload is ambiguous
188193
return static_cast<EnumType>(getValue<int>(key, static_cast<int>(default_value)));
189194
}
195+
template<typename EnumType>
196+
requires std::is_enum_v<EnumType>
197+
QFlags<EnumType> getValue(const ConfigKey& key, const QFlags<EnumType>& default_value) const {
198+
// we need to take default_value as const ref otherwise the overload is ambiguous
199+
return QFlags<EnumType>::fromInt(getValue<int>(key, default_value.toInt()));
200+
}
190201

191202
QMultiHash<ValueType, ConfigKey> transpose() const;
192203

src/waveform/waveformwidgetfactory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ void WaveformWidgetFactory::setWaveformOption(
14211421
currentOptions.setFlag(option, enabled);
14221422
// clear unsupported options
14231423
currentOptions &= supportedOptions;
1424-
m_config->setValue<int>(kWaveformOptionsKey, currentOptions);
1424+
m_config->setValue(kWaveformOptionsKey, currentOptions);
14251425
}
14261426

14271427
void WaveformWidgetFactory::resetWaveformOptions() {

0 commit comments

Comments
 (0)