-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(fix) Multi-track 'Track Properties': accept entered text directly (clearing not required) #13631
base: 2.5
Are you sure you want to change the base?
Conversation
b8a025d
to
a4330b1
Compare
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.
LGTM, except for the "trim trailing whitespace" code that should really be in an utility function (and should probably handle other types of (white)space instead of just the " "
)
src/library/dlgtrackinfomulti.cpp
Outdated
// Remove trailing whitespaces. Keep Leading whitespaces to be consistent | ||
// with the track table's inline editor. | ||
while (currVal.endsWith(' ')) { | ||
currVal.chop(1); | ||
} | ||
return currVal; |
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.
This should probably be moved into an utility function mixxx::trimTrailingWhitespace(QString) -> QString
in utils/string.h
src/library/dlgtrackinfomulti.cpp
Outdated
void DlgTrackInfoMulti::commentTextChanged() { | ||
if (!txtComment->placeholderText().isNull() && | ||
!txtComment->toPlainText().isEmpty()) { | ||
// The comboox has multiple values and has not been cleared yet, |
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.
Small nitpick: comboox
-> combobox
src/library/dlgtrackinfomulti.cpp
Outdated
// Let's clear the placeholder text so we know this is new text. | ||
txtCommentBox->blockSignals(true); | ||
txtComment->setPlaceholderText(QString()); | ||
// The Clear item is not needed anymore, remove. |
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.
Suggestion: // The Clear item is not needed anymore, so remove it.
@@ -84,6 +84,14 @@ inline QString convertWCStringToQString( | |||
return QString::fromWCharArray(wcs, static_cast<int>(wcsnlen_s(wcs, maxLen))); | |||
} | |||
|
|||
inline QString removeTrailingWhitespaces(const QString& str) { |
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.
inline QString removeTrailingWhitespaces(const QString& str) { | |
/// Remove trailing spaces (" ") from the specified string. | |
/// | |
/// Currently only handles simple ASCII spaces (" "). and none of the additional | |
/// Unicode whitespace characters (https://en.wikipedia.org/wiki/Whitespace_character#Unicode). | |
inline QString removeTrailingWhitespaces(const QString& str) { | |
// TODO(XXX): Evaluate whether it makes sense to extend this to all characters within the "Whitespace" Unicode character class |
Maybe it would make sense to handle other kinds of whitespace that one may encounter when pasting something from somewhere else? For example, non-breakable spaces.
Although, after checking the sources and against my expectations, QString::trimmed()
also only handles the ASCII whitespace characters, and none of the UTF-8/Unicode Whitespace Characters. This is opposed to e.g. .NET String::Trim()
which supports all Unicode whitespace characters.
So, probably a topic for a different PR/issue/discussion.
…ulti Co-authored-by: Lukas Waslowski <[email protected]>
ab93fd9
to
74dc793
Compare
Something I overlooked earlier, it seems:
previously we had to explicitly clear a tag before a manually entered text would be accepted as new text.
background: editors with multiple values have a placeholder text
<various>
. It is removed when another item is selected (Clear or text item).On Apply this placeholder is checked to detect whether a multi-value field has been edited.
Now the placeholder is also cleared when the
editingFinished()
signal is fired (Return, Esc, focus out, checks for valid text).For the comment editor this signal doesn't exist. There is
textChanged()
but this is fired for each change (character add/remove), which is not ideal. Instead we catch thefocusOut
event of the comment editor and check whether the current text is 'new'.Small fix:
Don't use QString::trimmed() to be consistent with the track table's inline editor.
Only trailing whitespaces are removed, which allows to clear tags by entering a single space.