diff --git a/ui/ui_utility.h b/ui/ui_utility.h index 4a1ce5e..6a76a62 100644 --- a/ui/ui_utility.h +++ b/ui/ui_utility.h @@ -24,23 +24,11 @@ class object_ptr; namespace Ui { namespace details { -struct ForwardTag { -}; - -struct InPlaceTag { -}; - template class AttachmentOwner : public QObject { public: - template - AttachmentOwner(QObject *parent, const ForwardTag&, OtherValue &&value) - : QObject(parent) - , _value(std::forward(value)) { - } - template - AttachmentOwner(QObject *parent, const InPlaceTag&, Args &&...args) + AttachmentOwner(QObject *parent, Args &&...args) : QObject(parent) , _value(std::forward(args)...) { } @@ -56,6 +44,15 @@ private: } // namespace details +template +inline not_null>*> WrapAsQObject( + not_null parent, + Value &&value) { + return CreateChild>>( + parent.get(), + std::forward(value)); +} + template inline base::unique_qptr CreateObject(Args &&...args) { return base::make_unique_q( @@ -74,7 +71,6 @@ inline Value *CreateChild( } else { return CreateChild>( parent, - details::InPlaceTag{}, std::forward(args)...)->value(); } } @@ -92,10 +88,7 @@ template inline not_null*> AttachAsChild( not_null parent, Value &&value) { - return CreateChild>>( - parent.get(), - details::ForwardTag{}, - std::forward(value))->value(); + return WrapAsQObject(parent, std::forward(value))->value(); } [[nodiscard]] bool AppInFocus();