1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

notepad: QOL updates

This commit is contained in:
purian23
2026-01-18 23:49:38 -05:00
parent cc30e2a9e4
commit 65486ed3cf
3 changed files with 35 additions and 32 deletions

View File

@@ -182,31 +182,21 @@ Item {
} }
onOpenRequested: { onOpenRequested: {
if (hasUnsavedChanges()) { textEditor.autoSaveToSession();
root.pendingAction = "open"; if (textEditor.text.length > 0) {
root.confirmationDialogOpen = true; createNewTab();
confirmationDialogLoader.active = true; }
if (confirmationDialogLoader.item)
confirmationDialogLoader.item.open();
} else {
root.fileDialogOpen = true; root.fileDialogOpen = true;
loadBrowserLoader.active = true; loadBrowserLoader.active = true;
if (loadBrowserLoader.item) if (loadBrowserLoader.item)
loadBrowserLoader.item.open(); loadBrowserLoader.item.open();
} }
}
onNewRequested: { onNewRequested: {
if (hasUnsavedChanges()) { textEditor.autoSaveToSession();
root.pendingAction = "new";
root.confirmationDialogOpen = true;
confirmationDialogLoader.active = true;
if (confirmationDialogLoader.item)
confirmationDialogLoader.item.open();
} else {
createNewTab(); createNewTab();
} }
}
onEscapePressed: { onEscapePressed: {
root.hideRequested(); root.hideRequested();
@@ -266,7 +256,7 @@ Item {
id: saveBrowserLoader id: saveBrowserLoader
active: false active: false
FileBrowserModal { FileBrowserSurfaceModal {
id: saveBrowser id: saveBrowser
browserTitle: I18n.tr("Save Notepad File") browserTitle: I18n.tr("Save Notepad File")
@@ -332,7 +322,7 @@ Item {
id: loadBrowserLoader id: loadBrowserLoader
active: false active: false
FileBrowserModal { FileBrowserSurfaceModal {
id: loadBrowser id: loadBrowser
browserTitle: I18n.tr("Open Notepad File") browserTitle: I18n.tr("Open Notepad File")

View File

@@ -52,20 +52,15 @@ Column {
readonly property bool isActive: NotepadStorageService.currentTabIndex === index readonly property bool isActive: NotepadStorageService.currentTabIndex === index
readonly property bool isHovered: tabMouseArea.containsMouse && !closeMouseArea.containsMouse readonly property bool isHovered: tabMouseArea.containsMouse && !closeMouseArea.containsMouse
readonly property real calculatedWidth: { readonly property real tabWidth: 128
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));
}
width: calculatedWidth width: tabWidth
height: 32 height: 32
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: isActive ? Theme.primaryPressed : isHovered ? Theme.primaryHoverLight : Theme.withAlpha(Theme.primaryPressed, 0) color: isActive ? Theme.primaryPressed : isHovered ? Theme.primaryHoverLight : Theme.withAlpha(Theme.primaryPressed, 0)
border.width: isActive ? 0 : 1 border.width: isActive ? 0 : 1
border.color: Theme.outlineMedium border.color: Theme.outlineMedium
clip: true
MouseArea { MouseArea {
id: tabMouseArea id: tabMouseArea
@@ -79,11 +74,14 @@ Column {
Row { Row {
id: tabContent id: tabContent
anchors.centerIn: parent anchors.fill: parent
anchors.leftMargin: Theme.spacingM
anchors.rightMargin: Theme.spacingM
spacing: Theme.spacingXS spacing: Theme.spacingXS
StyledText { StyledText {
id: tabText id: tabText
width: parent.width - (tabCloseButton.visible ? tabCloseButton.width + Theme.spacingXS : 0)
text: { text: {
var prefix = ""; var prefix = "";
if (hasUnsavedChangesForTab(modelData)) { if (hasUnsavedChangesForTab(modelData)) {
@@ -96,6 +94,7 @@ Column {
font.weight: isActive ? Font.Medium : Font.Normal font.weight: isActive ? Font.Medium : Font.Normal
elide: Text.ElideMiddle elide: Text.ElideMiddle
maximumLineCount: 1 maximumLineCount: 1
wrapMode: Text.NoWrap
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }

View File

@@ -383,7 +383,7 @@ Column {
TextArea.flickable: TextArea { TextArea.flickable: TextArea {
id: 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) 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.family: SettingsData.notepadUseMonospace ? SettingsData.monoFontFamily : (SettingsData.notepadFontFamily || SettingsData.fontFamily)
font.pixelSize: SettingsData.notepadFontSize * SettingsData.fontScale font.pixelSize: SettingsData.notepadFontSize * SettingsData.fontScale
@@ -480,6 +480,20 @@ Column {
color: "transparent" 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
}
} }
} }