init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s

This commit is contained in:
allhaileris
2026-02-16 15:50:16 +03:00
commit afb81b8278
13816 changed files with 3689732 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
// This file is part of Desktop App Toolkit,
// a set of libraries for developing nice desktop applications.
//
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
#pragma once
#include <QtWidgets/QWidget>
namespace Ui {
namespace details {
template <typename Value>
class AttachmentOwner : public QObject {
public:
template <typename ...Args>
AttachmentOwner(QObject *parent, Args &&...args)
: QObject(parent)
, _value(std::forward<Args>(args)...) {
}
gsl::not_null<Value*> value() {
return &_value;
}
private:
Value _value;
};
} // namespace details
template <typename Value, typename Parent, typename ...Args>
inline Value *CreateChild(
Parent parent,
Args &&...args) {
if constexpr (std::is_pointer_v<Parent>) {
Expects(parent != nullptr);
if constexpr (std::is_base_of_v<QObject, Value>) {
return new Value(parent, std::forward<Args>(args)...);
} else {
return CreateChild<details::AttachmentOwner<Value>>(
parent,
std::forward<Args>(args)...)->value();
}
} else if constexpr (requires(const Parent & t) { t.get(); }) {
return new Value(parent.get(), std::forward<Args>(args)...);
} else {
static_assert(requires(const Parent &t) { t.data(); });
return new Value(parent.data(), std::forward<Args>(args)...);
}
}
template <typename Value>
inline gsl::not_null<details::AttachmentOwner<std::decay_t<Value>>*> WrapAsQObject(
gsl::not_null<QObject*> parent,
Value &&value) {
return CreateChild<details::AttachmentOwner<std::decay_t<Value>>>(
parent.get(),
std::forward<Value>(value));
}
} // namespace Ui