mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 23:42:51 -05:00
feat: Implement Color Picker
This commit is contained in:
37
Modals/ColorPickerModal.qml
Normal file
37
Modals/ColorPickerModal.qml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Qt.labs.platform
|
||||||
|
import Quickshell
|
||||||
|
import qs.Common
|
||||||
|
import qs.Services
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: colorPickerModal
|
||||||
|
|
||||||
|
signal colorSelected(color selectedColor)
|
||||||
|
|
||||||
|
function show() {
|
||||||
|
colorDialog.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide() {
|
||||||
|
colorDialog.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyColorToClipboard(colorValue) {
|
||||||
|
Quickshell.execDetached(["sh", "-c", `echo "${colorValue}" | wl-copy`])
|
||||||
|
ToastService.showInfo(`Color ${colorValue} copied to clipboard`)
|
||||||
|
console.log("Copied color to clipboard:", colorValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorDialog {
|
||||||
|
id: colorDialog
|
||||||
|
title: "Color Picker - Select and copy color"
|
||||||
|
color: Theme.primary
|
||||||
|
|
||||||
|
onAccepted: {
|
||||||
|
const colorString = color.toString()
|
||||||
|
copyColorToClipboard(colorString)
|
||||||
|
colorSelected(color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -157,6 +157,12 @@ Item {
|
|||||||
"description": "Quick access to notepad",
|
"description": "Quick access to notepad",
|
||||||
"icon": "assignment",
|
"icon": "assignment",
|
||||||
"enabled": true
|
"enabled": true
|
||||||
|
}, {
|
||||||
|
"id": "colorPicker",
|
||||||
|
"text": "Color Picker",
|
||||||
|
"description": "Quick access to color picker",
|
||||||
|
"icon": "palette",
|
||||||
|
"enabled": true
|
||||||
}]
|
}]
|
||||||
property var defaultLeftWidgets: [{
|
property var defaultLeftWidgets: [{
|
||||||
"id": "launcherButton",
|
"id": "launcherButton",
|
||||||
|
|||||||
60
Modules/TopBar/ColorPicker.qml
Normal file
60
Modules/TopBar/ColorPicker.qml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import QtQuick
|
||||||
|
import qs.Common
|
||||||
|
import qs.Widgets
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property bool isActive: false
|
||||||
|
property string section: "right"
|
||||||
|
property var popupTarget: null
|
||||||
|
property var parentScreen: null
|
||||||
|
property real widgetHeight: 30
|
||||||
|
property real barHeight: 48
|
||||||
|
readonly property real horizontalPadding: SettingsData.topBarNoBackground ? 0 : Math.max(Theme.spacingXS, Theme.spacingS * (widgetHeight / 30))
|
||||||
|
|
||||||
|
signal clicked()
|
||||||
|
|
||||||
|
width: colorPickerIcon.width + horizontalPadding * 2
|
||||||
|
height: widgetHeight
|
||||||
|
radius: SettingsData.topBarNoBackground ? 0 : Theme.cornerRadius
|
||||||
|
color: {
|
||||||
|
if (SettingsData.topBarNoBackground) {
|
||||||
|
return "transparent";
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseColor = colorPickerArea.containsMouse || root.isActive ? Theme.primaryPressed : Theme.secondaryHover;
|
||||||
|
return Qt.rgba(baseColor.r, baseColor.g, baseColor.b, baseColor.a * Theme.widgetTransparency);
|
||||||
|
}
|
||||||
|
|
||||||
|
DankIcon {
|
||||||
|
id: colorPickerIcon
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
name: "palette"
|
||||||
|
size: Theme.iconSize - 6
|
||||||
|
color: colorPickerArea.containsMouse || root.isActive ? Theme.primary : Theme.surfaceText
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: colorPickerArea
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onPressed: {
|
||||||
|
console.log("Color picker button clicked!")
|
||||||
|
root.colorPickerRequested();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Signal to notify TopBar to open color picker
|
||||||
|
signal colorPickerRequested()
|
||||||
|
|
||||||
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Theme.standardEasing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,8 @@ PanelWindow {
|
|||||||
property var modelData
|
property var modelData
|
||||||
property var notepadVariants: null
|
property var notepadVariants: null
|
||||||
|
|
||||||
|
signal colorPickerRequested()
|
||||||
|
|
||||||
function getNotepadInstanceForScreen() {
|
function getNotepadInstanceForScreen() {
|
||||||
if (!notepadVariants || !notepadVariants.instances) return null
|
if (!notepadVariants || !notepadVariants.instances) return null
|
||||||
|
|
||||||
@@ -370,7 +372,8 @@ PanelWindow {
|
|||||||
"network_speed_monitor": networkComponent,
|
"network_speed_monitor": networkComponent,
|
||||||
"keyboard_layout_name": keyboardLayoutNameComponent,
|
"keyboard_layout_name": keyboardLayoutNameComponent,
|
||||||
"vpn": vpnComponent,
|
"vpn": vpnComponent,
|
||||||
"notepadButton": notepadButtonComponent
|
"notepadButton": notepadButtonComponent,
|
||||||
|
"colorPicker": colorPickerComponent
|
||||||
})
|
})
|
||||||
|
|
||||||
function getWidgetComponent(widgetId) {
|
function getWidgetComponent(widgetId) {
|
||||||
@@ -999,9 +1002,24 @@ PanelWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: colorPickerComponent
|
||||||
|
|
||||||
|
ColorPicker {
|
||||||
|
widgetHeight: root.widgetHeight
|
||||||
|
barHeight: root.effectiveBarHeight
|
||||||
|
section: topBarContent.getWidgetSection(parent) || "right"
|
||||||
|
parentScreen: root.screen
|
||||||
|
onColorPickerRequested: {
|
||||||
|
root.colorPickerRequested()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ ShellRoot {
|
|||||||
delegate: TopBar {
|
delegate: TopBar {
|
||||||
modelData: item
|
modelData: item
|
||||||
notepadVariants: notepadSlideoutVariants
|
notepadVariants: notepadSlideoutVariants
|
||||||
|
onColorPickerRequested: colorPickerModal.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,6 +259,9 @@ ShellRoot {
|
|||||||
NotificationModal {
|
NotificationModal {
|
||||||
id: notificationModal
|
id: notificationModal
|
||||||
}
|
}
|
||||||
|
ColorPickerModal {
|
||||||
|
id: colorPickerModal
|
||||||
|
}
|
||||||
|
|
||||||
LazyLoader {
|
LazyLoader {
|
||||||
id: processListModalLoader
|
id: processListModalLoader
|
||||||
|
|||||||
Reference in New Issue
Block a user