mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
@@ -51,6 +51,7 @@ Item {
|
|||||||
signal dialogClosed
|
signal dialogClosed
|
||||||
signal backgroundClicked
|
signal backgroundClicked
|
||||||
|
|
||||||
|
property bool animationsEnabled: true
|
||||||
readonly property bool useBackgroundWindow: true
|
readonly property bool useBackgroundWindow: true
|
||||||
|
|
||||||
function open() {
|
function open() {
|
||||||
@@ -75,6 +76,18 @@ Item {
|
|||||||
closeTimer.restart();
|
closeTimer.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function instantClose() {
|
||||||
|
animationsEnabled = false;
|
||||||
|
shouldBeVisible = false;
|
||||||
|
shouldHaveFocus = false;
|
||||||
|
closeTimer.stop();
|
||||||
|
contentWindow.visible = false;
|
||||||
|
if (useBackgroundWindow)
|
||||||
|
backgroundWindow.visible = false;
|
||||||
|
dialogClosed();
|
||||||
|
Qt.callLater(() => animationsEnabled = true);
|
||||||
|
}
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
shouldBeVisible ? close() : open();
|
shouldBeVisible ? close() : open();
|
||||||
}
|
}
|
||||||
@@ -180,6 +193,7 @@ Item {
|
|||||||
visible: root.showBackground && SettingsData.modalDarkenBackground
|
visible: root.showBackground && SettingsData.modalDarkenBackground
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
|
enabled: root.animationsEnabled
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: root.animationDuration
|
duration: root.animationDuration
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
@@ -272,6 +286,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Behavior on animX {
|
Behavior on animX {
|
||||||
|
enabled: root.animationsEnabled
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: root.animationDuration
|
duration: root.animationDuration
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
@@ -280,6 +295,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Behavior on animY {
|
Behavior on animY {
|
||||||
|
enabled: root.animationsEnabled
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: root.animationDuration
|
duration: root.animationDuration
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
@@ -288,6 +304,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Behavior on scaleValue {
|
Behavior on scaleValue {
|
||||||
|
enabled: root.animationsEnabled
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: root.animationDuration
|
duration: root.animationDuration
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
@@ -312,6 +329,7 @@ Item {
|
|||||||
y: Theme.snap(modalContainer.animY, root.dpr) + (parent.height - height) * (1 - modalContainer.scaleValue) * 0.5
|
y: Theme.snap(modalContainer.animY, root.dpr) + (parent.height - height) * (1 - modalContainer.scaleValue) * 0.5
|
||||||
|
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
|
enabled: root.animationsEnabled
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: animationDuration
|
duration: animationDuration
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ DankModal {
|
|||||||
|
|
||||||
function hideInstant() {
|
function hideInstant() {
|
||||||
onColorSelectedCallback = null;
|
onColorSelectedCallback = null;
|
||||||
shouldBeVisible = false;
|
instantClose();
|
||||||
visible = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onColorSelected: color => {
|
onColorSelected: color => {
|
||||||
@@ -81,16 +80,9 @@ DankModal {
|
|||||||
selectedColor = currentColor;
|
selectedColor = currentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
function pickColorFromScreen() {
|
function applyPickedColor(colorStr) {
|
||||||
hideInstant();
|
if (colorStr.length < 7 || !colorStr.startsWith('#'))
|
||||||
Proc.runCommand("hyprpicker", ["hyprpicker", "--format=hex"], (output, errorCode) => {
|
|
||||||
if (errorCode !== 0) {
|
|
||||||
console.warn("hyprpicker exited with code:", errorCode);
|
|
||||||
root.show();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
const colorStr = output.trim();
|
|
||||||
if (colorStr.length >= 7 && colorStr.startsWith('#')) {
|
|
||||||
const pickedColor = Qt.color(colorStr);
|
const pickedColor = Qt.color(colorStr);
|
||||||
root.selectedColor = pickedColor;
|
root.selectedColor = pickedColor;
|
||||||
root.currentColor = pickedColor;
|
root.currentColor = pickedColor;
|
||||||
@@ -98,6 +90,44 @@ DankModal {
|
|||||||
copyColorToClipboard(colorStr);
|
copyColorToClipboard(colorStr);
|
||||||
root.show();
|
root.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function runNiriPicker() {
|
||||||
|
Proc.runCommand("niri-pick-color", ["niri", "msg", "pick-color"], (output, exitCode) => {
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
console.warn("niri msg pick-color exited with code:", exitCode);
|
||||||
|
root.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const hexMatch = output.match(/Hex:\s*(#[0-9A-Fa-f]{6})/);
|
||||||
|
if (hexMatch) {
|
||||||
|
applyPickedColor(hexMatch[1]);
|
||||||
|
} else {
|
||||||
|
console.warn("Failed to parse niri pick-color output:", output);
|
||||||
|
root.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickColorFromScreen() {
|
||||||
|
hideInstant();
|
||||||
|
Proc.runCommand("check-hyprpicker", ["which", "hyprpicker"], (output, exitCode) => {
|
||||||
|
if (exitCode === 0) {
|
||||||
|
Proc.runCommand("hyprpicker", ["hyprpicker", "--format=hex"], (hpOutput, hpCode) => {
|
||||||
|
if (hpCode !== 0) {
|
||||||
|
console.warn("hyprpicker exited with code:", hpCode);
|
||||||
|
root.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
applyPickedColor(hpOutput.trim());
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (CompositorService.isNiri) {
|
||||||
|
runNiriPicker();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.warn("No color picker available");
|
||||||
|
root.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user