From 724fed60013a0e0dfcbaa86556623b0f82218e51 Mon Sep 17 00:00:00 2001 From: Corey Woodworth Date: Fri, 21 Nov 2025 20:23:34 -0500 Subject: [PATCH 1/6] Initial commit --- Helpers/ColorList.js | 187 ++++++++++++++++++++++++++++++ Shaders/frag/color_picker.frag | 54 +++++++++ Shaders/qsb/color_picker.frag.qsb | Bin 0 -> 2482 bytes Widgets/NColorSlider.qml | 177 ++++++++++++++++++++++++++++ 4 files changed, 418 insertions(+) create mode 100644 Helpers/ColorList.js create mode 100644 Shaders/frag/color_picker.frag create mode 100644 Shaders/qsb/color_picker.frag.qsb create mode 100644 Widgets/NColorSlider.qml diff --git a/Helpers/ColorList.js b/Helpers/ColorList.js new file mode 100644 index 00000000..38932149 --- /dev/null +++ b/Helpers/ColorList.js @@ -0,0 +1,187 @@ +var colors = [ + // --- REDS --- + { name: "MistyRose", color: "mistyrose" }, + { name: "LightPink", color: "lightpink" }, + { name: "Pink", color: "pink" }, + { name: "PaleVioletRed", color: "palevioletred" }, + { name: "Pink 500", color: "#E91E63" }, // Material + { name: "HotPink", color: "hotpink" }, + { name: "DeepPink", color: "deeppink" }, + { name: "MediumVioletRed", color: "mediumvioletred" }, + { name: "LightSalmon", color: "lightsalmon" }, + { name: "Salmon", color: "salmon" }, + { name: "DarkSalmon", color: "darksalmon" }, + { name: "LightCoral", color: "lightcoral" }, + { name: "IndianRed", color: "indianred" }, + { name: "Alizarin", color: "#E74C3C" }, // Flat UI + { name: "Red 500", color: "#F44336" }, // Material + { name: "Crimson", color: "crimson" }, + { name: "Red", color: "red" }, + { name: "FireBrick", color: "firebrick" }, + { name: "DarkRed", color: "darkred" }, + { name: "Maroon", color: "maroon" }, + { name: "Brown", color: "brown" }, + + // --- ORANGES & BROWNS --- + { name: "Coral", color: "coral" }, + { name: "Tomato", color: "tomato" }, + { name: "OrangeRed", color: "orangered" }, + { name: "Deep Orange 500", color: "#FF5722" }, // Material + { name: "DarkOrange", color: "darkorange" }, + { name: "Carrot", color: "#E67E22" }, // Flat UI + { name: "Orange 500", color: "#FF9800" }, // Material + { name: "Orange", color: "orange" }, + { name: "SandyBrown", color: "sandybrown" }, + { name: "Peru", color: "peru" }, + { name: "Chocolate", color: "chocolate" }, + { name: "SaddleBrown", color: "saddlebrown" }, + { name: "Sienna", color: "sienna" }, + { name: "Brown 500", color: "#795548" }, // Material + + // --- YELLOWS, BEIGES & GOLDS --- + { name: "LightYellow", color: "lightyellow" }, + { name: "LemonChiffon", color: "lemonchiffon" }, + { name: "LightGoldenrodYellow", color: "lightgoldenrodyellow" }, + { name: "PapayaWhip", color: "papayawhip" }, + { name: "Moccasin", color: "moccasin" }, + { name: "PeachPuff", color: "peachpuff" }, + { name: "NavajoWhite", color: "navajowhite" }, + { name: "Wheat", color: "wheat" }, + { name: "BurlyWood", color: "burlywood" }, + { name: "Tan", color: "tan" }, + { name: "Bisque", color: "bisque" }, + { name: "BlanchedAlmond", color: "blanchedalmond" }, + { name: "Cornsilk", color: "cornsilk" }, + { name: "PaleGoldenrod", color: "palegoldenrod" }, + { name: "Khaki", color: "khaki" }, + { name: "DarkKhaki", color: "darkkhaki" }, + { name: "Goldenrod", color: "goldenrod" }, + { name: "DarkGoldenrod", color: "darkgoldenrod" }, + { name: "Sun Flower", color: "#F1C40F" }, // Flat UI + { name: "Yellow 500", color: "#FFEB3B" }, // Material + { name: "Yellow", color: "yellow" }, + { name: "Gold", color: "gold" }, + { name: "Amber 500", color: "#FFC107" }, // Material + + // --- GREENS --- + { name: "GreenYellow", color: "greenyellow" }, + { name: "Chartreuse", color: "chartreuse" }, + { name: "LawnGreen", color: "lawngreen" }, + { name: "Lime 500", color: "#CDDC39" }, // Material + { name: "Lime", color: "lime" }, + { name: "LimeGreen", color: "limegreen" }, + { name: "PaleGreen", color: "palegreen" }, + { name: "LightGreen", color: "lightgreen" }, + { name: "Light Green 500", color: "#8BC34A" }, // Material + { name: "MediumSpringGreen", color: "mediumspringgreen" }, + { name: "SpringGreen", color: "springgreen" }, + { name: "Emerald", color: "#2ECC71" }, // Flat UI + { name: "Green 500", color: "#4CAF50" }, // Material + { name: "MediumSeaGreen", color: "mediumseagreen" }, + { name: "SeaGreen", color: "seagreen" }, + { name: "ForestGreen", color: "forestgreen" }, + { name: "Green", color: "green" }, + { name: "DarkGreen", color: "darkgreen" }, + { name: "YellowGreen", color: "yellowgreen" }, + { name: "OliveDrab", color: "olivedrab" }, + { name: "Olive", color: "olive" }, + { name: "DarkOliveGreen", color: "darkolivegreen" }, + + // --- TEALS & CYANS --- + { name: "MediumAquamarine", color: "mediumaquamarine" }, + { name: "DarkSeaGreen", color: "darkseagreen" }, + { name: "LightSeaGreen", color: "lightseagreen" }, + { name: "DarkCyan", color: "darkcyan" }, + { name: "Teal", color: "teal" }, + { name: "Turquoise", color: "#1ABC9C" }, // Flat UI + { name: "LightCyan", color: "lightcyan" }, + { name: "PaleTurquoise", color: "paleturquoise" }, + { name: "Aquamarine", color: "aquamarine" }, + { name: "Turquoise", color: "turquoise" }, + { name: "MediumTurquoise", color: "mediumturquoise" }, + { name: "DarkTurquoise", color: "darkturquoise" }, + { name: "Aqua", color: "aqua" }, + { name: "Cyan", color: "cyan" }, + { name: "Cyan 500", color: "#00BCD4" }, // Material + { name: "CadetBlue", color: "cadetblue" }, + { name: "Teal 500", color: "#009688" }, // Material + { name: "DarkSlateGray", color: "darkslategray" }, + + // --- BLUES --- + { name: "PowderBlue", color: "powderblue" }, + { name: "LightBlue", color: "lightblue" }, + { name: "SkyBlue", color: "skyblue" }, + { name: "LightSkyBlue", color: "lightskyblue" }, + { name: "Light Blue 500", color: "#03A9F4" }, // Material + { name: "DeepSkyBlue", color: "deepskyblue" }, + { name: "DodgerBlue", color: "dodgerblue" }, + { name: "CornflowerBlue", color: "cornflowerblue" }, + { name: "Peter River", color: "#3498DB" }, // Flat UI + { name: "Blue 500", color: "#2196F3" }, // Material + { name: "SteelBlue", color: "steelblue" }, + { name: "LightSteelBlue", color: "lightsteelblue" }, + { name: "RoyalBlue", color: "royalblue" }, + { name: "Blue", color: "blue" }, + { name: "MediumBlue", color: "mediumblue" }, + { name: "Belize Hole", color: "#2980B9" }, // Flat UI + { name: "DarkBlue", color: "darkblue" }, + { name: "Navy", color: "navy" }, + { name: "MidnightBlue", color: "midnightblue" }, + { name: "Midnight Blue", color: "#2C3E50" }, // Flat UI (Same name, different color) + { name: "Indigo 500", color: "#3F51B5" }, // Material + { name: "DarkSlateBlue", color: "darkslateblue" }, + { name: "MediumSlateBlue", color: "mediumslateblue" }, + { name: "SlateBlue", color: "slateblue" }, + + // --- PURPLES & MAGENTAS --- + { name: "Lavender", color: "lavender" }, + { name: "Thistle", color: "thistle" }, + { name: "Plum", color: "plum" }, + { name: "Violet", color: "violet" }, + { name: "Orchid", color: "orchid" }, + { name: "Fuchsia", color: "fuchsia" }, + { name: "Magenta", color: "magenta" }, + { name: "MediumOrchid", color: "mediumorchid" }, + { name: "MediumPurple", color: "mediumpurple" }, + { name: "Amethyst", color: "#9B59B6" }, // Flat UI + { name: "Purple 500", color: "#9C27B0" }, // Material + { name: "BlueViolet", color: "blueviolet" }, + { name: "DarkViolet", color: "darkviolet" }, + { name: "DarkOrchid", color: "darkorchid" }, + { name: "DarkMagenta", color: "darkmagenta" }, + { name: "Purple", color: "purple" }, + { name: "Deep Purple 500", color: "#673AB7" }, // Material + { name: "Indigo", color: "indigo" }, + + // --- NEUTRALS --- + { name: "White", color: "white" }, + { name: "Snow", color: "snow" }, + { name: "HoneyDew", color: "honeydew" }, + { name: "MintCream", color: "mintcream" }, + { name: "Azure", color: "azure" }, + { name: "AliceBlue", color: "aliceblue" }, + { name: "GhostWhite", color: "ghostwhite" }, + { name: "WhiteSmoke", color: "whitesmoke" }, + { name: "Seashell", color: "seashell" }, + { name: "Beige", color: "beige" }, + { name: "OldLace", color: "oldlace" }, + { name: "FloralWhite", color: "floralwhite" }, + { name: "Ivory", color: "ivory" }, + { name: "AntiqueWhite", color: "antiquewhite" }, + { name: "Linen", color: "linen" }, + { name: "LavenderBlush", color: "lavenderblush" }, + { name: "Gainsboro", color: "gainsboro" }, + { name: "LightGray", color: "lightgray" }, + { name: "Silver", color: "silver" }, + { name: "DarkGray", color: "darkgray" }, + { name: "Gray", color: "gray" }, + { name: "Grey 500", color: "#9E9E9E" }, // Material + { name: "Concrete", color: "#95A5A6" }, // Flat UI + { name: "DimGray", color: "dimgray" }, + { name: "LightSlateGray", color: "lightslategray" }, + { name: "SlateGray", color: "slategray" }, + { name: "Asbestos", color: "#7F8C8D" }, // Flat UI + { name: "Blue Grey 500", color: "#607D8B" }, // Material + { name: "Wet Asphalt", color: "#34495E" }, // Flat UI + { name: "Black", color: "black" } + ] diff --git a/Shaders/frag/color_picker.frag b/Shaders/frag/color_picker.frag new file mode 100644 index 00000000..c38539cd --- /dev/null +++ b/Shaders/frag/color_picker.frag @@ -0,0 +1,54 @@ +#version 450 + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +layout(std140, binding = 0) uniform buf +{ + mat4 qt_Matrix; + vec4 params; // x=opacity, y=fixedVal, z=mode, w=padding +}; + +vec3 hsv2rgb(vec3 c) +{ + vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); +} + +void main() +{ + float x = qt_TexCoord0.x; + float y = 1.0 - qt_TexCoord0.y; // Flip Y direction + + // Unpack vector + float opacity = params.x; + float fixedVal = params.y; + float mode = params.z + 0.1; // +0.1 safely handles float rounding + + // Build permutation matrices for swizzling + vec3 base = vec3(x, y, fixedVal); + + // Determine Mode Logic + // 0: (Red/Hue) 1: (Green/Sat) 2: (Blue/Val) + int perm = int(mode) % 3; + + float isHSV = step(3.0, mode); + + // Branchless Selection + vec3 mask = vec3( + float(perm == 0), + float(perm == 1), + float(perm == 2)); + + // Swizzle fo shizzle + // If perm 0: base.zxy -> (fixedVal, x, y) + // If perm 1: base.xzy -> (x, fixedVal, y) + // If perm 2: base.xyz -> (x, y, fixedVal) + vec3 rgb_base = (base.zxy * mask.x) + (base.xzy * mask.y) + (base.xyz * mask.z); + + // Final mix + vec3 finalColor = mix(rgb_base, hsv2rgb(rgb_base), isHSV); + + fragColor = vec4(finalColor, 1.0) * opacity; +} diff --git a/Shaders/qsb/color_picker.frag.qsb b/Shaders/qsb/color_picker.frag.qsb new file mode 100644 index 0000000000000000000000000000000000000000..f73dfd6618c3662d3abf45cc691b7c2fbea63487 GIT binary patch literal 2482 zcmV;j2~G9@040uiob6g`dlSbM9&BT$4!IC6A#Iv$a6=@p70Hri8)IT>NFauq00C0h z-K?dRyg}L(yDM9AN)tj#)25_p)AkSaQ|X`R4@mz&KlexUOE2flyd#g+;*yj;PoLJC zXYrhO&SmDzIq#1BLA;bW^JLo+iu8UaM;*xMhOU#Ra{tHD}WNEICUhz*nqQ}Dy zo)Hx?a70xa*QB{}|3K40u_Bse&Ldk)iad?Z8#;Z`y;|Qn3K5fQk5(zfBgS7qjMF5)f$>f$@9fAU9i2^V zNT`fxYzOq_r0;%-^&!p~`gss`T7Jop?-=XYLsorqzF+Q&$NOo-$+GBumh^{^yncxd zP^Q#+hNRtqEKnXl2K^_XKLGtFG0*rBk_Ux8-49>W@@{(nc=vEeen!f7k8634)SsIh zB~R>UFMRBV?jFPU^HTRubNfg>hID%QW3JgpjdVC3N!uz3ROWcd!TBGqgk_9%e;jgXzt z$J3Ct{&%6DGxXi-eh25Q^70k^dP6ah}m*Q|w zc)++<{y?7C*L%SE495)HYYE#Lum!`m4m@e=Cu|$Q0>kz?aBZve8DdR!=tiMmp@H1wZRXoOUA42Cz0_^d;iFk2q${ z{s_2^a|3=DzX|Neh=0R~{Q+WY-yg!aS=%>(Yu_Ki?xx}U7W{vNTt>ijoSz8ABU=6` zWY)b6c^bYx5$c+B+gQWTgyJcEem@7M-(ASvr^rNfc44ssBiGEVgEVipElP1g;1Q$`D5MRK>rJ@>khELQ=KH9`9ATK=;q^nkl8oS?KSqiA3k)gJqv8V=zeB#cR2w6TK_p<2cWkD zdC+z6P569Ho{2iEZ$WPu^SX|{jk)KIcrPU4y$Fooe&f9b9~S()XvBL7@dhx@dDsVB z*ZIp>k6Gu3fa|rql2}U$*egA9#q(+8UfUl|*dGCQIAO2%G72B8r|X>Sc+7Y;{;E(l zre9tES)uPg%3lV$df(&Nx5*uO;M#Wqn0~eI39;E*Da0xm=UIdf=kXs@6)aCl3o(G- z2UyUb6@~{#*4!}i0^iDIv%`(hEqPK}^{T54t5OS`cxDUi`2-F}ao8-y)=IN7{Qj^- zPu+9F+)v}IQ3z=4X zBW)eFillChk-WaX4!h8eo1t&jy;f?0)km#T&8at14XGyqcAd(SDTcJul-?KFEX zWi}{HwC}(xTYO|GyDb*pqasRw1ZdwPTNlg&^K$tPEs&gOE(Ty8o)RhTSJ6vrow^sYFOtIjQ-qP(<6 zJ0X!wsxPbIQjyH^FvZc**2`AjT!I&!zId4wqS$Su@_hPI%?ML>qH8*gv`HzSvlbsg zHVy~q1lZ0W;b+ZPD>f-q`7cSfLVGu?38Nbnt z%~tC6M)5D5x;nqOc;RGLh3?^Fu^A_v7-7l7#mn|3C#Ut2{iL z*$-wj`~GZZKP;P7x{?fLP|~BLv`QDJAr@E-vHlHSgTF`1Y`W@tavLVQ*iBa1z3EM+ zL>ARnazoQ3=&h3Ex2+wlKCD~Vf%5KDUEAZaF4QiLm^C#r-DIQ}hdNh4kI>3PAO)pl zBAKrJZ8DnCmfa3+nDjj$|4Ot;-)kcca#44)_axx)(+C zE7({g4B{YeH{9sp@bHM|mugMwieq&*c4~GMmuue2aRZOMdihoUC$oB-?s)9N@}0UH zQRZDsTJ`$tQ0FU=xHWRis#on-?ePpiD{iH&Dgc=RLZHXJMG9;lj(GlH-S^S6E2NODvyJ-Sv$#RHKwW8Okvofo`hhl wGH}l?OxFj-XrVw6GBff{S)jO4CvMgHukPx9Z`w-RTjn*E)RWJ@0FwNz>!?~4ApigX literal 0 HcmV?d00001 diff --git a/Widgets/NColorSlider.qml b/Widgets/NColorSlider.qml new file mode 100644 index 00000000..1e7264eb --- /dev/null +++ b/Widgets/NColorSlider.qml @@ -0,0 +1,177 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Effects +import qs.Commons +import qs.Services.UI + +Slider { + id: root + + property color fillColor: "transparent" + property var cutoutColor: Color.mSurface + property bool snapAlways: true + property real widthRatio: 0.7 + property string tooltipText + property string tooltipDirection: "auto" + property bool hovering: false + property color topColor: "white" + property color bottomColor: "black" + property bool rainbowMode: false + + readonly property real knobDiameter: Math.round((Style.baseWidgetSize * widthRatio * Style.uiScaleRatio) / 2) * 2 + readonly property real trackWidth: Math.round((knobDiameter * 0.4 * Style.uiScaleRatio) / 2) * 2 + readonly property real cutoutExtra: Math.round((Style.baseWidgetSize * 0.1 * Style.uiScaleRatio) / 2) * 2 + + //horizontal: false + orientation: Qt.Vertical + + padding: cutoutExtra / 2 + + snapMode: snapAlways ? Slider.SnapAlways : Slider.SnapOnRelease + implicitWidth: Math.max(trackWidth, knobDiameter) + + background: Rectangle { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + + x: root.leftPadding + root.availableWidth / 2 - width / 2 + + height: root.availableHeight - root.knobDiameter + width: root.trackWidth + + radius: width / 2 + color: Qt.alpha(Color.mSurface, 0.5) + border.color: Qt.alpha(Color.mOutline, 0.5) + border.width: Style.borderS + + // Gradients + gradient: root.rainbowMode ? rainbowGradient : standardGradient + Gradient { + id: standardGradient + orientation: Gradient.Vertical + GradientStop { + position: 0.0 + color: root.topColor + } + GradientStop { + position: 1.0 + color: root.bottomColor + } + } + Gradient { + id: rainbowGradient + orientation: Gradient.Vertical + GradientStop { + position: 0.000 + color: "#FF0000" + } + GradientStop { + position: 0.167 + color: "#FF00FF" + } + GradientStop { + position: 0.333 + color: "#0000FF" + } + GradientStop { + position: 0.500 + color: "#00FFFF" + } + GradientStop { + position: 0.667 + color: "#00FF00" + } + GradientStop { + position: 0.833 + color: "#FFFF00" + } + GradientStop { + position: 1.000 + color: "#FF0000" + } + } + + // Circular cutout + Rectangle { + id: knobCutout + implicitWidth: root.knobDiameter + root.cutoutExtra + implicitHeight: root.knobDiameter + root.cutoutExtra + radius: width / 2 + color: root.cutoutColor !== undefined ? root.cutoutColor : Color.mSurface + + y: root.visualPosition * (root.availableHeight - root.knobDiameter) - ((root.knobDiameter + root.cutoutExtra) / 2) + anchors.horizontalCenter: parent.horizontalCenter + } + } + + handle: Item { + implicitWidth: root.knobDiameter + implicitHeight: root.knobDiameter + y: root.topPadding + root.visualPosition * (root.availableHeight - height) + anchors.horizontalCenter: parent.horizontalCenter + + Rectangle { + id: knob + implicitWidth: root.knobDiameter + implicitHeight: root.knobDiameter + radius: width / 2 + color: { + if (root.rainbowMode) { + // Hue Logic: Map position (0.0 to 1.0) directly to Hue + return Qt.hsva(1 - root.visualPosition, 1, 1, 1); + } else { + // Linear Interpolation for Standard Gradients + // visualPosition 0.0 = Top, 1.0 = Bottom + var t = root.visualPosition; + var r = root.topColor.r * (1 - t) + root.bottomColor.r * t; + var g = root.topColor.g * (1 - t) + root.bottomColor.g * t; + var b = root.topColor.b * (1 - t) + root.bottomColor.b * t; + return Qt.rgba(r, g, b, 1); + } + } + + border.color: root.pressed ? Color.mHover : Color.mPrimary + border.width: Style.borderL + anchors.centerIn: parent + + Behavior on color { + ColorAnimation { + duration: Style.animationFast + } + } + } + + MouseArea { + enabled: true + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + acceptedButtons: Qt.NoButton // Don't accept any mouse buttons - only hover + propagateComposedEvents: true + + onEntered: { + root.hovering = true; + if (root.tooltipText) { + TooltipService.show(screen, knob, root.tooltipText, root.tooltipDirection); + } + } + + onExited: { + root.hovering = false; + if (root.tooltipText) { + TooltipService.hide(); + } + } + } + + // Hide tooltip when slider is pressed (anywhere on the slider) + Connections { + target: root + function onPressedChanged() { + if (root.pressed && root.tooltipText) { + TooltipService.hide(); + } + } + } + } +} From bd1c9d30d9d1acca685a50111d17da2e27da748f Mon Sep 17 00:00:00 2001 From: Corey Woodworth Date: Fri, 21 Nov 2025 20:29:46 -0500 Subject: [PATCH 2/6] I forgor to add the ColorPicker file --- Widgets/NColorPickerDialog.qml | 791 ++++++++++++++++++++++++--------- 1 file changed, 577 insertions(+), 214 deletions(-) diff --git a/Widgets/NColorPickerDialog.qml b/Widgets/NColorPickerDialog.qml index cae30ea6..09e20ffe 100644 --- a/Widgets/NColorPickerDialog.qml +++ b/Widgets/NColorPickerDialog.qml @@ -1,16 +1,25 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts -import "../Helpers/ColorsConvert.js" as ColorsConvert import qs.Commons import qs.Widgets +import qs.Services.UI +import "../Helpers/ColorList.js" as ColorList Popup { id: root property color selectedColor: Color.black - property real currentHue: 0 - property real currentSaturation: 0 + property string editMode: "r" // Options: "r", "g", "b", "h", "s", "v" + + // Code to deal with Hue when color is achromatic + property real stableHue: 0 + onSelectedColorChanged: { + if (selectedColor.hsvHue >= 0) { + stableHue = selectedColor.hsvHue; + } + } + readonly property real displayHue: selectedColor.hsvHue < 0 ? stableHue : selectedColor.hsvHue signal colorSelected(color color) @@ -116,256 +125,610 @@ Popup { } } - // Hex input - RowLayout { - Layout.fillWidth: true - spacing: Style.marginM - - NLabel { - label: I18n.tr("widgets.color-picker.hex.label") - description: I18n.tr("widgets.color-picker.hex.description") - Layout.fillWidth: true - } - - NTextInput { - text: root.selectedColor.toString().toUpperCase() - fontFamily: Settings.data.ui.fontFixed - Layout.fillWidth: true - onEditingFinished: { - if (/^#[0-9A-F]{6}$/i.test(text)) { - root.selectedColor = text; - } - } - } - } - - // RGB sliders section + // Main Box NBox { Layout.fillWidth: true - Layout.preferredHeight: slidersSection.implicitHeight + Style.marginL * 2 + Layout.preferredHeight: controlsOutterColumn.implicitHeight + Style.marginL * 2 + + ButtonGroup { + id: colorValues + } ColumnLayout { - id: slidersSection + id: controlsOutterColumn anchors.fill: parent anchors.margins: Style.marginL spacing: Style.marginM - NLabel { - label: I18n.tr("widgets.color-picker.rgb.label") - description: I18n.tr("widgets.color-picker.rgb.description") - Layout.fillWidth: true - } - RowLayout { - Layout.fillWidth: true - spacing: Style.marginM + spacing: Style.marginL // Ensure nice gap between Left and Right groups - NText { - text: "R" - font.weight: Font.Bold - Layout.preferredWidth: 20 - } - - NValueSlider { - id: redSlider + // SpinBoxes Column + ColumnLayout { Layout.fillWidth: true - from: 0 - to: 255 - value: Math.round(root.selectedColor.r * 255) - onMoved: value => { - root.selectedColor = Qt.rgba(value / 255, root.selectedColor.g, root.selectedColor.b, 1); - var hsv = ColorsConvert.rgbToHsv(root.selectedColor.r * 255, root.selectedColor.g * 255, root.selectedColor.b * 255); - root.currentHue = hsv.h; - root.currentSaturation = hsv.s; - } - text: Math.round(value) - } - } + Layout.fillHeight: true + Layout.alignment: Qt.AlignTop + Layout.preferredWidth: 3 - RowLayout { - Layout.fillWidth: true - spacing: Style.marginM + // --- RED --- + RowLayout { + Layout.fillWidth: true + spacing: Style.marginM - NText { - text: "G" - font.weight: Font.Bold - Layout.preferredWidth: 20 - } + NRadioButton { + ButtonGroup.group: colorValues + text: "R" + font.weight: Font.Bold + checked: true + onClicked: root.editMode = "r" + Layout.fillWidth: false + } - NValueSlider { - id: greenSlider - Layout.fillWidth: true - from: 0 - to: 255 - value: Math.round(root.selectedColor.g * 255) - onMoved: value => { - root.selectedColor = Qt.rgba(root.selectedColor.r, value / 255, root.selectedColor.b, 1); - // Update stored hue and saturation when RGB changes - var hsv = ColorsConvert.rgbToHsv(root.selectedColor.r * 255, root.selectedColor.g * 255, root.selectedColor.b * 255); - root.currentHue = hsv.h; - root.currentSaturation = hsv.s; - } - text: Math.round(value) - } - } + NSpinBox { + id: redSpinBox + from: 0 + to: 255 - RowLayout { - Layout.fillWidth: true - spacing: Style.marginM - - NText { - text: "B" - font.weight: Font.Bold - Layout.preferredWidth: 20 - } - - NValueSlider { - id: blueSlider - Layout.fillWidth: true - from: 0 - to: 255 - value: Math.round(root.selectedColor.b * 255) - onMoved: value => { - root.selectedColor = Qt.rgba(root.selectedColor.r, root.selectedColor.g, value / 255, 1); - // Update stored hue and saturation when RGB changes - var hsv = ColorsConvert.rgbToHsv(root.selectedColor.r * 255, root.selectedColor.g * 255, root.selectedColor.b * 255); - root.currentHue = hsv.h; - root.currentSaturation = hsv.s; - } - text: Math.round(value) - } - } - - RowLayout { - Layout.fillWidth: true - spacing: Style.marginM - - NText { - text: I18n.tr("widgets.color-picker.brightness") - font.weight: Font.Bold - Layout.preferredWidth: 80 - } - - NValueSlider { - id: brightnessSlider - Layout.fillWidth: true - from: 0 - to: 100 - value: { - var hsv = ColorsConvert.rgbToHsv(root.selectedColor.r * 255, root.selectedColor.g * 255, root.selectedColor.b * 255); - return hsv.v; + onValueChanged: { + if (!selectedSlider.pressed && !fieldMouse.pressed && !hexInput.activeFocus && value !== Math.round(root.selectedColor.r * 255)) { + root.selectedColor = Qt.rgba(value / 255, root.selectedColor.g, root.selectedColor.b, 1); + } + } + Binding { + target: redSpinBox + property: "value" + value: Math.round(root.selectedColor.r * 255) + } + } } - onMoved: value => { - var hue = root.currentHue; - var saturation = root.currentSaturation; - if (hue === 0 && saturation === 0) { - var hsv = ColorsConvert.rgbToHsv(root.selectedColor.r * 255, root.selectedColor.g * 255, root.selectedColor.b * 255); - hue = hsv.h; - saturation = hsv.s; - root.currentHue = hue; - root.currentSaturation = saturation; - } + // --- GREEN --- + RowLayout { + Layout.fillWidth: true + spacing: Style.marginM - var rgb = ColorsConvert.hsvToRgb(hue, saturation, value); - root.selectedColor = Qt.rgba(rgb.r / 255, rgb.g / 255, rgb.b / 255, 1); - } - text: Math.round(brightnessSlider.value) + "%" - } - } - } - } + NRadioButton { + ButtonGroup.group: colorValues + text: "G" + font.weight: Font.Bold + onClicked: root.editMode = "g" + Layout.fillWidth: false + } - NBox { - Layout.fillWidth: true - Layout.preferredHeight: themePalette.implicitHeight + Style.marginL * 2 + NSpinBox { + id: greenSpinBox + from: 0 + to: 255 - ColumnLayout { - id: themePalette - anchors.fill: parent - anchors.margins: Style.marginL - spacing: Style.marginS + onValueChanged: { + if (!selectedSlider.pressed && !fieldMouse.pressed && !hexInput.activeFocus && value !== Math.round(root.selectedColor.g * 255)) { + root.selectedColor = Qt.rgba(root.selectedColor.r, value / 255, root.selectedColor.b, 1); + } + } + Binding { + target: greenSpinBox + property: "value" + value: Math.round(root.selectedColor.g * 255) + } + } + } - NLabel { - label: I18n.tr("widgets.color-picker.theme-colors.label") - description: I18n.tr("widgets.color-picker.theme-colors.description") - Layout.fillWidth: true - } + // --- BLUE --- + RowLayout { + Layout.fillWidth: true + spacing: Style.marginM - Flow { - spacing: 6 - Layout.fillWidth: true - flow: Flow.LeftToRight + NRadioButton { + ButtonGroup.group: colorValues + text: "B" + font.weight: Font.Bold + onClicked: root.editMode = "b" + Layout.fillWidth: false + } - Repeater { - model: [Color.mPrimary, Color.mSecondary, Color.mTertiary, Color.mError, Color.mSurface, Color.mSurfaceVariant, Color.mOutline, Color.white, Color.black] + NSpinBox { + id: blueSpinBox + from: 0 + to: 255 - Rectangle { - width: 24 - height: 24 - radius: 4 - color: modelData - border.color: root.selectedColor === modelData ? Color.mPrimary : Color.mOutline - border.width: root.selectedColor === modelData ? 2 : 1 + onValueChanged: { + if (!selectedSlider.pressed && !fieldMouse.pressed && !hexInput.activeFocus && value !== Math.round(root.selectedColor.b * 255)) { + root.selectedColor = Qt.rgba(root.selectedColor.r, root.selectedColor.g, value / 255, 1); + } + } + Binding { + target: blueSpinBox + property: "value" + value: Math.round(root.selectedColor.b * 255) + } + } + } - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - root.selectedColor = modelData; - var hsv = ColorsConvert.rgbToHsv(root.selectedColor.r * 255, root.selectedColor.g * 255, root.selectedColor.b * 255); - root.currentHue = hsv.h; - root.currentSaturation = hsv.s; + // Spacer + Item { + Layout.fillHeight: true + Layout.fillWidth: true + } + + // --- HUE --- + RowLayout { + Layout.fillWidth: true + spacing: Style.marginM + + NRadioButton { + ButtonGroup.group: colorValues + text: "H" + font.weight: Font.Bold + checked: true + onClicked: root.editMode = "h" + Layout.fillWidth: false + } + + NSpinBox { + id: hueSpinBox + from: 0 + to: 360 + + onValueChanged: { + if (!selectedSlider.pressed && !fieldMouse.pressed && !hexInput.activeFocus && value !== Math.round(root.displayHue * 360)) { + var newHue = value / 360; + root.selectedColor = Qt.hsva(newHue, root.selectedColor.hsvSaturation, root.selectedColor.hsvValue, 1); + root.stableHue = newHue; + } + } + + Binding { + target: hueSpinBox + property: "value" + value: Math.round(root.displayHue * 360) + } + } + } + + // --- SATURATION --- + RowLayout { + Layout.fillWidth: true + spacing: Style.marginM + + NRadioButton { + ButtonGroup.group: colorValues + text: "S" + font.weight: Font.Bold + onClicked: root.editMode = "s" + Layout.fillWidth: false + } + + NSpinBox { + id: satSpinBox + from: 0 + to: 100 + + onValueChanged: { + if (!selectedSlider.pressed && !fieldMouse.pressed && !hexInput.activeFocus && value !== Math.round(root.selectedColor.hsvSaturation * 100)) { + root.selectedColor = Qt.hsva(root.selectedColor.hsvHue, value / 100, root.selectedColor.hsvValue, 1); + } + } + Binding { + target: satSpinBox + property: "value" + value: Math.round(root.selectedColor.hsvSaturation * 100) + } + } + } + + // --- VALUE --- + RowLayout { + spacing: Style.marginM + + NRadioButton { + ButtonGroup.group: colorValues + text: "V" + font.weight: Font.Bold + onClicked: root.editMode = "v" + Layout.fillWidth: false + } + + NSpinBox { + id: valSpinBox + from: 0 + to: 100 + + onValueChanged: { + if (!selectedSlider.pressed && !fieldMouse.pressed && !hexInput.activeFocus && value !== Math.round(root.selectedColor.hsvValue * 100)) { + root.selectedColor = Qt.hsva(root.selectedColor.hsvHue, root.selectedColor.hsvSaturation, value / 100, 1); + } + } + Binding { + target: valSpinBox + property: "value" + value: Math.round(root.selectedColor.hsvValue * 100) + } + } + } + + // Spacer + Item { + Layout.fillHeight: true + Layout.fillWidth: true + } + + // Hex input + RowLayout { + id: hexInput + Layout.fillWidth: true + spacing: Style.marginM + + NLabel { + label: "Hex:" // I18n.tr("widgets.color-picker.hex.label") + // description: I18n.tr("widgets.color-picker.hex.description") + Layout.alignment: Qt.AlignVCenter + } + + NTextInput { + text: root.selectedColor.toString().toUpperCase() + fontFamily: Settings.data.ui.fontFixed + Layout.fillWidth: true + Layout.minimumWidth: implicitWidth + onEditingFinished: { + if (/^#[0-9A-F]{6}$/i.test(text)) { + root.selectedColor = text; + } } } } } - } - } - } - NBox { - Layout.fillWidth: true - Layout.preferredHeight: genericPalette.implicitHeight + Style.marginL * 2 + RowLayout { + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredWidth: 5 + Layout.alignment: Qt.AlignTop + spacing: Style.marginS - ColumnLayout { - id: genericPalette - anchors.fill: parent - anchors.margins: Style.marginL - spacing: Style.marginS + Layout.topMargin: Math.round(2 * Style.uiScaleRatio) //Shim to try and line up colorField with SpinBoxes - NLabel { - label: I18n.tr("widgets.color-picker.palette.label") - description: I18n.tr("widgets.color-picker.palette.description") - Layout.fillWidth: true - } + // --- SLIDER --- + NColorSlider { + id: selectedSlider + Layout.fillHeight: true + rainbowMode: root.editMode === "h" + topColor: { + if (rainbowMode) + return "transparent"; + switch (root.editMode) { + case "r": + return "#FF0000"; + case "g": + return "#00FF00"; + case "b": + return "#0000FF"; + default: + return "#FFFFFF"; + } + } - Flow { - Layout.fillWidth: true - Layout.fillHeight: true - spacing: 6 - flow: Flow.LeftToRight + Binding { + target: selectedSlider + property: "value" + when: !selectedSlider.pressed // Only update from model when NOT dragging + value: { + switch (root.editMode) { + case "r": + return root.selectedColor.r; + case "g": + return root.selectedColor.g; + case "b": + return root.selectedColor.b; + case "h": + return root.displayHue; + case "s": + return root.selectedColor.hsvSaturation; + case "v": + return root.selectedColor.hsvValue; + default: + return 0; + } + } + } - Repeater { - model: ["#F44336", "#E91E63", "#9C27B0", "#673AB7", "#3F51B5", "#2196F3", "#03A9F4", "#00BCD4", "#009688", "#4CAF50", "#8BC34A", "#CDDC39", "#FFEB3B", "#FFC107", "#FF9800", "#FF5722", "#795548", "#9E9E9E", "#E74C3C", "#E67E22", "#F1C40F", "#2ECC71", "#1ABC9C", "#3498DB", "#2980B9", "#9B59B6", "#34495E", "#2C3E50", "#95A5A6", "#7F8C8D", - Color.white, Color.black] + onMoved: { + var v = value; + switch (root.editMode) { + case "r": + root.selectedColor = Qt.rgba(v, root.selectedColor.g, root.selectedColor.b, 1); + break; + case "g": + root.selectedColor = Qt.rgba(root.selectedColor.r, v, root.selectedColor.b, 1); + break; + case "b": + root.selectedColor = Qt.rgba(root.selectedColor.r, root.selectedColor.g, v, 1); + break; + case "h": + root.selectedColor = Qt.hsva(v, root.selectedColor.hsvSaturation, root.selectedColor.hsvValue, 1); + root.stableHue = v; + break; + case "s": + root.selectedColor = Qt.hsva(root.selectedColor.hsvHue, v, root.selectedColor.hsvValue, 1); + break; + case "v": + root.selectedColor = Qt.hsva(root.selectedColor.hsvHue, root.selectedColor.hsvSaturation, v, 1); + break; + } + } + } + // Color Field Rectangle { - width: 24 - height: 24 - radius: Style.radiusXXS - color: modelData - border.color: root.selectedColor === modelData ? Color.mPrimary : Color.mOutline - border.width: Math.max(1, root.selectedColor === modelData ? Style.borderM : Style.borderS) + id: colorField + Layout.fillWidth: true + + Layout.preferredHeight: width + Layout.alignment: Qt.AlignTop + + radius: 0 + border.color: Color.mOutline + border.width: Style.borderS + clip: true + + ShaderEffect { + anchors.fill: parent + anchors.margins: 1 // Avoid drawing over the border + + fragmentShader: "../Shaders/qsb/color_picker.frag.qsb" + + // Map strings to integers + readonly property int modeInt: { + switch (root.editMode) { + case "r": + return 0; + case "g": + return 1; + case "b": + return 2; + case "h": + return 3; + case "s": + return 4; + case "v": + return 5; + default: + return 0; + } + } + + // Pass which radio is selected + readonly property real fixedVal: { + switch (root.editMode) { + case "r": + return root.selectedColor.r; + case "g": + return root.selectedColor.g; + case "b": + return root.selectedColor.b; + case "h": + return root.displayHue; + case "s": + return root.selectedColor.hsvSaturation; + case "v": + return root.selectedColor.hsvValue; + default: + return 0; + } + } + + // Send as one vector because GPUs are so damn picky + property vector4d params: Qt.vector4d(1.0, fixedVal, modeInt, 0) + } MouseArea { + id: fieldMouse anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - root.selectedColor = modelData; - var hsv = ColorsConvert.rgbToHsv(root.selectedColor.r * 255, root.selectedColor.g * 255, root.selectedColor.b * 255); - root.currentHue = hsv.h; - root.currentSaturation = hsv.s; + cursorShape: Qt.CrossCursor + + // Update color when clicking or dragging + function updateColor(mouse) { + // Normalize X and Y (0.0 to 1.0) + var xVal = Math.max(0, Math.min(1, mouse.x / width)); + var yVal = Math.max(0, Math.min(1, 1.0 - (mouse.y / height))); // Flip Y (0 at bottom) + + // Get the current fixed value (from the slider) + var fixed = 0.0; + + switch (root.editMode) { + case "r": + fixed = root.selectedColor.r; + root.selectedColor = Qt.rgba(fixed, xVal, yVal, 1); + break; + case "g": + fixed = root.selectedColor.g; + root.selectedColor = Qt.rgba(xVal, fixed, yVal, 1); + break; + case "b": + fixed = root.selectedColor.b; + root.selectedColor = Qt.rgba(xVal, yVal, fixed, 1); + break; + case "h": + // Use stableHue to prevent flipping to -1 + fixed = root.displayHue; + root.selectedColor = Qt.hsva(fixed, xVal, yVal, 1); + root.stableHue = fixed; + break; + case "s": + fixed = root.selectedColor.hsvSaturation; + root.selectedColor = Qt.hsva(xVal, fixed, yVal, 1); + // If we dragged Hue (xVal), update stableHue + root.stableHue = yVal; + break; + case "v": + fixed = root.selectedColor.hsvValue; + root.selectedColor = Qt.hsva(xVal, yVal, fixed, 1); + // If we dragged Hue (xVal), update stableHue + root.stableHue = xVal; + break; + } + } + onPressed: mouse => updateColor(mouse) + onPositionChanged: mouse => updateColor(mouse) + } + + // Color Indicator + Rectangle { + width: 10 + height: 10 + radius: 5 + color: "transparent" + border.color: root.selectedColor.hsvValue < 0.5 ? "white" : "black" + border.width: 1 + + // Find position based on the current color + readonly property point selectedPos: { + switch (root.editMode) { + case "r": + return Qt.point(root.selectedColor.g, root.selectedColor.b); + case "g": + return Qt.point(root.selectedColor.r, root.selectedColor.b); + case "b": + return Qt.point(root.selectedColor.r, root.selectedColor.g); + case "h": + return Qt.point(root.selectedColor.hsvSaturation, root.selectedColor.hsvValue); + case "s": + return Qt.point(root.displayHue, root.selectedColor.hsvValue); + case "v": + return Qt.point(root.displayHue, root.selectedColor.hsvSaturation); + default: + return Qt.point(0, 0); + } + } + + // Convert values to pixel position + x: (selectedPos.x * parent.width) - width / 2 + y: ((1.0 - selectedPos.y) * parent.height) - height / 2 + } + + // Redraw the border in case Color Indicator is near the edge + Rectangle { + anchors.fill: parent + color: "transparent" + border.color: Color.mOutline + border.width: Style.borderS + antialiasing: false + } + } + } + } + + NCollapsible { + id: paletteCollapsible + label: I18n.tr("widgets.color-picker.palette.label") + description: I18n.tr("widgets.color-picker.palette.description") + + Layout.fillWidth: true + contentSpacing: Style.marginS + + GridLayout { + Layout.alignment: Qt.AlignHCenter + columns: 15 + columnSpacing: 6 + rowSpacing: 6 + + Repeater { + model: ColorList.colors + + Rectangle { + width: 24 + height: 24 + radius: Style.radiusXXS + color: modelData.color + border.color: root.selectedColor.toString() === modelData.color.toString() ? Color.mPrimary : Color.mOutline + border.width: Math.max(1, root.selectedColor.toString() === modelData.color.toString() ? Style.borderM : Style.borderS) + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + + onEntered: { + TooltipService.show(screen, parent, modelData.name + "\n" + parent.color.toString().toUpperCase(), "auto"); + } + onExited: { + TooltipService.hide(); + } + onClicked: { + root.selectedColor = modelData.color; + TooltipService.hide(); + } + } + } + } + + NDivider { + Layout.columnSpan: 15 + Layout.fillWidth: true + Layout.topMargin: Style.marginXS + Layout.bottomMargin: 0 + } + + NLabel { + Layout.columnSpan: 15 + Layout.fillWidth: true + description: I18n.tr("widgets.color-picker.theme-colors.description") + } + + Repeater { + model: [ + { + name: "mPrimary", + color: Color.mPrimary + }, + { + name: "mSecondary", + color: Color.mSecondary + }, + { + name: "mTertiary", + color: Color.mTertiary + }, + { + name: "mError", + color: Color.mError + }, + { + name: "mSurface", + color: Color.mSurface + }, + { + name: "mSurfaceVariant", + color: Color.mSurfaceVariant + }, + { + name: "mOutline", + color: Color.mOutline + } + ] + + Rectangle { + width: 24 + height: 24 + radius: 4 + color: modelData.color + border.color: root.selectedColor.toString() === modelData.color.toString() ? Color.mPrimary : Color.mOutline + border.width: root.selectedColor.toString() === modelData.color.toString() ? 2 : 1 + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + + onEntered: { + TooltipService.show(screen, parent, modelData.name + "\n" + parent.color.toString().toUpperCase(), "auto"); + } + onExited: { + TooltipService.hide(); + } + onClicked: { + root.selectedColor = modelData.color; + TooltipService.hide(); + } } } } From 42f782abbf289ce53cde872bab456862daee3037 Mon Sep 17 00:00:00 2001 From: Corey Woodworth Date: Fri, 21 Nov 2025 22:39:05 -0500 Subject: [PATCH 3/6] Update tooltip code, Use an Enum for editMode, setup strings for i18n --- Widgets/NColorPickerDialog.qml | 119 +++++++++++++++------------------ 1 file changed, 54 insertions(+), 65 deletions(-) diff --git a/Widgets/NColorPickerDialog.qml b/Widgets/NColorPickerDialog.qml index 09e20ffe..7d1ad5c7 100644 --- a/Widgets/NColorPickerDialog.qml +++ b/Widgets/NColorPickerDialog.qml @@ -1,6 +1,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts +import QtQml import qs.Commons import qs.Widgets import qs.Services.UI @@ -10,7 +11,16 @@ Popup { id: root property color selectedColor: Color.black - property string editMode: "r" // Options: "r", "g", "b", "h", "s", "v" + + enum EditMode { + R, + G, + B, + H, + S, + V + } + property int editMode: NColorPickerDialog.EditMode.R // Code to deal with Hue when color is achromatic property real stableHue: 0 @@ -160,7 +170,7 @@ Popup { text: "R" font.weight: Font.Bold checked: true - onClicked: root.editMode = "r" + onClicked: root.editMode = NColorPickerDialog.EditMode.R Layout.fillWidth: false } @@ -191,7 +201,7 @@ Popup { ButtonGroup.group: colorValues text: "G" font.weight: Font.Bold - onClicked: root.editMode = "g" + onClicked: root.editMode = NColorPickerDialog.EditMode.G Layout.fillWidth: false } @@ -222,7 +232,7 @@ Popup { ButtonGroup.group: colorValues text: "B" font.weight: Font.Bold - onClicked: root.editMode = "b" + onClicked: root.editMode = NColorPickerDialog.EditMode.B Layout.fillWidth: false } @@ -260,7 +270,7 @@ Popup { text: "H" font.weight: Font.Bold checked: true - onClicked: root.editMode = "h" + onClicked: root.editMode = NColorPickerDialog.EditMode.H Layout.fillWidth: false } @@ -294,7 +304,7 @@ Popup { ButtonGroup.group: colorValues text: "S" font.weight: Font.Bold - onClicked: root.editMode = "s" + onClicked: root.editMode = NColorPickerDialog.EditMode.S Layout.fillWidth: false } @@ -324,7 +334,7 @@ Popup { ButtonGroup.group: colorValues text: "V" font.weight: Font.Bold - onClicked: root.editMode = "v" + onClicked: root.editMode = NColorPickerDialog.EditMode.V Layout.fillWidth: false } @@ -359,8 +369,7 @@ Popup { spacing: Style.marginM NLabel { - label: "Hex:" // I18n.tr("widgets.color-picker.hex.label") - // description: I18n.tr("widgets.color-picker.hex.description") + label: I18n.tr("widgets.color-picker.hex") Layout.alignment: Qt.AlignVCenter } @@ -396,11 +405,11 @@ Popup { if (rainbowMode) return "transparent"; switch (root.editMode) { - case "r": + case NColorPickerDialog.EditMode.R: return "#FF0000"; - case "g": + case NColorPickerDialog.EditMode.G: return "#00FF00"; - case "b": + case NColorPickerDialog.EditMode.B: return "#0000FF"; default: return "#FFFFFF"; @@ -413,17 +422,17 @@ Popup { when: !selectedSlider.pressed // Only update from model when NOT dragging value: { switch (root.editMode) { - case "r": + case NColorPickerDialog.EditMode.R: return root.selectedColor.r; - case "g": + case NColorPickerDialog.EditMode.G: return root.selectedColor.g; - case "b": + case NColorPickerDialog.EditMode.B: return root.selectedColor.b; - case "h": + case NColorPickerDialog.EditMode.H: return root.displayHue; - case "s": + case NColorPickerDialog.EditMode.S: return root.selectedColor.hsvSaturation; - case "v": + case NColorPickerDialog.EditMode.V: return root.selectedColor.hsvValue; default: return 0; @@ -434,23 +443,23 @@ Popup { onMoved: { var v = value; switch (root.editMode) { - case "r": + case NColorPickerDialog.EditMode.R: root.selectedColor = Qt.rgba(v, root.selectedColor.g, root.selectedColor.b, 1); break; - case "g": + case NColorPickerDialog.EditMode.G: root.selectedColor = Qt.rgba(root.selectedColor.r, v, root.selectedColor.b, 1); break; - case "b": + case NColorPickerDialog.EditMode.B: root.selectedColor = Qt.rgba(root.selectedColor.r, root.selectedColor.g, v, 1); break; - case "h": + case NColorPickerDialog.EditMode.H: root.selectedColor = Qt.hsva(v, root.selectedColor.hsvSaturation, root.selectedColor.hsvValue, 1); root.stableHue = v; break; - case "s": + case NColorPickerDialog.EditMode.S: root.selectedColor = Qt.hsva(root.selectedColor.hsvHue, v, root.selectedColor.hsvValue, 1); break; - case "v": + case NColorPickerDialog.EditMode.V: root.selectedColor = Qt.hsva(root.selectedColor.hsvHue, root.selectedColor.hsvSaturation, v, 1); break; } @@ -476,40 +485,20 @@ Popup { fragmentShader: "../Shaders/qsb/color_picker.frag.qsb" - // Map strings to integers - readonly property int modeInt: { - switch (root.editMode) { - case "r": - return 0; - case "g": - return 1; - case "b": - return 2; - case "h": - return 3; - case "s": - return 4; - case "v": - return 5; - default: - return 0; - } - } - // Pass which radio is selected readonly property real fixedVal: { switch (root.editMode) { - case "r": + case NColorPickerDialog.EditMode.R: return root.selectedColor.r; - case "g": + case NColorPickerDialog.EditMode.G: return root.selectedColor.g; - case "b": + case NColorPickerDialog.EditMode.B: return root.selectedColor.b; - case "h": + case NColorPickerDialog.EditMode.H: return root.displayHue; - case "s": + case NColorPickerDialog.EditMode.S: return root.selectedColor.hsvSaturation; - case "v": + case NColorPickerDialog.EditMode.V: return root.selectedColor.hsvValue; default: return 0; @@ -517,7 +506,7 @@ Popup { } // Send as one vector because GPUs are so damn picky - property vector4d params: Qt.vector4d(1.0, fixedVal, modeInt, 0) + property vector4d params: Qt.vector4d(1.0, fixedVal, root.editMode, 0) } MouseArea { @@ -535,31 +524,31 @@ Popup { var fixed = 0.0; switch (root.editMode) { - case "r": + case NColorPickerDialog.EditMode.R: fixed = root.selectedColor.r; root.selectedColor = Qt.rgba(fixed, xVal, yVal, 1); break; - case "g": + case NColorPickerDialog.EditMode.G: fixed = root.selectedColor.g; root.selectedColor = Qt.rgba(xVal, fixed, yVal, 1); break; - case "b": + case NColorPickerDialog.EditMode.B: fixed = root.selectedColor.b; root.selectedColor = Qt.rgba(xVal, yVal, fixed, 1); break; - case "h": + case NColorPickerDialog.EditMode.H: // Use stableHue to prevent flipping to -1 fixed = root.displayHue; root.selectedColor = Qt.hsva(fixed, xVal, yVal, 1); root.stableHue = fixed; break; - case "s": + case NColorPickerDialog.EditMode.S: fixed = root.selectedColor.hsvSaturation; root.selectedColor = Qt.hsva(xVal, fixed, yVal, 1); // If we dragged Hue (xVal), update stableHue root.stableHue = yVal; break; - case "v": + case NColorPickerDialog.EditMode.V: fixed = root.selectedColor.hsvValue; root.selectedColor = Qt.hsva(xVal, yVal, fixed, 1); // If we dragged Hue (xVal), update stableHue @@ -583,17 +572,17 @@ Popup { // Find position based on the current color readonly property point selectedPos: { switch (root.editMode) { - case "r": + case NColorPickerDialog.EditMode.R: return Qt.point(root.selectedColor.g, root.selectedColor.b); - case "g": + case NColorPickerDialog.EditMode.G: return Qt.point(root.selectedColor.r, root.selectedColor.b); - case "b": + case NColorPickerDialog.EditMode.B: return Qt.point(root.selectedColor.r, root.selectedColor.g); - case "h": + case NColorPickerDialog.EditMode.H: return Qt.point(root.selectedColor.hsvSaturation, root.selectedColor.hsvValue); - case "s": + case NColorPickerDialog.EditMode.S: return Qt.point(root.displayHue, root.selectedColor.hsvValue); - case "v": + case NColorPickerDialog.EditMode.V: return Qt.point(root.displayHue, root.selectedColor.hsvSaturation); default: return Qt.point(0, 0); @@ -648,7 +637,7 @@ Popup { hoverEnabled: true onEntered: { - TooltipService.show(screen, parent, modelData.name + "\n" + parent.color.toString().toUpperCase(), "auto"); + TooltipService.show(parent, modelData.name + "\n" + parent.color.toString().toUpperCase(), "auto"); } onExited: { TooltipService.hide(); @@ -671,7 +660,7 @@ Popup { NLabel { Layout.columnSpan: 15 Layout.fillWidth: true - description: I18n.tr("widgets.color-picker.theme-colors.description") + description: I18n.tr("widgets.color-picker.palette.theme-colors") } Repeater { From 89d7a63248df5f5b96ab6b06696418b703e3cfc3 Mon Sep 17 00:00:00 2001 From: Corey Woodworth Date: Fri, 21 Nov 2025 22:43:03 -0500 Subject: [PATCH 4/6] removed unneeded 'auto' since it's by default --- Widgets/NColorPickerDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Widgets/NColorPickerDialog.qml b/Widgets/NColorPickerDialog.qml index 7d1ad5c7..d90b6253 100644 --- a/Widgets/NColorPickerDialog.qml +++ b/Widgets/NColorPickerDialog.qml @@ -637,7 +637,7 @@ Popup { hoverEnabled: true onEntered: { - TooltipService.show(parent, modelData.name + "\n" + parent.color.toString().toUpperCase(), "auto"); + TooltipService.show(parent, modelData.name + "\n" + parent.color.toString().toUpperCase()); } onExited: { TooltipService.hide(); From 0ba80b10a9a5eb121c6455a02bb6baaf3b16dd34 Mon Sep 17 00:00:00 2001 From: Corey Woodworth Date: Fri, 21 Nov 2025 22:59:40 -0500 Subject: [PATCH 5/6] removed 'Hex:' from i18n because of numerous translation issues --- Widgets/NColorPickerDialog.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Widgets/NColorPickerDialog.qml b/Widgets/NColorPickerDialog.qml index d90b6253..b3b777b5 100644 --- a/Widgets/NColorPickerDialog.qml +++ b/Widgets/NColorPickerDialog.qml @@ -369,7 +369,7 @@ Popup { spacing: Style.marginM NLabel { - label: I18n.tr("widgets.color-picker.hex") + label: "Hex:" Layout.alignment: Qt.AlignVCenter } From 2c1c1da64cd54a61a8aa166a222b192ccdb1a8cd Mon Sep 17 00:00:00 2001 From: Corey Woodworth Date: Fri, 21 Nov 2025 23:00:29 -0500 Subject: [PATCH 6/6] Translations done --- Assets/Translations/de.json | 16 ++-------------- Assets/Translations/en.json | 16 ++-------------- Assets/Translations/es.json | 16 ++-------------- Assets/Translations/fr.json | 16 ++-------------- Assets/Translations/nl.json | 16 ++-------------- Assets/Translations/pt.json | 16 ++-------------- Assets/Translations/ru.json | 16 ++-------------- Assets/Translations/tr.json | 16 ++-------------- Assets/Translations/uk-UA.json | 16 ++-------------- Assets/Translations/zh-CN.json | 16 ++-------------- 10 files changed, 20 insertions(+), 140 deletions(-) diff --git a/Assets/Translations/de.json b/Assets/Translations/de.json index 28a127cc..c106e70b 100644 --- a/Assets/Translations/de.json +++ b/Assets/Translations/de.json @@ -2241,23 +2241,11 @@ "widgets": { "color-picker": { "apply": "Anwenden", - "brightness": "Helligkeit", "cancel": "Abbrechen", - "hex": { - "description": "Geben Sie einen hexadezimalen Farbcode ein.", - "label": "Hex-Farbe" - }, "palette": { "description": "Wählen Sie aus einer großen Auswahl vordefinierter Farben.", - "label": "Palette" - }, - "rgb": { - "description": "Passen Sie Rot-, Grün-, Blau- und Helligkeitswerte an.", - "label": "RGB-Werte" - }, - "theme-colors": { - "description": "Schnellzugriff auf die Farbpalette Ihres Themes.", - "label": "Theme-Farben" + "label": "Palette", + "theme-colors": "Schneller Zugriff auf die Farbpalette Ihres Themes." }, "title": "Farbauswahl" }, diff --git a/Assets/Translations/en.json b/Assets/Translations/en.json index 424f2974..3fc0fb6b 100644 --- a/Assets/Translations/en.json +++ b/Assets/Translations/en.json @@ -2241,23 +2241,11 @@ "widgets": { "color-picker": { "apply": "Apply", - "brightness": "Brightness", "cancel": "Cancel", - "hex": { - "description": "Enter a hexadecimal color code.", - "label": "Hex color" - }, "palette": { "description": "Choose from a wide range of predefined colors.", - "label": "Palette" - }, - "rgb": { - "description": "Adjust red, green, blue, and brightness values.", - "label": "RGB values" - }, - "theme-colors": { - "description": "Quick access to your theme's color palette.", - "label": "Theme colors" + "label": "Palette", + "theme-colors": "Quick access to your theme's color palette." }, "title": "Color picker" }, diff --git a/Assets/Translations/es.json b/Assets/Translations/es.json index b677803a..ea441e9f 100644 --- a/Assets/Translations/es.json +++ b/Assets/Translations/es.json @@ -2241,23 +2241,11 @@ "widgets": { "color-picker": { "apply": "Aplicar", - "brightness": "Brillo", "cancel": "Cancelar", - "hex": { - "description": "Ingresa un código de color hexadecimal.", - "label": "Color hexadecimal" - }, "palette": { "description": "Elige entre una amplia gama de colores predefinidos.", - "label": "Paleta" - }, - "rgb": { - "description": "Ajusta los valores de rojo, verde, azul y brillo.", - "label": "Valores RGB" - }, - "theme-colors": { - "description": "Acceso rápido a la paleta de colores de tu tema.", - "label": "Colores del tema" + "label": "Paleta", + "theme-colors": "Acceso rápido a la paleta de colores de tu tema." }, "title": "Selector de colores" }, diff --git a/Assets/Translations/fr.json b/Assets/Translations/fr.json index 372e5a2a..7959a3a3 100644 --- a/Assets/Translations/fr.json +++ b/Assets/Translations/fr.json @@ -2241,23 +2241,11 @@ "widgets": { "color-picker": { "apply": "Appliquer", - "brightness": "Luminosité", "cancel": "Annuler", - "hex": { - "description": "Entrez un code couleur hexadécimal.", - "label": "Couleur hexadécimale" - }, "palette": { "description": "Choisissez parmi une large gamme de couleurs prédéfinies.", - "label": "Palette" - }, - "rgb": { - "description": "Ajustez les valeurs de rouge, vert, bleu et de luminosité.", - "label": "Valeurs RVB" - }, - "theme-colors": { - "description": "Accès rapide à la palette de couleurs de votre thème.", - "label": "Couleurs du thème" + "label": "Palette", + "theme-colors": "Accès rapide à la palette de couleurs de votre thème." }, "title": "Sélecteur de couleurs" }, diff --git a/Assets/Translations/nl.json b/Assets/Translations/nl.json index cee09441..9f886059 100644 --- a/Assets/Translations/nl.json +++ b/Assets/Translations/nl.json @@ -2241,23 +2241,11 @@ "widgets": { "color-picker": { "apply": "Toepassen", - "brightness": "Helderheid", "cancel": "Annuleren", - "hex": { - "description": "Voer een hexadecimale kleurcode in.", - "label": "Hex-kleur" - }, "palette": { "description": "Kies uit een breed scala aan vooraf gedefinieerde kleuren.", - "label": "Palet" - }, - "rgb": { - "description": "Pas de waarden voor rood, groen, blauw en helderheid aan.", - "label": "RGB-waarden" - }, - "theme-colors": { - "description": "Snelle toegang tot het kleurenpalet van je thema.", - "label": "Themakleuren" + "label": "Palet", + "theme-colors": "Snelle toegang tot het kleurenpalet van je thema." }, "title": "Kleurkiezer" }, diff --git a/Assets/Translations/pt.json b/Assets/Translations/pt.json index 27622da3..55a45b50 100644 --- a/Assets/Translations/pt.json +++ b/Assets/Translations/pt.json @@ -2241,23 +2241,11 @@ "widgets": { "color-picker": { "apply": "Aplicar", - "brightness": "Brilho", "cancel": "Cancelar", - "hex": { - "description": "Digite um código de cor hexadecimal.", - "label": "Cor hexadecimal" - }, "palette": { "description": "Escolha entre uma vasta gama de cores predefinidas.", - "label": "Paleta" - }, - "rgb": { - "description": "Ajuste os valores de vermelho, verde, azul e brilho.", - "label": "Valores RGB" - }, - "theme-colors": { - "description": "Acesso rápido à paleta de cores do seu tema.", - "label": "Cores do tema" + "label": "Paleta", + "theme-colors": "Acesso rápido à paleta de cores do seu tema." }, "title": "Seletor de cores" }, diff --git a/Assets/Translations/ru.json b/Assets/Translations/ru.json index 58862aa7..0dedcfe3 100644 --- a/Assets/Translations/ru.json +++ b/Assets/Translations/ru.json @@ -2241,23 +2241,11 @@ "widgets": { "color-picker": { "apply": "Применить", - "brightness": "Яркость", "cancel": "Отмена", - "hex": { - "description": "Введите шестнадцатеричный код цвета.", - "label": "Hex-цвет" - }, "palette": { "description": "Выберите из широкого диапазона предопределенных цветов.", - "label": "Палитра" - }, - "rgb": { - "description": "Настройте значения красного, зеленого, синего и яркости.", - "label": "Значения RGB" - }, - "theme-colors": { - "description": "Быстрый доступ к цветовой палитре вашей темы.", - "label": "Цвета темы" + "label": "Палитра", + "theme-colors": "Быстрый доступ к цветовой палитре вашей темы." }, "title": "Выбор цвета" }, diff --git a/Assets/Translations/tr.json b/Assets/Translations/tr.json index 7b902047..2d2aaee3 100644 --- a/Assets/Translations/tr.json +++ b/Assets/Translations/tr.json @@ -2241,23 +2241,11 @@ "widgets": { "color-picker": { "apply": "Uygula", - "brightness": "Parlaklık", "cancel": "İptal", - "hex": { - "description": "Onaltılık renk kodu girin.", - "label": "Hex renk" - }, "palette": { "description": "Önceden tanımlı renkler geniş yelpazesinden seçin.", - "label": "Palet" - }, - "rgb": { - "description": "Kırmızı, yeşil, mavi ve parlaklık değerlerini ayarlayın.", - "label": "RGB değerleri" - }, - "theme-colors": { - "description": "Temanızın renk paletine hızlı erişim.", - "label": "Tema renkleri" + "label": "Palet", + "theme-colors": "Temanızın renk paletine hızlı erişim." }, "title": "Renk seçici" }, diff --git a/Assets/Translations/uk-UA.json b/Assets/Translations/uk-UA.json index c20ff7a8..0e9a2c07 100644 --- a/Assets/Translations/uk-UA.json +++ b/Assets/Translations/uk-UA.json @@ -2241,23 +2241,11 @@ "widgets": { "color-picker": { "apply": "Застосувати", - "brightness": "Яскравість", "cancel": "Скасувати", - "hex": { - "description": "Введіть шістнадцятковий код кольору.", - "label": "Hex-колір" - }, "palette": { "description": "Виберіть із широкого діапазону попередньо визначених кольорів.", - "label": "Палітра" - }, - "rgb": { - "description": "Налаштуйте значення червоного, зеленого, синього та яскравості.", - "label": "Значення RGB" - }, - "theme-colors": { - "description": "Швидкий доступ до колірної палітри вашої теми.", - "label": "Кольори теми" + "label": "Палітра", + "theme-colors": "Швидкий доступ до колірної палітри вашої теми." }, "title": "Вибір кольору" }, diff --git a/Assets/Translations/zh-CN.json b/Assets/Translations/zh-CN.json index 98c641ef..7d375a7d 100644 --- a/Assets/Translations/zh-CN.json +++ b/Assets/Translations/zh-CN.json @@ -2241,23 +2241,11 @@ "widgets": { "color-picker": { "apply": "应用", - "brightness": "亮度", "cancel": "取消", - "hex": { - "description": "输入十六进制颜色代码。", - "label": "十六进制颜色" - }, "palette": { "description": "从各种预定义颜色中选择。", - "label": "调色板" - }, - "rgb": { - "description": "调整红、绿、蓝和亮度值。", - "label": "RGB 值" - }, - "theme-colors": { - "description": "快速访问您的主题调色板。", - "label": "主题颜色" + "label": "调色板", + "theme-colors": "快速访问您主题的调色板。" }, "title": "颜色选择器" },