mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
notepad: QOL updates
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user