diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,6 @@ Crash I18n ItemViews - KDELibs4Support KIO Notifications Service diff --git a/libpala/CMakeLists.txt b/libpala/CMakeLists.txt --- a/libpala/CMakeLists.txt +++ b/libpala/CMakeLists.txt @@ -1,5 +1,7 @@ project(libpala) +include(GenerateExportHeader) + set(libpala_VERSION "0.2.0") set(libpala_SOVERSION "0") @@ -28,7 +30,7 @@ add_library(pala SHARED ${libpala_SRCS}) generate_export_header(pala BASE_NAME libpala) -target_link_libraries(pala KF5::KDELibs4Support Qt5::Gui) +target_link_libraries(pala KF5::I18n Qt5::Gui) set_target_properties(pala PROPERTIES VERSION ${libpala_VERSION} SOVERSION ${libpala_SOVERSION} diff --git a/mime/CMakeLists.txt b/mime/CMakeLists.txt --- a/mime/CMakeLists.txt +++ b/mime/CMakeLists.txt @@ -10,7 +10,7 @@ # thumbnail creator plugin add_library(palathumbcreator MODULE thumbnail-creator.cpp) -target_link_libraries(palathumbcreator KF5::KIOCore KF5::KIOWidgets KF5::Archive KF5::KDELibs4Support) +target_link_libraries(palathumbcreator KF5::KIOCore KF5::KIOWidgets KF5::Archive) install(TARGETS palathumbcreator DESTINATION ${KDE_INSTALL_PLUGINDIR}) install(FILES palathumbcreator.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) diff --git a/mime/thumbnail-creator.cpp b/mime/thumbnail-creator.cpp --- a/mime/thumbnail-creator.cpp +++ b/mime/thumbnail-creator.cpp @@ -18,10 +18,9 @@ ***************************************************************************/ #include -#include #include +#include #include -#include namespace Palapeli { @@ -34,7 +33,7 @@ extern "C" { - KDE_EXPORT ThumbCreator* new_creator() + Q_DECL_EXPORT ThumbCreator* new_creator() { return new Palapeli::ThumbCreator; } @@ -47,8 +46,8 @@ KTar tar(path, "application/x-gzip"); if (!tar.open(QIODevice::ReadOnly)) return false; - KTempDir cache; - const QString cachePath = cache.name(); //note: includes trailing slash + QTemporaryDir cache; + const QString cachePath = cache.path() + QLatin1Char('/'); tar.directory()->copyTo(cachePath); tar.close(); //read image diff --git a/slicers/CMakeLists.txt b/slicers/CMakeLists.txt --- a/slicers/CMakeLists.txt +++ b/slicers/CMakeLists.txt @@ -20,7 +20,7 @@ #correctly include the headers of libpala when they are not yet installed set_directory_properties(PROPERTIES COMPILE_DEFINITIONS USE_LOCAL_LIBPALA) -set(SLICER_LINK_LIBS KF5::KDELibs4Support Qt5::Gui pala) +set(SLICER_LINK_LIBS KF5::CoreAddons KF5::I18n Qt5::Gui pala) add_library(palapeli_rectslicer MODULE slicer-rect.cpp) target_link_libraries(palapeli_rectslicer ${SLICER_LINK_LIBS}) diff --git a/slicers/goldberg/slicer-goldberg.cpp b/slicers/goldberg/slicer-goldberg.cpp --- a/slicers/goldberg/slicer-goldberg.cpp +++ b/slicers/goldberg/slicer-goldberg.cpp @@ -20,7 +20,6 @@ #include "slicer-goldberg.h" -#include #include #include #include @@ -31,7 +30,6 @@ #include "utilities.h" K_PLUGIN_FACTORY(SvgSlicerFactory, registerPlugin();) -K_EXPORT_PLUGIN(SvgSlicerFactory("palapeli_goldbergslicer")) GoldbergSlicer::GoldbergSlicer(QObject* parent, const QVariantList& args) : Pala::Slicer(parent, args) { diff --git a/slicers/slicer-jigsaw.cpp b/slicers/slicer-jigsaw.cpp --- a/slicers/slicer-jigsaw.cpp +++ b/slicers/slicer-jigsaw.cpp @@ -85,7 +85,6 @@ } K_PLUGIN_FACTORY(SvgSlicerFactory, registerPlugin();) -K_EXPORT_PLUGIN(SvgSlicerFactory("palapeli_jigsawslicer")) JigsawSlicer::JigsawSlicer(QObject* parent, const QVariantList& args) : Pala::Slicer(parent, args) diff --git a/slicers/slicer-rect.cpp b/slicers/slicer-rect.cpp --- a/slicers/slicer-rect.cpp +++ b/slicers/slicer-rect.cpp @@ -23,7 +23,6 @@ #include K_PLUGIN_FACTORY(RectSlicerFactory, registerPlugin();) -K_EXPORT_PLUGIN(RectSlicerFactory("palapeli_rectslicer")) RectSlicer::RectSlicer(QObject* parent, const QVariantList& args) : Pala::Slicer(parent, args) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,9 +52,16 @@ add_executable(palapeli ${palapeli_SRCS}) target_link_libraries(palapeli pala - KF5::KDELibs4Support KF5::Archive + KF5::Completion + KF5::ConfigWidgets KF5::Crash + KF5::ItemViews + KF5::Notifications + KF5::KIOWidgets + KF5::Service + KF5::WidgetsAddons + KF5::XmlGui Qt5::Concurrent Qt5::Svg ) diff --git a/src/config/triggerconfigwidget.h b/src/config/triggerconfigwidget.h --- a/src/config/triggerconfigwidget.h +++ b/src/config/triggerconfigwidget.h @@ -20,14 +20,14 @@ #define PALAPELI_TRIGGERCONFIGWIDGET_H #include -#include +#include namespace Palapeli { class Interactor; class TriggerListView; - class TriggerConfigWidget : public KTabWidget + class TriggerConfigWidget : public QTabWidget { Q_OBJECT public: diff --git a/src/config/triggerconfigwidget.cpp b/src/config/triggerconfigwidget.cpp --- a/src/config/triggerconfigwidget.cpp +++ b/src/config/triggerconfigwidget.cpp @@ -24,7 +24,7 @@ #include Palapeli::TriggerConfigWidget::TriggerConfigWidget(QWidget* parent) - : KTabWidget(parent) + : QTabWidget(parent) , m_interactors(Palapeli::TriggerMapper::createInteractors(0)) //these interactors are just for reading metadata , m_mouseView(new Palapeli::TriggerListView(m_interactors, Palapeli::MouseInteractor, this)) , m_wheelView(new Palapeli::TriggerListView(m_interactors, Palapeli::WheelInteractor, this)) diff --git a/src/config/triggerlistview_p.h b/src/config/triggerlistview_p.h --- a/src/config/triggerlistview_p.h +++ b/src/config/triggerlistview_p.h @@ -22,8 +22,8 @@ #include "triggerlistview.h" #include "elidinglabel.h" #include "mouseinputbutton.h" -#include #include +#include #include #include #include @@ -53,7 +53,8 @@ { const QString textLeft = left.data(Qt::DisplayRole).toString(); const QString textRight = right.data(Qt::DisplayRole).toString(); - return KStringHandler::naturalCompare(textLeft, textRight) < 0; + QCollator col; + return col.compare(textLeft, textRight) < 0; } }; diff --git a/src/creator/propertywidget_p.h b/src/creator/propertywidget_p.h --- a/src/creator/propertywidget_p.h +++ b/src/creator/propertywidget_p.h @@ -21,8 +21,8 @@ #include "propertywidget.h" #include +#include #include -#include #include namespace Palapeli diff --git a/src/engine/gameplay.cpp b/src/engine/gameplay.cpp --- a/src/engine/gameplay.cpp +++ b/src/engine/gameplay.cpp @@ -35,19 +35,19 @@ #include "../config/configdialog.h" #include "settings.h" -#include +#include #include #include #include #include #include +#include #include #include +#include #include #include #include -#include -#include // Use this because comma in type is not possible in foreach macro. typedef QPair DoubleIntPair; @@ -313,8 +313,11 @@ void Palapeli::GamePlay::actionImport() { - const QString filter = i18nc("Filter for a file dialog", "*.puzzle|Palapeli puzzles (*.puzzle)"); - const QStringList paths = KFileDialog::getOpenFileNames(KUrl("kfiledialog:///palapeli-import"), filter); + const QString filter = i18nc("Filter for a file dialog", "Palapeli puzzles (*.puzzle)"); + const QStringList paths = QFileDialog::getOpenFileNames(m_mainWindow, + i18n("Import Palapeli puzzles"), + QString(), + filter); Palapeli::Collection* coll = Palapeli::Collection::instance(); foreach (const QString& path, paths) coll->importPuzzle(path); @@ -335,9 +338,12 @@ if (!cmp) continue; //ask user for target file name - const QString startLoc = QString::fromLatin1("kfiledialog:///palapeli-export/%1.puzzle").arg(cmp->metadata.name); - const QString filter = i18nc("Filter for a file dialog", "*.puzzle|Palapeli puzzles (*.puzzle)"); - const QString location = KFileDialog::getSaveFileName(KUrl(startLoc), filter); + const QString startLoc = QString::fromLatin1("%1.puzzle").arg(cmp->metadata.name); + const QString filter = i18nc("Filter for a file dialog", "Palapeli puzzles (*.puzzle)"); + const QString location = QFileDialog::getSaveFileName(m_mainWindow, + i18n("Save Palapeli puzzles"), + startLoc, + filter); if (location.isEmpty()) continue; //process aborted by user //do export @@ -508,7 +514,7 @@ // Discard the *.save file. static const QString pathTemplate = QString::fromLatin1("collection/%1.save"); - QFile(KStandardDirs::locateLocal("appdata", + QFile(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, pathTemplate.arg(m_puzzle->identifier()))).remove(); // Load the puzzle and re-shuffle the pieces. loadPuzzle(); @@ -726,7 +732,7 @@ // Is there a saved game? static const QString pathTemplate = QString::fromLatin1("collection/%1.save"); - KConfig savedConfig(KStandardDirs::locateLocal("appdata", + KConfig savedConfig(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, pathTemplate.arg(m_puzzle->identifier()))); if (savedConfig.hasGroup(AppearanceSaveGroup)) { // Get settings for background, shadows, etc. in this puzzle. @@ -827,7 +833,7 @@ // Is there a saved game? static const QString pathTemplate = QString::fromLatin1("collection/%1.save"); - KConfig savedConfig(KStandardDirs::locateLocal("appdata", + KConfig savedConfig(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, pathTemplate.arg(m_puzzle->identifier()))); bool oldFormat = false; m_restoredGame = false; @@ -1192,7 +1198,7 @@ { static const QString pathTemplate = QString::fromLatin1("collection/%1.save"); - KConfig savedConfig(KStandardDirs::locateLocal("appdata", + KConfig savedConfig(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, pathTemplate.arg(m_puzzle->identifier()))); savePuzzleSettings(&savedConfig); diff --git a/src/engine/texturehelper.h b/src/engine/texturehelper.h --- a/src/engine/texturehelper.h +++ b/src/engine/texturehelper.h @@ -42,7 +42,7 @@ void removeScene(QObject* object); private: TextureHelper(); - static QPixmap render(const QString& fileName); + static QPixmap render(const QString& filePath); QList m_scenes; int m_currentIndex; diff --git a/src/engine/texturehelper.cpp b/src/engine/texturehelper.cpp --- a/src/engine/texturehelper.cpp +++ b/src/engine/texturehelper.cpp @@ -19,12 +19,11 @@ #include "texturehelper.h" #include "settings.h" +#include #include #include #include -#include #include -#include #include const QSize Palapeli::TextureHelper::DefaultThumbnailSize(32, 32); @@ -36,21 +35,20 @@ return &instance; } -QPixmap Palapeli::TextureHelper::render(const QString& fileName) +QPixmap Palapeli::TextureHelper::render(const QString& filePath) { - const QString path = KStandardDirs::locate("appdata", "backgrounds/" + fileName); QPixmap pixmap; - if (fileName.contains(".svg")) + if (filePath.endsWith(QLatin1String(".svg"))) { - QSvgRenderer renderer(path); + QSvgRenderer renderer(filePath); pixmap = QPixmap(DefaultPixmapSize); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); renderer.render(&painter); painter.end(); } else - pixmap.load(path); + pixmap.load(filePath); return pixmap; } @@ -66,19 +64,24 @@ colorItem->setData(i18nc("@item:inlistbox", "Single color"), Qt::DisplayRole); appendRow(colorItem); //fetch backgrounds, and create menu items - const QStringList backgroundFiles = KGlobal::dirs()->findAllResources("appdata", "backgrounds/*"); - foreach (const QString& path, backgroundFiles) + const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::AppLocalDataLocation, + "backgrounds", + QStandardPaths::LocateDirectory); + foreach (const QString& dir, dirs) { - //get file name and find selected or default backgrounds - const QString fileName = QFileInfo(path).fileName(); - //create item for this brush - const QPixmap pixmap = render(fileName); - QStandardItem* item = new QStandardItem; - item->setData(pixmap, BrushRole); - item->setData(fileName, IdentifierRole); - item->setData(pixmap.scaled(DefaultThumbnailSize, Qt::KeepAspectRatio), Qt::DecorationRole); - item->setData(fileName, Qt::DisplayRole); - appendRow(item); + const QStringList fileNames = QDir(dir).entryList(QStringList() << QStringLiteral("*"), QDir::Files); + Q_FOREACH (const QString& fileName, fileNames) + { + const QString filePath = dir + QLatin1Char('/') + fileName; + //create item for this brush + const QPixmap pixmap = render(filePath); + QStandardItem* item = new QStandardItem; + item->setData(pixmap, BrushRole); + item->setData(fileName, IdentifierRole); + item->setData(pixmap.scaled(DefaultThumbnailSize, Qt::KeepAspectRatio), Qt::DecorationRole); + item->setData(fileName, Qt::DisplayRole); + appendRow(item); + } } //select initial brush readSettings(); diff --git a/src/file-io/collection.cpp b/src/file-io/collection.cpp --- a/src/file-io/collection.cpp +++ b/src/file-io/collection.cpp @@ -25,10 +25,10 @@ #include #include #include +#include #include #include #include -#include //BEGIN Palapeli::Collection::Item @@ -82,9 +82,9 @@ QString path(path_); path.remove(QRegExp("^palapeli:/*")); if (local) - return KStandardDirs::locateLocal("appdata", path); + return QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, path); else - return KStandardDirs::locate("appdata", path); + return QStandardPaths::locate(QStandardPaths::AppDataLocation, path); } else return path_; @@ -150,7 +150,7 @@ //determine new location const QString id = puzzle->identifier(); const QString fileName = QString::fromLatin1("collection/%1.puzzle").arg(id); - puzzle->setLocation(KStandardDirs::locateLocal("appdata", fileName)); + puzzle->setLocation(QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, fileName)); //store puzzle puzzle->get(Palapeli::PuzzleComponent::ArchiveStorage).waitForFinished(); //create the config group for this puzzle (use pseudo-URL to avoid problems diff --git a/src/file-io/components-directorystorage.cpp b/src/file-io/components-directorystorage.cpp --- a/src/file-io/components-directorystorage.cpp +++ b/src/file-io/components-directorystorage.cpp @@ -22,27 +22,27 @@ #include #include #include -#include +#include Palapeli::DirectoryStorageComponent::DirectoryStorageComponent() - : m_dir(new KTempDir) + : m_dir(new QTemporaryDir) { } Palapeli::DirectoryStorageComponent::~DirectoryStorageComponent() { - m_dir->unlink(); + m_dir->remove(); delete m_dir; } QString Palapeli::DirectoryStorageComponent::directory() const { - return m_dir->name(); + return m_dir->path() + QLatin1Char('/'); } Palapeli::PuzzleComponent* Palapeli::DirectoryStorageComponent::cast(Palapeli::PuzzleComponent::Type type) const { - QDir dir(m_dir->name()); + QDir dir(m_dir->path()); //load metadata from directory if (type == Metadata) { diff --git a/src/file-io/components.h b/src/file-io/components.h --- a/src/file-io/components.h +++ b/src/file-io/components.h @@ -23,7 +23,7 @@ #include "puzzlestructs.h" class KConfigGroup; -class KTempDir; +class QTemporaryDir; #define COMPONENT_SUBCLASS(mytype) \ public: \ @@ -86,7 +86,7 @@ QString directory() const; Palapeli::PuzzleComponent* cast(Type type) const Q_DECL_OVERRIDE; private: - KTempDir* m_dir; + QTemporaryDir* m_dir; }; ///This is a valid mainComponent.