mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 10:40:39 +00:00
Qt: general performance improvements, fix crash on switching playlists quickly in grid view, prevent initial loading of grid items from blocking
This commit is contained in:
parent
d55b1a0ad4
commit
de71a4dee7
@ -48,153 +48,184 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/* Original work Copyright (C) 2016 The Qt Company Ltd.
|
||||
* Modified work Copyright (C) 2018 - Brad Parker
|
||||
*/
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "flowlayout.h"
|
||||
|
||||
FlowLayout::FlowLayout(QWidget *parent, int margin, int hSpacing, int vSpacing)
|
||||
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
|
||||
: QLayout(parent), m_hSpace(hSpacing), m_vSpace(vSpacing)
|
||||
{
|
||||
setContentsMargins(margin, margin, margin, margin);
|
||||
setContentsMargins(margin, margin, margin, margin);
|
||||
}
|
||||
|
||||
FlowLayout::FlowLayout(int margin, int hSpacing, int vSpacing)
|
||||
: m_hSpace(hSpacing), m_vSpace(vSpacing)
|
||||
: m_hSpace(hSpacing), m_vSpace(vSpacing)
|
||||
{
|
||||
setContentsMargins(margin, margin, margin, margin);
|
||||
setContentsMargins(margin, margin, margin, margin);
|
||||
}
|
||||
|
||||
FlowLayout::~FlowLayout()
|
||||
{
|
||||
QLayoutItem *item;
|
||||
while ((item = takeAt(0)))
|
||||
delete item;
|
||||
QLayoutItem *item;
|
||||
|
||||
while ((item = takeAt(0)))
|
||||
delete item;
|
||||
}
|
||||
|
||||
void FlowLayout::addItem(QLayoutItem *item)
|
||||
{
|
||||
itemList.append(item);
|
||||
itemList.append(item);
|
||||
}
|
||||
|
||||
int FlowLayout::horizontalSpacing() const
|
||||
{
|
||||
if (m_hSpace >= 0) {
|
||||
return m_hSpace;
|
||||
} else {
|
||||
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
|
||||
}
|
||||
if (m_hSpace >= 0)
|
||||
return m_hSpace;
|
||||
else
|
||||
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
|
||||
}
|
||||
|
||||
int FlowLayout::verticalSpacing() const
|
||||
{
|
||||
if (m_vSpace >= 0) {
|
||||
return m_vSpace;
|
||||
} else {
|
||||
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
|
||||
}
|
||||
if (m_vSpace >= 0)
|
||||
return m_vSpace;
|
||||
else
|
||||
return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
|
||||
}
|
||||
|
||||
int FlowLayout::count() const
|
||||
{
|
||||
return itemList.size();
|
||||
return itemList.size();
|
||||
}
|
||||
|
||||
QLayoutItem *FlowLayout::itemAt(int index) const
|
||||
QLayoutItem* FlowLayout::itemAt(int index) const
|
||||
{
|
||||
return itemList.value(index);
|
||||
return itemList.value(index);
|
||||
}
|
||||
|
||||
QLayoutItem *FlowLayout::takeAt(int index)
|
||||
QLayoutItem* FlowLayout::takeAt(int index)
|
||||
{
|
||||
if (index >= 0 && index < itemList.size())
|
||||
return itemList.takeAt(index);
|
||||
else
|
||||
return 0;
|
||||
if (index >= 0 && index < itemList.size())
|
||||
return itemList.takeAt(index);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Qt::Orientations FlowLayout::expandingDirections() const
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool FlowLayout::hasHeightForWidth() const
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
int FlowLayout::heightForWidth(int width) const
|
||||
{
|
||||
int height = doLayout(QRect(0, 0, width, 0), true);
|
||||
return height;
|
||||
int height = doLayout(QRect(0, 0, width, 0), true);
|
||||
return height;
|
||||
}
|
||||
|
||||
void FlowLayout::setGeometry(const QRect &rect)
|
||||
{
|
||||
QLayout::setGeometry(rect);
|
||||
doLayout(rect, false);
|
||||
QLayout::setGeometry(rect);
|
||||
doLayout(rect, false);
|
||||
}
|
||||
|
||||
QSize FlowLayout::sizeHint() const
|
||||
{
|
||||
return minimumSize();
|
||||
return minimumSize();
|
||||
}
|
||||
|
||||
QSize FlowLayout::minimumSize() const
|
||||
{
|
||||
QSize size;
|
||||
QLayoutItem *item;
|
||||
foreach (item, itemList)
|
||||
size = size.expandedTo(item->minimumSize());
|
||||
QSize size;
|
||||
int i = 0;
|
||||
|
||||
size += QSize(2*margin(), 2*margin());
|
||||
return size;
|
||||
if (itemList.isEmpty())
|
||||
return size;
|
||||
|
||||
for (i = 0; i < itemList.count(); i++)
|
||||
{
|
||||
const QLayoutItem *item = itemList.at(i);
|
||||
size = size.expandedTo(item->minimumSize());
|
||||
}
|
||||
|
||||
size += QSize(2 * margin(), 2 * margin());
|
||||
return size;
|
||||
}
|
||||
|
||||
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
|
||||
{
|
||||
int left, top, right, bottom;
|
||||
getContentsMargins(&left, &top, &right, &bottom);
|
||||
QRect effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
|
||||
int x = effectiveRect.x();
|
||||
int y = effectiveRect.y();
|
||||
int lineHeight = 0;
|
||||
QRect effectiveRect;
|
||||
int left = 0, top = 0, right = 0, bottom = 0;
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int lineHeight = 0;
|
||||
int i = 0;
|
||||
|
||||
QLayoutItem *item;
|
||||
foreach (item, itemList) {
|
||||
QWidget *wid = item->widget();
|
||||
int spaceX = horizontalSpacing();
|
||||
if (spaceX == -1)
|
||||
spaceX = wid->style()->layoutSpacing(
|
||||
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
|
||||
int spaceY = verticalSpacing();
|
||||
if (spaceY == -1)
|
||||
spaceY = wid->style()->layoutSpacing(
|
||||
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
|
||||
int nextX = x + item->sizeHint().width() + spaceX;
|
||||
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) {
|
||||
x = effectiveRect.x();
|
||||
y = y + lineHeight + spaceY;
|
||||
nextX = x + item->sizeHint().width() + spaceX;
|
||||
lineHeight = 0;
|
||||
}
|
||||
getContentsMargins(&left, &top, &right, &bottom);
|
||||
effectiveRect = rect.adjusted(+left, +top, -right, -bottom);
|
||||
x = effectiveRect.x();
|
||||
y = effectiveRect.y();
|
||||
|
||||
if (!testOnly)
|
||||
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
|
||||
if (itemList.isEmpty())
|
||||
return y + lineHeight - rect.y() + bottom;
|
||||
|
||||
x = nextX;
|
||||
lineHeight = qMax(lineHeight, item->sizeHint().height());
|
||||
}
|
||||
return y + lineHeight - rect.y() + bottom;
|
||||
for (i = 0; i < itemList.count(); i++)
|
||||
{
|
||||
QLayoutItem *item = itemList.at(i);
|
||||
const QWidget *wid = item->widget();
|
||||
int spaceX = horizontalSpacing();
|
||||
int spaceY = 0;
|
||||
int nextX = 0;
|
||||
|
||||
if (spaceX == -1)
|
||||
spaceX = wid->style()->layoutSpacing(
|
||||
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
|
||||
|
||||
spaceY = verticalSpacing();
|
||||
|
||||
if (spaceY == -1)
|
||||
spaceY = wid->style()->layoutSpacing(
|
||||
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
|
||||
|
||||
nextX = x + item->sizeHint().width() + spaceX;
|
||||
|
||||
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0)
|
||||
{
|
||||
x = effectiveRect.x();
|
||||
y = y + lineHeight + spaceY;
|
||||
nextX = x + item->sizeHint().width() + spaceX;
|
||||
lineHeight = 0;
|
||||
}
|
||||
|
||||
if (!testOnly)
|
||||
item->setGeometry(QRect(QPoint(x, y), item->sizeHint()));
|
||||
|
||||
x = nextX;
|
||||
lineHeight = qMax(lineHeight, item->sizeHint().height());
|
||||
}
|
||||
|
||||
return y + lineHeight - rect.y() + bottom;
|
||||
}
|
||||
|
||||
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
|
||||
{
|
||||
QObject *parent = this->parent();
|
||||
if (!parent) {
|
||||
return -1;
|
||||
} else if (parent->isWidgetType()) {
|
||||
QWidget *pw = static_cast<QWidget *>(parent);
|
||||
return pw->style()->pixelMetric(pm, 0, pw);
|
||||
} else {
|
||||
return static_cast<QLayout *>(parent)->spacing();
|
||||
}
|
||||
const QObject *parentObj = parent();
|
||||
|
||||
if (!parentObj)
|
||||
return -1;
|
||||
else if (parentObj->isWidgetType())
|
||||
{
|
||||
const QWidget *pw = static_cast<const QWidget*>(parentObj);
|
||||
return pw->style()->pixelMetric(pm, 0, pw);
|
||||
}
|
||||
else
|
||||
return static_cast<const QLayout*>(parentObj)->spacing();
|
||||
}
|
||||
|
@ -48,7 +48,13 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
/* bparker: Removed C++11 override keyword from original source */
|
||||
/* Original work Copyright (C) 2016 The Qt Company Ltd.
|
||||
* Modified work Copyright (C) 2018 - Brad Parker
|
||||
*/
|
||||
|
||||
/* bparker: Removed C++11 override keyword from original source
|
||||
* Changed QList to QVector
|
||||
*/
|
||||
|
||||
#ifndef FLOWLAYOUT_H
|
||||
#define FLOWLAYOUT_H
|
||||
@ -60,30 +66,30 @@
|
||||
class FlowLayout : public QLayout
|
||||
{
|
||||
public:
|
||||
explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1);
|
||||
explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);
|
||||
~FlowLayout();
|
||||
explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1);
|
||||
explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);
|
||||
~FlowLayout();
|
||||
|
||||
void addItem(QLayoutItem *item);
|
||||
int horizontalSpacing() const;
|
||||
int verticalSpacing() const;
|
||||
Qt::Orientations expandingDirections() const;
|
||||
bool hasHeightForWidth() const;
|
||||
int heightForWidth(int) const;
|
||||
int count() const;
|
||||
QLayoutItem *itemAt(int index) const;
|
||||
QSize minimumSize() const;
|
||||
void setGeometry(const QRect &rect);
|
||||
QSize sizeHint() const;
|
||||
QLayoutItem *takeAt(int index);
|
||||
void addItem(QLayoutItem *item);
|
||||
int horizontalSpacing() const;
|
||||
int verticalSpacing() const;
|
||||
Qt::Orientations expandingDirections() const;
|
||||
bool hasHeightForWidth() const;
|
||||
int heightForWidth(int) const;
|
||||
int count() const;
|
||||
QLayoutItem* itemAt(int index) const;
|
||||
QSize minimumSize() const;
|
||||
void setGeometry(const QRect &rect);
|
||||
QSize sizeHint() const;
|
||||
QLayoutItem* takeAt(int index);
|
||||
|
||||
private:
|
||||
int doLayout(const QRect &rect, bool testOnly) const;
|
||||
int smartSpacing(QStyle::PixelMetric pm) const;
|
||||
int doLayout(const QRect &rect, bool testOnly) const;
|
||||
int smartSpacing(QStyle::PixelMetric pm) const;
|
||||
|
||||
QList<QLayoutItem *> itemList;
|
||||
int m_hSpace;
|
||||
int m_vSpace;
|
||||
QVector<QLayoutItem*> itemList;
|
||||
int m_hSpace;
|
||||
int m_vSpace;
|
||||
};
|
||||
|
||||
#endif // FLOWLAYOUT_H
|
||||
|
@ -266,8 +266,11 @@ void LoadCoreWindow::initCoreList(const QStringList &extensionFilters)
|
||||
|
||||
if (rowsToHide.size() != m_table->rowCount())
|
||||
{
|
||||
foreach (const int &row, rowsToHide)
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < rowsToHide.count() && rowsToHide.count() > 0; i++)
|
||||
{
|
||||
const int &row = rowsToHide.at(i);
|
||||
m_table->setRowHidden(row, true);
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ void CoreInfoDialog::showCoreInfo()
|
||||
int row = 0;
|
||||
int rowCount = m_formLayout->rowCount();
|
||||
int i = 0;
|
||||
QList<QHash<QString, QString> > infoList = m_mainwindow->getCoreInfo();
|
||||
QVector<QHash<QString, QString> > infoList = m_mainwindow->getCoreInfo();
|
||||
|
||||
if (rowCount > 0)
|
||||
{
|
||||
@ -526,6 +526,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
,m_gridLayoutWidget(new QWidget())
|
||||
,m_zoomSlider(NULL)
|
||||
,m_lastZoomSliderValue(0)
|
||||
,m_pendingItemUpdates()
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
QDir playlistDir(settings->paths.directory_playlist);
|
||||
@ -707,7 +708,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
qApp->processEvents();
|
||||
QTimer::singleShot(0, this, SLOT(onBrowserStartClicked()));
|
||||
|
||||
for (i = 0; i < m_listWidget->count(); i++)
|
||||
for (i = 0; i < m_listWidget->count() && m_listWidget->count() > 0; i++)
|
||||
{
|
||||
/* select the first non-hidden row */
|
||||
if (!m_listWidget->isRowHidden(i))
|
||||
@ -737,22 +738,27 @@ MainWindow::~MainWindow()
|
||||
removeGridItems();
|
||||
}
|
||||
|
||||
inline void MainWindow::calcGridItemSize(GridItem *item, int zoomValue)
|
||||
{
|
||||
QMutexLocker lock(&item->mutex);
|
||||
int newSize = 0;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void MainWindow::onZoomValueChanged(int value)
|
||||
{
|
||||
if (m_gridItems.count() == 0)
|
||||
return;
|
||||
int i = 0;
|
||||
|
||||
foreach(GridItem *item, m_gridItems)
|
||||
for (i = 0; i < m_gridItems.count() && m_gridItems.count() > 0; i++)
|
||||
{
|
||||
QMutexLocker lock(&item->mutex);
|
||||
int newSize = 0;
|
||||
|
||||
if (value < 50)
|
||||
newSize = expScale(lerp(0, 49, 25, 49, value) / 50.0, 102, 256);
|
||||
else
|
||||
newSize = expScale(value / 100.0, 256, 1024);
|
||||
|
||||
item->widget->setFixedSize(QSize(newSize, newSize));
|
||||
GridItem *item = m_gridItems.at(i);
|
||||
calcGridItemSize(item, value);
|
||||
}
|
||||
|
||||
m_lastZoomSliderValue = value;
|
||||
@ -948,20 +954,17 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||
|
||||
menu->addAction(hideAction.data());
|
||||
|
||||
if (m_listWidget->count() > 0)
|
||||
for (j = 0; j < m_listWidget->count() && m_listWidget->count() > 0; j++)
|
||||
{
|
||||
for (j = 0; j < m_listWidget->count(); j++)
|
||||
{
|
||||
QListWidgetItem *item = m_listWidget->item(j);
|
||||
bool hidden = m_listWidget->isItemHidden(item);
|
||||
QListWidgetItem *item = m_listWidget->item(j);
|
||||
bool hidden = m_listWidget->isItemHidden(item);
|
||||
|
||||
if (hidden)
|
||||
{
|
||||
QAction *action = hiddenPlaylistsMenu->addAction(item->text());
|
||||
action->setProperty("row", j);
|
||||
action->setProperty("core_path", item->data(Qt::UserRole).toString());
|
||||
foundHiddenPlaylist = true;
|
||||
}
|
||||
if (hidden)
|
||||
{
|
||||
QAction *action = hiddenPlaylistsMenu->addAction(item->text());
|
||||
action->setProperty("row", j);
|
||||
action->setProperty("core_path", item->data(Qt::UserRole).toString());
|
||||
foundHiddenPlaylist = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -986,17 +989,28 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
|
||||
|
||||
core_info_get_list(&core_info_list);
|
||||
|
||||
for (i = 0; i < core_info_list->count; i++)
|
||||
for (i = 0; i < core_info_list->count && core_info_list->count > 0; i++)
|
||||
{
|
||||
const core_info_t *core = &core_info_list->list[i];
|
||||
coreList[core->core_name] = core;
|
||||
}
|
||||
|
||||
foreach (const QString &key, coreList.keys())
|
||||
{
|
||||
const core_info_t *core = coreList.value(key);
|
||||
QAction *action = associateMenu->addAction(core->core_name);
|
||||
action->setProperty("core_path", core->path);
|
||||
QMapIterator<QString, const core_info_t*> coreListIterator(coreList);
|
||||
|
||||
while (coreListIterator.hasNext())
|
||||
{
|
||||
QString key;
|
||||
const core_info_t *core = NULL;
|
||||
QAction *action = NULL;
|
||||
|
||||
coreListIterator.next();
|
||||
|
||||
key = coreListIterator.key();
|
||||
core = coreList.value(key);
|
||||
action = associateMenu->addAction(core->core_name);
|
||||
action->setProperty("core_path", core->path);
|
||||
}
|
||||
}
|
||||
|
||||
menu->addMenu(associateMenu.data());
|
||||
@ -1180,6 +1194,7 @@ void MainWindow::reloadPlaylists()
|
||||
QDir playlistDir(settings->paths.directory_playlist);
|
||||
QString currentPlaylistPath;
|
||||
QStringList hiddenPlaylists = m_settings->value("hidden_playlists").toStringList();
|
||||
int i = 0;
|
||||
|
||||
currentItem = m_listWidget->currentItem();
|
||||
|
||||
@ -1230,9 +1245,10 @@ void MainWindow::reloadPlaylists()
|
||||
if (hiddenPlaylists.contains(QFileInfo(settings->paths.path_content_video_history).fileName()))
|
||||
m_listWidget->setRowHidden(m_listWidget->row(videoPlaylistsItem), true);
|
||||
|
||||
foreach (QString file, m_playlistFiles)
|
||||
for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++)
|
||||
{
|
||||
QListWidgetItem *item = NULL;
|
||||
const QString &file = m_playlistFiles.at(i);
|
||||
QString fileDisplayName = file;
|
||||
QString fileName = file;
|
||||
bool hasIcon = false;
|
||||
@ -1270,7 +1286,6 @@ void MainWindow::reloadPlaylists()
|
||||
|
||||
if (firstItem)
|
||||
{
|
||||
int i = 0;
|
||||
bool found = false;
|
||||
|
||||
for (i = 0; i < m_listWidget->count(); i++)
|
||||
@ -1318,7 +1333,7 @@ void MainWindow::onGotLogMessage(const QString &msg)
|
||||
|
||||
void MainWindow::onLaunchWithComboBoxIndexChanged(int)
|
||||
{
|
||||
QList<QHash<QString, QString> > infoList = getCoreInfo();
|
||||
QVector<QHash<QString, QString> > infoList = getCoreInfo();
|
||||
QString coreInfoText;
|
||||
QVariantMap coreMap = m_launchWithComboBox->currentData(Qt::UserRole).value<QVariantMap>();
|
||||
CoreSelection coreSelection = static_cast<CoreSelection>(coreMap.value("core_selection").toInt());
|
||||
@ -1423,9 +1438,9 @@ void MainWindow::setTheme(Theme theme)
|
||||
}
|
||||
}
|
||||
|
||||
QList<QHash<QString, QString> > MainWindow::getCoreInfo()
|
||||
QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
|
||||
{
|
||||
QList<QHash<QString, QString> > infoList;
|
||||
QVector<QHash<QString, QString> > infoList;
|
||||
QHash<QString, QString> currentCore = getSelectedCore();
|
||||
core_info_list_t *core_info_list = NULL;
|
||||
const core_info_t *core_info = NULL;
|
||||
@ -1850,7 +1865,7 @@ QHash<QString, QString> MainWindow::getSelectedCore()
|
||||
}
|
||||
case CORE_SELECTION_PLAYLIST_DEFAULT:
|
||||
{
|
||||
QList<QHash<QString, QString> > cores;
|
||||
QVector<QHash<QString, QString> > cores;
|
||||
int i = 0;
|
||||
|
||||
if (!contentItem || contentHash["db_name"].isEmpty())
|
||||
@ -1982,7 +1997,7 @@ void MainWindow::onRunClicked()
|
||||
}
|
||||
case CORE_SELECTION_PLAYLIST_DEFAULT:
|
||||
{
|
||||
QList<QHash<QString, QString> > cores = getPlaylistDefaultCores();
|
||||
QVector<QHash<QString, QString> > cores = getPlaylistDefaultCores();
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; i < cores.count(); i++)
|
||||
@ -2047,13 +2062,13 @@ ViewOptionsDialog* MainWindow::viewOptionsDialog()
|
||||
return m_viewOptionsDialog;
|
||||
}
|
||||
|
||||
QList<QHash<QString, QString> > MainWindow::getPlaylistDefaultCores()
|
||||
QVector<QHash<QString, QString> > MainWindow::getPlaylistDefaultCores()
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct string_list *playlists = string_split(settings->arrays.playlist_names, ";");
|
||||
struct string_list *cores = string_split(settings->arrays.playlist_cores, ";");
|
||||
unsigned i = 0;
|
||||
QList<QHash<QString, QString> > coreList;
|
||||
QVector<QHash<QString, QString> > coreList;
|
||||
|
||||
if (!playlists || !cores)
|
||||
{
|
||||
@ -2164,7 +2179,7 @@ void MainWindow::setCoreActions()
|
||||
|
||||
if (!hash["db_name"].isEmpty())
|
||||
{
|
||||
QList<QHash<QString, QString> > defaultCores = getPlaylistDefaultCores();
|
||||
QVector<QHash<QString, QString> > defaultCores = getPlaylistDefaultCores();
|
||||
int i = 0;
|
||||
|
||||
if (defaultCores.count() > 0)
|
||||
@ -2406,6 +2421,7 @@ void MainWindow::onViewClosedDocksAboutToShow()
|
||||
QMenu *menu = qobject_cast<QMenu*>(sender());
|
||||
QList<QDockWidget*> dockWidgets;
|
||||
bool found = false;
|
||||
int i = 0;
|
||||
|
||||
if (!menu)
|
||||
return;
|
||||
@ -2420,8 +2436,10 @@ void MainWindow::onViewClosedDocksAboutToShow()
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (QDockWidget *dock, dockWidgets)
|
||||
for (i = 0; i < dockWidgets.count() && dockWidgets.count() > 0; i++)
|
||||
{
|
||||
const QDockWidget *dock = dockWidgets.at(i);
|
||||
|
||||
if (!dock->isVisible())
|
||||
{
|
||||
QAction *action = menu->addAction(dock->property("menu_text").toString(), this, SLOT(onShowHiddenDockWidgetAction()));
|
||||
@ -2431,9 +2449,7 @@ void MainWindow::onViewClosedDocksAboutToShow()
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
menu->addAction(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onShowHiddenDockWidgetAction()
|
||||
@ -2826,6 +2842,7 @@ void MainWindow::removeGridItems()
|
||||
items.remove();
|
||||
|
||||
m_gridLayout->removeWidget(item->widget);
|
||||
m_pendingItemUpdates.removeAll(item);
|
||||
|
||||
delete item->widget;
|
||||
|
||||
@ -2854,13 +2871,39 @@ void MainWindow::onDeferredImageLoaded()
|
||||
|
||||
if (!item->image.isNull())
|
||||
{
|
||||
item->label->setPixmap(QPixmap::fromImage(item->image));
|
||||
item->label->update();
|
||||
m_pendingItemUpdates.append(item);
|
||||
QTimer::singleShot(0, this, SLOT(onPendingItemUpdates()));
|
||||
}
|
||||
|
||||
item->mutex.unlock();
|
||||
}
|
||||
|
||||
void MainWindow::onPendingItemUpdates()
|
||||
{
|
||||
QMutableListIterator<GridItem*> list(m_pendingItemUpdates);
|
||||
|
||||
while (list.hasNext())
|
||||
{
|
||||
GridItem *item = list.next();
|
||||
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
onUpdateGridItemPixmapFromImage(item);
|
||||
|
||||
list.remove();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onUpdateGridItemPixmapFromImage(GridItem *item)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
item->label->setPixmap(QPixmap::fromImage(item->image));
|
||||
item->label->update();
|
||||
}
|
||||
|
||||
void MainWindow::loadImageDeferred(GridItem *item, QString path)
|
||||
{
|
||||
connect(&item->imageWatcher, SIGNAL(finished()), this, SLOT(onDeferredImageLoaded()), Qt::QueuedConnection);
|
||||
@ -2882,13 +2925,14 @@ GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path)
|
||||
return item;
|
||||
}
|
||||
|
||||
void MainWindow::addPlaylistItemsToGrid(QString pathString)
|
||||
void MainWindow::addPlaylistItemsToGrid(const QString &pathString)
|
||||
{
|
||||
QList<QHash<QString, QString> > items = getPlaylistItems(pathString);
|
||||
QVector<QHash<QString, QString> > items = getPlaylistItems(pathString);
|
||||
QScreen *screen = qApp->primaryScreen();
|
||||
QSize screenSize = screen->size();
|
||||
settings_t *settings = config_get_ptr();
|
||||
int i = 0;
|
||||
int zoomValue = m_zoomSlider->value();
|
||||
|
||||
for (i = 0; i < items.count(); i++)
|
||||
{
|
||||
@ -2938,6 +2982,8 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString)
|
||||
|
||||
item->label = label;
|
||||
|
||||
calcGridItemSize(item, zoomValue);
|
||||
|
||||
item->widget->layout()->addWidget(label);
|
||||
|
||||
newLabel = new QLabel(hash.value("label"), item->widget);
|
||||
@ -2950,6 +2996,8 @@ void MainWindow::addPlaylistItemsToGrid(QString pathString)
|
||||
m_gridItems.append(item);
|
||||
|
||||
loadImageDeferred(item, imagePath);
|
||||
|
||||
qApp->processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2969,9 +3017,11 @@ void MainWindow::initContentGridLayout()
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
QDir playlistDir(settings->paths.directory_playlist);
|
||||
int i = 0;
|
||||
|
||||
foreach (QString playlist, m_playlistFiles)
|
||||
for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++)
|
||||
{
|
||||
const QString &playlist = m_playlistFiles.at(i);
|
||||
addPlaylistItemsToGrid(playlistDir.absoluteFilePath(playlist));
|
||||
}
|
||||
}
|
||||
@ -3018,9 +3068,11 @@ void MainWindow::initContentTableWidget()
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
QDir playlistDir(settings->paths.directory_playlist);
|
||||
int i = 0;
|
||||
|
||||
foreach (QString playlist, m_playlistFiles)
|
||||
for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++)
|
||||
{
|
||||
const QString &playlist = m_playlistFiles.at(i);
|
||||
addPlaylistItemsToTable(playlistDir.absoluteFilePath(playlist));
|
||||
}
|
||||
}
|
||||
@ -3047,10 +3099,10 @@ void MainWindow::initContentTableWidget()
|
||||
onSearchEnterPressed();
|
||||
}
|
||||
|
||||
QList<QHash<QString, QString> > MainWindow::getPlaylistItems(QString pathString)
|
||||
QVector<QHash<QString, QString> > MainWindow::getPlaylistItems(QString pathString)
|
||||
{
|
||||
QByteArray pathArray;
|
||||
QList<QHash<QString, QString> > items;
|
||||
QVector<QHash<QString, QString> > items;
|
||||
const char *pathData = NULL;
|
||||
playlist_t *playlist = NULL;
|
||||
unsigned playlistSize = 0;
|
||||
@ -3118,7 +3170,7 @@ QList<QHash<QString, QString> > MainWindow::getPlaylistItems(QString pathString)
|
||||
|
||||
void MainWindow::addPlaylistItemsToTable(QString pathString)
|
||||
{
|
||||
QList<QHash<QString, QString> > items = getPlaylistItems(pathString);
|
||||
QVector<QHash<QString, QString> > items = getPlaylistItems(pathString);
|
||||
int i = 0;
|
||||
int oldRowCount = m_tableWidget->rowCount();
|
||||
|
||||
|
@ -256,10 +256,10 @@ public:
|
||||
QToolButton* runPushButton();
|
||||
QToolButton* stopPushButton();
|
||||
QTabWidget* browserAndPlaylistTabWidget();
|
||||
QList<QHash<QString, QString> > getPlaylistDefaultCores();
|
||||
QVector<QHash<QString, QString> > getPlaylistDefaultCores();
|
||||
ViewOptionsDialog* viewOptionsDialog();
|
||||
QSettings* settings();
|
||||
QList<QHash<QString, QString> > getCoreInfo();
|
||||
QVector<QHash<QString, QString> > getCoreInfo();
|
||||
void setTheme(Theme theme = THEME_SYSTEM_DEFAULT);
|
||||
Theme theme();
|
||||
Theme getThemeFromString(QString themeString);
|
||||
@ -315,7 +315,7 @@ private slots:
|
||||
void onSearchEnterPressed();
|
||||
void onSearchLineEditEdited(const QString &text);
|
||||
void addPlaylistItemsToTable(QString path);
|
||||
void addPlaylistItemsToGrid(QString path);
|
||||
void addPlaylistItemsToGrid(const QString &path);
|
||||
void onContentItemDoubleClicked(QTableWidgetItem *item);
|
||||
void onCoreLoadWindowClosed();
|
||||
void onTabWidgetIndexChanged(int index);
|
||||
@ -328,6 +328,8 @@ private slots:
|
||||
void onDeferredImageLoaded();
|
||||
void onZoomValueChanged(int value);
|
||||
void onContentGridInited();
|
||||
void onUpdateGridItemPixmapFromImage(GridItem *item);
|
||||
void onPendingItemUpdates();
|
||||
|
||||
private:
|
||||
void setCurrentCoreLabel();
|
||||
@ -336,7 +338,8 @@ private:
|
||||
bool isContentLessCore();
|
||||
void removeGridItems();
|
||||
void loadImageDeferred(GridItem *item, QString path);
|
||||
QList<QHash<QString, QString> > getPlaylistItems(QString pathString);
|
||||
void calcGridItemSize(GridItem *item, int zoomValue);
|
||||
QVector<QHash<QString, QString> > getPlaylistItems(QString pathString);
|
||||
|
||||
LoadCoreWindow *m_loadCoreWindow;
|
||||
QTimer *m_timer;
|
||||
@ -385,6 +388,7 @@ private:
|
||||
QWidget *m_gridLayoutWidget;
|
||||
QSlider *m_zoomSlider;
|
||||
int m_lastZoomSliderValue;
|
||||
QList<GridItem*> m_pendingItemUpdates;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
Loading…
Reference in New Issue
Block a user