Commit 7d4fde1f authored by Albert Astals Cid's avatar Albert Astals Cid

Add initial Android version

Includes a few other tweaks for the desktop version too but very minor
parent d2a9bf97
......@@ -7,26 +7,27 @@ set (KF5_MIN_VERSION "5.15.0")
find_package(ECM 1.7.0 REQUIRED CONFIG)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS PrintSupport Svg Widgets Xml)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Completion
Config
ConfigWidgets
CoreAddons
Crash
DBusAddons
KIO
DocTools
I18n
KDELibs4Support #TODO eventually remove kdelibs4support
WidgetsAddons
XmlGui
)
find_package(KF5KDEGames 4.9.0 REQUIRED)
find_package(Phonon4Qt5 CONFIG REQUIRED)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS PrintSupport Svg Widgets Xml Multimedia)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Config)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS
Completion
ConfigWidgets
CoreAddons
Crash
DBusAddons
KIO
DocTools
I18n
KDELibs4Support #TODO eventually remove kdelibs4support
WidgetsAddons
XmlGui
)
find_package(KF5KDEGames 4.9.0 REQUIRED)
endif()
include_directories(BEFORE ${PHONON_INCLUDES})
include(FeatureSummary)
include(ECMAddAppIcon)
......@@ -40,59 +41,87 @@ add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
add_subdirectory(sounds)
add_subdirectory(pics)
add_subdirectory(doc)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Android")
add_subdirectory(doc)
endif()
########### next target ###############
set(ktuberling_SRCS
action.cpp
main.cpp
toplevel.cpp
playground.cpp
todraw.cpp
soundfactory.cpp
playgrounddelegate.cpp
set(ktuberling_common_SRCS
action.cpp
playground.cpp
todraw.cpp
soundfactory.cpp
filefactory.cpp
)
file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/*-apps-ktuberling.png")
ecm_add_app_icon(ktuberling_SRCS ICONS ${ICONS_SRCS})
add_executable(ktuberling ${ktuberling_SRCS})
target_link_libraries(ktuberling
Qt5::PrintSupport
Qt5::Svg
KF5::Completion
KF5::Crash
KF5::DBusAddons
KF5::KIOCore
KF5::KDELibs4Support
KF5::XmlGui
Phonon::phonon4qt5
KF5KDEGames
)
install(TARGETS ktuberling ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
########### install files ###############
install(PROGRAMS org.kde.ktuberling.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES ktuberlingui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/ktuberling)
ecm_install_icons(ICONS
128-apps-ktuberling.png
16-apps-ktuberling.png
22-apps-ktuberling.png
32-apps-ktuberling.png
48-apps-ktuberling.png
64-apps-ktuberling.png
128-mimetypes-application-x-tuberling.png
16-mimetypes-application-x-tuberling.png
22-mimetypes-application-x-tuberling.png
32-mimetypes-application-x-tuberling.png
48-mimetypes-application-x-tuberling.png
64-mimetypes-application-x-tuberling.png
DESTINATION ${KDE_INSTALL_ICONDIR} THEME hicolor
)
if(${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(ktuberling_mobile_SRCS
${ktuberling_common_SRCS}
main_mobile.cpp
)
qt5_add_resources(ktuberling_mobile_SRCS android_data/resources.qrc)
add_executable(ktuberling_mobile ${ktuberling_mobile_SRCS})
target_link_libraries(ktuberling_mobile
Qt5::Gui
Qt5::Svg
Qt5::Multimedia
Qt5::Xml
Qt5::Widgets
KF5::ConfigCore )
install(TARGETS ktuberling_mobile RUNTIME DESTINATION bin)
else()
set(ktuberling_SRCS
${ktuberling_common_SRCS}
main.cpp
toplevel.cpp
playgrounddelegate.cpp
)
file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/*-apps-ktuberling.png")
ecm_add_app_icon(ktuberling_SRCS ICONS ${ICONS_SRCS})
add_executable(ktuberling ${ktuberling_SRCS})
target_link_libraries(ktuberling
Qt5::PrintSupport
Qt5::Svg
Qt5::Multimedia
KF5::Completion
KF5::Crash
KF5::DBusAddons
KF5::KIOCore
KF5::KDELibs4Support
KF5::XmlGui
KF5KDEGames
)
install(TARGETS ktuberling ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(PROGRAMS org.kde.ktuberling.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES ktuberlingui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/ktuberling)
ecm_install_icons(ICONS
128-apps-ktuberling.png
16-apps-ktuberling.png
22-apps-ktuberling.png
32-apps-ktuberling.png
48-apps-ktuberling.png
64-apps-ktuberling.png
128-mimetypes-application-x-tuberling.png
16-mimetypes-application-x-tuberling.png
22-mimetypes-application-x-tuberling.png
32-mimetypes-application-x-tuberling.png
48-mimetypes-application-x-tuberling.png
64-mimetypes-application-x-tuberling.png
DESTINATION ${KDE_INSTALL_ICONDIR} THEME hicolor
)
endif()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
<?xml version="1.0"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.0.3" package="org.kde.ktuberling" android:installLocation="auto" android:versionCode="7">
<application android:name="org.qtproject.qt5.android.bindings.QtApplication"
android:label="KTuberling"
android:icon="@drawable/ktuberling">
<activity android:name="org.qtproject.qt5.android.bindings.QtActivity"
android:label="KTuberling"
android:screenOrientation="landscape"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Messages maps -->
<meta-data android:name="android.app.ministro_not_found_msg" android:value="@string/ministro_not_found_msg"/>
<meta-data android:name="android.app.ministro_needed_msg" android:value="@string/ministro_needed_msg"/>
<meta-data android:name="android.app.fatal_error_msg" android:value="@string/fatal_error_msg"/>
</activity>
</application>
<supports-screens android:anyDensity="true" android:normalScreens="true" android:smallScreens="true" android:largeScreens="true"/>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19"/>
</manifest>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 10.988281 3 L 6 7.9902344 L 6 8 L 6 9 L 6 13 L 6 14 L 6 14.009766 L 10.988281 19 L 12 19 L 12 18.597656 L 12 3.4023438 L 12 3 L 10.988281 3 z M 13.865234 3.5371094 L 13.621094 4.5136719 A 7 7 0 0 1 18 11 A 7 7 0 0 1 13.619141 17.478516 L 13.863281 18.453125 A 8 8 0 0 0 19 11 A 8 8 0 0 0 13.865234 3.5371094 z M 14.324219 7.28125 L 13.785156 8.1425781 A 4 4 0 0 1 15 11 A 4 4 0 0 1 13.789062 13.861328 L 14.328125 14.724609 A 5 5 0 0 0 16 11 A 5 5 0 0 0 14.324219 7.28125 z M 3 8 L 3 9 L 3 13 L 3 14 L 5 14 L 5 13 L 5 9 L 5 8 L 3 8 z "
class="ColorScheme-Text"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
.ColorScheme-NegativeText {
color:#da4453;
}
</style>
</defs>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 10.988281 3 L 6 7.9902344 L 6 8 L 6 9 L 6 13 L 6 14 L 6 14.009766 L 10.988281 19 L 12 19 L 12 18.597656 L 12 3.4023438 L 12 3 L 10.988281 3 z M 3 8 L 3 9 L 3 13 L 3 14 L 5 14 L 5 13 L 5 9 L 5 8 L 3 8 z "
class="ColorScheme-Text"/>
<path
style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 13 10 L 13 12 L 19 12 L 19 10 L 13 10 z "
class="ColorScheme-NegativeText"
/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 19.513672 4.0078125 A 2 9 45 0 0 12.068359 9.1054688 A 2 9 45 0 0 8.5253906 13.21875 C 9.6014506 13.56139 10.440563 14.400494 10.783203 15.476562 A 2 9 45 0 0 14.896484 11.933594 A 2 9 45 0 0 19.845703 4.15625 A 2 9 45 0 0 19.513672 4.0078125 z M 8 14.664062 C 3.99999 15.735864 7 18.26795 4 20 C 8.00339 20 10 17.99918 10 16.664062 C 10 15.999182 10.0676 14.774622 8 14.664062 z "
class="ColorScheme-Text"
/>
</svg>
<RCC>
<qresource prefix="/">
<file>games-config-theme.png</file>
<file>audio-volume-high.png</file>
<file>audio-volume-muted.png</file>
</qresource>
</RCC>
......@@ -508,12 +508,6 @@ It will contain the playgrounds installed in your system.
<sect2>
<title>The Speech Menu</title>
<!--FIXME
<para>
Please note that you need to have <command>&phonon;</command> installed
and properly configured to be able to hear sounds.
</para>-->
<variablelist>
<varlistentry>
......
/***************************************************************************
* Copyright (C) 2017 by Albert Astals Cid <aacid@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "filefactory.h"
#include <QFileInfo>
#include <QStandardPaths>
bool FileFactory::folderExists(const QString &relativePath)
{
#if defined(Q_OS_ANDROID)
QFileInfo fi("/data/data/org.kde.ktuberling/qt-reserved-files/share/ktuberling/" + relativePath);
return fi.isDir();
#else
return !(QStandardPaths::locate(QStandardPaths::AppDataLocation, relativePath, QStandardPaths::LocateDirectory).isEmpty());
#endif
}
QString FileFactory::locate(const QString &relativePath)
{
#if defined(Q_OS_ANDROID)
return "/data/data/org.kde.ktuberling/qt-reserved-files/share/ktuberling/" + relativePath;
#else
return QStandardPaths::locate(QStandardPaths::AppDataLocation, relativePath);
#endif
}
QStringList FileFactory::locateAll(const QString &relativePath)
{
#if defined(Q_OS_ANDROID)
return { "/data/data/org.kde.ktuberling/qt-reserved-files/share/ktuberling/" + relativePath };
#else
return QStandardPaths::locateAll(QStandardPaths::AppDataLocation, relativePath, QStandardPaths::LocateDirectory);
#endif
}
/***************************************************************************
* Copyright (C) 2017 by Albert Astals Cid <aacid@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef FILEFACTORY_H
#define FILEFACTORY_H
class QString;
class QStringList;
namespace FileFactory
{
bool folderExists(const QString &relativePath);
QString locate(const QString &relativePath);
QStringList locateAll(const QString &relativePath);
};
#endif
/***************************************************************************
* Copyright (C) 1999-2006 by Éric Bischoff <ebischoff@nerim.net> *
* Copyright (C) 2007 by Albert Astals Cid <aacid@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include <QApplication>
#include <QDebug>
#include <QDesktopWidget>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include "filefactory.h"
#include "soundfactory.h"
#include "playground.h"
static const char version[] = "1.0.0";
class KTuberlingMobile : public PlayGroundCallbacks, public SoundFactoryCallbacks
{
public:
KTuberlingMobile()
: m_soundEnabled(true)
{
m_soundFactory = new SoundFactory(this);
m_soundFactory->registerLanguages();
m_soundFactory->loadLanguage(FileFactory::locate("sounds/en.soundtheme"));
QWidget *mainWidget = new QWidget();
QHBoxLayout *lay = new QHBoxLayout(mainWidget);
m_themesWidget = new QWidget();
m_gameboardLayout = new QGridLayout(m_themesWidget);
m_playground = new PlayGround(this, mainWidget);
m_playground->registerPlayGrounds();
m_playground->lockAspectRatio(true);
m_playground->setAllowOnlyDrag(true);
m_playground->loadPlayGround(FileFactory::locate("pics/default_theme.theme"));
QVBoxLayout *sideLayout = new QVBoxLayout();
// Not sure this is the best way but it works for now
const int screenWidth = QDesktopWidget().screenGeometry().width();
const int iconWidth = screenWidth / 15;
QPushButton *themesButton = new QPushButton(mainWidget);
themesButton->setIcon(QPixmap(":/games-config-theme.png"));
themesButton->setIconSize(QSize(iconWidth, iconWidth));
themesButton->setFocusPolicy(Qt::NoFocus);
QObject::connect(themesButton, &QPushButton::clicked, [this, mainWidget] {
m_themesWidget->showFullScreen();
});
QPushButton *soundsButton = new QPushButton(mainWidget);
soundsButton->setIcon(QPixmap(":/audio-volume-high.png"));
soundsButton->setIconSize(QSize(iconWidth, iconWidth));
soundsButton->setFocusPolicy(Qt::NoFocus);
QObject::connect(soundsButton, &QPushButton::clicked, [this, soundsButton] {
m_soundEnabled = !m_soundEnabled;
soundsButton->setIcon(QPixmap(m_soundEnabled ? ":/audio-volume-high.png" : ":/audio-volume-muted.png"));
});
sideLayout->addWidget(themesButton);
sideLayout->addWidget(soundsButton);
sideLayout->addStretch(1);
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(0);
lay->addWidget(m_playground);
lay->addLayout(sideLayout);
mainWidget->showFullScreen();
}
~KTuberlingMobile()
{
delete m_soundFactory;
}
void playSound(const QString &ref) override
{
m_soundFactory->playSound(ref);
}
void changeGameboard(const QString &/*gameboard*/) override
{
// Only needed when loading a file so not needed for now
}
void registerGameboard(const QString& menuText, const QString& boardFile, const QPixmap &/*pixmap*/) override
{
// TODO this should be scrollable
// TODO use the pixmap
QPushButton *pb = new QPushButton(menuText);
QObject::connect(pb, &QPushButton::clicked, [this, boardFile] {
m_playground->loadPlayGround(boardFile);
m_themesWidget->hide();
});
m_gameboardLayout->addWidget(pb, m_gameboardLayout->count() / 2, m_gameboardLayout->count() % 2);
}
bool isSoundEnabled() const override
{
return m_soundEnabled;
}
void registerLanguage(const QString &/*code*/, const QString &/*soundFile*/, bool /*enabled*/)
{
// TODO
}
private:
SoundFactory *m_soundFactory;
PlayGround *m_playground;
QWidget *m_themesWidget;
QGridLayout *m_gameboardLayout;
bool m_soundEnabled;
};
// Main function
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLocale::system().name(); // needed to workaround QTBUG-41385
app.setApplicationName("ktuberling");
KTuberlingMobile tuberling;
return app.exec();
}
No preview for this file type
......@@ -12,12 +12,12 @@
#include "playground.h"
#include <KLocalizedString>
#include <kconfig.h>
#include <kconfiggroup.h>
#include <qdebug.h>
#include <QAction>
#include <QApplication>
#include <QCursor>
#include <QDataStream>
#include <QDir>
......@@ -27,15 +27,10 @@
#include <QGraphicsSvgItem>
#include <QMouseEvent>
#include <QPainter>
#include <QPrinter>
#include <QStandardPaths>
#include <kstandardaction.h>
#include <kactioncollection.h>
#include <kstandardshortcut.h>
#include <QPagedPaintDevice>
#include "action.h"
#include "toplevel.h"
#include "filefactory.h"
#include "todraw.h"
static const char *saveGameTextScaleTextMode = "KTuberlingSaveGameV2";
......@@ -43,10 +38,9 @@ static const char *saveGameTextTextMode = "KTuberlingSaveGameV3";
static const char *saveGameText = "KTuberlingSaveGameV4";
// Constructor
PlayGround::PlayGround(TopLevel *parent)
: QGraphicsView(parent), m_newItem(0), m_dragItem(0), m_nextZValue(1), m_lockAspect(false)
PlayGround::PlayGround(PlayGroundCallbacks *callbacks, QWidget *parent)
: QGraphicsView(parent), m_callbacks(callbacks), m_newItem(0), m_dragItem(0), m_nextZValue(1), m_lockAspect(false), m_allowOnlyDrag(false)
{
m_topLevel = parent;
setFrameStyle(QFrame::NoFrame);
setOptimizationFlag(QGraphicsView::DontSavePainterState, true); // all items here save the painter state
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
......@@ -99,7 +93,7 @@ bool PlayGround::saveAs(const QString & name)
}
// Print gameboard's picture
bool PlayGround::printPicture(QPrinter &printer)
bool PlayGround::printPicture(QPagedPaintDevice &printer)
{
QPainter artist;
QPixmap picture(getPicture());
......@@ -139,6 +133,8 @@ void PlayGround::mousePressEvent(QMouseEvent *event)
if (event->button() != Qt::LeftButton) return;
m_mousePressPos = event->pos();
if (m_dragItem) placeDraggedItem(event->pos());
else if (m_newItem) placeNewItem(event->pos());
else
......@@ -163,7 +159,7 @@ void PlayGround::mousePressEvent(QMouseEvent *event)
QPointF itemPos = mapToScene(event->pos());
itemPos -= QPointF(elementSize.width()/2, elementSize.height()/2);
m_topLevel->playSound(m_objectsNameSound.value(foundElem));
m_callbacks->playSound(m_objectsNameSound.value(foundElem));
m_newItem = new ToDraw;
m_newItem->setBeingDragged(true);
......@@ -186,7 +182,7 @@ void PlayGround::mousePressEvent(QMouseEvent *event)
{
QString elem = m_dragItem->elementId();
m_topLevel->playSound(m_objectsNameSound.value(elem));
m_callbacks->playSound(m_objectsNameSound.value(elem));
setCursor(Qt::BlankCursor);
m_dragItem->setBeingDragged(true);
m_itemDraggedPos = m_dragItem->pos();
......@@ -202,18 +198,22 @@ void PlayGround::mousePressEvent(QMouseEvent *event)
void PlayGround::mouseMoveEvent(QMouseEvent *event)
{
if (m_newItem) {
ToDraw *movingItem = m_newItem ? m_newItem : m_dragItem;
if (movingItem) {
QPointF itemPos = mapToScene(event->pos());
const QSizeF elementSize = m_newItem->transform().mapRect(m_newItem->unclippedRect()).size();
const QSizeF elementSize = movingItem->transform().mapRect(movingItem->unclippedRect()).size();
itemPos -= QPointF(elementSize.width()/2, elementSize.height()/2);
m_newItem->setPos(clipPos(itemPos, m_newItem));
} else if (m_dragItem) {
QPointF itemPos = mapToScene(event->pos());
const QSizeF elementSize = m_dragItem->transform().mapRect(m_dragItem->unclippedRect()).size();
itemPos -= QPointF(elementSize.width()/2, elementSize.height()/2);
movingItem->setPos(clipPos(itemPos, movingItem));
}
}
m_dragItem->setPos(clipPos(itemPos, m_dragItem));
void PlayGround::mouseReleaseEvent(QMouseEvent *event)
{
QPoint point = event->pos() - m_mousePressPos;
if (m_allowOnlyDrag || point.manhattanLength() > qApp->startDragDistance()) {
if (m_dragItem) placeDraggedItem(event->pos());
else if (m_newItem) placeNewItem(event->pos());
}
}
......@@ -317,7 +317,7 @@ bool PlayGround::isAspectRatioLocked() const
void PlayGround::registerPlayGrounds()
{
QSet<QString> list;
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, QStringLiteral("pics"), QStandardPaths::LocateDirectory);
const QStringList dirs = FileFactory::locateAll(QStringLiteral("pics"));
Q_FOREACH (const QString &dir, dirs)
{
const QStringList fileNames = QDir(dir).entryList(QStringList() << QStringLiteral("*.theme"));
......@@ -327,6 +327,8 @@ void PlayGround::registerPlayGrounds()
}
}
QMap<QString, QPair<QString, QPixmap>> sortedByName;
foreach(const QString &theme, list)
{
QFile layoutFile(theme);
......@@ -336,21 +338,26 @@ void PlayGround::registerPlayGrounds()
if (layoutDocument.setContent(&layoutFile))
{
QString desktop = layoutDocument.documentElement().attribute(QStringLiteral( "desktop" ));
KConfig c( QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1String( "pics/" ) + desktop ) );
KConfig c( FileFactory::locate( QLatin1String( "pics/" ) + desktop ) );
KConfigGroup cg = c.group("KTuberlingTheme");
QString gameboard = layoutDocument.documentElement().attribute(QStringLiteral( "gameboard" ));
QPixmap pixmap(200,100);
pixmap.fill(Qt::transparent);
playGroundPixmap(gameboard,pixmap);
m_topLevel->registerGameboard(cg.readEntry("Name"), theme, pixmap);
sortedByName.insertMulti(cg.readEntry("Name"), QPair<QString, QPixmap>(theme, pixmap));
}
}
}