forked from quickshell/quickshell
		
	core/util: add experimental member macros
An experiment that should reduce boilerplate for properties that just access a backing value. Code also exists for using it as an interface for other properties as well, but isn't currently in use.
This commit is contained in:
		
							parent
							
								
									8873a06962
								
							
						
					
					
						commit
						ba1e535f9c
					
				
					 6 changed files with 236 additions and 185 deletions
				
			
		| 
						 | 
					@ -3,8 +3,8 @@
 | 
				
			||||||
#include <qdebug.h>
 | 
					#include <qdebug.h>
 | 
				
			||||||
#include <qnamespace.h>
 | 
					#include <qnamespace.h>
 | 
				
			||||||
#include <qpoint.h>
 | 
					#include <qpoint.h>
 | 
				
			||||||
#include <qrect.h>
 | 
					 | 
				
			||||||
#include <qqmlintegration.h>
 | 
					#include <qqmlintegration.h>
 | 
				
			||||||
 | 
					#include <qrect.h>
 | 
				
			||||||
#include <qtmetamacros.h>
 | 
					#include <qtmetamacros.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Box {
 | 
					class Box {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
 | 
					#include <type_traits>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// NOLINTBEGIN
 | 
					// NOLINTBEGIN
 | 
				
			||||||
#define DROP_EMIT(object, func)                                                                    \
 | 
					#define DROP_EMIT(object, func)                                                                    \
 | 
				
			||||||
| 
						 | 
					@ -14,34 +15,6 @@
 | 
				
			||||||
		object->member = local;                                                                        \
 | 
							object->member = local;                                                                        \
 | 
				
			||||||
		signal = DROP_EMIT(object, signal);                                                            \
 | 
							signal = DROP_EMIT(object, signal);                                                            \
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// generic accessor declarations
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define GDECL_GETTER(type, name) [[nodiscard]] type name() const
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define GDEF_GETTER(class, type, member, name)                                                     \
 | 
					 | 
				
			||||||
	type class::name() const { return this->member; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define GDECL_SETTER(type, name) DropEmitter name(type value)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define GDEF_SETTER(class, type, member, name, signal)                                             \
 | 
					 | 
				
			||||||
	DropEmitter class ::name(type value) {                                                           \
 | 
					 | 
				
			||||||
		if (value == this->member) return DropEmitter();                                               \
 | 
					 | 
				
			||||||
		this->member = value;                                                                          \
 | 
					 | 
				
			||||||
		return DROP_EMIT(this, signal);                                                                \
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define GDECL_MEMBER(type, getter, setter)                                                         \
 | 
					 | 
				
			||||||
	GDECL_GETTER(type, getter)                                                             \
 | 
					 | 
				
			||||||
	GDECL_SETTER(type, setter)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define GDEF_MEMBER(class, type, member, getter, setter, signal)                                   \
 | 
					 | 
				
			||||||
	GDEF_GETTER(class, type, member, getter)                                               \
 | 
					 | 
				
			||||||
	GDEF_SETTER(class, type, member, setter, signal)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define GDEF_MEMBER_S(class, type, lower, upper)                                         \
 | 
					 | 
				
			||||||
	GDEF_MEMBER(class, type, m##upper, lower, set##upper, lower##Changed)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// NOLINTEND
 | 
					// NOLINTEND
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class DropEmitter {
 | 
					class DropEmitter {
 | 
				
			||||||
| 
						 | 
					@ -75,7 +48,125 @@ public:
 | 
				
			||||||
		this->object = nullptr;
 | 
							this->object = nullptr;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// orders calls for multiple emitters (instead of reverse definition order)
 | 
				
			||||||
 | 
						template <typename... Args>
 | 
				
			||||||
 | 
						static void call(Args&... args) {
 | 
				
			||||||
 | 
							(args.call(), ...);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	void* object = nullptr;
 | 
						void* object = nullptr;
 | 
				
			||||||
	void (*signal)(void*) = nullptr;
 | 
						void (*signal)(void*) = nullptr;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// NOLINTBEGIN
 | 
				
			||||||
 | 
					#define DECLARE_MEMBER(class, name, member, signal)                                                \
 | 
				
			||||||
 | 
						using M_##name = MemberMetadata<&class ::member, &class ::signal>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DECLARE_MEMBER_NS(class, name, member) using M_##name = MemberMetadata<&class ::member>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DECLARE_MEMBER_GET(name) [[nodiscard]] M_##name::Ref name() const
 | 
				
			||||||
 | 
					#define DECLARE_MEMBER_SET(name, setter) M_##name::Ret setter(M_##name::Ref value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DECLARE_MEMBER_GETSET(name, setter)                                                        \
 | 
				
			||||||
 | 
						DECLARE_MEMBER_GET(name);                                                                        \
 | 
				
			||||||
 | 
						DECLARE_MEMBER_SET(name, setter)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DECLARE_MEMBER_FULL(class, name, setter, member, signal)                                   \
 | 
				
			||||||
 | 
						DECLARE_MEMBER(class, name, member, signal);                                                     \
 | 
				
			||||||
 | 
						DECLARE_MEMBER_GETSET(name, setter)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DECLARE_MEMBER_WITH_GET(class, name, member, signal)                                       \
 | 
				
			||||||
 | 
						DECLARE_MEMBER(class, name, member, signal);                                                     \
 | 
				
			||||||
 | 
					                                                                                                   \
 | 
				
			||||||
 | 
					public:                                                                                            \
 | 
				
			||||||
 | 
						DECLARE_MEMBER_GET(name);                                                                        \
 | 
				
			||||||
 | 
					                                                                                                   \
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DECLARE_PRIVATE_MEMBER(class, name, setter, member, signal)                                \
 | 
				
			||||||
 | 
						DECLARE_MEMBER_WITH_GET(class, name, member, signal);                                            \
 | 
				
			||||||
 | 
						DECLARE_MEMBER_SET(name, setter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DECLARE_PMEMBER(type, name) using M_##name = PseudomemberMetadata<type, true>;
 | 
				
			||||||
 | 
					#define DECLARE_PMEMBER_NS(type, name) using M_##name = PseudomemberMetadata<type, false>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DECLARE_PMEMBER_FULL(type, name, setter)                                                   \
 | 
				
			||||||
 | 
						DECLARE_PMEMBER(type, name);                                                                     \
 | 
				
			||||||
 | 
						DECLARE_MEMBER_GETSET(name, setter)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DECLARE_PMEMBER_WITH_GET(type, name)                                                       \
 | 
				
			||||||
 | 
						DECLARE_PMEMBER(type, name);                                                                     \
 | 
				
			||||||
 | 
					                                                                                                   \
 | 
				
			||||||
 | 
					public:                                                                                            \
 | 
				
			||||||
 | 
						DECLARE_MEMBER_GET(name);                                                                        \
 | 
				
			||||||
 | 
					                                                                                                   \
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DECLARE_PRIVATE_PMEMBER(type, name, setter)                                                \
 | 
				
			||||||
 | 
						DECLARE_PMEMBER_WITH_GET(type, name);                                                            \
 | 
				
			||||||
 | 
						DECLARE_MEMBER_SET(name, setter);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DEFINE_PMEMBER_GET_M(Class, Member, name) Member::Ref Class::name() const
 | 
				
			||||||
 | 
					#define DEFINE_PMEMBER_GET(Class, name) DEFINE_PMEMBER_GET_M(Class, Class::M_##name, name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DEFINE_MEMBER_GET_M(Class, Member, name)                                                   \
 | 
				
			||||||
 | 
						DEFINE_PMEMBER_GET_M(Class, Member, name) { return Member::get(this); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DEFINE_MEMBER_GET(Class, name) DEFINE_MEMBER_GET_M(Class, Class::M_##name, name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DEFINE_MEMBER_SET_M(Class, Member, setter)                                                 \
 | 
				
			||||||
 | 
						Member::Ret Class::setter(Member::Ref value) { return Member::set(this, value); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DEFINE_MEMBER_SET(Class, name, setter) DEFINE_MEMBER_SET_M(Class, Class::M_##name, setter)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define DEFINE_MEMBER_GETSET(Class, name, setter)                                                  \
 | 
				
			||||||
 | 
						DEFINE_MEMBER_GET(Class, name)                                                                   \
 | 
				
			||||||
 | 
						DEFINE_MEMBER_SET(Class, name, setter)
 | 
				
			||||||
 | 
					// NOLINTEND
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename T>
 | 
				
			||||||
 | 
					class MemberPointerTraits;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <typename T, typename C>
 | 
				
			||||||
 | 
					class MemberPointerTraits<T C::*> {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						using Class = C;
 | 
				
			||||||
 | 
						using Type = T;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <auto member, auto signal = nullptr>
 | 
				
			||||||
 | 
					class MemberMetadata {
 | 
				
			||||||
 | 
						using Traits = MemberPointerTraits<decltype(member)>;
 | 
				
			||||||
 | 
						using Class = Traits::Class;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						using Type = Traits::Type;
 | 
				
			||||||
 | 
						using Ref = const Type&;
 | 
				
			||||||
 | 
						using Ret = std::conditional_t<signal == nullptr, void, DropEmitter>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static Ref get(const Class* obj) { return obj->*member; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static Ret set(Class* obj, Ref value) {
 | 
				
			||||||
 | 
							if constexpr (signal == nullptr) {
 | 
				
			||||||
 | 
								if (MemberMetadata::get(obj) == value) return;
 | 
				
			||||||
 | 
								obj->*member = value;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								if (MemberMetadata::get(obj) == value) return DropEmitter();
 | 
				
			||||||
 | 
								obj->*member = value;
 | 
				
			||||||
 | 
								return DropEmitter(obj, &MemberMetadata::emitForObject);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						static void emitForObject(Class* obj) { (obj->*signal)(); }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// allows use of member macros without an actual field backing them
 | 
				
			||||||
 | 
					template <typename T, bool hasSignal>
 | 
				
			||||||
 | 
					class PseudomemberMetadata {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						using Type = T;
 | 
				
			||||||
 | 
						using Ref = const Type&;
 | 
				
			||||||
 | 
						using Ret = std::conditional_t<hasSignal, DropEmitter, void>;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,4 @@
 | 
				
			||||||
#include "player.hpp"
 | 
					#include "player.hpp"
 | 
				
			||||||
#include <utility>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <qcontainerfwd.h>
 | 
					#include <qcontainerfwd.h>
 | 
				
			||||||
#include <qdatetime.h>
 | 
					#include <qdatetime.h>
 | 
				
			||||||
| 
						 | 
					@ -12,7 +11,7 @@
 | 
				
			||||||
#include <qtmetamacros.h>
 | 
					#include <qtmetamacros.h>
 | 
				
			||||||
#include <qtypes.h>
 | 
					#include <qtypes.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "../../core/types.hpp"
 | 
					#include "../../core/util.hpp"
 | 
				
			||||||
#include "../../dbus/properties.hpp"
 | 
					#include "../../dbus/properties.hpp"
 | 
				
			||||||
#include "dbus_player.h"
 | 
					#include "dbus_player.h"
 | 
				
			||||||
#include "dbus_player_app.h"
 | 
					#include "dbus_player_app.h"
 | 
				
			||||||
| 
						 | 
					@ -167,8 +166,8 @@ bool MprisPlayer::canQuit() const { return this->pCanQuit.get(); }
 | 
				
			||||||
bool MprisPlayer::canRaise() const { return this->pCanRaise.get(); }
 | 
					bool MprisPlayer::canRaise() const { return this->pCanRaise.get(); }
 | 
				
			||||||
bool MprisPlayer::canSetFullscreen() const { return this->pCanSetFullscreen.get(); }
 | 
					bool MprisPlayer::canSetFullscreen() const { return this->pCanSetFullscreen.get(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString MprisPlayer::identity() const { return this->pIdentity.get(); }
 | 
					const QString& MprisPlayer::identity() const { return this->pIdentity.get(); }
 | 
				
			||||||
QString MprisPlayer::desktopEntry() const { return this->pDesktopEntry.get(); }
 | 
					const QString& MprisPlayer::desktopEntry() const { return this->pDesktopEntry.get(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
qlonglong MprisPlayer::positionMs() const {
 | 
					qlonglong MprisPlayer::positionMs() const {
 | 
				
			||||||
	if (!this->positionSupported()) return 0; // unsupported
 | 
						if (!this->positionSupported()) return 0; // unsupported
 | 
				
			||||||
| 
						 | 
					@ -256,13 +255,7 @@ void MprisPlayer::setVolume(qreal volume) {
 | 
				
			||||||
	this->pVolume.write();
 | 
						this->pVolume.write();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
quint32 MprisPlayer::uniqueId() const { return this->mUniqueId; }
 | 
					const QVariantMap& MprisPlayer::metadata() const { return this->pMetadata.get(); }
 | 
				
			||||||
QVariantMap MprisPlayer::metadata() const { return this->pMetadata.get(); }
 | 
					 | 
				
			||||||
QString MprisPlayer::trackTitle() const { return this->mTrackTitle; }
 | 
					 | 
				
			||||||
QString MprisPlayer::trackAlbum() const { return this->mTrackAlbum; }
 | 
					 | 
				
			||||||
QString MprisPlayer::trackAlbumArtist() const { return this->mTrackAlbumArtist; }
 | 
					 | 
				
			||||||
QVector<QString> MprisPlayer::trackArtists() const { return this->mTrackArtists; }
 | 
					 | 
				
			||||||
QString MprisPlayer::trackArtUrl() const { return this->mTrackArtUrl; }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MprisPlayer::onMetadataChanged() {
 | 
					void MprisPlayer::onMetadataChanged() {
 | 
				
			||||||
	emit this->metadataChanged();
 | 
						emit this->metadataChanged();
 | 
				
			||||||
| 
						 | 
					@ -273,7 +266,7 @@ void MprisPlayer::onMetadataChanged() {
 | 
				
			||||||
		length = lengthVariant.value<qlonglong>();
 | 
							length = lengthVariant.value<qlonglong>();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto emitLengthChanged = this->setLength(length);
 | 
						auto lengthChanged = this->setLength(length);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto trackChanged = false;
 | 
						auto trackChanged = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -298,45 +291,20 @@ void MprisPlayer::onMetadataChanged() {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DropEmitter emitTrackTitle;
 | 
						auto trackTitle = this->pMetadata.get().value("xesam:title").toString();
 | 
				
			||||||
	auto trackTitle = this->pMetadata.get().value("xesam:title");
 | 
						auto trackTitleChanged = this->setTrackTitle(trackTitle.isNull() ? "Unknown Track" : trackTitle);
 | 
				
			||||||
	if (trackTitle.isValid() && trackTitle.canConvert<QString>()) {
 | 
					 | 
				
			||||||
		emitTrackTitle = this->setTrackTitle(trackTitle.toString());
 | 
					 | 
				
			||||||
	} else if (trackChanged) {
 | 
					 | 
				
			||||||
		emitTrackTitle = this->setTrackTitle("Unknown Track");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DropEmitter emitTrackAlbum;
 | 
						auto trackArtists = this->pMetadata.get().value("xesam:artist").value<QVector<QString>>();
 | 
				
			||||||
	auto trackAlbum = this->pMetadata.get().value("xesam:album");
 | 
						auto trackArtistsChanged = this->setTrackArtists(trackArtists);
 | 
				
			||||||
	if (trackAlbum.isValid() && trackAlbum.canConvert<QString>()) {
 | 
					 | 
				
			||||||
		emitTrackAlbum = this->setTrackAlbum(trackAlbum.toString());
 | 
					 | 
				
			||||||
	} else if (trackChanged) {
 | 
					 | 
				
			||||||
		emitTrackAlbum = this->setTrackAlbum("Unknown Album");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DropEmitter emitTrackAlbumArtist;
 | 
						auto trackAlbum = this->pMetadata.get().value("xesam:album").toString();
 | 
				
			||||||
	auto trackAlbumArtist = this->pMetadata.get().value("xesam:albumArtist");
 | 
						auto trackAlbumChanged = this->setTrackAlbum(trackAlbum.isNull() ? "Unknown Album" : trackAlbum);
 | 
				
			||||||
	if (trackAlbumArtist.isValid() && trackAlbumArtist.canConvert<QString>()) {
 | 
					 | 
				
			||||||
		emitTrackAlbumArtist = this->setTrackAlbumArtist(trackAlbumArtist.toString());
 | 
					 | 
				
			||||||
	} else if (trackChanged) {
 | 
					 | 
				
			||||||
		emitTrackAlbumArtist = this->setTrackAlbumArtist("Unknown Artist");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DropEmitter emitTrackArtists;
 | 
						auto trackAlbumArtist = this->pMetadata.get().value("xesam:albumArtist").toString();
 | 
				
			||||||
	auto trackArtists = this->pMetadata.get().value("xesam:artist");
 | 
						auto trackAlbumArtistChanged = this->setTrackAlbumArtist(trackAlbumArtist);
 | 
				
			||||||
	if (trackArtists.isValid() && trackArtists.canConvert<QVector<QString>>()) {
 | 
					 | 
				
			||||||
		emitTrackArtists = this->setTrackArtists(trackArtists.value<QVector<QString>>());
 | 
					 | 
				
			||||||
	} else if (trackChanged) {
 | 
					 | 
				
			||||||
		emitTrackArtists = this->setTrackArtists({});
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DropEmitter emitTrackArtUrl;
 | 
						auto trackArtUrl = this->pMetadata.get().value("mpris:artUrl").toString();
 | 
				
			||||||
	auto trackArtUrl = this->pMetadata.get().value("mpris:artUrl");
 | 
						auto trackArtUrlChanged = this->setTrackArtUrl(trackArtUrl);
 | 
				
			||||||
	if (trackArtUrl.isValid() && trackArtUrl.canConvert<QString>()) {
 | 
					 | 
				
			||||||
		emitTrackArtUrl = this->setTrackArtUrl(trackArtUrl.toString());
 | 
					 | 
				
			||||||
	} else if (trackChanged) {
 | 
					 | 
				
			||||||
		emitTrackArtUrl = this->setTrackArtUrl("");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (trackChanged) {
 | 
						if (trackChanged) {
 | 
				
			||||||
		this->mUniqueId++;
 | 
							this->mUniqueId++;
 | 
				
			||||||
| 
						 | 
					@ -344,49 +312,25 @@ void MprisPlayer::onMetadataChanged() {
 | 
				
			||||||
		this->pPosition.update();
 | 
							this->pPosition.update();
 | 
				
			||||||
		emit this->trackChanged();
 | 
							emit this->trackChanged();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						DropEmitter::call(
 | 
				
			||||||
 | 
						    trackTitleChanged,
 | 
				
			||||||
 | 
						    trackArtistsChanged,
 | 
				
			||||||
 | 
						    trackAlbumChanged,
 | 
				
			||||||
 | 
						    trackAlbumArtistChanged,
 | 
				
			||||||
 | 
						    trackArtUrlChanged,
 | 
				
			||||||
 | 
						    lengthChanged
 | 
				
			||||||
 | 
						);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DropEmitter MprisPlayer::setLength(qlonglong length) {
 | 
					DEFINE_MEMBER_GET(MprisPlayer, uniqueId);
 | 
				
			||||||
	if (length == this->mLength) return DropEmitter();
 | 
					DEFINE_MEMBER_SET(MprisPlayer, length, setLength);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	this->mLength = length;
 | 
					DEFINE_MEMBER_GETSET(MprisPlayer, trackTitle, setTrackTitle);
 | 
				
			||||||
	return DROP_EMIT(this, lengthChanged);
 | 
					DEFINE_MEMBER_GETSET(MprisPlayer, trackArtists, setTrackArtists);
 | 
				
			||||||
}
 | 
					DEFINE_MEMBER_GETSET(MprisPlayer, trackAlbum, setTrackAlbum);
 | 
				
			||||||
 | 
					DEFINE_MEMBER_GETSET(MprisPlayer, trackAlbumArtist, setTrackAlbumArtist);
 | 
				
			||||||
DropEmitter MprisPlayer::setTrackTitle(QString title) {
 | 
					DEFINE_MEMBER_GETSET(MprisPlayer, trackArtUrl, setTrackArtUrl);
 | 
				
			||||||
	if (title == this->mTrackTitle) return DropEmitter();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	this->mTrackTitle = std::move(title);
 | 
					 | 
				
			||||||
	return DROP_EMIT(this, trackTitleChanged);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
DropEmitter MprisPlayer::setTrackAlbum(QString album) {
 | 
					 | 
				
			||||||
	if (album == this->mTrackAlbum) return DropEmitter();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	this->mTrackAlbum = std::move(album);
 | 
					 | 
				
			||||||
	return DROP_EMIT(this, trackAlbumChanged);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
DropEmitter MprisPlayer::setTrackAlbumArtist(QString albumArtist) {
 | 
					 | 
				
			||||||
	if (albumArtist == this->mTrackAlbumArtist) return DropEmitter();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	this->mTrackAlbumArtist = std::move(albumArtist);
 | 
					 | 
				
			||||||
	return DROP_EMIT(this, trackAlbumArtistChanged);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
DropEmitter MprisPlayer::setTrackArtists(QVector<QString> artists) {
 | 
					 | 
				
			||||||
	if (artists == this->mTrackArtists) return DropEmitter();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	this->mTrackArtists = std::move(artists);
 | 
					 | 
				
			||||||
	return DROP_EMIT(this, trackArtistsChanged);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
DropEmitter MprisPlayer::setTrackArtUrl(QString artUrl) {
 | 
					 | 
				
			||||||
	if (artUrl == this->mTrackArtUrl) return DropEmitter();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	this->mTrackArtUrl = std::move(artUrl);
 | 
					 | 
				
			||||||
	return DROP_EMIT(this, trackArtUrlChanged);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
MprisPlaybackState::Enum MprisPlayer::playbackState() const { return this->mPlaybackState; }
 | 
					MprisPlaybackState::Enum MprisPlayer::playbackState() const { return this->mPlaybackState; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -426,9 +370,7 @@ void MprisPlayer::setPlaybackState(MprisPlaybackState::Enum playbackState) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MprisPlayer::play() { this->setPlaybackState(MprisPlaybackState::Playing); }
 | 
					void MprisPlayer::play() { this->setPlaybackState(MprisPlaybackState::Playing); }
 | 
				
			||||||
 | 
					 | 
				
			||||||
void MprisPlayer::pause() { this->setPlaybackState(MprisPlaybackState::Paused); }
 | 
					void MprisPlayer::pause() { this->setPlaybackState(MprisPlaybackState::Paused); }
 | 
				
			||||||
 | 
					 | 
				
			||||||
void MprisPlayer::stop() { this->setPlaybackState(MprisPlaybackState::Stopped); }
 | 
					void MprisPlayer::stop() { this->setPlaybackState(MprisPlaybackState::Stopped); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MprisPlayer::togglePlaying() {
 | 
					void MprisPlayer::togglePlaying() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,7 +7,7 @@
 | 
				
			||||||
#include <qtypes.h>
 | 
					#include <qtypes.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "../../core/doc.hpp"
 | 
					#include "../../core/doc.hpp"
 | 
				
			||||||
#include "../../core/types.hpp"
 | 
					#include "../../core/util.hpp"
 | 
				
			||||||
#include "../../dbus/properties.hpp"
 | 
					#include "../../dbus/properties.hpp"
 | 
				
			||||||
#include "dbus_player.h"
 | 
					#include "dbus_player.h"
 | 
				
			||||||
#include "dbus_player_app.h"
 | 
					#include "dbus_player_app.h"
 | 
				
			||||||
| 
						 | 
					@ -239,8 +239,8 @@ public:
 | 
				
			||||||
	[[nodiscard]] bool canRaise() const;
 | 
						[[nodiscard]] bool canRaise() const;
 | 
				
			||||||
	[[nodiscard]] bool canSetFullscreen() const;
 | 
						[[nodiscard]] bool canSetFullscreen() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] QString identity() const;
 | 
						[[nodiscard]] const QString& identity() const;
 | 
				
			||||||
	[[nodiscard]] QString desktopEntry() const;
 | 
						[[nodiscard]] const QString& desktopEntry() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] qlonglong positionMs() const;
 | 
						[[nodiscard]] qlonglong positionMs() const;
 | 
				
			||||||
	[[nodiscard]] qreal position() const;
 | 
						[[nodiscard]] qreal position() const;
 | 
				
			||||||
| 
						 | 
					@ -254,13 +254,7 @@ public:
 | 
				
			||||||
	[[nodiscard]] bool volumeSupported() const;
 | 
						[[nodiscard]] bool volumeSupported() const;
 | 
				
			||||||
	void setVolume(qreal volume);
 | 
						void setVolume(qreal volume);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] quint32 uniqueId() const;
 | 
						[[nodiscard]] const QVariantMap& metadata() const;
 | 
				
			||||||
	[[nodiscard]] QVariantMap metadata() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QString trackTitle() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QString trackAlbum() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QString trackAlbumArtist() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QVector<QString> trackArtists() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QString trackArtUrl() const;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] MprisPlaybackState::Enum playbackState() const;
 | 
						[[nodiscard]] MprisPlaybackState::Enum playbackState() const;
 | 
				
			||||||
	void setPlaybackState(MprisPlaybackState::Enum playbackState);
 | 
						void setPlaybackState(MprisPlaybackState::Enum playbackState);
 | 
				
			||||||
| 
						 | 
					@ -338,13 +332,6 @@ private slots:
 | 
				
			||||||
	void onLoopStatusChanged();
 | 
						void onLoopStatusChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	DropEmitter setLength(qlonglong length);
 | 
					 | 
				
			||||||
	DropEmitter setTrackTitle(QString title);
 | 
					 | 
				
			||||||
	DropEmitter setTrackAlbum(QString album);
 | 
					 | 
				
			||||||
	DropEmitter setTrackAlbumArtist(QString albumArtist);
 | 
					 | 
				
			||||||
	DropEmitter setTrackArtists(QVector<QString> artists);
 | 
					 | 
				
			||||||
	DropEmitter setTrackArtUrl(QString artUrl);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// clang-format off
 | 
						// clang-format off
 | 
				
			||||||
	dbus::DBusPropertyGroup appProperties;
 | 
						dbus::DBusPropertyGroup appProperties;
 | 
				
			||||||
	dbus::DBusProperty<QString> pIdentity {this->appProperties, "Identity"};
 | 
						dbus::DBusProperty<QString> pIdentity {this->appProperties, "Identity"};
 | 
				
			||||||
| 
						 | 
					@ -386,10 +373,26 @@ private:
 | 
				
			||||||
	QString mTrackId;
 | 
						QString mTrackId;
 | 
				
			||||||
	QString mTrackUrl;
 | 
						QString mTrackUrl;
 | 
				
			||||||
	QString mTrackTitle;
 | 
						QString mTrackTitle;
 | 
				
			||||||
 | 
						QVector<QString> mTrackArtists;
 | 
				
			||||||
	QString mTrackAlbum;
 | 
						QString mTrackAlbum;
 | 
				
			||||||
	QString mTrackAlbumArtist;
 | 
						QString mTrackAlbumArtist;
 | 
				
			||||||
	QVector<QString> mTrackArtists;
 | 
					 | 
				
			||||||
	QString mTrackArtUrl;
 | 
						QString mTrackArtUrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						DECLARE_MEMBER_NS(MprisPlayer, uniqueId, mUniqueId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						DECLARE_MEMBER(MprisPlayer, length, mLength, lengthChanged);
 | 
				
			||||||
 | 
						DECLARE_MEMBER_SET(length, setLength);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// clang-format off
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(MprisPlayer, trackTitle, setTrackTitle, mTrackTitle, trackTitleChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(MprisPlayer, trackArtists, setTrackArtists, mTrackArtists, trackArtistsChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(MprisPlayer, trackAlbum, setTrackAlbum, mTrackAlbum, trackAlbumChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(MprisPlayer, trackAlbumArtist, setTrackAlbumArtist, mTrackAlbumArtist, trackAlbumArtistChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(MprisPlayer, trackArtUrl, setTrackArtUrl, mTrackArtUrl, trackArtUrlChanged);
 | 
				
			||||||
 | 
						// clang-format on
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						DECLARE_MEMBER_GET(uniqueId);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace qs::service::mpris
 | 
					} // namespace qs::service::mpris
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,9 +8,9 @@
 | 
				
			||||||
#include <qtmetamacros.h>
 | 
					#include <qtmetamacros.h>
 | 
				
			||||||
#include <qtypes.h>
 | 
					#include <qtypes.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "../../core/util.hpp"
 | 
					 | 
				
			||||||
#include "../../core/desktopentry.hpp"
 | 
					#include "../../core/desktopentry.hpp"
 | 
				
			||||||
#include "../../core/iconimageprovider.hpp"
 | 
					#include "../../core/iconimageprovider.hpp"
 | 
				
			||||||
 | 
					#include "../../core/util.hpp"
 | 
				
			||||||
#include "dbusimage.hpp"
 | 
					#include "dbusimage.hpp"
 | 
				
			||||||
#include "server.hpp"
 | 
					#include "server.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ void NotificationAction::invoke() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	NotificationServer::instance()->ActionInvoked(this->notification->id(), this->mIdentifier);
 | 
						NotificationServer::instance()->ActionInvoked(this->notification->id(), this->mIdentifier);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!this->notification->isResident()) {
 | 
						if (!this->notification->resident()) {
 | 
				
			||||||
		this->notification->close(NotificationCloseReason::Dismissed);
 | 
							this->notification->close(NotificationCloseReason::Dismissed);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -88,8 +88,8 @@ void Notification::updateProperties(
 | 
				
			||||||
	                                         : NotificationUrgency::Normal;
 | 
						                                         : NotificationUrgency::Normal;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	auto hasActionIcons = hints.value("action-icons").value<bool>();
 | 
						auto hasActionIcons = hints.value("action-icons").value<bool>();
 | 
				
			||||||
	auto isResident = hints.value("resident").value<bool>();
 | 
						auto resident = hints.value("resident").value<bool>();
 | 
				
			||||||
	auto isTransient = hints.value("transient").value<bool>();
 | 
						auto transient = hints.value("transient").value<bool>();
 | 
				
			||||||
	auto desktopEntry = hints.value("desktop-entry").value<QString>();
 | 
						auto desktopEntry = hints.value("desktop-entry").value<QString>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	QString imageDataName;
 | 
						QString imageDataName;
 | 
				
			||||||
| 
						 | 
					@ -131,20 +131,18 @@ void Notification::updateProperties(
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DROP_EMIT_SET(this, appName, mAppName, appNameChanged);
 | 
						auto expireTimeoutChanged = this->setExpireTimeout(expireTimeout);
 | 
				
			||||||
	DROP_EMIT_SET(this, appIcon, mAppIcon, appIconChanged);
 | 
						auto appNameChanged = this->setAppName(appName);
 | 
				
			||||||
	DROP_EMIT_SET(this, summary, mSummary, summaryChanged);
 | 
						auto appIconChanged = this->setAppIcon(appIcon);
 | 
				
			||||||
	DROP_EMIT_SET(this, body, mBody, bodyChanged);
 | 
						auto summaryChanged = this->setSummary(summary);
 | 
				
			||||||
	DROP_EMIT_SET(this, expireTimeout, mExpireTimeout, expireTimeoutChanged);
 | 
						auto bodyChanged = this->setBody(body);
 | 
				
			||||||
	DEFINE_DROP_EMIT_IF(urgency != this->mUrgency, this, urgencyChanged);
 | 
						auto urgencyChanged = this->setUrgency(static_cast<NotificationUrgency::Enum>(urgency));
 | 
				
			||||||
	DROP_EMIT_SET(this, hasActionIcons, mHasActionIcons, hasActionIconsChanged);
 | 
						auto hasActionIconsChanged = this->setHasActionIcons(hasActionIcons);
 | 
				
			||||||
	DROP_EMIT_SET(this, isResident, mIsResident, isResidentChanged);
 | 
						auto residentChanged = this->setResident(resident);
 | 
				
			||||||
	DROP_EMIT_SET(this, isTransient, mIsTransient, isTransientChanged);
 | 
						auto transientChanged = this->setTransient(transient);
 | 
				
			||||||
	DROP_EMIT_SET(this, desktopEntry, mDesktopEntry, desktopEntryChanged);
 | 
						auto desktopEntryChanged = this->setDesktopEntry(desktopEntry);
 | 
				
			||||||
	DEFINE_DROP_EMIT_IF(imagePixmap || imagePath != this->mImagePath, this, imageChanged);
 | 
						DEFINE_DROP_EMIT_IF(imagePixmap || imagePath != this->mImagePath, this, imageChanged);
 | 
				
			||||||
	DROP_EMIT_SET(this, hints, mHints, hintsChanged);
 | 
						auto hintsChanged = this->setHints(hints);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (urgencyChanged) this->mUrgency = static_cast<NotificationUrgency::Enum>(urgency);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	NotificationImage* oldImage = nullptr;
 | 
						NotificationImage* oldImage = nullptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -154,8 +152,6 @@ void Notification::updateProperties(
 | 
				
			||||||
		this->mImagePath = imagePath;
 | 
							this->mImagePath = imagePath;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (hintsChanged) this->mHints = hints;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	bool actionsChanged = false;
 | 
						bool actionsChanged = false;
 | 
				
			||||||
	auto deletedActions = QVector<NotificationAction*>();
 | 
						auto deletedActions = QVector<NotificationAction*>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -195,6 +191,21 @@ void Notification::updateProperties(
 | 
				
			||||||
		                            << "sent an action set of an invalid length.";
 | 
							                            << "sent an action set of an invalid length.";
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						DropEmitter::call(
 | 
				
			||||||
 | 
						    expireTimeoutChanged,
 | 
				
			||||||
 | 
						    appNameChanged,
 | 
				
			||||||
 | 
						    appIconChanged,
 | 
				
			||||||
 | 
						    summaryChanged,
 | 
				
			||||||
 | 
						    bodyChanged,
 | 
				
			||||||
 | 
						    urgencyChanged,
 | 
				
			||||||
 | 
						    hasActionIconsChanged,
 | 
				
			||||||
 | 
						    residentChanged,
 | 
				
			||||||
 | 
						    transientChanged,
 | 
				
			||||||
 | 
						    desktopEntryChanged,
 | 
				
			||||||
 | 
						    imageChanged,
 | 
				
			||||||
 | 
						    hintsChanged
 | 
				
			||||||
 | 
						);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (actionsChanged) emit this->actionsChanged();
 | 
						if (actionsChanged) emit this->actionsChanged();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (auto* action: deletedActions) {
 | 
						for (auto* action: deletedActions) {
 | 
				
			||||||
| 
						 | 
					@ -217,17 +228,17 @@ void Notification::setTracked(bool tracked) {
 | 
				
			||||||
bool Notification::isLastGeneration() const { return this->mLastGeneration; }
 | 
					bool Notification::isLastGeneration() const { return this->mLastGeneration; }
 | 
				
			||||||
void Notification::setLastGeneration() { this->mLastGeneration = true; }
 | 
					void Notification::setLastGeneration() { this->mLastGeneration = true; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
qreal Notification::expireTimeout() const { return this->mExpireTimeout; }
 | 
					DEFINE_MEMBER_GETSET(Notification, expireTimeout, setExpireTimeout);
 | 
				
			||||||
QString Notification::appName() const { return this->mAppName; }
 | 
					DEFINE_MEMBER_GETSET(Notification, appName, setAppName);
 | 
				
			||||||
QString Notification::appIcon() const { return this->mAppIcon; }
 | 
					DEFINE_MEMBER_GETSET(Notification, appIcon, setAppIcon);
 | 
				
			||||||
QString Notification::summary() const { return this->mSummary; }
 | 
					DEFINE_MEMBER_GETSET(Notification, summary, setSummary);
 | 
				
			||||||
QString Notification::body() const { return this->mBody; }
 | 
					DEFINE_MEMBER_GETSET(Notification, body, setBody);
 | 
				
			||||||
NotificationUrgency::Enum Notification::urgency() const { return this->mUrgency; }
 | 
					DEFINE_MEMBER_GETSET(Notification, urgency, setUrgency);
 | 
				
			||||||
QVector<NotificationAction*> Notification::actions() const { return this->mActions; }
 | 
					DEFINE_MEMBER_GET(Notification, actions);
 | 
				
			||||||
bool Notification::hasActionIcons() const { return this->mHasActionIcons; }
 | 
					DEFINE_MEMBER_GETSET(Notification, hasActionIcons, setHasActionIcons);
 | 
				
			||||||
bool Notification::isResident() const { return this->mIsResident; }
 | 
					DEFINE_MEMBER_GETSET(Notification, resident, setResident);
 | 
				
			||||||
bool Notification::isTransient() const { return this->mIsTransient; }
 | 
					DEFINE_MEMBER_GETSET(Notification, transient, setTransient);
 | 
				
			||||||
QString Notification::desktopEntry() const { return this->mDesktopEntry; }
 | 
					DEFINE_MEMBER_GETSET(Notification, desktopEntry, setDesktopEntry);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString Notification::image() const {
 | 
					QString Notification::image() const {
 | 
				
			||||||
	if (this->mImagePixmap) {
 | 
						if (this->mImagePixmap) {
 | 
				
			||||||
| 
						 | 
					@ -237,6 +248,6 @@ QString Notification::image() const {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QVariantMap Notification::hints() const { return this->mHints; }
 | 
					DEFINE_MEMBER_GETSET(Notification, hints, setHints);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
} // namespace qs::service::notifications
 | 
					} // namespace qs::service::notifications
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@
 | 
				
			||||||
#include <qtmetamacros.h>
 | 
					#include <qtmetamacros.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "../../core/retainable.hpp"
 | 
					#include "../../core/retainable.hpp"
 | 
				
			||||||
 | 
					#include "../../core/util.hpp"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace qs::service::notifications {
 | 
					namespace qs::service::notifications {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -94,9 +95,9 @@ class Notification
 | 
				
			||||||
	/// See @@NotificationAction.identifier for details.
 | 
						/// See @@NotificationAction.identifier for details.
 | 
				
			||||||
	Q_PROPERTY(bool hasActionIcons READ hasActionIcons NOTIFY hasActionIconsChanged);
 | 
						Q_PROPERTY(bool hasActionIcons READ hasActionIcons NOTIFY hasActionIconsChanged);
 | 
				
			||||||
	/// If true, the notification will not be destroyed after an action is invoked.
 | 
						/// If true, the notification will not be destroyed after an action is invoked.
 | 
				
			||||||
	Q_PROPERTY(bool resident READ isResident NOTIFY isResidentChanged);
 | 
						Q_PROPERTY(bool resident READ resident NOTIFY residentChanged);
 | 
				
			||||||
	/// If true, the notification should skip any kind of persistence function like a notification area.
 | 
						/// If true, the notification should skip any kind of persistence function like a notification area.
 | 
				
			||||||
	Q_PROPERTY(bool transient READ isTransient NOTIFY isTransientChanged);
 | 
						Q_PROPERTY(bool transient READ transient NOTIFY transientChanged);
 | 
				
			||||||
	/// The name of the sender's desktop entry or "" if none was supplied.
 | 
						/// The name of the sender's desktop entry or "" if none was supplied.
 | 
				
			||||||
	Q_PROPERTY(QString desktopEntry READ desktopEntry NOTIFY desktopEntryChanged);
 | 
						Q_PROPERTY(QString desktopEntry READ desktopEntry NOTIFY desktopEntryChanged);
 | 
				
			||||||
	/// An image associated with the notification.
 | 
						/// An image associated with the notification.
 | 
				
			||||||
| 
						 | 
					@ -140,19 +141,7 @@ public:
 | 
				
			||||||
	[[nodiscard]] bool isLastGeneration() const;
 | 
						[[nodiscard]] bool isLastGeneration() const;
 | 
				
			||||||
	void setLastGeneration();
 | 
						void setLastGeneration();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] qreal expireTimeout() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QString appName() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QString appIcon() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QString summary() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QString body() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] NotificationUrgency::Enum urgency() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QVector<NotificationAction*> actions() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] bool hasActionIcons() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] bool isResident() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] bool isTransient() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QString desktopEntry() const;
 | 
					 | 
				
			||||||
	[[nodiscard]] QString image() const;
 | 
						[[nodiscard]] QString image() const;
 | 
				
			||||||
	[[nodiscard]] QVariantMap hints() const;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
signals:
 | 
					signals:
 | 
				
			||||||
	/// Sent when a notification has been closed.
 | 
						/// Sent when a notification has been closed.
 | 
				
			||||||
| 
						 | 
					@ -169,8 +158,8 @@ signals:
 | 
				
			||||||
	void urgencyChanged();
 | 
						void urgencyChanged();
 | 
				
			||||||
	void actionsChanged();
 | 
						void actionsChanged();
 | 
				
			||||||
	void hasActionIconsChanged();
 | 
						void hasActionIconsChanged();
 | 
				
			||||||
	void isResidentChanged();
 | 
						void residentChanged();
 | 
				
			||||||
	void isTransientChanged();
 | 
						void transientChanged();
 | 
				
			||||||
	void desktopEntryChanged();
 | 
						void desktopEntryChanged();
 | 
				
			||||||
	void imageChanged();
 | 
						void imageChanged();
 | 
				
			||||||
	void hintsChanged();
 | 
						void hintsChanged();
 | 
				
			||||||
| 
						 | 
					@ -187,12 +176,27 @@ private:
 | 
				
			||||||
	NotificationUrgency::Enum mUrgency = NotificationUrgency::Normal;
 | 
						NotificationUrgency::Enum mUrgency = NotificationUrgency::Normal;
 | 
				
			||||||
	QVector<NotificationAction*> mActions;
 | 
						QVector<NotificationAction*> mActions;
 | 
				
			||||||
	bool mHasActionIcons = false;
 | 
						bool mHasActionIcons = false;
 | 
				
			||||||
	bool mIsResident = false;
 | 
						bool mResident = false;
 | 
				
			||||||
	bool mIsTransient = false;
 | 
						bool mTransient = false;
 | 
				
			||||||
	QString mImagePath;
 | 
						QString mImagePath;
 | 
				
			||||||
	NotificationImage* mImagePixmap = nullptr;
 | 
						NotificationImage* mImagePixmap = nullptr;
 | 
				
			||||||
	QString mDesktopEntry;
 | 
						QString mDesktopEntry;
 | 
				
			||||||
	QVariantMap mHints;
 | 
						QVariantMap mHints;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// clang-format off
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, expireTimeout, setExpireTimeout, mExpireTimeout, expireTimeoutChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, appName, setAppName, mAppName, appNameChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, appIcon, setAppIcon, mAppIcon, appIconChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, summary, setSummary, mSummary, summaryChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, body, setBody, mBody, bodyChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, urgency, setUrgency, mUrgency, urgencyChanged);
 | 
				
			||||||
 | 
						DECLARE_MEMBER_WITH_GET(Notification, actions, mActions, actionsChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, hasActionIcons, setHasActionIcons, mHasActionIcons, hasActionIconsChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, resident, setResident, mResident, residentChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, transient, setTransient, mTransient, transientChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, desktopEntry, setDesktopEntry, mDesktopEntry, desktopEntryChanged);
 | 
				
			||||||
 | 
						DECLARE_PRIVATE_MEMBER(Notification, hints, setHints, mHints, hintsChanged);
 | 
				
			||||||
 | 
						// clang-format on
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
///! An action associated with a Notification.
 | 
					///! An action associated with a Notification.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue