diff options
-rw-r--r-- | src/library/library.cpp | 9 | ||||
-rw-r--r-- | src/preferences/dialog/dlgpreflibrary.cpp | 8 | ||||
-rw-r--r-- | src/widget/wlibrarytableview.cpp | 7 |
3 files changed, 16 insertions, 8 deletions
diff --git a/src/library/library.cpp b/src/library/library.cpp index dec5cc5b3a..59c528c37c 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -522,8 +522,17 @@ QStringList Library::getDirs() { } void Library::setFont(const QFont& font) { + QFontMetrics currMetrics(m_trackTableFont); + QFontMetrics newMetrics(font); + double currFontHeight = currMetrics.height(); + double newFontHeight = newMetrics.height(); + m_trackTableFont = font; emit setTrackTableFont(font); + // adapt the previous font heigh/row height ratio + int scaledRowHeight = static_cast<int>(std::round( + (newFontHeight / currFontHeight) * m_iTrackTableRowHeight)); + setRowHeight(scaledRowHeight); } void Library::setRowHeight(int rowHeight) { diff --git a/src/preferences/dialog/dlgpreflibrary.cpp b/src/preferences/dialog/dlgpreflibrary.cpp index 861b2eec08..8c9bebdc9a 100644 --- a/src/preferences/dialog/dlgpreflibrary.cpp +++ b/src/preferences/dialog/dlgpreflibrary.cpp @@ -383,13 +383,13 @@ void DlgPrefLibrary::setLibraryFont(const QFont& font) { font.family(), font.styleName(), QString::number(font.pointSizeF()))); m_pLibrary->setFont(font); - // Don't let the row height exceed the library height. + // Don't let the font height exceed the row height. QFontMetrics metrics(font); int fontHeight = metrics.height(); - if (fontHeight > spinBoxRowHeight->value()) { - spinBoxRowHeight->setValue(fontHeight); - } spinBoxRowHeight->setMinimum(fontHeight); + // library.cpp takes care of setting the new row height according to the + // previous font height/ row height ratio + spinBoxRowHeight->setValue(m_pLibrary->getTrackTableRowHeight()); } void DlgPrefLibrary::slotSelectFont() { diff --git a/src/widget/wlibrarytableview.cpp b/src/widget/wlibrarytableview.cpp index 6c63faf993..8ed732a69f 100644 --- a/src/widget/wlibrarytableview.cpp +++ b/src/widget/wlibrarytableview.cpp @@ -132,14 +132,13 @@ void WLibraryTableView::restoreVScrollBarPos(TrackModel* key){ void WLibraryTableView::setTrackTableFont(const QFont& font) { setFont(font); - setTrackTableRowHeight(verticalHeader()->defaultSectionSize()); + QFontMetrics metrics(font); + verticalHeader()->setMinimumSectionSize(metrics.height()); } void WLibraryTableView::setTrackTableRowHeight(int rowHeight) { - QFontMetrics metrics(font()); - int fontHeightPx = metrics.height(); verticalHeader()->setDefaultSectionSize(math_max( - rowHeight, fontHeightPx)); + rowHeight, verticalHeader()->minimumSectionSize())); } void WLibraryTableView::setSelectedClick(bool enable) { |