mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 09:40:06 +00:00
Qt: add progress bar for grid view loading
This commit is contained in:
parent
75ce796c34
commit
f78337e02e
@ -3630,3 +3630,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE,
|
||||
"パフォーマンス維持モード")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT,
|
||||
"mpv対応")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS,
|
||||
"進行状況:")
|
||||
|
@ -3788,3 +3788,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_SUSTAINED_PERFORMANCE_MODE,
|
||||
"Sustained Performance Mode")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_MPV_SUPPORT,
|
||||
"mpv support")
|
||||
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PROGRESS,
|
||||
"Progress:")
|
||||
|
@ -1875,6 +1875,7 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_VALUE_QT_VIEW,
|
||||
MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_ICONS,
|
||||
MENU_ENUM_LABEL_VALUE_QT_VIEW_TYPE_LIST,
|
||||
MENU_ENUM_LABEL_VALUE_QT_PROGRESS,
|
||||
|
||||
MENU_LABEL(MIDI_INPUT),
|
||||
MENU_LABEL(MIDI_OUTPUT),
|
||||
|
@ -532,6 +532,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
,m_lastZoomSliderValue(0)
|
||||
,m_pendingItemUpdates()
|
||||
,m_viewType(VIEW_TYPE_LIST)
|
||||
,m_gridProgressBar(NULL)
|
||||
,m_gridProgressWidget(NULL)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
QDir playlistDir(settings->paths.directory_playlist);
|
||||
@ -544,10 +546,16 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
QMenu *viewTypeMenu = new QMenu(viewTypePushButton);
|
||||
QAction *viewTypeIconsAction = NULL;
|
||||
QAction *viewTypeListAction = NULL;
|
||||
QHBoxLayout *gridProgressLayout = new QHBoxLayout();
|
||||
QLabel *gridProgressLabel = NULL;
|
||||
QHBoxLayout *gridFooterLayout = NULL;
|
||||
int i = 0;
|
||||
|
||||
qRegisterMetaType<QPointer<ThumbnailWidget> >("ThumbnailWidget");
|
||||
|
||||
m_gridProgressWidget = new QWidget();
|
||||
gridProgressLabel = new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PROGRESS), m_gridProgressWidget);
|
||||
|
||||
viewTypePushButton->setObjectName("viewTypePushButton");
|
||||
viewTypePushButton->setFlat(true);
|
||||
|
||||
@ -556,6 +564,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
viewTypePushButton->setMenu(viewTypeMenu);
|
||||
|
||||
gridProgressLabel->setObjectName("gridProgressLabel");
|
||||
|
||||
m_gridProgressBar = new QProgressBar(m_gridProgressWidget);
|
||||
|
||||
m_gridProgressBar->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred));
|
||||
|
||||
zoomLabel->setObjectName("zoomLabel");
|
||||
|
||||
m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget);
|
||||
@ -563,6 +577,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
m_zoomSlider->setMinimum(0);
|
||||
m_zoomSlider->setMaximum(100);
|
||||
m_zoomSlider->setValue(50);
|
||||
m_zoomSlider->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred));
|
||||
|
||||
m_lastZoomSliderValue = m_zoomSlider->value();
|
||||
|
||||
@ -578,16 +593,28 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
m_gridWidget->layout()->addWidget(m_gridScrollArea);
|
||||
m_gridWidget->layout()->setAlignment(Qt::AlignCenter);
|
||||
|
||||
m_zoomSlider->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred));
|
||||
m_gridProgressWidget->setLayout(gridProgressLayout);
|
||||
gridProgressLayout->setContentsMargins(0, 0, 0, 0);
|
||||
gridProgressLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred));
|
||||
gridProgressLayout->addWidget(gridProgressLabel);
|
||||
gridProgressLayout->addWidget(m_gridProgressBar);
|
||||
|
||||
m_gridWidget->layout()->addWidget(m_gridProgressWidget);
|
||||
|
||||
zoomWidget->setLayout(zoomLayout);
|
||||
zoomLayout->setContentsMargins(0, 0, 0, 0);
|
||||
zoomLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred));
|
||||
zoomLayout->addWidget(zoomLabel);
|
||||
zoomLayout->addWidget(m_zoomSlider);
|
||||
zoomLayout->addWidget(viewTypePushButton);
|
||||
|
||||
m_gridWidget->layout()->addWidget(zoomWidget);
|
||||
gridFooterLayout = new QHBoxLayout();
|
||||
gridFooterLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Preferred));
|
||||
gridFooterLayout->addWidget(m_gridProgressWidget);
|
||||
gridFooterLayout->addWidget(zoomWidget);
|
||||
|
||||
static_cast<QVBoxLayout*>(m_gridWidget->layout())->addLayout(gridFooterLayout);
|
||||
|
||||
m_gridProgressWidget->hide();
|
||||
|
||||
m_tableWidget->setAlternatingRowColors(true);
|
||||
|
||||
@ -2994,7 +3021,7 @@ GridItem* MainWindow::doDeferredImageLoad(GridItem *item, QString path)
|
||||
return item;
|
||||
}
|
||||
|
||||
void MainWindow::addPlaylistItemsToGrid(const QString &pathString)
|
||||
void MainWindow::addPlaylistItemsToGrid(const QString &pathString, bool setProgress)
|
||||
{
|
||||
QVector<QHash<QString, QString> > items = getPlaylistItems(pathString);
|
||||
QScreen *screen = qApp->primaryScreen();
|
||||
@ -3004,6 +3031,14 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString)
|
||||
int i = 0;
|
||||
int zoomValue = m_zoomSlider->value();
|
||||
|
||||
/* setProgress means we are resetting the range of the progress bar as we are only loading a single playlist. If false, just increment by 1 since instead we're loading multiple playlists and we only track the progress of each entire playlist that is loaded, instead of every single entry. */
|
||||
if (setProgress)
|
||||
{
|
||||
m_gridProgressBar->setMinimum(0);
|
||||
m_gridProgressBar->setMaximum(items.count() - 1);
|
||||
m_gridProgressBar->setValue(0);
|
||||
}
|
||||
|
||||
for (i = 0; i < items.count(); i++)
|
||||
{
|
||||
const QHash<QString, QString> &hash = items.at(i);
|
||||
@ -3077,7 +3112,17 @@ void MainWindow::addPlaylistItemsToGrid(const QString &pathString)
|
||||
|
||||
if (i % 25 == 0)
|
||||
qApp->processEvents();
|
||||
|
||||
if (setProgress)
|
||||
m_gridProgressBar->setValue(i);
|
||||
}
|
||||
|
||||
if (!setProgress)
|
||||
m_gridProgressBar->setValue(m_gridProgressBar->value() + 1);
|
||||
|
||||
/* If there's only one entry, a min/max/value of all zero would make an indeterminate progress bar that never ends... so just hide it when we are done. */
|
||||
if (m_gridProgressBar->value() == m_gridProgressBar->maximum())
|
||||
m_gridProgressWidget->hide();
|
||||
}
|
||||
|
||||
void MainWindow::initContentGridLayout()
|
||||
@ -3088,6 +3133,11 @@ void MainWindow::initContentGridLayout()
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
m_gridProgressBar->setMinimum(0);
|
||||
m_gridProgressBar->setMaximum(0);
|
||||
m_gridProgressBar->setValue(0);
|
||||
m_gridProgressWidget->show();
|
||||
|
||||
removeGridItems();
|
||||
|
||||
path = item->data(Qt::UserRole).toString();
|
||||
@ -3098,10 +3148,15 @@ void MainWindow::initContentGridLayout()
|
||||
QDir playlistDir(settings->paths.directory_playlist);
|
||||
int i = 0;
|
||||
|
||||
m_gridProgressBar->setMinimum(0);
|
||||
m_gridProgressBar->setMaximum(m_playlistFiles.count() - 1);
|
||||
m_gridProgressBar->setValue(0);
|
||||
|
||||
for (i = 0; i < m_playlistFiles.count() && m_playlistFiles.count() > 0; i++)
|
||||
{
|
||||
const QString &playlist = m_playlistFiles.at(i);
|
||||
addPlaylistItemsToGrid(playlistDir.absoluteFilePath(playlist));
|
||||
m_gridProgressBar->setValue(i);
|
||||
addPlaylistItemsToGrid(playlistDir.absoluteFilePath(playlist), false);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <QPixmap>
|
||||
#include <QImage>
|
||||
#include <QPointer>
|
||||
#include <QProgressBar>
|
||||
|
||||
extern "C" {
|
||||
#include <retro_common_api.h>
|
||||
@ -327,7 +328,7 @@ private slots:
|
||||
void onSearchEnterPressed();
|
||||
void onSearchLineEditEdited(const QString &text);
|
||||
void addPlaylistItemsToTable(QString path);
|
||||
void addPlaylistItemsToGrid(const QString &path);
|
||||
void addPlaylistItemsToGrid(const QString &path, bool setProgress = true);
|
||||
void onContentItemDoubleClicked(QTableWidgetItem *item);
|
||||
void onCoreLoadWindowClosed();
|
||||
void onTreeViewItemsSelected(QModelIndexList selectedIndexes);
|
||||
@ -403,6 +404,8 @@ private:
|
||||
int m_lastZoomSliderValue;
|
||||
QList<GridItem*> m_pendingItemUpdates;
|
||||
ViewType m_viewType;
|
||||
QProgressBar *m_gridProgressBar;
|
||||
QWidget *m_gridProgressWidget;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
Loading…
x
Reference in New Issue
Block a user