From 60f18e6c3c816f4bca7c72e5a4f114787309485a Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 27 Aug 2020 12:52:48 +0100 Subject: Introduce method to query KConfigSkeletonItem default value 5.64 added an isDefault method however this doesn't suffice for usage in KConfigDialogManager which compares a current value to the default. KConfigDialogManager currently uses a hack with side effects. Exposing the value directly solves that. --- src/core/kcoreconfigskeleton.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/core/kcoreconfigskeleton.h') diff --git a/src/core/kcoreconfigskeleton.h b/src/core/kcoreconfigskeleton.h index 9cf131b2..69f52060 100644 --- a/src/core/kcoreconfigskeleton.h +++ b/src/core/kcoreconfigskeleton.h @@ -230,6 +230,12 @@ public: */ bool isSaveNeeded() const; + /** + * Returns the default value + * @since 5.74 + */ + QVariant getDefault() const; + protected: explicit KConfigSkeletonItem(KConfigSkeletonItemPrivate &dd, const QString &_group, const QString &_key); @@ -247,6 +253,7 @@ protected: // KF6: Use proper pure virtuals in KConfigSkeletonItem void setIsDefaultImpl(const std::function &impl); void setIsSaveNeededImpl(const std::function &impl); + void setGetDefaultImpl(const std::function &impl); KConfigSkeletonItemPrivate *const d_ptr; }; @@ -324,6 +331,8 @@ public: { setIsDefaultImpl([this] { return mReference == mDefault; }); setIsSaveNeededImpl([this] { return mReference != mLoadedValue; }); + setGetDefaultImpl([this] { return QVariant::fromValue(mDefault); }); + } /** -- cgit v1.2.1