mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Qt: windows buildfix
This commit is contained in:
parent
648705154e
commit
1966b04832
@ -37,6 +37,20 @@ inline static bool comp_hash_label_key_lower(const QHash<QString, QString> &lhs,
|
||||
return lhs.value("label").toLower() < rhs.value("label").toLower();
|
||||
}
|
||||
|
||||
/* 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);
|
||||
@ -908,6 +922,33 @@ 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<QLabel*>("thumbnailQLabel");
|
||||
|
||||
if (label)
|
||||
setElidedText(label, item->widget, item->widget->layout()->contentsMargins().left() + item->widget->layout()->spacing() + 2, item->labelText);
|
||||
}
|
||||
|
||||
void MainWindow::addPlaylistHashToGrid(const QVector<QHash<QString, QString> > &items)
|
||||
{
|
||||
QScreen *screen = qApp->primaryScreen();
|
||||
|
@ -113,24 +113,6 @@ static const QPixmap getInvader()
|
||||
return pix;
|
||||
}
|
||||
|
||||
static double lerp(double x, double y, double a, double b, double d) {
|
||||
return a + (b - a) * ((double)(d - x) / (double)(y - x));
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBRETRODB
|
||||
static void scan_finished_handler(void *task_data, void *user_data, const char *err)
|
||||
{
|
||||
@ -156,15 +138,6 @@ static void scan_finished_handler(void *task_data, void *user_data, const char *
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 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)
|
||||
@ -586,6 +559,10 @@ MainWindow::~MainWindow()
|
||||
removeGridItems();
|
||||
}
|
||||
|
||||
double MainWindow::lerp(double x, double y, double a, double b, double d) {
|
||||
return a + (b - a) * ((double)(d - x) / (double)(y - x));
|
||||
}
|
||||
|
||||
void MainWindow::onShaderParamsDialogResized(QSize size)
|
||||
{
|
||||
QVariant scrollAreaVariant = m_shaderParamsDialog->property("scrollArea");
|
||||
@ -949,24 +926,6 @@ void MainWindow::onListViewClicked()
|
||||
onCurrentListItemChanged(m_listWidget->currentItem(), NULL);
|
||||
}
|
||||
|
||||
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<QLabel*>("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;
|
||||
|
@ -276,6 +276,7 @@ public:
|
||||
void addFilesToPlaylist(QStringList files);
|
||||
QString getCurrentPlaylistPath();
|
||||
QHash<QString, QString> getCurrentContentHash();
|
||||
static double lerp(double x, double y, double a, double b, double d);
|
||||
|
||||
signals:
|
||||
void thumbnailChanged(const QPixmap &pixmap);
|
||||
|
Loading…
x
Reference in New Issue
Block a user