forked from quickshell/quickshell
		
	core/window: move implicit width/height to bindable properties
This commit is contained in:
		
							parent
							
								
									cb195d4b2a
								
							
						
					
					
						commit
						5ae8e4901a
					
				
					 2 changed files with 27 additions and 16 deletions
				
			
		| 
						 | 
					@ -300,12 +300,9 @@ qint32 ProxyWindowBase::y() const {
 | 
				
			||||||
	else return this->window->y();
 | 
						else return this->window->y();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
qint32 ProxyWindowBase::implicitWidth() const { return this->mImplicitWidth; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ProxyWindowBase::setImplicitWidth(qint32 implicitWidth) {
 | 
					void ProxyWindowBase::setImplicitWidth(qint32 implicitWidth) {
 | 
				
			||||||
	if (implicitWidth == this->mImplicitWidth) return;
 | 
						if (implicitWidth == this->bImplicitWidth) return;
 | 
				
			||||||
	this->mImplicitWidth = implicitWidth;
 | 
						this->bImplicitWidth = implicitWidth;
 | 
				
			||||||
	emit this->implicitWidthChanged();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->window) this->trySetWidth(implicitWidth);
 | 
						if (this->window) this->trySetWidth(implicitWidth);
 | 
				
			||||||
	else emit this->widthChanged();
 | 
						else emit this->widthChanged();
 | 
				
			||||||
| 
						 | 
					@ -313,12 +310,9 @@ void ProxyWindowBase::setImplicitWidth(qint32 implicitWidth) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ProxyWindowBase::trySetWidth(qint32 implicitWidth) { this->window->setWidth(implicitWidth); }
 | 
					void ProxyWindowBase::trySetWidth(qint32 implicitWidth) { this->window->setWidth(implicitWidth); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
qint32 ProxyWindowBase::implicitHeight() const { return this->mImplicitHeight; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
void ProxyWindowBase::setImplicitHeight(qint32 implicitHeight) {
 | 
					void ProxyWindowBase::setImplicitHeight(qint32 implicitHeight) {
 | 
				
			||||||
	if (implicitHeight == this->mImplicitHeight) return;
 | 
						if (implicitHeight == this->bImplicitHeight) return;
 | 
				
			||||||
	this->mImplicitHeight = implicitHeight;
 | 
						this->bImplicitHeight = implicitHeight;
 | 
				
			||||||
	emit this->implicitHeightChanged();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (this->window) this->trySetHeight(implicitHeight);
 | 
						if (this->window) this->trySetHeight(implicitHeight);
 | 
				
			||||||
	else emit this->heightChanged();
 | 
						else emit this->heightChanged();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,7 @@
 | 
				
			||||||
#include <qevent.h>
 | 
					#include <qevent.h>
 | 
				
			||||||
#include <qnamespace.h>
 | 
					#include <qnamespace.h>
 | 
				
			||||||
#include <qobject.h>
 | 
					#include <qobject.h>
 | 
				
			||||||
 | 
					#include <qproperty.h>
 | 
				
			||||||
#include <qqmllist.h>
 | 
					#include <qqmllist.h>
 | 
				
			||||||
#include <qqmlparserstatus.h>
 | 
					#include <qqmlparserstatus.h>
 | 
				
			||||||
#include <qquickitem.h>
 | 
					#include <qquickitem.h>
 | 
				
			||||||
| 
						 | 
					@ -42,8 +43,8 @@ class ProxyWindowBase: public Reloadable {
 | 
				
			||||||
	Q_PROPERTY(QQuickWindow* _backingWindow READ backingWindow);
 | 
						Q_PROPERTY(QQuickWindow* _backingWindow READ backingWindow);
 | 
				
			||||||
	Q_PROPERTY(QQuickItem* contentItem READ contentItem CONSTANT);
 | 
						Q_PROPERTY(QQuickItem* contentItem READ contentItem CONSTANT);
 | 
				
			||||||
	Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged);
 | 
						Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged);
 | 
				
			||||||
	Q_PROPERTY(qint32 implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged);
 | 
						Q_PROPERTY(qint32 implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged BINDABLE bindableImplicitWidth);
 | 
				
			||||||
	Q_PROPERTY(qint32 implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged);
 | 
						Q_PROPERTY(qint32 implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged BINDABLE bindableImplicitHeight);
 | 
				
			||||||
	Q_PROPERTY(qint32 width READ width WRITE setWidth NOTIFY widthChanged);
 | 
						Q_PROPERTY(qint32 width READ width WRITE setWidth NOTIFY widthChanged);
 | 
				
			||||||
	Q_PROPERTY(qint32 height READ height WRITE setHeight NOTIFY heightChanged);
 | 
						Q_PROPERTY(qint32 height READ height WRITE setHeight NOTIFY heightChanged);
 | 
				
			||||||
	Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged);
 | 
						Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged);
 | 
				
			||||||
| 
						 | 
					@ -94,11 +95,13 @@ public:
 | 
				
			||||||
	[[nodiscard]] virtual qint32 x() const;
 | 
						[[nodiscard]] virtual qint32 x() const;
 | 
				
			||||||
	[[nodiscard]] virtual qint32 y() const;
 | 
						[[nodiscard]] virtual qint32 y() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] qint32 implicitWidth() const;
 | 
						[[nodiscard]] qint32 implicitWidth() const { return this->bImplicitWidth; }
 | 
				
			||||||
	void setImplicitWidth(qint32 implicitWidth);
 | 
						void setImplicitWidth(qint32 implicitWidth);
 | 
				
			||||||
 | 
						QBindable<qint32> bindableImplicitWidth() { return &this->bImplicitWidth; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] qint32 implicitHeight() const;
 | 
						[[nodiscard]] qint32 implicitHeight() const { return this->bImplicitHeight; }
 | 
				
			||||||
	void setImplicitHeight(qint32 implicitHeight);
 | 
						void setImplicitHeight(qint32 implicitHeight);
 | 
				
			||||||
 | 
						QBindable<qint32> bindableImplicitHeight() { return &this->bImplicitHeight; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[nodiscard]] virtual qint32 width() const;
 | 
						[[nodiscard]] virtual qint32 width() const;
 | 
				
			||||||
	void setWidth(qint32 width);
 | 
						void setWidth(qint32 width);
 | 
				
			||||||
| 
						 | 
					@ -158,8 +161,6 @@ protected slots:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
	bool mVisible = true;
 | 
						bool mVisible = true;
 | 
				
			||||||
	qint32 mImplicitWidth = 100;
 | 
					 | 
				
			||||||
	qint32 mImplicitHeight = 100;
 | 
					 | 
				
			||||||
	QScreen* mScreen = nullptr;
 | 
						QScreen* mScreen = nullptr;
 | 
				
			||||||
	QColor mColor = Qt::white;
 | 
						QColor mColor = Qt::white;
 | 
				
			||||||
	PendingRegion* mMask = nullptr;
 | 
						PendingRegion* mMask = nullptr;
 | 
				
			||||||
| 
						 | 
					@ -174,6 +175,22 @@ protected:
 | 
				
			||||||
		bool inputMask : 1 = false;
 | 
							bool inputMask : 1 = false;
 | 
				
			||||||
	} pendingPolish;
 | 
						} pendingPolish;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(
 | 
				
			||||||
 | 
						    ProxyWindowBase,
 | 
				
			||||||
 | 
						    qint32,
 | 
				
			||||||
 | 
						    bImplicitWidth,
 | 
				
			||||||
 | 
						    100,
 | 
				
			||||||
 | 
						    &ProxyWindowBase::implicitWidthChanged
 | 
				
			||||||
 | 
						);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(
 | 
				
			||||||
 | 
						    ProxyWindowBase,
 | 
				
			||||||
 | 
						    qint32,
 | 
				
			||||||
 | 
						    bImplicitHeight,
 | 
				
			||||||
 | 
						    100,
 | 
				
			||||||
 | 
						    &ProxyWindowBase::implicitHeightChanged
 | 
				
			||||||
 | 
						);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	void polishItems();
 | 
						void polishItems();
 | 
				
			||||||
	void updateMask();
 | 
						void updateMask();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue