[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegames
From: Stefan Majewsky <majewsky () gmx ! net>
Date: 2012-04-11 20:34:56
Message-ID: 20120411203456.7C80DAC89C () svn ! kde ! org
[Download RAW message or body]
SVN commit 1289085 by majewsky:
Rename KgTheme::svgPath -> ::graphicsPath, as suggested by aacid.
Also fix some other API issues Albert pointed out.
M +1 -1 granatier/src/arenaselector.cpp
M +1 -1 granatier/src/gamescene.cpp
M +1 -1 katomic/playfield.cpp
M +1 -1 kolf/game.cpp
M +1 -1 kollision/mainarea.cpp
M +1 -1 kreversi/kreversiscene.cpp
M +9 -8 libkdegames/kgamerenderer.cpp
M +7 -2 libkdegames/kgamerenderer.h
M +1 -1 libkdegames/kgamerenderer_p.h
M +6 -6 libkdegames/kgtheme.cpp
M +17 -13 libkdegames/kgtheme.h
M +1 -0 libkdegames/kgthemeprovider.cpp
M +2 -0 libkdegames/kgthemeprovider.h
--- trunk/KDE/kdegames/granatier/src/arenaselector.cpp #1289084:1289085
@@ -234,7 +234,7 @@
delete m_renderer;
KgTheme* theme = new KgTheme(QByteArray());
- theme->setSvgPath(KStandardDirs::locate("appdata", \
QString("themes/granatier.svgz"))); + \
theme->setGraphicsPath(KStandardDirs::locate("appdata", \
QString("themes/granatier.svgz"))); m_renderer = new KGameRenderer(theme);
ui.arenaPreview->setSceneRect(0, 0, arena->getNbColumns()*Cell::SIZE, \
arena->getNbRows()*Cell::SIZE);
--- trunk/KDE/kdegames/granatier/src/gamescene.cpp #1289084:1289085
@@ -71,7 +71,7 @@
{
selectedThemeIsDefault = false;
KgTheme* theme = new KgTheme("themes/granatier.desktop");
- theme->setSvgPath(KStandardDirs::locate("appdata", \
"themes/granatier.svgz")); + \
theme->setGraphicsPath(KStandardDirs::locate("appdata", "themes/granatier.svgz")); \
m_rendererDefaultTheme = new KGameRenderer(theme); //uncomment this if the crash in \
KSharedDataCache appears again
//m_rendererDefaultTheme->setStrategyEnabled(KGameRenderer::UseDiskCache, \
false);
--- trunk/KDE/kdegames/katomic/playfield.cpp #1289084:1289085
@@ -46,7 +46,7 @@
{
Theme() : KgTheme("pics/default_theme.desktop")
{
- setSvgPath(KStandardDirs::locate("appdata", "pics/default_theme.svgz"));
+ setGraphicsPath(KStandardDirs::locate("appdata", "pics/default_theme.svgz"));
}
};
--- trunk/KDE/kdegames/kolf/game.cpp #1289084:1289085
@@ -85,7 +85,7 @@
public:
KolfTheme() : KgTheme("pics/default_theme.desktop")
{
- setSvgPath(KStandardDirs::locate("appdata", "pics/default_theme.svgz"));
+ setGraphicsPath(KStandardDirs::locate("appdata", "pics/default_theme.svgz"));
}
};
--- trunk/KDE/kdegames/kollision/mainarea.cpp #1289084:1289085
@@ -43,7 +43,7 @@
{
Theme() : KgTheme("pictures/theme.desktop")
{
- setSvgPath(KStandardDirs::locate("appdata", "pictures/theme.svgz"));
+ setGraphicsPath(KStandardDirs::locate("appdata", "pictures/theme.svgz"));
}
};
--- trunk/KDE/kdegames/kreversi/kreversiscene.cpp #1289084:1289085
@@ -38,7 +38,7 @@
static KgTheme* theme()
{
KgTheme* theme = new KgTheme("pics/default_theme.desktop");
- theme->setSvgPath(KStandardDirs::locate("appdata", "pics/default_theme.svgz"));
+ theme->setGraphicsPath(KStandardDirs::locate("appdata", \
"pics/default_theme.svgz")); return theme;
}
--- trunk/KDE/kdegames/libkdegames/kgamerenderer.cpp #1289084:1289085
@@ -180,6 +180,7 @@
it1.value().clear(); //because the pixmap is outdated
it1.key()->d->fetchPixmap();
}
+ emit m_parent->themeChanged(m_currentTheme);
}
bool KGameRendererPrivate::setTheme(const KgTheme* theme)
@@ -197,7 +198,7 @@
m_imageCache->setPixmapCaching(false); //see big comment in KGRPrivate class \
declaration //check timestamp of cache vs. last write access to theme/SVG
const uint svgTimestamp = qMax(
- QFileInfo(theme->svgPath()).lastModified().toTime_t(),
+ QFileInfo(theme->graphicsPath()).lastModified().toTime_t(),
theme->property("_k_themeDescTimestamp").value<uint>()
);
QByteArray buffer;
@@ -209,10 +210,10 @@
if (cacheTimestamp < svgTimestamp)
{
kDebug(11000) << "Theme newer than cache, checking SVG";
- QScopedPointer<QSvgRenderer> renderer(new QSvgRenderer(theme->svgPath()));
+ QScopedPointer<QSvgRenderer> renderer(new QSvgRenderer(theme->graphicsPath()));
if (renderer->isValid())
{
- m_rendererPool.setPath(theme->svgPath(), renderer.take());
+ m_rendererPool.setPath(theme->graphicsPath(), renderer.take());
m_imageCache->insert(QString::fromLatin1("kgr_timestamp"), \
QByteArray::number(svgTimestamp)); }
else
@@ -228,15 +229,15 @@
}
//theme is cached - just delete the old renderer after making sure that no worker \
threads are using it anymore else if (m_currentTheme != theme)
- m_rendererPool.setPath(theme->svgPath());
+ m_rendererPool.setPath(theme->graphicsPath());
}
else // !(m_strategies & KGameRenderer::UseDiskCache) -> no cache is used
{
//load SVG file
- QScopedPointer<QSvgRenderer> renderer(new QSvgRenderer(theme->svgPath()));
+ QScopedPointer<QSvgRenderer> renderer(new QSvgRenderer(theme->graphicsPath()));
if (renderer->isValid())
{
- m_rendererPool.setPath(theme->svgPath(), renderer.take());
+ m_rendererPool.setPath(theme->graphicsPath(), renderer.take());
}
else
{
@@ -589,7 +590,7 @@
setPath(QString());
}
-void KGRInternal::RendererPool::setPath(const QString& svgPath, QSvgRenderer* \
renderer) +void KGRInternal::RendererPool::setPath(const QString& graphicsPath, \
QSvgRenderer* renderer) {
QMutexLocker locker(&m_mutex);
//delete all renderers
@@ -602,7 +603,7 @@
}
m_hash.clear();
//set path
- m_path = svgPath;
+ m_path = graphicsPath;
//existence of a renderer instance is evidence for the validity of the SVG file
if (renderer)
{
--- trunk/KDE/kdegames/libkdegames/kgamerenderer.h #1289084:1289085
@@ -94,8 +94,8 @@
class KDEGAMES_EXPORT KGameRenderer : public QObject
{
Q_OBJECT
- Q_PROPERTY(const KgTheme* theme READ theme)
- Q_PROPERTY(KgThemeProvider* themeProvider READ themeProvider)
+ Q_PROPERTY(const KgTheme* theme READ theme NOTIFY themeChanged)
+ Q_PROPERTY(KgThemeProvider* themeProvider READ themeProvider NOTIFY \
readOnlyProperty) public:
///Describes the various strategies which KGameRenderer can use to speed
///up rendering.
@@ -212,6 +212,11 @@
// The parentheses around QHash<QColor, QColor>() avoid compile
// errors on platforms with older gcc versions, e.g. OS X 10.6.
QPixmap spritePixmap(const QString& key, const QSize& size, int frame = -1, const \
QHash<QColor, QColor>& customColors = (QHash<QColor, QColor>())) const; + Q_SIGNALS:
+ void themeChanged(const KgTheme* theme);
+ ///This signal is never emitted. It is provided because QML likes to
+ ///complain about properties without NOTIFY signals, even readonly ones.
+ void readOnlyProperty();
private:
friend class KGameRendererPrivate;
friend class KGameRendererClient;
--- trunk/KDE/kdegames/libkdegames/kgamerenderer_p.h #1289084:1289085
@@ -61,7 +61,7 @@
//The second argument can be used to pass an instance which has been
//used earlier to check the validity of the SVG file.
- inline void setPath(const QString& svgPath, QSvgRenderer* renderer = 0);
+ inline void setPath(const QString& graphicsPath, QSvgRenderer* renderer = 0);
//This can be used to determine whether a call to allocRenderer()
//would need to create a new renderer instance.
inline bool hasAvailableRenderers() const;
--- trunk/KDE/kdegames/libkdegames/kgtheme.cpp #1289084:1289085
@@ -28,7 +28,7 @@
struct KgTheme::Private
{
const QByteArray m_identifier;
- QString m_name, m_description, m_author, m_authorEmail, m_svgPath, m_previewPath;
+ QString m_name, m_description, m_author, m_authorEmail, m_graphicsPath, \
m_previewPath; QMap<QString, QString> m_customData;
Private(const QByteArray& id) : m_identifier(id) {}
@@ -62,7 +62,7 @@
KGTHEME_STRING_PROPERTY(description, setDescription)
KGTHEME_STRING_PROPERTY(author, setAuthor)
KGTHEME_STRING_PROPERTY(authorEmail, setAuthorEmail)
-KGTHEME_STRING_PROPERTY(svgPath, setSvgPath)
+KGTHEME_STRING_PROPERTY(graphicsPath, setGraphicsPath)
KGTHEME_STRING_PROPERTY(previewPath, setPreviewPath)
QMap<QString, QString> KgTheme::customData() const
@@ -128,9 +128,9 @@
//resolve paths
const QFileInfo fi(path);
const QDir dir = fi.dir();
- QString svgPath = group.readEntry("FileName", QString());
- if (!svgPath.isEmpty() && QFileInfo(svgPath).isRelative())
- svgPath = dir.absoluteFilePath(svgPath);
+ QString graphicsPath = group.readEntry("FileName", QString());
+ if (!graphicsPath.isEmpty() && QFileInfo(graphicsPath).isRelative())
+ graphicsPath = dir.absoluteFilePath(graphicsPath);
QString previewPath = group.readEntry("Preview", QString());
if (!previewPath.isEmpty() && QFileInfo(previewPath).isRelative())
previewPath = dir.absoluteFilePath(previewPath);
@@ -139,7 +139,7 @@
setDescription(group.readEntry("Description", QString()));
setAuthor(group.readEntry("Author", QString()));
setAuthorEmail(group.readEntry("AuthorEmail", QString()));
- setSvgPath(svgPath);
+ setGraphicsPath(graphicsPath);
setPreviewPath(previewPath);
setCustomData(group.entryMap());
//store modification date of this file in private property (KGameRenderer
--- trunk/KDE/kdegames/libkdegames/kgtheme.h #1289084:1289085
@@ -68,16 +68,16 @@
class KDEGAMES_EXPORT KgTheme : public QObject
{
Q_OBJECT
- Q_PROPERTY(QByteArray identifier READ identifier)
- //no NOTIFY signals here - it is not intended to allow these properties
- //to change after the initial setup (note how KgThemeProvider returns only
- //const KgTheme*)
- Q_PROPERTY(QString name READ name WRITE setName)
- Q_PROPERTY(QString description READ description WRITE setDescription)
- Q_PROPERTY(QString author READ author WRITE setAuthor)
- Q_PROPERTY(QString authorEmail READ authorEmail WRITE setAuthorEmail)
- Q_PROPERTY(QString svgPath READ svgPath WRITE setSvgPath)
- Q_PROPERTY(QString previewPath READ previewPath WRITE setPreviewPath)
+ Q_PROPERTY(QByteArray identifier READ identifier NOTIFY readOnlyProperty)
+ //it is not intended to allow these properties to change after the initial
+ //setup (note how KgThemeProvider returns only const KgTheme*), hence
+ //a dummy NOTIFY signal is enough
+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY readOnlyProperty)
+ Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY \
readOnlyProperty) + Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY \
readOnlyProperty) + Q_PROPERTY(QString authorEmail READ authorEmail WRITE \
setAuthorEmail NOTIFY readOnlyProperty) + Q_PROPERTY(QString graphicsPath READ \
graphicsPath WRITE setGraphicsPath NOTIFY readOnlyProperty) + Q_PROPERTY(QString \
previewPath READ previewPath WRITE setPreviewPath NOTIFY readOnlyProperty) \
Q_DISABLE_COPY(KgTheme) public:
///Constructor. The @a identifier must be application-unique.
@@ -123,9 +123,9 @@
void setAuthorEmail(const QString& authorEmail);
///@return the path of the SVG file which holds the theme contents
- QString svgPath() const;
- ///@see svgPath()
- void setSvgPath(const QString& path);
+ QString graphicsPath() const;
+ ///@see graphicsPath()
+ void setGraphicsPath(const QString& path);
///@return the path to an image file containing a preview, or an empty
/// string if no preview file is known
QString previewPath() const;
@@ -141,6 +141,10 @@
QString customData(const QString& key, const QString& defaultValue = QString()) \
const; ///@see customData()
void setCustomData(const QMap<QString, QString>& customData);
+ Q_SIGNALS:
+ ///This signal is never emitted. It is provided because QML likes to
+ ///complain about properties without NOTIFY signals, even readonly ones.
+ void readOnlyProperty();
private:
class Private;
Private* const d;
--- trunk/KDE/kdegames/libkdegames/kgthemeprovider.cpp #1289084:1289085
@@ -49,6 +49,7 @@
, d(new Private(configKey))
{
qRegisterMetaType<const KgTheme*>();
+ qRegisterMetaType<KgThemeProvider*>();
}
KgThemeProvider::~KgThemeProvider()
--- trunk/KDE/kdegames/libkdegames/kgthemeprovider.h #1289084:1289085
@@ -117,4 +117,6 @@
Private* const d;
};
+Q_DECLARE_METATYPE(KgThemeProvider*)
+
#endif // KGTHEMEPROVIDER_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic