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