rename FxLine directly in a QLineEdit#2918
Conversation
|
The beginning of the qlinedit is higher than the text's original position, which seems inconsistent to me. Other than that, looks good and avoids dialogs, so I'm all for that. |
|
Can someone explain the purpose of using two components over one in this instance? For example, can't we simply keep the input a |
Well, if one can make the disabled QLineEdit completely backgroundless and borderless, then that would be a better solution. |
|
Update: Now it uses for both (labeling and renaming) a QLineEdit. |
| m_scene->setSceneRect( 0, 0, 33, FxLineHeight ); | ||
|
|
||
| m_view = new QGraphicsView( this ); | ||
| m_view->setStyleSheet( "border-style: none; background: transparent;" ); |
There was a problem hiding this comment.
Shouldn't you do this in the CSS?
There was a problem hiding this comment.
I don't think so. The QGraphicsView is only a container for the QLineEdit. With it we can rotate the QLineEdit. I can't imagine a situation where the view should have borders or a background color. It's an internal solution the user (themer) don't need to know.
There was a problem hiding this comment.
Ah, ok, thanks for clarifying 👍. This looks good to merge.
There was a problem hiding this comment.
Just to let you know: if a track or a fx is renamed Lmms does not consider the project as modified.
You can quit with no question about saving...
|
@jasp00 Thanks for your revisiting. I updated the branch. |
I think you just add |
|
Undo and redo should work with renaming. A |
@zonkmachine works!
@jasp00 can you point me to some code where I can learn how to do this? |
|
The model classes are generated dynamically, si they're a bit hard to find in the code, but search for |
|
I have updated. Now the project is set modified if the FxLine is renamed. But I fear I have no clue how to handle the undo/redo stuff. 😟 |
That can be done later. |
src/gui/widgets/FxLine.cpp
Outdated
| setToolTip( m_newName ); | ||
| } | ||
| m_renameLineEdit->setText( elideName( m_newName ) ); | ||
| Engine::getSong()->setModified(); |
There was a problem hiding this comment.
setModified() should be called only if text has changed.
|
So, now it should works better. |
include/FxLine.h
Outdated
|
|
||
| QStaticText m_staticTextName; | ||
| bool m_inRename; | ||
| QString m_newName; |
There was a problem hiding this comment.
It looks like this member is not needed. A local variable newName would be better.
src/gui/widgets/FxLine.cpp
Outdated
| QString FxLine::elideName( QString name ) | ||
| { | ||
| const int maxTextHeight = 70; | ||
| QFontMetrics metrics( FxLine::font() ); |
There was a problem hiding this comment.
Why FxLine::font() instead of font()?
|
Update. @jasp00 thank you very much for your revisiting! |
src/gui/widgets/FxLine.cpp
Outdated
| m_renameLineEdit = new QLineEdit(); | ||
| m_renameLineEdit->setText( name ); | ||
| m_renameLineEdit->setFixedWidth( 65 ); | ||
| m_renameLineEdit->setFont( pointSizeF( FxLine::font(), 7.5f ) ); |
|
👍 |
|
Cool! One comment. When you hover over the text ( shows horizontally ) the string is remembered. |
include/FxLine.h
Outdated
| private: | ||
| void drawFxLine( QPainter* p, const FxLine *fxLine, const QString& name, bool isActive, bool sendToThis, bool receiveFromThis ); | ||
| void drawFxLine( QPainter* p, const FxLine *fxLine, bool isActive, bool sendToThis, bool receiveFromThis ); | ||
| QString elideName( QString name ); |
There was a problem hiding this comment.
const QString & name should be used instead of QString name to avoid the copy of the QString.
|
@jasp00 update. 👍 |
* rename FxLine directly in a QLineEdit * set project modified only if FxLine text is changed * clean up some code. Optimize some things * optimizing code / removing a couple of member variables * minor code optimizations * turn off the tool tip in rename mode / minor code changes


Same as #2916. For avoiding dialog window we can use a QLineEdit for renaming the FxLine. I used a QGraphicsView for rotating the QLineEdit.