From 65486ed3cf982fcb8ba61d7fd4489299b3e88a85 Mon Sep 17 00:00:00 2001 From: purian23 Date: Sun, 18 Jan 2026 23:49:38 -0500 Subject: [PATCH] notepad: QOL updates --- quickshell/Modules/Notepad/Notepad.qml | 34 +++++++------------ quickshell/Modules/Notepad/NotepadTabs.qml | 17 +++++----- .../Modules/Notepad/NotepadTextEditor.qml | 16 ++++++++- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/quickshell/Modules/Notepad/Notepad.qml b/quickshell/Modules/Notepad/Notepad.qml index 16ad29fb..5894a301 100644 --- a/quickshell/Modules/Notepad/Notepad.qml +++ b/quickshell/Modules/Notepad/Notepad.qml @@ -182,30 +182,20 @@ Item { } onOpenRequested: { - if (hasUnsavedChanges()) { - root.pendingAction = "open"; - root.confirmationDialogOpen = true; - confirmationDialogLoader.active = true; - if (confirmationDialogLoader.item) - confirmationDialogLoader.item.open(); - } else { - root.fileDialogOpen = true; - loadBrowserLoader.active = true; - if (loadBrowserLoader.item) - loadBrowserLoader.item.open(); + textEditor.autoSaveToSession(); + if (textEditor.text.length > 0) { + createNewTab(); } + + root.fileDialogOpen = true; + loadBrowserLoader.active = true; + if (loadBrowserLoader.item) + loadBrowserLoader.item.open(); } onNewRequested: { - if (hasUnsavedChanges()) { - root.pendingAction = "new"; - root.confirmationDialogOpen = true; - confirmationDialogLoader.active = true; - if (confirmationDialogLoader.item) - confirmationDialogLoader.item.open(); - } else { - createNewTab(); - } + textEditor.autoSaveToSession(); + createNewTab(); } onEscapePressed: { @@ -266,7 +256,7 @@ Item { id: saveBrowserLoader active: false - FileBrowserModal { + FileBrowserSurfaceModal { id: saveBrowser browserTitle: I18n.tr("Save Notepad File") @@ -332,7 +322,7 @@ Item { id: loadBrowserLoader active: false - FileBrowserModal { + FileBrowserSurfaceModal { id: loadBrowser browserTitle: I18n.tr("Open Notepad File") diff --git a/quickshell/Modules/Notepad/NotepadTabs.qml b/quickshell/Modules/Notepad/NotepadTabs.qml index 975da5d1..6e2e6e24 100644 --- a/quickshell/Modules/Notepad/NotepadTabs.qml +++ b/quickshell/Modules/Notepad/NotepadTabs.qml @@ -52,20 +52,15 @@ Column { readonly property bool isActive: NotepadStorageService.currentTabIndex === index readonly property bool isHovered: tabMouseArea.containsMouse && !closeMouseArea.containsMouse - readonly property real calculatedWidth: { - const textWidth = tabText.paintedWidth || 100; - const closeButtonWidth = NotepadStorageService.tabs.length > 1 ? 20 : 0; - const spacing = Theme.spacingXS; - const padding = Theme.spacingM * 2; - return Math.max(120, Math.min(200, textWidth + closeButtonWidth + spacing + padding)); - } + readonly property real tabWidth: 128 - width: calculatedWidth + width: tabWidth height: 32 radius: Theme.cornerRadius color: isActive ? Theme.primaryPressed : isHovered ? Theme.primaryHoverLight : Theme.withAlpha(Theme.primaryPressed, 0) border.width: isActive ? 0 : 1 border.color: Theme.outlineMedium + clip: true MouseArea { id: tabMouseArea @@ -79,11 +74,14 @@ Column { Row { id: tabContent - anchors.centerIn: parent + anchors.fill: parent + anchors.leftMargin: Theme.spacingM + anchors.rightMargin: Theme.spacingM spacing: Theme.spacingXS StyledText { id: tabText + width: parent.width - (tabCloseButton.visible ? tabCloseButton.width + Theme.spacingXS : 0) text: { var prefix = ""; if (hasUnsavedChangesForTab(modelData)) { @@ -96,6 +94,7 @@ Column { font.weight: isActive ? Font.Medium : Font.Normal elide: Text.ElideMiddle maximumLineCount: 1 + wrapMode: Text.NoWrap anchors.verticalCenter: parent.verticalCenter } diff --git a/quickshell/Modules/Notepad/NotepadTextEditor.qml b/quickshell/Modules/Notepad/NotepadTextEditor.qml index 7cc47995..c2e63b9d 100644 --- a/quickshell/Modules/Notepad/NotepadTextEditor.qml +++ b/quickshell/Modules/Notepad/NotepadTextEditor.qml @@ -383,7 +383,7 @@ Column { TextArea.flickable: TextArea { id: textArea - placeholderText: I18n.tr("Start typing your notes here...") + placeholderText: "" placeholderTextColor: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.5) font.family: SettingsData.notepadUseMonospace ? SettingsData.monoFontFamily : (SettingsData.notepadFontFamily || SettingsData.fontFamily) font.pixelSize: SettingsData.notepadFontSize * SettingsData.fontScale @@ -480,6 +480,20 @@ Column { color: "transparent" } } + + StyledText { + id: placeholderOverlay + text: I18n.tr("Start typing your notes here...") + color: Qt.rgba(Theme.surfaceText.r, Theme.surfaceText.g, Theme.surfaceText.b, 0.5) + font.family: textArea.font.family + font.pixelSize: textArea.font.pixelSize + visible: textArea.text.length === 0 + anchors.left: textArea.left + anchors.top: textArea.top + anchors.leftMargin: textArea.leftPadding + anchors.topMargin: textArea.topPadding + z: textArea.z + 1 + } } }