improve sizing and dynamic width for view
C++ / fmt (pull_request) Successful in 6s
JS/TS / fmt (pull_request) Successful in 12s
JS/TS / lint (pull_request) Successful in 17s
Python / static (pull_request) Successful in 1m2s
Rust / fmt (pull_request) Successful in 1m5s
C++ / build (pull_request) Successful in 2m36s
Rust / build (pull_request) Successful in 2m27s
Rust / clippy (pull_request) Successful in 1m51s
Python / verify (pull_request) Successful in 3m33s
C++ / clang-tidy (pull_request) Successful in 7m12s

This commit is contained in:
2026-08-16 20:28:21 +02:00
parent 654632128f
commit 4e75f21446
4 changed files with 701 additions and 160 deletions
+3 -5
View File
@@ -15,8 +15,6 @@ CarouselView {
readonly property var values: Wallpapers.query(root.search.text.split(" ").slice(1).join(" "))
required property var visibilities
// Forwarded verbatim as a property of the same name onto every delegate
// instance (the delegate declares `required property PersistentProperties visibilities`).
delegateProperties: ({
visibilities: root.visibilities
})
@@ -29,9 +27,9 @@ CarouselView {
if (!screen)
return 0;
const barMargins = Config.bar.border * 2;
let margins = 0;
let margins = Math.round(screen.width / 6);
if (visibilities.utilities || visibilities.sidebar)
margins = panels.utilities.implicitWidth;
margins = Config.sidebar.sizes.width;
return screen.width - (barMargins + margins) * 2 - Config.bar.rounding * 4;
}
minEdgeWidth: 56
@@ -40,7 +38,7 @@ CarouselView {
delegate: Component {
WallpaperTile {
} // your existing delegate file, unchanged
}
}
Component.onCompleted: {
+1 -1
View File
@@ -110,9 +110,9 @@ Item {
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
width: root.implicitWidth
sourceComponent: CarouselView {
// content: root.content
panels: root.panels
search: root.search
visibilities: root.visibilities
File diff suppressed because it is too large Load Diff
+28 -9
View File
@@ -1,15 +1,15 @@
#pragma once
#include <QElapsedTimer>
#include <QEasingCurve>
#include <QList>
#include <QPointF>
#include <QQuickItem>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QVariantList>
#include <QVariantAnimation>
#include <QEasingCurve>
#include <QElapsedTimer>
#include <QPointF>
#include <QVariantList>
#include <QVector>
#include <QList>
namespace ZShell::components {
@@ -112,6 +112,7 @@ class CarouselView : public QQuickItem {
protected:
void geometryChange(const QRectF& newGeo, const QRectF& oldGeo) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
@@ -125,8 +126,11 @@ class CarouselView : public QQuickItem {
struct Arrangement {
int n = 0;
qreal width = 0;
qreal outerSpacing = 0;
QVector<qreal> sizes;
QVector<qreal> centers;
qreal effectiveExtraWidth = 0;
};
@@ -139,25 +143,36 @@ class CarouselView : public QQuickItem {
void rebuildArrangement();
void relayout();
Arrangement arrangementForCount(int n) const;
int layoutCapacityForWidth(qreal width) const;
qreal targetWidthForMaxWidth(qreal maxWidth) const;
void updateSlotContent(Slot& slot, int virtualIndex);
void positionSlot(const Slot& slot) const;
void applyPropertiesToItem(QQuickItem* item, int realIndex) const;
qreal pitch() const { return m_focalWidth + m_itemSpacing; }
qreal contentXForIndex(qreal index) const;
int indexForContentX(qreal x) const;
qreal snapTargetX(qreal x) const;
void snapToNearest();
void glideTo(qreal dest);
void cancelAnimations();
qreal keylineCenter(int io) const;
qreal keylineSize(int io) const;
qreal sampleCenter(qreal childLoc) const;
qreal sampleSize(qreal childLoc) const;
qreal continuousIndex() const;
int realIndexOf(int virtualIndex) const;
void updateCurrentIndexFromContentX(bool emitPreview);
void wrapContentIfNeeded();
void centerInstantlyOnReal(int realIndex);
@@ -176,12 +191,13 @@ class CarouselView : public QQuickItem {
Arrangement m_arrangement;
int m_layoutCapacity = 0;
qreal m_contentX = 0;
int m_currentVirtualIndex = 0;
int m_currentRealIndex = -1;
int m_previewRealIndex = -1;
static constexpr int kLoopMultiplier = 401;
int m_centerBlockStart = 0;
QList<Slot> m_slots;
@@ -192,16 +208,19 @@ class CarouselView : public QQuickItem {
bool m_dragging = false;
bool m_dragActive = false;
QPointF m_pressPos;
qreal m_pressContentX = 0;
QElapsedTimer m_dragTimer;
qreal m_lastMoveX = 0;
qint64 m_lastMoveT = 0;
qreal m_velocity = 0;
QVariantAnimation* m_flickAnim = nullptr;
bool m_initializedLayout = false;
bool m_relayoutQueued = false;
};
}; // namespace ZShell::components
} // namespace ZShell::components