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() ...@@ -131,7 +131,7 @@ void Palapeli::GamePlay::deletePuzzleViews()
void Palapeli::GamePlay::init() void Palapeli::GamePlay::init()
{ {
// Set up the collection view. // 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*))); connect(m_collectionView, SIGNAL(playRequest(Palapeli::Puzzle*)), SLOT(playPuzzle(Palapeli::Puzzle*)));
// Set up the puzzle table. // Set up the puzzle table.
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <QFileInfo> #include <QFileInfo>
#include <QUuid> #include <QUuid>
#include <QStandardPaths> #include <QStandardPaths>
#include <QProgressDialog>
#include <KConfig> #include <KConfig>
#include <KConfigGroup> #include <KConfigGroup>
#include <KLocalizedString> #include <KLocalizedString>
...@@ -67,9 +68,9 @@ void Palapeli::Collection::Item::populate() ...@@ -67,9 +68,9 @@ void Palapeli::Collection::Item::populate()
//END Palapeli::Collection::Item //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; return &instance;
} }
...@@ -108,14 +109,20 @@ static QString readPseudoUrl(const QString& path_, bool local) ...@@ -108,14 +109,20 @@ static QString readPseudoUrl(const QString& path_, bool local)
return path_; return path_;
} }
Palapeli::Collection::Collection() Palapeli::Collection::Collection(QWidget *parent)
: m_config(new KConfig(QStringLiteral("palapeli-collectionrc"), KConfig::CascadeConfig)) : m_config(new KConfig(QStringLiteral("palapeli-collectionrc"), KConfig::CascadeConfig))
, m_group(new KConfigGroup(m_config, "Palapeli Collection")) , m_group(new KConfigGroup(m_config, "Palapeli Collection"))
{ {
//read the puzzles //read the puzzles
const QStringList puzzleIds = m_group->groupList(); 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) foreach (const QString& puzzleId, puzzleIds)
{ {
dlg.setValue(count++);
KConfigGroup* puzzleGroup = new KConfigGroup(m_group, puzzleId); KConfigGroup* puzzleGroup = new KConfigGroup(m_group, puzzleId);
//find involved files //find involved files
const QString basePath = puzzleGroup->readEntry("Location", QString()); const QString basePath = puzzleGroup->readEntry("Location", QString());
......
...@@ -43,7 +43,7 @@ namespace Palapeli ...@@ -43,7 +43,7 @@ namespace Palapeli
IdentifierRole IdentifierRole
}; };
static Palapeli::Collection* instance(); static Palapeli::Collection* instance(QWidget * = nullptr);
Palapeli::Puzzle* puzzleFromIndex(const QModelIndex& index) const; Palapeli::Puzzle* puzzleFromIndex(const QModelIndex& index) const;
void importPuzzle(Palapeli::Puzzle* puzzle); ///< without copying! void importPuzzle(Palapeli::Puzzle* puzzle); ///< without copying!
...@@ -51,7 +51,7 @@ namespace Palapeli ...@@ -51,7 +51,7 @@ namespace Palapeli
void exportPuzzle(const QModelIndex& index, const QString& path); void exportPuzzle(const QModelIndex& index, const QString& path);
bool deletePuzzle(const QModelIndex& index); bool deletePuzzle(const QModelIndex& index);
protected: protected:
Collection(); Collection(QWidget *);
virtual ~Collection(); virtual ~Collection();
private: private:
class Item; 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