Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74261f0a49 | ||
|
|
eb65e44ac8 | ||
|
|
e76350fa7f | ||
|
|
de44096132 | ||
|
|
59213cf30d | ||
|
|
8ec454306f | ||
|
|
015c1fb27d | ||
|
|
968055a24e |
@@ -1,33 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
import QtQuick.Effects
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property real radius
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: shadowRect
|
|
||||||
|
|
||||||
anchors.fill: root
|
|
||||||
color: "black"
|
|
||||||
layer.enabled: true
|
|
||||||
radius: root.radius
|
|
||||||
visible: false
|
|
||||||
}
|
|
||||||
|
|
||||||
MultiEffect {
|
|
||||||
id: effects
|
|
||||||
|
|
||||||
anchors.fill: shadowRect
|
|
||||||
autoPaddingEnabled: true
|
|
||||||
maskEnabled: true
|
|
||||||
maskInverted: true
|
|
||||||
maskSource: shadowRect
|
|
||||||
shadowBlur: 2.0
|
|
||||||
shadowColor: "black"
|
|
||||||
shadowEnabled: true
|
|
||||||
shadowOpacity: 1
|
|
||||||
source: shadowRect
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
pragma Singleton
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import Quickshell
|
|
||||||
import Quickshell.Wayland
|
|
||||||
import qs.Components
|
|
||||||
import ZShell.Config
|
|
||||||
|
|
||||||
Singleton {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property list<var> apps: {
|
|
||||||
var map = new Map();
|
|
||||||
|
|
||||||
const pinnedApps = Config.dock?.pinnedApps ?? [];
|
|
||||||
for (const appId of pinnedApps) {
|
|
||||||
if (!map.has(appId.toLowerCase()))
|
|
||||||
map.set(appId.toLowerCase(), ({
|
|
||||||
pinned: true,
|
|
||||||
toplevels: []
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pinnedApps.length > 0) {
|
|
||||||
map.set("SEPARATOR", {
|
|
||||||
pinned: false,
|
|
||||||
toplevels: []
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var values = [];
|
|
||||||
|
|
||||||
for (const [key, value] of map) {
|
|
||||||
values.push(appEntryComp.createObject(null, {
|
|
||||||
appId: key,
|
|
||||||
toplevels: value.toplevels,
|
|
||||||
pinned: value.pinned
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isPinned(appId) {
|
|
||||||
return Config.dock.pinnedApps.indexOf(appId) !== -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function togglePin(appId) {
|
|
||||||
if (root.isPinned(appId)) {
|
|
||||||
Config.dock.pinnedApps = Config.dock.pinnedApps.filter(id => id !== appId);
|
|
||||||
} else {
|
|
||||||
Config.dock.pinnedApps = Config.dock.pinnedApps.concat([appId]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component {
|
|
||||||
id: appEntryComp
|
|
||||||
|
|
||||||
TaskbarAppEntry {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
component TaskbarAppEntry: QtObject {
|
|
||||||
id: wrapper
|
|
||||||
|
|
||||||
required property string appId
|
|
||||||
required property bool pinned
|
|
||||||
required property list<var> toplevels
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
// FetchPresets.qml
|
|
||||||
pragma Singleton
|
|
||||||
|
|
||||||
import QtQuick
|
|
||||||
import Quickshell
|
|
||||||
import Quickshell.Io
|
|
||||||
|
|
||||||
Singleton {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
property var parsedPresets: ({})
|
|
||||||
readonly property var presets: parsedPresets
|
|
||||||
property bool ready: false
|
|
||||||
|
|
||||||
function accents(presetName, variantName) {
|
|
||||||
const variant = parsedPresets[presetName]?.variants?.[variantName];
|
|
||||||
|
|
||||||
return variant?.accents ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function defaultAccent(presetName, variantName) {
|
|
||||||
const variant = parsedPresets[presetName]?.variants?.[variantName];
|
|
||||||
|
|
||||||
return variant?.default_accent ?? "";
|
|
||||||
}
|
|
||||||
|
|
||||||
function modes(presetName, variantName) {
|
|
||||||
const variant = parsedPresets[presetName]?.variants?.[variantName];
|
|
||||||
|
|
||||||
return variant?.modes ?? [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function presetNames() {
|
|
||||||
return Object.keys(parsedPresets);
|
|
||||||
}
|
|
||||||
|
|
||||||
function variantNames(presetName) {
|
|
||||||
const preset = parsedPresets[presetName];
|
|
||||||
|
|
||||||
if (!preset || !preset.variants)
|
|
||||||
return [];
|
|
||||||
|
|
||||||
return Object.keys(preset.variants);
|
|
||||||
}
|
|
||||||
|
|
||||||
Process {
|
|
||||||
command: ["zshell-cli", "scheme", "list-presets", "--json"]
|
|
||||||
running: true
|
|
||||||
|
|
||||||
stdout: StdioCollector {
|
|
||||||
onStreamFinished: {
|
|
||||||
try {
|
|
||||||
const parsed = JSON.parse(text);
|
|
||||||
|
|
||||||
root.parsedPresets = parsed.presets ?? {};
|
|
||||||
root.ready = true;
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Failed to parse presets JSON:", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -103,10 +103,10 @@ Item {
|
|||||||
readonly property bool shouldBeActive: root.popouts.currentName === name
|
readonly property bool shouldBeActive: root.popouts.currentName === name
|
||||||
|
|
||||||
active: false
|
active: false
|
||||||
// anchors.horizontalCenter: parent.horizontalCenter
|
anchors.centerIn: opacity === 1 ? undefined : parent
|
||||||
// anchors.top: parent.top
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
// anchors.topMargin: 5
|
anchors.top: opacity === 1 ? parent.top : undefined
|
||||||
anchors.centerIn: parent
|
anchors.topMargin: 5
|
||||||
opacity: 0
|
opacity: 0
|
||||||
scale: 0.8
|
scale: 0.8
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ Item {
|
|||||||
Comp {
|
Comp {
|
||||||
id: content
|
id: content
|
||||||
|
|
||||||
anchors.centerIn: parent
|
anchors.fill: parent
|
||||||
shouldBeActive: root.hasCurrent
|
shouldBeActive: root.hasCurrent
|
||||||
|
|
||||||
sourceComponent: Content {
|
sourceComponent: Content {
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ CarouselView {
|
|||||||
readonly property var values: Wallpapers.query(root.search.text.split(" ").slice(1).join(" "))
|
readonly property var values: Wallpapers.query(root.search.text.split(" ").slice(1).join(" "))
|
||||||
required property var visibilities
|
required property var visibilities
|
||||||
|
|
||||||
|
currentIndex: {
|
||||||
|
const idx = Wallpapers.list.findIndex(w => w.path === Wallpapers.actualCurrent);
|
||||||
|
return idx >= 0 ? idx : 0;
|
||||||
|
}
|
||||||
delegateProperties: ({
|
delegateProperties: ({
|
||||||
visibilities: root.visibilities
|
visibilities: root.visibilities
|
||||||
})
|
})
|
||||||
@@ -41,11 +45,6 @@ CarouselView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
const idx = Wallpapers.list.findIndex(w => w.path === Wallpapers.actualCurrent);
|
|
||||||
if (idx >= 0)
|
|
||||||
jumpToIndex(idx);
|
|
||||||
}
|
|
||||||
Component.onDestruction: Wallpapers.stopPreview()
|
Component.onDestruction: Wallpapers.stopPreview()
|
||||||
onCurrentItemChanged: {
|
onCurrentItemChanged: {
|
||||||
if (currentItem)
|
if (currentItem)
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
#include "carouselview.hpp"
|
#include "carouselview.hpp"
|
||||||
|
|
||||||
|
#include <QSignalBlocker>
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQmlProperty>
|
#include <QQmlProperty>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <qobject.h>
|
||||||
|
|
||||||
namespace ZShell::components {
|
namespace ZShell::components {
|
||||||
|
|
||||||
@@ -81,6 +83,33 @@ void CarouselView::setDelegate(QQmlComponent* c) {
|
|||||||
relayout();
|
relayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CarouselView::notifyCurrentIndexChanged() {
|
||||||
|
if (!m_completed) return;
|
||||||
|
emit currentIndexChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CarouselView::notifyCurrentItemChanged() {
|
||||||
|
if (!m_completed) return;
|
||||||
|
emit currentItemChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CarouselView::notifyPreviewIndexChanged(int realIndex) {
|
||||||
|
if (!m_completed || realIndex < 0) return;
|
||||||
|
emit previewIndexChanged(realIndex, m_model.at(realIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CarouselView::classBegin() {}
|
||||||
|
|
||||||
|
void CarouselView::componentComplete() {
|
||||||
|
m_completed = true;
|
||||||
|
emit currentIndexChanged();
|
||||||
|
if (m_currentRealIndex >= 0 && m_currentRealIndex < m_model.size())
|
||||||
|
emit previewIndexChanged(
|
||||||
|
m_currentRealIndex, m_model.at(m_currentRealIndex));
|
||||||
|
|
||||||
|
emit currentItemChanged();
|
||||||
|
}
|
||||||
|
|
||||||
bool CarouselView::childMouseEventFilter(QQuickItem* item, QEvent* event) {
|
bool CarouselView::childMouseEventFilter(QQuickItem* item, QEvent* event) {
|
||||||
Q_UNUSED(item);
|
Q_UNUSED(item);
|
||||||
|
|
||||||
@@ -163,7 +192,7 @@ void CarouselView::setModel(const QVariantList& m) {
|
|||||||
if (newCount == 0) {
|
if (newCount == 0) {
|
||||||
m_currentRealIndex = -1;
|
m_currentRealIndex = -1;
|
||||||
m_currentItem = nullptr;
|
m_currentItem = nullptr;
|
||||||
emit currentItemChanged();
|
notifyCurrentItemChanged();
|
||||||
|
|
||||||
releaseAllItems();
|
releaseAllItems();
|
||||||
rebuildArrangement();
|
rebuildArrangement();
|
||||||
@@ -173,19 +202,23 @@ void CarouselView::setModel(const QVariantList& m) {
|
|||||||
|
|
||||||
if (!m_initializedLayout) {
|
if (!m_initializedLayout) {
|
||||||
m_centerBlockStart = 0;
|
m_centerBlockStart = 0;
|
||||||
m_currentVirtualIndex = 0;
|
|
||||||
|
|
||||||
m_contentX = contentXForIndex(0);
|
const int startVirtual =
|
||||||
|
m_pendingCurrentIndex >= 0
|
||||||
|
? qBound(0, m_pendingCurrentIndex, newCount - 1)
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
m_pendingCurrentIndex = -1;
|
||||||
|
|
||||||
|
m_currentVirtualIndex = startVirtual;
|
||||||
|
m_contentX = contentXForIndex(startVirtual);
|
||||||
m_currentRealIndex = realIndexOf(m_currentVirtualIndex);
|
m_currentRealIndex = realIndexOf(m_currentVirtualIndex);
|
||||||
|
|
||||||
m_previewRealIndex = m_currentRealIndex;
|
m_previewRealIndex = m_currentRealIndex;
|
||||||
|
|
||||||
m_initializedLayout = true;
|
m_initializedLayout = true;
|
||||||
|
|
||||||
m_layoutCapacity =
|
m_layoutCapacity =
|
||||||
qMax(m_layoutCapacity, layoutCapacityForWidth(m_maxWidth));
|
qMax(m_layoutCapacity, layoutCapacityForWidth(m_maxWidth));
|
||||||
|
|
||||||
setImplicitWidth(targetWidthForMaxWidth(m_maxWidth));
|
setImplicitWidth(targetWidthForMaxWidth(m_maxWidth));
|
||||||
|
|
||||||
rebuildArrangement();
|
rebuildArrangement();
|
||||||
@@ -320,6 +353,22 @@ void CarouselView::setDelegateProperties(const QVariantMap& v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CarouselView::setCurrentIndex(int idx) {
|
void CarouselView::setCurrentIndex(int idx) {
|
||||||
|
if (m_model.isEmpty()) {
|
||||||
|
m_pendingCurrentIndex = idx;
|
||||||
|
|
||||||
|
if (m_currentRealIndex != idx) {
|
||||||
|
m_currentRealIndex = idx;
|
||||||
|
notifyCurrentIndexChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_completed) {
|
||||||
|
centerInstantlyOnReal(idx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
goToIndex(idx);
|
goToIndex(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +385,7 @@ void CarouselView::updateCurrentItem() {
|
|||||||
if (item == m_currentItem) return;
|
if (item == m_currentItem) return;
|
||||||
|
|
||||||
m_currentItem = item;
|
m_currentItem = item;
|
||||||
emit currentItemChanged();
|
notifyCurrentItemChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CarouselView::geometryChange(const QRectF& newGeo, const QRectF& oldGeo) {
|
void CarouselView::geometryChange(const QRectF& newGeo, const QRectF& oldGeo) {
|
||||||
@@ -676,15 +725,12 @@ void CarouselView::updateCurrentIndexFromContentX(bool emitPreview) {
|
|||||||
if (newReal != m_currentRealIndex) {
|
if (newReal != m_currentRealIndex) {
|
||||||
m_currentRealIndex = newReal;
|
m_currentRealIndex = newReal;
|
||||||
|
|
||||||
emit currentIndexChanged();
|
notifyCurrentIndexChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emitPreview && newReal != m_previewRealIndex) {
|
if (emitPreview && newReal != m_previewRealIndex) {
|
||||||
m_previewRealIndex = newReal;
|
m_previewRealIndex = newReal;
|
||||||
|
notifyPreviewIndexChanged(newReal);
|
||||||
if (newReal >= 0) {
|
|
||||||
emit previewIndexChanged(newReal, m_model.at(newReal));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1029,13 +1075,14 @@ void CarouselView::glideTo(qreal dest) {
|
|||||||
|
|
||||||
cancelAnimations();
|
cancelAnimations();
|
||||||
|
|
||||||
m_glideAnim->setDuration(m_glideDuration);
|
{
|
||||||
|
QSignalBlocker blocker(m_glideAnim);
|
||||||
|
|
||||||
m_glideAnim->setStartValue(m_contentX);
|
m_glideAnim->setDuration(m_glideDuration);
|
||||||
|
m_glideAnim->setStartValue(m_contentX);
|
||||||
m_glideAnim->setEndValue(dest);
|
m_glideAnim->setEndValue(dest);
|
||||||
|
m_glideAnim->start();
|
||||||
m_glideAnim->start();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CarouselView::snapToNearest() {
|
void CarouselView::snapToNearest() {
|
||||||
@@ -1078,10 +1125,6 @@ void CarouselView::decrementCurrentIndex() {
|
|||||||
glideTo(contentXForIndex(m_currentVirtualIndex - 1));
|
glideTo(contentXForIndex(m_currentVirtualIndex - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CarouselView::jumpToIndex(int realIndex) {
|
|
||||||
centerInstantlyOnReal(realIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CarouselView::centerInstantlyOnReal(int realIndex) {
|
void CarouselView::centerInstantlyOnReal(int realIndex) {
|
||||||
const int count = m_model.size();
|
const int count = m_model.size();
|
||||||
|
|
||||||
@@ -1115,7 +1158,7 @@ void CarouselView::centerInstantlyOnReal(int realIndex) {
|
|||||||
|
|
||||||
if (changed) emit currentIndexChanged();
|
if (changed) emit currentIndexChanged();
|
||||||
|
|
||||||
emit previewIndexChanged(realIndex, m_model.at(realIndex));
|
notifyPreviewIndexChanged(realIndex);
|
||||||
|
|
||||||
relayout();
|
relayout();
|
||||||
}
|
}
|
||||||
@@ -1219,12 +1262,16 @@ void CarouselView::mouseReleaseEvent(QMouseEvent* event) {
|
|||||||
|
|
||||||
cancelAnimations();
|
cancelAnimations();
|
||||||
|
|
||||||
m_flickAnim->setDuration(
|
{
|
||||||
static_cast<int>(qBound<qreal>(120, duration, 900)));
|
QSignalBlocker blocker(m_flickAnim);
|
||||||
m_flickAnim->setEasingCurve(QEasingCurve::OutQuad);
|
|
||||||
m_flickAnim->setStartValue(m_contentX);
|
m_flickAnim->setDuration(
|
||||||
m_flickAnim->setEndValue(dest);
|
static_cast<int>(qBound<qreal>(120, duration, 900)));
|
||||||
m_flickAnim->start();
|
m_flickAnim->setEasingCurve(QEasingCurve::OutQuad);
|
||||||
|
m_flickAnim->setStartValue(m_contentX);
|
||||||
|
m_flickAnim->setEndValue(dest);
|
||||||
|
m_flickAnim->start();
|
||||||
|
}
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QQmlParserStatus>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QEasingCurve>
|
#include <QEasingCurve>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@@ -100,8 +101,6 @@ class CarouselView : public QQuickItem {
|
|||||||
Q_INVOKABLE void incrementCurrentIndex();
|
Q_INVOKABLE void incrementCurrentIndex();
|
||||||
Q_INVOKABLE void decrementCurrentIndex();
|
Q_INVOKABLE void decrementCurrentIndex();
|
||||||
|
|
||||||
Q_INVOKABLE void jumpToIndex(int realIndex);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void delegateChanged();
|
void delegateChanged();
|
||||||
void modelChanged();
|
void modelChanged();
|
||||||
@@ -120,10 +119,10 @@ class CarouselView : public QQuickItem {
|
|||||||
void previewIndexChanged(int realIndex, QVariant modelData);
|
void previewIndexChanged(int realIndex, QVariant modelData);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void classBegin() override;
|
||||||
|
void componentComplete() override;
|
||||||
bool childMouseEventFilter(QQuickItem* item, QEvent* event) override;
|
bool childMouseEventFilter(QQuickItem* item, QEvent* event) override;
|
||||||
|
|
||||||
void geometryChange(const QRectF& newGeo, const QRectF& oldGeo) override;
|
void geometryChange(const QRectF& newGeo, const QRectF& oldGeo) override;
|
||||||
|
|
||||||
void mousePressEvent(QMouseEvent* event) override;
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
void mouseMoveEvent(QMouseEvent* event) override;
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
@@ -200,6 +199,10 @@ class CarouselView : public QQuickItem {
|
|||||||
void addVelocitySample(qint64 t, qreal x);
|
void addVelocitySample(qint64 t, qreal x);
|
||||||
qreal sampledVelocity() const;
|
qreal sampledVelocity() const;
|
||||||
|
|
||||||
|
void notifyCurrentIndexChanged();
|
||||||
|
void notifyCurrentItemChanged();
|
||||||
|
void notifyPreviewIndexChanged(int realIndex);
|
||||||
|
|
||||||
QQmlComponent* m_delegate = nullptr;
|
QQmlComponent* m_delegate = nullptr;
|
||||||
QVariantList m_model;
|
QVariantList m_model;
|
||||||
QVariantMap m_delegateProperties;
|
QVariantMap m_delegateProperties;
|
||||||
@@ -242,6 +245,9 @@ class CarouselView : public QQuickItem {
|
|||||||
|
|
||||||
QVariantAnimation* m_flickAnim = nullptr;
|
QVariantAnimation* m_flickAnim = nullptr;
|
||||||
|
|
||||||
|
bool m_completed = false;
|
||||||
|
int m_pendingCurrentIndex = -1;
|
||||||
|
|
||||||
bool m_initializedLayout = false;
|
bool m_initializedLayout = false;
|
||||||
bool m_relayoutQueued = false;
|
bool m_relayoutQueued = false;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user