forked from quickshell/quickshell
		
	dbus/dbusmenu: use bindable dbus properties
This commit is contained in:
		
							parent
							
								
									ff55ac874b
								
							
						
					
					
						commit
						f53e6fb515
					
				
					 2 changed files with 18 additions and 12 deletions
				
			
		| 
						 | 
					@ -41,12 +41,7 @@ DBusMenuItem::DBusMenuItem(qint32 id, DBusMenu* menu, DBusMenuItem* parentMenu)
 | 
				
			||||||
	QObject::connect(this, &QsMenuEntry::closed, this, &DBusMenuItem::sendClosed);
 | 
						QObject::connect(this, &QsMenuEntry::closed, this, &DBusMenuItem::sendClosed);
 | 
				
			||||||
	QObject::connect(this, &QsMenuEntry::triggered, this, &DBusMenuItem::sendTriggered);
 | 
						QObject::connect(this, &QsMenuEntry::triggered, this, &DBusMenuItem::sendTriggered);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QObject::connect(
 | 
						QObject::connect(this->menu, &DBusMenu::iconThemePathChanged, this, &DBusMenuItem::iconChanged);
 | 
				
			||||||
	    &this->menu->iconThemePath,
 | 
					 | 
				
			||||||
	    &AbstractDBusProperty::changed,
 | 
					 | 
				
			||||||
	    this,
 | 
					 | 
				
			||||||
	    &DBusMenuItem::iconChanged
 | 
					 | 
				
			||||||
	);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void DBusMenuItem::sendOpened() const { this->menu->sendEvent(this->id, "opened"); }
 | 
					void DBusMenuItem::sendOpened() const { this->menu->sendEvent(this->id, "opened"); }
 | 
				
			||||||
| 
						 | 
					@ -61,7 +56,7 @@ QString DBusMenuItem::icon() const {
 | 
				
			||||||
	if (!this->iconName.isEmpty()) {
 | 
						if (!this->iconName.isEmpty()) {
 | 
				
			||||||
		return IconImageProvider::requestString(
 | 
							return IconImageProvider::requestString(
 | 
				
			||||||
		    this->iconName,
 | 
							    this->iconName,
 | 
				
			||||||
		    this->menu->iconThemePath.get().join(':')
 | 
							    this->menu->iconThemePath.value().join(':')
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
	} else if (this->image != nullptr) {
 | 
						} else if (this->image != nullptr) {
 | 
				
			||||||
		return this->image->url();
 | 
							return this->image->url();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,6 +13,7 @@
 | 
				
			||||||
#include <qtmetamacros.h>
 | 
					#include <qtmetamacros.h>
 | 
				
			||||||
#include <qtypes.h>
 | 
					#include <qtypes.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "../../core/doc.hpp"
 | 
				
			||||||
#include "../../core/imageprovider.hpp"
 | 
					#include "../../core/imageprovider.hpp"
 | 
				
			||||||
#include "../../core/qsmenu.hpp"
 | 
					#include "../../core/qsmenu.hpp"
 | 
				
			||||||
#include "../properties.hpp"
 | 
					#include "../properties.hpp"
 | 
				
			||||||
| 
						 | 
					@ -115,11 +116,16 @@ class DBusMenu: public QObject {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	explicit DBusMenu(const QString& service, const QString& path, QObject* parent = nullptr);
 | 
						explicit DBusMenu(const QString& service, const QString& path, QObject* parent = nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dbus::DBusPropertyGroup properties;
 | 
						QS_DBUS_BINDABLE_PROPERTY_GROUP(DBusMenu, properties);
 | 
				
			||||||
	dbus::DBusProperty<quint32> version {this->properties, "Version"};
 | 
					
 | 
				
			||||||
	dbus::DBusProperty<QString> textDirection {this->properties, "TextDirection", "", false};
 | 
					signals:
 | 
				
			||||||
	dbus::DBusProperty<QString> status {this->properties, "Status"};
 | 
						QSDOC_HIDE void iconThemePathChanged();
 | 
				
			||||||
	dbus::DBusProperty<QStringList> iconThemePath {this->properties, "IconThemePath", {}, false};
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						Q_OBJECT_BINDABLE_PROPERTY(DBusMenu, quint32, version);
 | 
				
			||||||
 | 
						Q_OBJECT_BINDABLE_PROPERTY(DBusMenu, QString, textDirection);
 | 
				
			||||||
 | 
						Q_OBJECT_BINDABLE_PROPERTY(DBusMenu, QString, status);
 | 
				
			||||||
 | 
						Q_OBJECT_BINDABLE_PROPERTY(DBusMenu, QStringList, iconThemePath, &DBusMenu::iconThemePathChanged);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void prepareToShow(qint32 item, qint32 depth);
 | 
						void prepareToShow(qint32 item, qint32 depth);
 | 
				
			||||||
	void updateLayout(qint32 parent, qint32 depth);
 | 
						void updateLayout(qint32 parent, qint32 depth);
 | 
				
			||||||
| 
						 | 
					@ -141,6 +147,11 @@ private slots:
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	void updateLayoutRecursive(const DBusMenuLayout& layout, DBusMenuItem* parent, qint32 depth);
 | 
						void updateLayoutRecursive(const DBusMenuLayout& layout, DBusMenuItem* parent, qint32 depth);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						QS_DBUS_PROPERTY_BINDING(DBusMenu, pVersion, version, properties, "Version");
 | 
				
			||||||
 | 
						QS_DBUS_PROPERTY_BINDING(DBusMenu, pTextDirection, textDirection, properties, "TextDirection");
 | 
				
			||||||
 | 
						QS_DBUS_PROPERTY_BINDING(DBusMenu, pStatus, status, properties, "Status");
 | 
				
			||||||
 | 
						QS_DBUS_PROPERTY_BINDING(DBusMenu, pIconThemePath, iconThemePath, properties, "IconThemePath");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DBusMenuInterface* interface = nullptr;
 | 
						DBusMenuInterface* interface = nullptr;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue