diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) set (QT_MIN_VERSION "5.3.0") -set (KF5_MIN_VERSION "5.15.0") +set (KF5_MIN_VERSION "5.31.0") find_package(ECM 1.7.0 REQUIRED CONFIG) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) diff --git a/src/gui/gamevariants.h b/src/gui/gamevariants.h --- a/src/gui/gamevariants.h +++ b/src/gui/gamevariants.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include @@ -167,7 +167,7 @@ class CustomGame : public GameVariant { public: - CustomGame(const QString& name, const KUrl& url, GameVariantCollection* collection=0); + CustomGame(const QString& name, const QUrl& url, GameVariantCollection* collection=0); public: bool canConfigure() const; @@ -181,7 +181,7 @@ uint m_order; uint m_symmetry; - KUrl m_url; + QUrl m_url; SKGraph* m_graph; bool createSKGraphObject(); }; diff --git a/src/gui/gamevariants.cpp b/src/gui/gamevariants.cpp --- a/src/gui/gamevariants.cpp +++ b/src/gui/gamevariants.cpp @@ -363,7 +363,7 @@ // class CustomGame /////////////////////////////////////////////////////////////////////////////// -CustomGame::CustomGame(const QString& name, const KUrl& url, +CustomGame::CustomGame(const QString& name, const QUrl& url, GameVariantCollection* collection) : GameVariant(name, collection), m_url(url), m_graph(0) { diff --git a/src/gui/ksudoku.h b/src/gui/ksudoku.h --- a/src/gui/ksudoku.h +++ b/src/gui/ksudoku.h @@ -24,15 +24,17 @@ #ifndef _KSUDOKU_H_ #define _KSUDOKU_H_ +#include + #include #if 0 #include #endif #define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API #include + class QPrinter; -class KUrl; namespace ksudoku { class KsView; @@ -85,7 +87,7 @@ */ virtual ~KSudoku(); - void loadGame(const KUrl& url); + void loadGame(const QUrl& url); public: void updateShapesList(); diff --git a/src/gui/ksudoku.cpp b/src/gui/ksudoku.cpp --- a/src/gui/ksudoku.cpp +++ b/src/gui/ksudoku.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include #include #include @@ -44,7 +46,7 @@ #define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API #include #include -#include +#include #include #include #include @@ -67,6 +69,7 @@ #include #include #include +#include #include "gamevariants.h" #include "welcomescreen.h" @@ -204,18 +207,20 @@ QString variantIcon; foreach(const QString &filepath, filepaths) { + const QFileInfo configFileInfo(filepath); + const QDir variantDir = configFileInfo.dir(); KConfig variantConfig(filepath, KConfig::SimpleConfig); KConfigGroup group = variantConfig.group ("KSudokuVariant"); variantName = group.readEntry("Name", i18n("Missing Variant Name")); // Translated. variantDescr = group.readEntry("Description", ""); // Translated. variantIcon = group.readEntry("Icon", "ksudoku-ksudoku_9x9"); - variantDataPath = group.readEntry("FileName", ""); - if(variantDataPath == "") continue; + const QString variantDataFile = group.readEntry("FileName", ""); + if(variantDataFile == "") continue; - variantDataPath = filepath.left(filepath.lastIndexOf("/")+1) + variantDataPath; + variantDataPath = variantDir.filePath(variantDataFile); - variant = new CustomGame(variantName, variantDataPath, m_gameVariants); + variant = new CustomGame(variantName, QUrl::fromLocalFile(variantDataPath), m_gameVariants); variant->setDescription(variantDescr); variant->setIcon(variantIcon); } @@ -364,7 +369,7 @@ } -void KSudoku::loadGame(const KUrl& Url) { +void KSudoku::loadGame(const QUrl& Url) { QString errorMsg; Game game = ksudoku::Serializer::load(Url, this, &errorMsg); if(!game.isValid()) { @@ -383,7 +388,7 @@ void KSudoku::homepage() { - KRun::runUrl (KUrl("http://ksudoku.sourceforge.net/"), "text/html", this); + KRun::runUrl (QUrl("http://ksudoku.sourceforge.net/"), "text/html", this, KRun::RunFlags()); } void KSudoku::giveHint() @@ -622,35 +627,30 @@ // if(glwin) glwin->pop(); } -void KSudoku::dragEnterEvent(QDragEnterEvent */*event*/) +void KSudoku::dragEnterEvent(QDragEnterEvent * event) { // accept uri drops only - - //TODO PORT - //KUrl::List::fromMimeData( e->mimeData() ) - - //event->accept(KUrlDrag::canDecode(event)); + if(event->mimeData()->hasUrls()) + event->accept(); } void KSudoku::dropEvent(QDropEvent *event) { - //TODO PORT - KUrl::List Urls = KUrl::List::fromMimeData( event->mimeData() ); - - - if ( !Urls.isEmpty() ) + const QMimeData * data = event->mimeData(); + if(data->hasUrls()) { - // okay, we have a URI.. process it - const KUrl &Url = Urls.first(); + QList Urls = data->urls(); - Game game = ksudoku::Serializer::load(Url, this); -// if(game) -// (new KSudoku(game))->show(); - if(game.isValid()) - startGame(game); -// delete game; - } + if ( !Urls.isEmpty() ) + { + // okay, we have a URI.. process it + const QUrl &Url = Urls.first(); + Game game = ksudoku::Serializer::load(Url, this); + if(game.isValid()) + startGame(game); + } + } } void KSudoku::gameNew() @@ -680,7 +680,7 @@ // the Open shortcut is pressed (usually CTRL+O) or the Open toolbar // button is clicked // standard filedialog - KUrl Url = QFileDialog::getOpenFileUrl(this, i18n("Open Location"), QUrl::fromLocalFile(QDir::homePath()), QString()); + const QUrl Url = QFileDialog::getOpenFileUrl(this, i18n("Open Location"), QUrl::fromLocalFile(QDir::homePath()), QString()); if (!Url.isEmpty() && Url.isValid()) { diff --git a/src/gui/ksudokugame.h b/src/gui/ksudokugame.h --- a/src/gui/ksudokugame.h +++ b/src/gui/ksudokugame.h @@ -24,11 +24,9 @@ #define _KSUDOKUGAME_H_ #include +#include #include "history.h" - -class KUrl; - class SKGraph; class QWidget; @@ -201,12 +199,12 @@ /** * Sets the URL. Game itself doesn't use the URL, but remembers it for other users. */ - void setUrl(const KUrl& url); + void setUrl(const QUrl& url); /** * Gets the URL. Game itself doesn't use the URL, but remembers it for other users. */ - KUrl getUrl() const; + QUrl getUrl() const; /** * Returns whether the user requested some hint. diff --git a/src/gui/ksudokugame.cpp b/src/gui/ksudokugame.cpp --- a/src/gui/ksudokugame.cpp +++ b/src/gui/ksudokugame.cpp @@ -35,7 +35,7 @@ #include // IDW -#include +#include class QWidget; @@ -81,7 +81,7 @@ Puzzle* puzzle; QTime time; int accumTime; - KUrl url; + QUrl url; QList history; int historyPos; @@ -218,14 +218,14 @@ return m_private->puzzle; } -void Game::setUrl(const KUrl& url) { +void Game::setUrl(const QUrl& url) { if(!m_private) return; m_private->url = url; } -KUrl Game::getUrl() const { - if(!m_private) return KUrl(); +QUrl Game::getUrl() const { + if(!m_private) return QUrl(); return m_private->url; } diff --git a/src/gui/serializer.h b/src/gui/serializer.h --- a/src/gui/serializer.h +++ b/src/gui/serializer.h @@ -24,12 +24,12 @@ #define _KSUDOKUSERIALIZER_H_ #include +#include +#include class SKGraph; class QDomElement; -class KUrl; class QWidget; -class QString; namespace ksudoku { @@ -39,11 +39,11 @@ class Serializer { public: static SKGraph* loadCustomShape - (const KUrl& url, QWidget* window, QString* errorMsg = 0); + (const QUrl& url, QWidget* window, QString* errorMsg = 0); static bool store - (const Game& game, const KUrl& url, QWidget* window); + (const Game& game, const QUrl& url, QWidget* window); static Game load - (const KUrl& url, QWidget* window, QString* errorMsg = 0); + (const QUrl& url, QWidget* window, QString* errorMsg = 0); private: // TODO - IDW. Maybe there should be shared methods for file handling. diff --git a/src/gui/serializer.cpp b/src/gui/serializer.cpp --- a/src/gui/serializer.cpp +++ b/src/gui/serializer.cpp @@ -28,7 +28,7 @@ //Added by qt3to4: #include #include -#include +#include #include #include #include @@ -398,7 +398,7 @@ return HistoryEvent(); } -SKGraph *Serializer::loadCustomShape(const KUrl &url, QWidget* window, QString *errorMsg) { +SKGraph *Serializer::loadCustomShape(const QUrl &url, QWidget* window, QString *errorMsg) { if ( url.isEmpty() ) return 0; QString tmpFile; bool success = false; @@ -436,7 +436,7 @@ return 0; } -Game Serializer::load(const KUrl& url, QWidget* window, QString *errorMsg) { +Game Serializer::load(const QUrl& url, QWidget* window, QString *errorMsg) { if ( url.isEmpty() ) return Game(); QString tmpFile; bool success = false; @@ -682,7 +682,7 @@ return true; } -bool Serializer::store(const Game& game, const KUrl& url, QWidget* window) { +bool Serializer::store(const Game& game, const QUrl& url, QWidget* window) { QDomDocument doc( "ksudoku" ); QDomElement root = doc.createElement( "ksudoku" ); doc.appendChild( root ); diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include