forked from quickshell/quickshell
feat: abstract out scavenger scopes
This commit is contained in:
parent
82aa7d45d3
commit
d6ed717c39
4 changed files with 74 additions and 56 deletions
|
@ -1,26 +1,7 @@
|
|||
#include "shell.hpp"
|
||||
#include <utility>
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qqmllist.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
void ShellRoot::earlyInit(QObject* old) {
|
||||
auto* oldshell = qobject_cast<ShellRoot*>(old);
|
||||
|
||||
if (oldshell != nullptr) {
|
||||
this->scavengeableChildren = std::move(oldshell->children);
|
||||
}
|
||||
}
|
||||
|
||||
QObject* ShellRoot::scavengeTargetFor(QObject* /* child */) {
|
||||
if (this->scavengeableChildren.length() > this->children.length()) {
|
||||
return this->scavengeableChildren[this->children.length()];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ShellRoot::setConfig(ShellConfig config) {
|
||||
this->mConfig = config;
|
||||
|
||||
|
@ -28,22 +9,3 @@ void ShellRoot::setConfig(ShellConfig config) {
|
|||
}
|
||||
|
||||
ShellConfig ShellRoot::config() const { return this->mConfig; }
|
||||
|
||||
QQmlListProperty<QObject> ShellRoot::components() {
|
||||
return QQmlListProperty<QObject>(
|
||||
this,
|
||||
nullptr,
|
||||
&ShellRoot::appendComponent,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr
|
||||
);
|
||||
}
|
||||
|
||||
void ShellRoot::appendComponent(QQmlListProperty<QObject>* list, QObject* component) {
|
||||
auto* shell = static_cast<ShellRoot*>(list->object); // NOLINT
|
||||
component->setParent(shell);
|
||||
shell->children.append(component);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue