-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix QgsDateTimeEdit paste when fully selected #60646
Fix QgsDateTimeEdit paste when fully selected #60646
Conversation
Fix qgis#53149 ...and possibly qgis#60625 The issue is deep into QT internals: the abstract spinbox has a line edit wich holds the different datetime components divided into "Sections", when the user selects all (e.g. with CTRL+A) and then pastes a datetime string from the clipboard, it may get pasted in the wrong position (i.e. not at the beginning of the selection) because the internal position of the cursor wasn't updated). I tried hard to write a test (even tried QTest::click* and events but I couldn't find a way to reproduce the issue programmatically using the QT public API).
@andreasneumann please give this a try when ready and check if it solves #60625 |
🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
@@ -109,6 +109,22 @@ bool QgsDateTimeEdit::event( QEvent *event ) | |||
mClearAction->setVisible( !isReadOnly() && mAllowNull && ( !mIsNull || mIsEmpty ) ); | |||
} | |||
|
|||
// Fix wrong internal logic of Qt when pasting text with selected text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth reporting to Qt upstream?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO it doesn't: I couldn't find a way to reproduce it by code, and even if I did my past experience with QT bug reporting makes me think it would be a complete waste of time.
Looks good. My issue is solved with this commit. Thank you very much! |
Thanks for checking, I realized that I misused the API when restoring the selection, would you mind re-testing after my last commit please? |
Fix #53149
...and possibly #60625
The issue is deep into QT internals: the abstract spinbox has a line edit wich holds the different datetime components divided into "Sections", when the user selects all (e.g. with CTRL+A) and then pastes a datetime string from the clipboard, it may get pasted in the wrong position (i.e. not at the beginning of the selection) because the internal position of the cursor wasn't updated.
I tried hard to write a test (even tried QTest::click* and injection of forged events) but I couldn't find a way to reproduce the issue programmatically using the QT public API).