diff --git a/ui/drivers/qt/playlist.cpp b/ui/drivers/qt/playlist.cpp index fbb6989da1..2f9271a0bf 100644 --- a/ui/drivers/qt/playlist.cpp +++ b/ui/drivers/qt/playlist.cpp @@ -38,19 +38,6 @@ inline static bool comp_hash_label_key_lower(const QHash &lhs, } /* https://stackoverflow.com/questions/7246622/how-to-create-a-slider-with-a-non-linear-scale */ -static double expScale(double inputValue, double midValue, double maxValue) -{ - double returnValue = 0; - double M = maxValue / midValue; - double C = log(pow(M - 1, 2)); - double B = maxValue / (exp(C) - 1); - double A = -1 * B; - - returnValue = A + B * exp(C * inputValue); - - return returnValue; -} - static void addDirectoryFilesToList(QStringList &list, QDir &dir) { QStringList dirList = dir.entryList(QStringList(), QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System, QDir::Name); @@ -922,33 +909,6 @@ finish: addPlaylistHashToGrid(items); } -/* https://gist.github.com/andrey-str/0f9c7709cbf0c9c49ef9 */ -static void setElidedText(QLabel *label, QWidget *clipWidget, int padding, const QString &text) -{ - QFontMetrics metrix(label->font()); - int width = clipWidget->width() - padding; - QString clippedText = metrix.elidedText(text, Qt::ElideRight, width); - label->setText(clippedText); -} - -inline void MainWindow::calcGridItemSize(GridItem *item, int zoomValue) -{ - int newSize = 0; - QLabel *label = NULL; - - if (zoomValue < 50) - newSize = expScale(lerp(0, 49, 25, 49, zoomValue) / 50.0, 102, 256); - else - newSize = expScale(zoomValue / 100.0, 256, 1024); - - item->widget->setFixedSize(QSize(newSize, newSize)); - - label = item->widget->findChild("thumbnailQLabel"); - - if (label) - setElidedText(label, item->widget, item->widget->layout()->contentsMargins().left() + item->widget->layout()->spacing() + 2, item->labelText); -} - void MainWindow::addPlaylistHashToGrid(const QVector > &items) { QScreen *screen = qApp->primaryScreen(); diff --git a/ui/drivers/qt/ui_qt_window.cpp b/ui/drivers/qt/ui_qt_window.cpp index 460e7542ad..d36d27dfd7 100644 --- a/ui/drivers/qt/ui_qt_window.cpp +++ b/ui/drivers/qt/ui_qt_window.cpp @@ -138,6 +138,28 @@ static void scan_finished_handler(void *task_data, void *user_data, const char * } #endif +static double expScale(double inputValue, double midValue, double maxValue) +{ + double returnValue = 0; + double M = maxValue / midValue; + double C = log(pow(M - 1, 2)); + double B = maxValue / (exp(C) - 1); + double A = -1 * B; + + returnValue = A + B * exp(C * inputValue); + + return returnValue; +} + +/* https://gist.github.com/andrey-str/0f9c7709cbf0c9c49ef9 */ +static void setElidedText(QLabel *label, QWidget *clipWidget, int padding, const QString &text) +{ + QFontMetrics metrix(label->font()); + int width = clipWidget->width() - padding; + QString clippedText = metrix.elidedText(text, Qt::ElideRight, width); + label->setText(clippedText); +} + GridItem::GridItem() : QObject() ,widget(NULL) @@ -926,6 +948,24 @@ void MainWindow::onListViewClicked() onCurrentListItemChanged(m_listWidget->currentItem(), NULL); } +void MainWindow::calcGridItemSize(GridItem *item, int zoomValue) +{ + int newSize = 0; + QLabel *label = NULL; + + if (zoomValue < 50) + newSize = expScale(lerp(0, 49, 25, 49, zoomValue) / 50.0, 102, 256); + else + newSize = expScale(zoomValue / 100.0, 256, 1024); + + item->widget->setFixedSize(QSize(newSize, newSize)); + + label = item->widget->findChild("thumbnailQLabel"); + + if (label) + setElidedText(label, item->widget, item->widget->layout()->contentsMargins().left() + item->widget->layout()->spacing() + 2, item->labelText); +} + void MainWindow::onZoomValueChanged(int value) { int i;