mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-15 07:35:20 -04:00
fix(Notepad): clean up edge cases & updated popout handling
This commit is contained in:
@@ -1096,6 +1096,11 @@ Item {
|
||||
edgeGap: SettingsData.notepadEffectiveEdgeGap
|
||||
slideEdge: SettingsData.notepadSlideoutSide
|
||||
|
||||
onIsVisibleChanged: {
|
||||
if (isVisible)
|
||||
PopoutService.notepadPopout?.hide();
|
||||
}
|
||||
|
||||
content: Component {
|
||||
Notepad {
|
||||
slideout: notepadSlideout
|
||||
|
||||
@@ -386,6 +386,10 @@ Item {
|
||||
}
|
||||
|
||||
function close(): string {
|
||||
if (SettingsData.notepadDefaultMode === "popout") {
|
||||
PopoutService.notepadPopout?.hide();
|
||||
return "NOTEPAD_CLOSE_SUCCESS";
|
||||
}
|
||||
var instance = getActiveNotepadInstance();
|
||||
if (instance) {
|
||||
instance.hide();
|
||||
|
||||
@@ -317,63 +317,67 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: bannerActions
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignRight
|
||||
spacing: Theme.spacingS
|
||||
Layout.preferredHeight: 32
|
||||
|
||||
StyledRect {
|
||||
readonly property real actionWidth: Math.min(keepText.implicitWidth + Theme.spacingM * 2, Math.max(104, (bannerActions.width - bannerActions.spacing) / 2))
|
||||
Layout.preferredWidth: actionWidth
|
||||
Layout.preferredHeight: 32
|
||||
radius: Theme.cornerRadius
|
||||
color: "transparent"
|
||||
border.color: Theme.outlineMedium
|
||||
border.width: 1
|
||||
Row {
|
||||
id: bannerActions
|
||||
anchors.right: parent.right
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StateLayer {
|
||||
anchors.fill: parent
|
||||
cornerRadius: parent.radius
|
||||
stateColor: Theme.surfaceText
|
||||
onClicked: root.resolveConflictKeepEdits()
|
||||
readonly property real available: parent.width
|
||||
|
||||
StyledRect {
|
||||
width: Math.min(keepText.implicitWidth + Theme.spacingM * 2, Math.max(104, (bannerActions.available - bannerActions.spacing) / 2))
|
||||
height: 32
|
||||
radius: Theme.cornerRadius
|
||||
color: "transparent"
|
||||
border.color: Theme.outlineMedium
|
||||
border.width: 1
|
||||
|
||||
StateLayer {
|
||||
anchors.fill: parent
|
||||
cornerRadius: parent.radius
|
||||
stateColor: Theme.surfaceText
|
||||
onClicked: root.resolveConflictKeepEdits()
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: keepText
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - Theme.spacingM
|
||||
text: I18n.tr("Keep My Edits")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: keepText
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - Theme.spacingM
|
||||
text: I18n.tr("Keep My Edits")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
StyledRect {
|
||||
width: Math.min(reloadText.implicitWidth + Theme.spacingM * 2, Math.max(116, (bannerActions.available - bannerActions.spacing) / 2))
|
||||
height: 32
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.primary
|
||||
|
||||
StyledRect {
|
||||
readonly property real actionWidth: Math.min(reloadText.implicitWidth + Theme.spacingM * 2, Math.max(116, (bannerActions.width - bannerActions.spacing) / 2))
|
||||
Layout.preferredWidth: actionWidth
|
||||
Layout.preferredHeight: 32
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.primary
|
||||
StateLayer {
|
||||
anchors.fill: parent
|
||||
cornerRadius: parent.radius
|
||||
stateColor: Theme.background
|
||||
onClicked: root.resolveConflictReload()
|
||||
}
|
||||
|
||||
StateLayer {
|
||||
anchors.fill: parent
|
||||
cornerRadius: parent.radius
|
||||
stateColor: Theme.background
|
||||
onClicked: root.resolveConflictReload()
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: reloadText
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - Theme.spacingM
|
||||
text: I18n.tr("Reload From Disk")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.background
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
StyledText {
|
||||
id: reloadText
|
||||
anchors.centerIn: parent
|
||||
width: parent.width - Theme.spacingM
|
||||
text: I18n.tr("Reload From Disk")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.background
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ FloatingWindow {
|
||||
}
|
||||
}
|
||||
|
||||
// A compositor close (e.g. niri close-window)
|
||||
onClosed: win.visible = false
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
|
||||
@@ -789,12 +789,41 @@ Singleton {
|
||||
networkInfoModal?.close();
|
||||
}
|
||||
|
||||
function closeNotepadSlideouts() {
|
||||
for (var i = 0; i < notepadSlideouts.length; i++) {
|
||||
if (notepadSlideouts[i] && notepadSlideouts[i].isVisible)
|
||||
notepadSlideouts[i].hide();
|
||||
}
|
||||
}
|
||||
|
||||
function openNotepadSlideout() {
|
||||
notepadPopout?.hide();
|
||||
if (notepadSlideouts.length > 0) {
|
||||
notepadSlideouts[0]?.show();
|
||||
}
|
||||
}
|
||||
|
||||
// Keep the notepad in a single presentation for default modes
|
||||
Connections {
|
||||
target: SettingsData
|
||||
function onNotepadDefaultModeChanged() {
|
||||
if (SettingsData.notepadDefaultMode === "popout") {
|
||||
var hadSlideout = false;
|
||||
for (var i = 0; i < root.notepadSlideouts.length; i++) {
|
||||
if (root.notepadSlideouts[i] && root.notepadSlideouts[i].isVisible) {
|
||||
hadSlideout = true;
|
||||
root.notepadSlideouts[i].hide();
|
||||
}
|
||||
}
|
||||
if (hadSlideout)
|
||||
root.openNotepadPopout();
|
||||
} else if (root.notepadPopout && root.notepadPopout.visible) {
|
||||
root.notepadPopout.hide();
|
||||
root.openNotepadSlideout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openNotepad() {
|
||||
if (SettingsData.notepadDefaultMode === "popout") {
|
||||
openNotepadPopout();
|
||||
@@ -828,6 +857,7 @@ Singleton {
|
||||
property bool _notepadPopoutWantsOpen: false
|
||||
|
||||
function openNotepadPopout() {
|
||||
closeNotepadSlideouts();
|
||||
if (notepadPopout) {
|
||||
notepadPopout.show();
|
||||
} else if (notepadPopoutLoader) {
|
||||
@@ -845,6 +875,8 @@ Singleton {
|
||||
|
||||
function toggleNotepadPopout() {
|
||||
if (notepadPopout) {
|
||||
if (!notepadPopout.visible)
|
||||
closeNotepadSlideouts();
|
||||
notepadPopout.toggle();
|
||||
} else {
|
||||
openNotepadPopout();
|
||||
|
||||
Reference in New Issue
Block a user