mirror of
https://git.outfoxxed.me/quickshell/quickshell.git
synced 2025-11-04 19:04:56 +11:00
wayland/screencopy: add constrained implicitSize for ScreencopyView
This commit is contained in:
parent
7390ae28e4
commit
05ed9ff74c
2 changed files with 32 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "view.hpp"
|
||||
|
||||
#include <qnamespace.h>
|
||||
#include <qobject.h>
|
||||
#include <qqmlinfo.h>
|
||||
#include <qquickitem.h>
|
||||
|
|
@ -12,6 +13,23 @@
|
|||
|
||||
namespace qs::wayland::screencopy {
|
||||
|
||||
ScreencopyView::ScreencopyView(QQuickItem* parent): QQuickItem(parent) {
|
||||
this->bImplicitSize.setBinding([this] {
|
||||
auto constraint = this->bConstraintSize.value();
|
||||
auto size = this->bSourceSize.value().toSizeF();
|
||||
|
||||
if (constraint.width() != 0 && constraint.height() != 0) {
|
||||
size.scale(constraint.width(), constraint.height(), Qt::KeepAspectRatio);
|
||||
} else if (constraint.width() != 0) {
|
||||
size = QSizeF(constraint.width(), size.height() / constraint.width());
|
||||
} else if (constraint.height() != 0) {
|
||||
size = QSizeF(size.width() / constraint.height(), constraint.height());
|
||||
}
|
||||
|
||||
return size;
|
||||
});
|
||||
}
|
||||
|
||||
void ScreencopyView::setCaptureSource(QObject* captureSource) {
|
||||
if (captureSource == this->mCaptureSource) return;
|
||||
auto hadContext = this->context != nullptr;
|
||||
|
|
@ -148,4 +166,9 @@ QSGNode* ScreencopyView::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*
|
|||
return node;
|
||||
}
|
||||
|
||||
void ScreencopyView::updateImplicitSize() {
|
||||
auto size = this->bImplicitSize.value();
|
||||
this->setImplicitSize(size.width(), size.height());
|
||||
}
|
||||
|
||||
} // namespace qs::wayland::screencopy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue