Merge branch 'main' of git.zach-dev.cc:zach/z-bar-qt
This commit is contained in:
@@ -242,6 +242,7 @@ Singleton {
|
|||||||
recolorLogo: lock.recolorLogo,
|
recolorLogo: lock.recolorLogo,
|
||||||
enableFprint: lock.enableFprint,
|
enableFprint: lock.enableFprint,
|
||||||
showNotifContent: lock.showNotifContent,
|
showNotifContent: lock.showNotifContent,
|
||||||
|
showNotifIcon: lock.showNotifIcon,
|
||||||
maxFprintTries: lock.maxFprintTries,
|
maxFprintTries: lock.maxFprintTries,
|
||||||
blurAmount: lock.blurAmount,
|
blurAmount: lock.blurAmount,
|
||||||
sizes: {
|
sizes: {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ JsonObject {
|
|||||||
property int maxFprintTries: 3
|
property int maxFprintTries: 3
|
||||||
property bool recolorLogo: false
|
property bool recolorLogo: false
|
||||||
property bool showNotifContent: false
|
property bool showNotifContent: false
|
||||||
|
property bool showNotifIcon: true
|
||||||
property Sizes sizes: Sizes {
|
property Sizes sizes: Sizes {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ CustomRect {
|
|||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
height: Config.notifs.sizes.image
|
height: Config.notifs.sizes.image
|
||||||
source: Qt.resolvedUrl(root.image)
|
source: Qt.resolvedUrl(root.image)
|
||||||
|
visible: Config.lock.showNotifIcon
|
||||||
width: Config.notifs.sizes.image
|
width: Config.notifs.sizes.image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ SettingsPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WallpaperCropper {
|
WallpaperCropper {
|
||||||
screen: root.screen
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,15 @@ SettingsPage {
|
|||||||
Separator {
|
Separator {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingSwitch {
|
||||||
|
name: "Show notification icon"
|
||||||
|
object: Config.lock
|
||||||
|
setting: "showNotifIcon"
|
||||||
|
}
|
||||||
|
|
||||||
|
Separator {
|
||||||
|
}
|
||||||
|
|
||||||
SettingSpinBox {
|
SettingSpinBox {
|
||||||
min: 0
|
min: 0
|
||||||
name: "Blur amount"
|
name: "Blur amount"
|
||||||
|
|||||||
@@ -4,171 +4,255 @@ import QtQuick
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
|
import ZShell.Internal
|
||||||
import qs.Config
|
import qs.Config
|
||||||
import qs.Components
|
import qs.Components
|
||||||
import qs.Helpers
|
import qs.Helpers
|
||||||
|
|
||||||
RowLayout {
|
Item {
|
||||||
id: root
|
id: wrapper
|
||||||
|
|
||||||
required property ShellScreen screen
|
property bool changesMade: false
|
||||||
|
|
||||||
|
signal requestCrop
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 400
|
Layout.preferredHeight: 400
|
||||||
spacing: Appearance.spacing.normal
|
|
||||||
|
|
||||||
Repeater {
|
IconButton {
|
||||||
model: ScriptModel {
|
anchors.margins: Appearance.padding.normal
|
||||||
values: [...Quickshell.screens].sort((a, b) => {
|
anchors.right: parent.right
|
||||||
return a.x - b.x;
|
anchors.top: parent.top
|
||||||
})
|
icon: "check"
|
||||||
|
opacity: wrapper.changesMade ? 1 : 0
|
||||||
|
scale: wrapper.changesMade ? 1 : 0
|
||||||
|
z: 2
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
Anim {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Behavior on scale {
|
||||||
|
Anim {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
onClicked: {
|
||||||
id: delegate
|
wrapper.requestCrop();
|
||||||
|
wrapper.changesMade = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
required property ShellScreen modelData
|
RowLayout {
|
||||||
|
id: root
|
||||||
|
|
||||||
Layout.fillHeight: true
|
anchors.fill: parent
|
||||||
Layout.fillWidth: true
|
spacing: Appearance.spacing.normal
|
||||||
|
|
||||||
Image {
|
Repeater {
|
||||||
id: scaledImg
|
model: ScriptModel {
|
||||||
|
values: [...Quickshell.screens].sort((a, b) => {
|
||||||
|
return a.x - b.x;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
property var displayData
|
Item {
|
||||||
readonly property real imageRatio: scaledImg.sourceSize.width / scaledImg.sourceSize.height
|
id: delegate
|
||||||
property real monitorScale: 1.0
|
|
||||||
readonly property real scaleDownX: scaledImg.width / scaledImg.sourceSize.width
|
|
||||||
readonly property real scaleDownY: scaledImg.height / scaledImg.sourceSize.height
|
|
||||||
readonly property real scaleX: (scaledImg.sourceSize.width * monitorScale) / scaledImg.width
|
|
||||||
readonly property real scaleY: (scaledImg.sourceSize.height * monitorScale) / scaledImg.height
|
|
||||||
|
|
||||||
anchors.left: parent.left
|
required property ShellScreen modelData
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
height: width / imageRatio
|
|
||||||
source: Wallpapers.current
|
|
||||||
|
|
||||||
onPaintedWidthChanged: {
|
function applyCrop(): void {
|
||||||
if (paintedWidth > 0) {
|
const croprect = cropRect.mapToItem(scaledImg, 0, 0, cropRect.width, cropRect.height);
|
||||||
scaledImg.displayData = Wallpapers.getCrop(delegate.modelData.name);
|
const upscaledRect = Qt.rect((croprect.x - cropRect.imageX) / scaledImg.paintedWidth, (croprect.y - cropRect.imageY) / scaledImg.paintedHeight, croprect.width / scaledImg.paintedWidth, croprect.height / scaledImg.paintedHeight);
|
||||||
cropRect.zoom = Wallpapers.getCrop(delegate.modelData.name).zoom;
|
Wallpapers.setCrop(delegate.modelData.name, upscaledRect, croprect, cropRect.zoom);
|
||||||
cropRect.restoreFromData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomText {
|
function zoomClipRect(zoom: real): void {
|
||||||
id: monitorId
|
let oldCenterX = cropRect.x + cropRect.width * 0.5;
|
||||||
|
let oldCenterY = cropRect.y + cropRect.height * 0.5;
|
||||||
|
|
||||||
anchors.centerIn: parent
|
cropRect.zoom = zoom;
|
||||||
color: Qt.alpha(DynamicColors.palette.m3surface, 0.85)
|
|
||||||
font.pointSize: Appearance.font.size.large * 4
|
cropRect.x = oldCenterX - cropRect.width * 0.5;
|
||||||
style: Text.Outline
|
cropRect.y = oldCenterY - cropRect.height * 0.5;
|
||||||
styleColor: DynamicColors.palette.m3onSurface
|
|
||||||
text: delegate.modelData.name
|
cropRect.clampToBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomRect {
|
Layout.fillHeight: true
|
||||||
id: cropRect
|
Layout.fillWidth: true
|
||||||
|
|
||||||
property real aspectRatio: delegate.modelData.width / delegate.modelData.height
|
Connections {
|
||||||
readonly property real baseHeight: baseWidth / aspectRatio
|
function onRequestCrop(): void {
|
||||||
readonly property real baseWidth: {
|
delegate.applyCrop();
|
||||||
let fittedHeight = scaledImg.height;
|
|
||||||
let fittedWidth = fittedHeight * aspectRatio;
|
|
||||||
|
|
||||||
if (fittedWidth > scaledImg.width) {
|
|
||||||
fittedWidth = scaledImg.width;
|
|
||||||
fittedHeight = fittedWidth / aspectRatio;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fittedWidth;
|
|
||||||
}
|
|
||||||
readonly property real imageX: (scaledImg.width - scaledImg.width) / 2
|
|
||||||
readonly property real imageY: (scaledImg.height - scaledImg.height) / 2
|
|
||||||
property real zoom: scaledImg.displayData.zoom
|
|
||||||
|
|
||||||
function centerInImage() {
|
|
||||||
x = imageX + (scaledImg.width - width) / 2;
|
|
||||||
y = imageY + (scaledImg.height - height) / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clampToBounds() {
|
target: wrapper
|
||||||
x = Math.max(imageX, Math.min(x, imageX + scaledImg.paintedWidth - width));
|
}
|
||||||
|
|
||||||
y = Math.max(imageY, Math.min(y, imageY + scaledImg.paintedHeight - height));
|
RowLayout {
|
||||||
|
id: sliderLayout
|
||||||
|
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
implicitHeight: 30
|
||||||
|
spacing: Appearance.spacing.large
|
||||||
|
|
||||||
|
CustomText {
|
||||||
|
text: qsTr("Crop scale")
|
||||||
}
|
}
|
||||||
|
|
||||||
function restoreFromData() {
|
CustomSlider {
|
||||||
let data = scaledImg.displayData;
|
id: zoomSlider
|
||||||
|
|
||||||
if (data && data.scaledX !== 0 || data.scaledY !== 0 || data.scaledWidth !== 0 || data.scaledHeight !== 0) {
|
Layout.fillWidth: true
|
||||||
x = data.scaledX;
|
Layout.preferredHeight: 10
|
||||||
y = data.scaledY;
|
from: 1.0
|
||||||
|
to: 5.0
|
||||||
|
value: cropRect.zoom
|
||||||
|
|
||||||
clampToBounds();
|
onMoved: {
|
||||||
} else {
|
delegate.zoomClipRect(value);
|
||||||
zoom = 1.0;
|
wrapper.changesMade = true;
|
||||||
centerInImage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
border.color: "lime"
|
|
||||||
border.width: 2
|
|
||||||
height: baseHeight / zoom
|
|
||||||
width: baseWidth / zoom
|
|
||||||
|
|
||||||
onHeightChanged: clampToBounds()
|
|
||||||
onWidthChanged: clampToBounds()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
CachingImage {
|
||||||
id: mouse
|
id: scaledImg
|
||||||
|
|
||||||
function updateCrop(mouseX, mouseY) {
|
property var displayData
|
||||||
let nx = mouseX - cropRect.width * 0.5;
|
property real monitorScale: 1.0
|
||||||
let ny = mouseY - cropRect.height * 0.5;
|
|
||||||
|
|
||||||
nx = Math.max(cropRect.imageX, Math.min(nx, cropRect.imageX + scaledImg.width - cropRect.width));
|
anchors.bottom: sliderLayout.top
|
||||||
|
anchors.bottomMargin: Appearance.spacing.normal
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
asynchronous: true
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
// retainWhileLoading: true
|
||||||
|
source: Wallpapers.current
|
||||||
|
sourceSize.height: parent.height
|
||||||
|
sourceSize.width: parent.width
|
||||||
|
|
||||||
ny = Math.max(cropRect.imageY, Math.min(ny, cropRect.imageY + scaledImg.height - cropRect.height));
|
onPaintedWidthChanged: {
|
||||||
|
if (paintedWidth > 0) {
|
||||||
|
scaledImg.displayData = Wallpapers.getCrop(delegate.modelData.name);
|
||||||
|
cropRect.zoom = Wallpapers.getCrop(delegate.modelData.name).zoom;
|
||||||
|
cropRect.restoreFromData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onSourceChanged: cropRect.clampToBounds()
|
||||||
|
onStatusChanged: if (scaledImg.status == Image.Ready)
|
||||||
|
cropRect.clampToBounds()
|
||||||
|
|
||||||
cropRect.x = nx;
|
CustomText {
|
||||||
cropRect.y = ny;
|
id: monitorId
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
color: Qt.alpha(DynamicColors.palette.m3surface, 0.85)
|
||||||
|
font.pointSize: Appearance.font.size.large * 4
|
||||||
|
style: Text.Outline
|
||||||
|
styleColor: DynamicColors.palette.m3onSurface
|
||||||
|
text: delegate.modelData.name
|
||||||
}
|
}
|
||||||
|
|
||||||
anchors.fill: parent
|
CustomRect {
|
||||||
hoverEnabled: true
|
id: cropRect
|
||||||
preventStealing: true
|
|
||||||
|
|
||||||
onPositionChanged: mouse => {
|
property real aspectRatio: delegate.modelData.width / delegate.modelData.height
|
||||||
if (pressed)
|
readonly property real baseHeight: baseWidth / aspectRatio
|
||||||
|
readonly property real baseWidth: {
|
||||||
|
let fittedHeight = scaledImg.paintedHeight;
|
||||||
|
let fittedWidth = fittedHeight * aspectRatio;
|
||||||
|
|
||||||
|
if (fittedWidth > scaledImg.paintedWidth) {
|
||||||
|
fittedWidth = scaledImg.paintedWidth;
|
||||||
|
fittedHeight = fittedWidth / aspectRatio;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fittedWidth;
|
||||||
|
}
|
||||||
|
readonly property real imageX: (scaledImg.width - scaledImg.paintedWidth) / 2
|
||||||
|
readonly property real imageY: (scaledImg.height - scaledImg.paintedHeight) / 2
|
||||||
|
property real imgAspectRatio: scaledImg.paintedWidth / scaledImg.paintedHeight
|
||||||
|
property real zoom: scaledImg.displayData.zoom
|
||||||
|
|
||||||
|
function centerInImage() {
|
||||||
|
x = imageX + (scaledImg.paintedWidth - width) / 2;
|
||||||
|
y = imageY + (scaledImg.paintedHeight - height) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clampToBounds() {
|
||||||
|
x = Math.max(imageX, Math.min(x, imageX + scaledImg.paintedWidth - width));
|
||||||
|
|
||||||
|
y = Math.max(imageY, Math.min(y, imageY + scaledImg.paintedHeight - height));
|
||||||
|
}
|
||||||
|
|
||||||
|
function restoreFromData() {
|
||||||
|
let data = scaledImg.displayData;
|
||||||
|
|
||||||
|
if (data && data.scaledX !== 0 || data.scaledY !== 0 || data.scaledWidth !== 0 || data.scaledHeight !== 0) {
|
||||||
|
x = data.scaledX;
|
||||||
|
y = data.scaledY;
|
||||||
|
|
||||||
|
clampToBounds();
|
||||||
|
} else {
|
||||||
|
zoom = 1.0;
|
||||||
|
centerInImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
border.color: DynamicColors.palette.m3primary
|
||||||
|
border.width: 2
|
||||||
|
height: baseHeight / zoom
|
||||||
|
opacity: 1
|
||||||
|
width: baseWidth / zoom
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
Anim {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: clampToBounds()
|
||||||
|
onHeightChanged: clampToBounds()
|
||||||
|
onWidthChanged: clampToBounds()
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: mouse
|
||||||
|
|
||||||
|
function updateCrop(mouseX, mouseY) {
|
||||||
|
let nx = mouseX - cropRect.width * 0.5;
|
||||||
|
let ny = mouseY - cropRect.height * 0.5;
|
||||||
|
|
||||||
|
nx = Math.max(cropRect.imageX, Math.min(nx, cropRect.imageX + scaledImg.paintedWidth - cropRect.width));
|
||||||
|
|
||||||
|
ny = Math.max(cropRect.imageY, Math.min(ny, cropRect.imageY + scaledImg.paintedHeight - cropRect.height));
|
||||||
|
|
||||||
|
cropRect.x = nx;
|
||||||
|
cropRect.y = ny;
|
||||||
|
}
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
preventStealing: true
|
||||||
|
|
||||||
|
onPositionChanged: mouse => {
|
||||||
|
if (pressed) {
|
||||||
|
updateCrop(mouse.x, mouse.y);
|
||||||
|
wrapper.changesMade = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onPressed: mouse => {
|
||||||
updateCrop(mouse.x, mouse.y);
|
updateCrop(mouse.x, mouse.y);
|
||||||
}
|
wrapper.changesMade = true;
|
||||||
onPressed: mouse => {
|
}
|
||||||
updateCrop(mouse.x, mouse.y);
|
onReleased: {
|
||||||
}
|
wrapper.changesMade = true;
|
||||||
onReleased: {
|
}
|
||||||
const croprect = cropRect.mapToItem(scaledImg, 0, 0, cropRect.width, cropRect.height);
|
|
||||||
const upscaledRect = Qt.rect(croprect.x / scaledImg.width, croprect.y / scaledImg.height, croprect.width / scaledImg.width, croprect.height / scaledImg.height);
|
|
||||||
Wallpapers.setCrop(delegate.modelData.name, upscaledRect, croprect, cropRect.zoom);
|
|
||||||
}
|
|
||||||
onWheel: wheel => {
|
|
||||||
let oldCenterX = cropRect.x + cropRect.width * 0.5;
|
|
||||||
let oldCenterY = cropRect.y + cropRect.height * 0.5;
|
|
||||||
|
|
||||||
if (wheel.angleDelta.y > 0)
|
|
||||||
cropRect.zoom *= 1.1;
|
|
||||||
else
|
|
||||||
cropRect.zoom /= 1.1;
|
|
||||||
|
|
||||||
cropRect.zoom = Math.max(1.0, Math.min(cropRect.zoom, 5.0));
|
|
||||||
console.log(cropRect.zoom);
|
|
||||||
|
|
||||||
cropRect.x = oldCenterX - cropRect.width * 0.5;
|
|
||||||
cropRect.y = oldCenterY - cropRect.height * 0.5;
|
|
||||||
|
|
||||||
cropRect.clampToBounds();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,6 +311,13 @@ export const settingsIndex = [
|
|||||||
section: "Lockscreen",
|
section: "Lockscreen",
|
||||||
keywords: ["notification", "hide", "privacy"],
|
keywords: ["notification", "hide", "privacy"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Show notification icon",
|
||||||
|
category: "lockscreen",
|
||||||
|
categoryName: "Lockscreen",
|
||||||
|
section: "Lockscreen",
|
||||||
|
keywords: ["notification", "hide", "icon"],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Blur amount",
|
name: "Blur amount",
|
||||||
category: "lockscreen",
|
category: "lockscreen",
|
||||||
|
|||||||
Reference in New Issue
Block a user