feat: colorful multi-accent quickshell design system
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A8TNMgnEa7Kia5Wcz2kyDx
This commit is contained in:
1 parent
2e8389d75c
commit
e6f6b5f09c
23 files changed
+1073
-577
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import QtQuick
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Io
|
||||
@@ -9,6 +8,10 @@ PanelWindow {
|
||||
id: clipboardWindow
|
||||
property QtObject rootState
|
||||
|
||||
readonly property int headerHeight: 50
|
||||
readonly property int footerHeight: 24
|
||||
readonly property int emptyStateHeight: 40
|
||||
|
||||
visible: rootState.clipboardManagerOpen
|
||||
|
||||
anchors {
|
||||
@@ -17,7 +20,7 @@ PanelWindow {
|
||||
left: true
|
||||
right: true
|
||||
}
|
||||
|
||||
|
||||
exclusiveZone: 0
|
||||
color: "transparent"
|
||||
|
||||
@@ -31,17 +34,19 @@ PanelWindow {
|
||||
onClicked: rootState.clipboardManagerOpen = false
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Surface {
|
||||
id: container
|
||||
width: 800
|
||||
height: Math.min(600, (clipList.count > 0 ? clipList.contentHeight : 0) + (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0) + Theme.geometry.padding * 2)
|
||||
height: Math.min(600,
|
||||
headerHeight + Theme.geometry.spacing
|
||||
+ (clipModel.count > 0 ? clipList.contentHeight : emptyStateHeight) + Theme.geometry.spacing
|
||||
+ footerHeight
|
||||
+ Theme.geometry.padding * 2)
|
||||
anchors.centerIn: parent
|
||||
radius: Theme.geometry.radiusMedium
|
||||
color: Theme.colors.background
|
||||
border.color: Theme.colors.border
|
||||
border.width: 1
|
||||
tint: Theme.colors.secondary
|
||||
glow: true
|
||||
|
||||
Behavior on scale { SpringAnimation { spring: 3; damping: 0.2 } }
|
||||
Behavior on scale { SpringAnimation { spring: Theme.motion.springSoft.spring; damping: Theme.motion.springSoft.damping } }
|
||||
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast; easing.type: Easing.OutCubic } }
|
||||
|
||||
@@ -50,161 +55,153 @@ PanelWindow {
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.geometry.padding
|
||||
spacing: searchInput.text.length > 0 ? Theme.geometry.spacing : 0
|
||||
spacing: Theme.geometry.spacing
|
||||
|
||||
Rectangle {
|
||||
TextField {
|
||||
id: searchInput
|
||||
width: parent.width
|
||||
height: searchInput.text.length > 0 ? 50 : 0
|
||||
opacity: searchInput.text.length > 0 ? 1 : 0
|
||||
clip: true
|
||||
color: Theme.colors.surface
|
||||
radius: Theme.geometry.radiusSmall
|
||||
border.width: 1
|
||||
border.color: searchInput.activeFocus ? Theme.colors.primary : Theme.colors.border
|
||||
height: clipboardWindow.headerHeight
|
||||
placeholder: "Search clipboard..."
|
||||
|
||||
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||
Behavior on border.color { ColorAnimation { duration: Theme.animation.durationFast } }
|
||||
|
||||
layer.enabled: searchInput.activeFocus
|
||||
layer.effect: MultiEffect {
|
||||
shadowEnabled: true
|
||||
shadowColor: Theme.colors.primary
|
||||
shadowOpacity: 0.35
|
||||
shadowBlur: 0.4
|
||||
shadowHorizontalOffset: 0
|
||||
shadowVerticalOffset: 0
|
||||
onVisibleChanged: {
|
||||
if (visible) focusInput();
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: searchInput
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.geometry.padding
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: 18
|
||||
color: Theme.colors.text
|
||||
clip: true
|
||||
|
||||
Text {
|
||||
text: "Search clipboard..."
|
||||
color: Theme.colors.textMuted
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: 18
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: searchInput.text.length === 0
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) forceActiveFocus();
|
||||
}
|
||||
onTextChanged: {
|
||||
loadProcess.restart();
|
||||
}
|
||||
|
||||
onTextChanged: {
|
||||
loadProcess.restart();
|
||||
}
|
||||
onEscapePressed: {
|
||||
rootState.clipboardManagerOpen = false;
|
||||
}
|
||||
|
||||
Keys.onEscapePressed: (event) => {
|
||||
rootState.clipboardManagerOpen = false;
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Keys.onUpPressed: (event) => {
|
||||
if (clipList.currentIndex > 0) {
|
||||
clipList.currentIndex--;
|
||||
clipList.positionViewAtIndex(clipList.currentIndex, ListView.Contain);
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Keys.onDownPressed: (event) => {
|
||||
if (clipList.currentIndex < clipList.count - 1) {
|
||||
clipList.currentIndex++;
|
||||
clipList.positionViewAtIndex(clipList.currentIndex, ListView.Contain);
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Keys.onReturnPressed: (event) => {
|
||||
if (clipList.currentIndex >= 0 && clipList.currentIndex < clipModel.count) {
|
||||
let item = clipModel.get(clipList.currentIndex);
|
||||
copyToClipboard(item.id);
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
|
||||
Keys.onPressed: (event) => {
|
||||
if (event.key === Qt.Key_Delete || (event.key === Qt.Key_Backspace && searchInput.text.length === 0)) {
|
||||
if (clipList.currentIndex >= 0 && clipList.currentIndex < clipModel.count) {
|
||||
let item = clipModel.get(clipList.currentIndex);
|
||||
deleteFromClipboard(item.id, item.rawLine, clipList.currentIndex);
|
||||
}
|
||||
event.accepted = true;
|
||||
}
|
||||
onUpPressed: {
|
||||
if (clipList.currentIndex > 0) {
|
||||
clipList.currentIndex--;
|
||||
clipList.positionViewAtIndex(clipList.currentIndex, ListView.Contain);
|
||||
}
|
||||
}
|
||||
|
||||
onDownPressed: {
|
||||
if (clipList.currentIndex < clipList.count - 1) {
|
||||
clipList.currentIndex++;
|
||||
clipList.positionViewAtIndex(clipList.currentIndex, ListView.Contain);
|
||||
}
|
||||
}
|
||||
|
||||
onReturnPressed: {
|
||||
if (clipList.currentIndex >= 0 && clipList.currentIndex < clipModel.count) {
|
||||
let item = clipModel.get(clipList.currentIndex);
|
||||
copyToClipboard(item.id);
|
||||
}
|
||||
}
|
||||
|
||||
onDeleteRequested: {
|
||||
if (clipList.currentIndex >= 0 && clipList.currentIndex < clipModel.count) {
|
||||
let item = clipModel.get(clipList.currentIndex);
|
||||
deleteFromClipboard(item.id, item.rawLine, clipList.currentIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
height: clipboardWindow.emptyStateHeight
|
||||
visible: clipModel.count === 0
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: searchInput.text.length > 0 ? "No clipboard entries match “" + searchInput.text + "”" : "Clipboard is empty"
|
||||
color: Theme.colors.textMuted
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: Theme.type.body
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: clipList
|
||||
width: parent.width
|
||||
height: parent.height - (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0)
|
||||
height: parent.height - clipboardWindow.headerHeight - clipboardWindow.footerHeight - Theme.geometry.spacing * 2
|
||||
visible: clipModel.count > 0
|
||||
clip: true
|
||||
spacing: Theme.geometry.spacing
|
||||
|
||||
model: ListModel { id: clipModel }
|
||||
|
||||
delegate: Rectangle {
|
||||
width: clipList.width
|
||||
height: 36
|
||||
color: ListView.isCurrentItem ? Theme.colors.surfaceHover : "transparent"
|
||||
radius: Theme.geometry.radiusTiny
|
||||
spacing: Theme.geometry.spacing / 2
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: Theme.geometry.padding
|
||||
anchors.rightMargin: Theme.geometry.padding
|
||||
|
||||
Text {
|
||||
text: model.content
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: 14
|
||||
anchors.fill: parent
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
model: ListModel { id: clipModel }
|
||||
|
||||
delegate: ListRow {
|
||||
id: clipRow
|
||||
width: clipList.width
|
||||
selected: ListView.isCurrentItem
|
||||
accent: Theme.colors.secondary
|
||||
|
||||
onEntered: clipList.currentIndex = index
|
||||
onClicked: (mouse) => {
|
||||
clipList.currentIndex = index;
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
let pos = mapToItem(backdrop, mouse.x, mouse.y);
|
||||
let itemId = model.id;
|
||||
let rawLine = model.rawLine;
|
||||
let itemIndex = index;
|
||||
contextMenu.model = [
|
||||
{ label: "Copy", icon: "", action: function() { copyToClipboard(itemId); } },
|
||||
{ separator: true },
|
||||
{ label: "Delete", icon: "", destructive: true, action: function() { deleteFromClipboard(itemId, rawLine, itemIndex); } }
|
||||
];
|
||||
contextMenu.openAt(pos.x, pos.y);
|
||||
} else {
|
||||
copyToClipboard(model.id);
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: clipItemMouse
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
onEntered: clipList.currentIndex = index
|
||||
onClicked: (mouse) => {
|
||||
clipList.currentIndex = index;
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
let pos = clipItemMouse.mapToItem(backdrop, mouse.x, mouse.y);
|
||||
let itemId = model.id;
|
||||
let rawLine = model.rawLine;
|
||||
let itemIndex = index;
|
||||
contextMenu.model = [
|
||||
{ label: "Copy", icon: "⧉", action: function() { copyToClipboard(itemId); } },
|
||||
{ separator: true },
|
||||
{ label: "Delete", icon: "🗑", destructive: true, action: function() { deleteFromClipboard(itemId, rawLine, itemIndex); } }
|
||||
];
|
||||
contextMenu.openAt(pos.x, pos.y);
|
||||
} else {
|
||||
copyToClipboard(model.id);
|
||||
}
|
||||
|
||||
Text {
|
||||
text: model.content
|
||||
color: Theme.colors.text
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: Theme.type.label
|
||||
anchors.left: parent.left
|
||||
anchors.right: deleteButton.left
|
||||
anchors.rightMargin: Theme.geometry.spacing
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Text {
|
||||
id: deleteButton
|
||||
text: ""
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
font.family: Theme.font.family
|
||||
font.pixelSize: Theme.type.body
|
||||
color: deleteMouse.containsMouse ? Theme.colors.alert : Theme.colors.textMuted
|
||||
opacity: clipRow.hovered ? 1 : 0
|
||||
|
||||
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
|
||||
Behavior on color { ColorAnimation { duration: Theme.animation.durationFast } }
|
||||
|
||||
MouseArea {
|
||||
id: deleteMouse
|
||||
anchors.fill: parent
|
||||
anchors.margins: -6
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: deleteFromClipboard(model.id, model.rawLine, index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HintBar {
|
||||
width: parent.width
|
||||
height: clipboardWindow.footerHeight
|
||||
hints: [
|
||||
{ key: "↵", label: "Copy" },
|
||||
{ key: "Del", label: "Delete" },
|
||||
{ key: "Esc", label: "Close" }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,8 +219,8 @@ PanelWindow {
|
||||
Process {
|
||||
id: loadProcess
|
||||
command: [
|
||||
"bash", "-c",
|
||||
"cliphist list | ( [ -z \"$1\" ] && cat || rg -i \"$1\" ) | head -n 50",
|
||||
"bash", "-c",
|
||||
"cliphist list | ( [ -z \"$1\" ] && cat || rg -i \"$1\" ) | head -n 50",
|
||||
"_", searchInput.text
|
||||
]
|
||||
running: false
|
||||
@@ -237,7 +234,7 @@ PanelWindow {
|
||||
if (firstTab !== -1) {
|
||||
let id = lines[i].substring(0, firstTab);
|
||||
// Clean up newlines for multiline strings natively copied
|
||||
let content = lines[i].substring(firstTab + 1).replace(/\n/g, ' ').replace(/\\n/g, ' ');
|
||||
let content = lines[i].substring(firstTab + 1).replace(/\n/g, ' ').replace(/\\n/g, ' ');
|
||||
clipModel.append({ "id": id, "content": content, "rawLine": lines[i] });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user