diff --git a/data/themes/default/style.css b/data/themes/default/style.css index ef98c060999..e2dd369f952 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -601,17 +601,11 @@ lmms--gui--TrackLabelButton:hover { background: #3B424A; border: 1px solid #515B66; border-radius: none; - font-size: 11px; - font-weight: normal; - padding: 2px 1px; } lmms--gui--TrackLabelButton:pressed { background: #262B30; border-radius: none; - font-size: 11px; - font-weight: normal; - padding: 2px 1px; } lmms--gui--TrackLabelButton:checked { @@ -619,17 +613,12 @@ lmms--gui--TrackLabelButton:checked { background: #1C1F24; background-image: url("resources:track_shadow_p.png"); border-radius: none; - font-size: 11px; - font-weight: normal; - padding: 2px 1px; } lmms--gui--TrackLabelButton:checked:pressed { border: 1px solid #2f353b; background: #0e1012; background-image: url("resources:track_shadow_p.png"); - font-size: 11px; - padding: 2px 1px; font-weight: solid; } diff --git a/src/gui/tracks/TrackLabelButton.cpp b/src/gui/tracks/TrackLabelButton.cpp index 871d42316e5..dd19f3d19fc 100644 --- a/src/gui/tracks/TrackLabelButton.cpp +++ b/src/gui/tracks/TrackLabelButton.cpp @@ -50,6 +50,7 @@ TrackLabelButton::TrackLabelButton( TrackView * _tv, QWidget * _parent ) : setAcceptDrops( true ); setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) ); setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); + m_renameLineEdit = new TrackRenameLineEdit( this ); m_renameLineEdit->hide(); @@ -60,8 +61,6 @@ TrackLabelButton::TrackLabelButton( TrackView * _tv, QWidget * _parent ) : else { setFixedSize( 160, 29 ); - m_renameLineEdit->move( 30, ( height() / 2 ) - ( m_renameLineEdit->sizeHint().height() / 2 ) ); - m_renameLineEdit->setFixedWidth( width() - 33 ); connect( m_renameLineEdit, SIGNAL(editingFinished()), this, SLOT(renameFinished())); } @@ -89,11 +88,22 @@ void TrackLabelButton::rename() } else { - QString txt = m_trackView->getTrack()->name(); - m_renameLineEdit->show(); - m_renameLineEdit->setText( txt ); + const auto & trackName = m_trackView->getTrack()->name(); + m_renameLineEdit->setText(trackName); m_renameLineEdit->selectAll(); m_renameLineEdit->setFocus(); + + // Make sure that the rename line edit uses the same font as the widget + // which is set via style sheets + m_renameLineEdit->setFont(font()); + + // Move the line edit to the correct position by taking the size of the + // icon into account. + const auto iconWidth = iconSize().width(); + m_renameLineEdit->move(iconWidth + 1, (height() / 2 - m_renameLineEdit->sizeHint().height() / 2) + 1); + m_renameLineEdit->setFixedWidth(width() - (iconWidth + 6)); + + m_renameLineEdit->show(); } }