Commit f7375190 authored by Bernd Schmidt's avatar Bernd Schmidt
Browse files

Add a QProgressDialog for loading the collection

parent 33aef95d
......@@ -131,7 +131,7 @@ void Palapeli::GamePlay::deletePuzzleViews()
void Palapeli::GamePlay::init()
{
// Set up the collection view.
m_collectionView->setModel(Palapeli::Collection::instance());
m_collectionView->setModel(Palapeli::Collection::instance(m_mainWindow));
connect(m_collectionView, SIGNAL(playRequest(Palapeli::Puzzle*)), SLOT(playPuzzle(Palapeli::Puzzle*)));
// Set up the puzzle table.
......
......@@ -26,6 +26,7 @@
#include <QFileInfo>
#include <QUuid>
#include <QStandardPaths>
#include <QProgressDialog>
#include <KConfig>
#include <KConfigGroup>
#include <KLocalizedString>
......@@ -67,9 +68,9 @@ void Palapeli::Collection::Item::populate()
//END Palapeli::Collection::Item
Palapeli::Collection* Palapeli::Collection::instance()
Palapeli::Collection* Palapeli::Collection::instance(QWidget *parent)
{
static Palapeli::Collection instance;
static Palapeli::Collection instance(parent);
return &instance;
}
......@@ -108,14 +109,20 @@ static QString readPseudoUrl(const QString& path_, bool local)
return path_;
}
Palapeli::Collection::Collection()
Palapeli::Collection::Collection(QWidget *parent)
: m_config(new KConfig(QStringLiteral("palapeli-collectionrc"), KConfig::CascadeConfig))
, m_group(new KConfigGroup(m_config, "Palapeli Collection"))
{
//read the puzzles
const QStringList puzzleIds = m_group->groupList();
int len = puzzleIds.length ();
int count = 0;
QProgressDialog dlg(i18n("Loading collection"), QString(), 0, len, parent);
dlg.setMinimumDuration(2000);
dlg.setWindowModality(Qt::WindowModal);
foreach (const QString& puzzleId, puzzleIds)
{
dlg.setValue(count++);
KConfigGroup* puzzleGroup = new KConfigGroup(m_group, puzzleId);
//find involved files
const QString basePath = puzzleGroup->readEntry("Location", QString());
......
......@@ -43,7 +43,7 @@ namespace Palapeli
IdentifierRole
};
static Palapeli::Collection* instance();
static Palapeli::Collection* instance(QWidget * = nullptr);
Palapeli::Puzzle* puzzleFromIndex(const QModelIndex& index) const;
void importPuzzle(Palapeli::Puzzle* puzzle); ///< without copying!
......@@ -51,7 +51,7 @@ namespace Palapeli
void exportPuzzle(const QModelIndex& index, const QString& path);
bool deletePuzzle(const QModelIndex& index);
protected:
Collection();
Collection(QWidget *);
virtual ~Collection();
private:
class Item;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment