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 backgroundClicked
|
||||
|
||||
property bool animationsEnabled: true
|
||||
readonly property bool useBackgroundWindow: true
|
||||
|
||||
function open() {
|
||||
@@ -75,6 +76,18 @@ Item {
|
||||
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() {
|
||||
shouldBeVisible ? close() : open();
|
||||
}
|
||||
@@ -180,6 +193,7 @@ Item {
|
||||
visible: root.showBackground && SettingsData.modalDarkenBackground
|
||||
|
||||
Behavior on opacity {
|
||||
enabled: root.animationsEnabled
|
||||
NumberAnimation {
|
||||
duration: root.animationDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
@@ -272,6 +286,7 @@ Item {
|
||||
}
|
||||
|
||||
Behavior on animX {
|
||||
enabled: root.animationsEnabled
|
||||
NumberAnimation {
|
||||
duration: root.animationDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
@@ -280,6 +295,7 @@ Item {
|
||||
}
|
||||
|
||||
Behavior on animY {
|
||||
enabled: root.animationsEnabled
|
||||
NumberAnimation {
|
||||
duration: root.animationDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
@@ -288,6 +304,7 @@ Item {
|
||||
}
|
||||
|
||||
Behavior on scaleValue {
|
||||
enabled: root.animationsEnabled
|
||||
NumberAnimation {
|
||||
duration: root.animationDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
@@ -312,6 +329,7 @@ Item {
|
||||
y: Theme.snap(modalContainer.animY, root.dpr) + (parent.height - height) * (1 - modalContainer.scaleValue) * 0.5
|
||||
|
||||
Behavior on opacity {
|
||||
enabled: root.animationsEnabled
|
||||
NumberAnimation {
|
||||
duration: animationDuration
|
||||
easing.type: Easing.BezierSpline
|
||||
|
||||
@@ -45,8 +45,7 @@ DankModal {
|
||||
|
||||
function hideInstant() {
|
||||
onColorSelectedCallback = null;
|
||||
shouldBeVisible = false;
|
||||
visible = false;
|
||||
instantClose();
|
||||
}
|
||||
|
||||
onColorSelected: color => {
|
||||
@@ -81,16 +80,9 @@ DankModal {
|
||||
selectedColor = currentColor;
|
||||
}
|
||||
|
||||
function pickColorFromScreen() {
|
||||
hideInstant();
|
||||
Proc.runCommand("hyprpicker", ["hyprpicker", "--format=hex"], (output, errorCode) => {
|
||||
if (errorCode !== 0) {
|
||||
console.warn("hyprpicker exited with code:", errorCode);
|
||||
root.show();
|
||||
function applyPickedColor(colorStr) {
|
||||
if (colorStr.length < 7 || !colorStr.startsWith('#'))
|
||||
return;
|
||||
}
|
||||
const colorStr = output.trim();
|
||||
if (colorStr.length >= 7 && colorStr.startsWith('#')) {
|
||||
const pickedColor = Qt.color(colorStr);
|
||||
root.selectedColor = pickedColor;
|
||||
root.currentColor = pickedColor;
|
||||
@@ -98,6 +90,44 @@ DankModal {
|
||||
copyColorToClipboard(colorStr);
|
||||
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