nuttyartist / notes

Fast and beautiful note-taking app written in C++. Write down your thoughts.
https://www.get-notes.com
Mozilla Public License 2.0
3.6k stars 316 forks source link

Editing the Kanban board doesn't work on wayland #617

Open zjeffer opened 11 months ago

zjeffer commented 11 months ago

But it does work with XWayland (running notes with --platform xcb)

nuttyartist commented 11 months ago

Why?

zjeffer commented 11 months ago

No idea. Doubleclicking the text selects it but typing doesn't edit it. The checkboxes work fine.

nuttyartist commented 11 months ago

Any error? Just editing the text doesn't work or anything else? Everything shows up normally tho (could you share a screenshot)?

zjeffer commented 11 months ago

No errors in the terminal. Here's a video:

https://github.com/nuttyartist/notes/assets/4633209/9a0624d8-4604-4bee-9710-e6bd635c0d78

nuttyartist commented 11 months ago

That's odd! Do you think you can run a simeple QML test with just TextArea {} and TextField {} Qt Quick componenets to see if it's an upstream issue with Qt and Wayland?

guihkx commented 5 months ago

Revisiting this, and it's still reproducible with Qt 6.6.1 on Wayland (KDE Plasma 5.27).

Do you think you can run a simeple QML test with just TextArea {} and TextField {} Qt Quick componenets to see if it's an upstream issue with Qt and Wayland?

Is this a good example?

// test.qml
import QtQuick 2.12
import QtQuick.Controls 2.12

Rectangle {
    width: 300
    height: 100
    Text {
        id: taskTextNonEditable
        width: 300
        text: "Double click here to edit me!"
        font.pointSize: 15
        textFormat: TextEdit.MarkdownText
        wrapMode: Text.Wrap

        MouseArea {
            anchors.fill: parent

            onDoubleClicked: {
                taskTextNonEditable.visible = false;
                taskTextEdit.visible = true;
                taskTextEdit.cursorPosition = taskTextEdit.length;
                taskTextEdit.forceActiveFocus();
                taskTextEdit.focus = true;
            }
        }
    }
    TextArea {
        id: taskTextEdit
        width: 300
        text: taskTextNonEditable.text
        font.pointSize: 15
        textFormat: TextEdit.PlainText
        wrapMode: Text.Wrap
        visible: false
        background: Rectangle {
            radius: 5
            color: "#efefef"
        }
    }
}

If I run that with qml6 test.qml, I'm able to edit the text inside the textarea on Wayland:

https://github.com/nuttyartist/notes/assets/626206/f29c496f-e629-4602-888d-92c688df44cf

nuttyartist commented 5 months ago

Yes, that should do. Can you try importing this as well?

import QtQuick.Controls.Universal 2.12
guihkx commented 5 months ago

Same result: Editing the text works.

nuttyartist commented 5 months ago

What about: import QtQuick.Controls.Material 2.12?

guihkx commented 5 months ago

That one made things a bit more weird while editing the text, but it still works (in the video below I first edit without the import, and then after that I edit with the import):

https://github.com/nuttyartist/notes/assets/626206/a0ba10d2-613b-4cf3-b155-d1a5b21de667

nuttyartist commented 5 months ago

Hmm. still works. Very odd! This is the code of CustomTextArea (https://github.com/nuttyartist/notes/blob/master/src/qml/CustomTextArea.qml) in one file for convenience. Can you try it:

EDIT: Changed import versions.

import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Universal 2.12

Window {
    id: rootWindow
    visible: true
    width: 640
    height: 480
    title: qsTr("Test")

    TextArea {
        id: root
        textFormat: TextEdit.PlainText
        wrapMode: Text.Wrap
        background: Rectangle {
            radius: 5
            color: root.themeData.theme === "Dark" ? "#313131" : "#efefef"
        }
        width: parent.width
        height: parent.height

        property var themeData
        property string accentColor
        property bool cursorAnimationRunning: true
        signal anyKeyPressed
        signal cursorHidden
        signal cursorShowed
        signal returnPressed
        property bool isHoldingShift: false

        Keys.onPressed: (event) => {
            if (event.key === Qt.Key_Shift) {
              isHoldingShift = true;
            }

            root.anyKeyPressed();
            root.cursorAnimationRunning = false;
        }

        Keys.onReleased: (event) => {
             if (event.key === Qt.Key_Shift) {
               isHoldingShift = false;
             }
            root.cursorAnimationRunning = true;
        }

        onPressed: {
            root.cursorShowed();
        }

        Keys.onReturnPressed: {
            returnPressed();
        }

        cursorDelegate: Rectangle {
            id: cursorDelegateObject
            visible: true
            color: root.accentColor
            width: 2

            Connections {
                target: root

                function onAnyKeyPressed () {
                    cursorDelegateObject.visible = true;
                }

                function onCursorHidden () {
                    cursorDelegateObject.visible = false;
                }

                function onCursorShowed () {
                    cursorDelegateObject.visible = true;
                }
            }

            SequentialAnimation {
                loops: Animation.Infinite
                running: root.cursorAnimationRunning

                PropertyAction {
                    target: cursorDelegateObject
                    property: 'visible'
                    value: true
                }

                PauseAnimation {
                    duration: 500
                }

                PropertyAction {
                    target: cursorDelegateObject
                    property: 'visible'
                    value: false
                }

                PauseAnimation {
                    duration: 500
                }
            }
        }
    }
}
guihkx commented 5 months ago

Typing still works:

https://github.com/nuttyartist/notes/assets/626206/8f83a718-2ae6-43eb-bdfd-ffead6e5ea2a

nuttyartist commented 5 months ago

Then, it's not immediately clear why on Wayland editing doesn't work in the Kanban. Needs deeper inspection.

guihkx commented 1 month ago

Revisiting as of Qt 6.7.1, and the issue is still present only on Wayland, unfortunately.

nuttyartist commented 1 month ago

That's very annoying. What distro has built-in Wayland that I can spin up to test this?

EDIT: Or can i just use my current PopOS machine? (Don't know much about Wayland)

guihkx commented 1 month ago

The latest version of Fedora is a probably a good choice, I think.

@nuttyartist Though you can probably use Wayland with Pop!_OS too: Logout from the current session and choose "GNOME" (and not "GNOME (Legacy)" or "GNOME (X11)" or whatever they call it) from the login manager screen.