forked from quickshell/quickshell
		
	dbus/properties: remove non bindable based dbus property impl
This commit is contained in:
		
							parent
							
								
									324fe9274d
								
							
						
					
					
						commit
						ec143d6119
					
				
					 2 changed files with 0 additions and 115 deletions
				
			
		| 
						 | 
				
			
			@ -110,24 +110,6 @@ void asyncReadPropertyInternal(
 | 
			
		|||
	QObject::connect(call, &QDBusPendingCallWatcher::finished, &interface, responseCallback);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AbstractDBusProperty::update() {
 | 
			
		||||
	if (this->group == nullptr) {
 | 
			
		||||
		qFatal(logDbusProperties) << "Tried to update dbus property" << this->nameRef()
 | 
			
		||||
		                          << "which is not attached to a group";
 | 
			
		||||
	} else {
 | 
			
		||||
		this->group->requestPropertyUpdate(this);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void AbstractDBusProperty::write() {
 | 
			
		||||
	if (this->group == nullptr) {
 | 
			
		||||
		qFatal(logDbusProperties) << "Tried to write dbus property" << this->nameRef()
 | 
			
		||||
		                          << "which is not attached to a group";
 | 
			
		||||
	} else {
 | 
			
		||||
		this->group->pushPropertyUpdate(this);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DBusPropertyGroup::DBusPropertyGroup(QVector<DBusPropertyCore*> properties, QObject* parent)
 | 
			
		||||
    : QObject(parent)
 | 
			
		||||
    , properties(std::move(properties)) {}
 | 
			
		||||
| 
						 | 
				
			
			@ -157,11 +139,6 @@ void DBusPropertyGroup::setInterface(QDBusAbstractInterface* interface) {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DBusPropertyGroup::attachProperty(AbstractDBusProperty* property) {
 | 
			
		||||
	this->properties.append(property);
 | 
			
		||||
	property->group = this;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void DBusPropertyGroup::attachProperty(DBusPropertyCore* property) {
 | 
			
		||||
	this->properties.append(property);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -325,8 +302,6 @@ QString DBusPropertyGroup::propertyString(const DBusPropertyCore* property) cons
 | 
			
		|||
	return this->toString() % ':' % property->nameRef();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString AbstractDBusProperty::toString() const { return this->group->propertyString(this); }
 | 
			
		||||
 | 
			
		||||
void DBusPropertyGroup::onPropertiesChanged(
 | 
			
		||||
    const QString& interfaceName,
 | 
			
		||||
    const QVariantMap& changedProperties,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -104,40 +104,6 @@ private:
 | 
			
		|||
	friend class DBusPropertyGroup;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class AbstractDBusProperty
 | 
			
		||||
    : public QObject
 | 
			
		||||
    , public DBusPropertyCore {
 | 
			
		||||
	Q_OBJECT;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	explicit AbstractDBusProperty(QString name, bool required, QObject* parent = nullptr)
 | 
			
		||||
	    : QObject(parent)
 | 
			
		||||
	    , required(required)
 | 
			
		||||
	    , mName(std::move(name)) {}
 | 
			
		||||
 | 
			
		||||
	[[nodiscard]] QString name() const override { return this->mName; };
 | 
			
		||||
	[[nodiscard]] QStringView nameRef() const override { return this->mName; };
 | 
			
		||||
	[[nodiscard]] bool isRequired() const override { return this->required; };
 | 
			
		||||
 | 
			
		||||
	[[nodiscard]] QString toString() const;
 | 
			
		||||
 | 
			
		||||
public slots:
 | 
			
		||||
	void update();
 | 
			
		||||
	void write();
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
	void changed();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	bool required : 1;
 | 
			
		||||
	bool mExists : 1 = false;
 | 
			
		||||
 | 
			
		||||
	DBusPropertyGroup* group = nullptr;
 | 
			
		||||
	QString mName;
 | 
			
		||||
 | 
			
		||||
	friend class DBusPropertyGroup;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Default implementation with no transformation
 | 
			
		||||
template <typename T>
 | 
			
		||||
struct DBusDataTransform {
 | 
			
		||||
| 
						 | 
				
			
			@ -265,7 +231,6 @@ public:
 | 
			
		|||
	explicit DBusPropertyGroup(QObject* parent): DBusPropertyGroup({}, parent) {}
 | 
			
		||||
 | 
			
		||||
	void setInterface(QDBusAbstractInterface* interface);
 | 
			
		||||
	void attachProperty(AbstractDBusProperty* property);
 | 
			
		||||
	void attachProperty(DBusPropertyCore* property);
 | 
			
		||||
	void updateAllDirect();
 | 
			
		||||
	void updateAllViaGetAll();
 | 
			
		||||
| 
						 | 
				
			
			@ -297,61 +262,6 @@ private:
 | 
			
		|||
	friend class AbstractDBusProperty;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <typename T>
 | 
			
		||||
class DBusProperty: public AbstractDBusProperty {
 | 
			
		||||
public:
 | 
			
		||||
	explicit DBusProperty(
 | 
			
		||||
	    QString name,
 | 
			
		||||
	    T value = T(),
 | 
			
		||||
	    bool required = true,
 | 
			
		||||
	    QObject* parent = nullptr
 | 
			
		||||
	)
 | 
			
		||||
	    : AbstractDBusProperty(std::move(name), required, parent)
 | 
			
		||||
	    , value(std::move(value)) {}
 | 
			
		||||
 | 
			
		||||
	explicit DBusProperty(
 | 
			
		||||
	    DBusPropertyGroup& group,
 | 
			
		||||
	    QString name,
 | 
			
		||||
	    T value = T(),
 | 
			
		||||
	    bool required = true,
 | 
			
		||||
	    QObject* parent = nullptr
 | 
			
		||||
	)
 | 
			
		||||
	    : DBusProperty(std::move(name), std::move(value), required, parent) {
 | 
			
		||||
		group.attachProperty(this);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[[nodiscard]] QString valueString() override {
 | 
			
		||||
		QString str;
 | 
			
		||||
		QDebug(&str) << this->value;
 | 
			
		||||
		return str;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	[[nodiscard]] const T& get() const { return this->value; }
 | 
			
		||||
 | 
			
		||||
	void set(T value) {
 | 
			
		||||
		this->value = std::move(value);
 | 
			
		||||
		emit this->changed();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
	QDBusError store(const QVariant& variant) override {
 | 
			
		||||
		auto result = demarshallVariant<T>(variant);
 | 
			
		||||
 | 
			
		||||
		if (result.isValid()) {
 | 
			
		||||
			this->set(std::move(result.value));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return result.error;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	QVariant serialize() override { return QVariant::fromValue(this->value); }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	T value;
 | 
			
		||||
 | 
			
		||||
	friend class DBusPropertyCore;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // namespace qs::dbus
 | 
			
		||||
 | 
			
		||||
// NOLINTBEGIN
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue