File indexing completed on 2024-04-21 04:02:25

0001 /*
0002     SPDX-FileCopyrightText: 2012 Ian Wadham <iandw.au@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include <QDir>
0008 #include <QFileInfo>
0009 #include <QString>
0010 
0011 #include "kgrthemetypes.h"
0012 
0013 // Helper: Find the absolute path of a file pointed to by the .desktop file.
0014 QString absolutePath (const QString & path, const QString & relativePath)
0015 {
0016     const QFileInfo file   (path);
0017     const QDir      dir    = file.dir();
0018     QString         result;
0019     // Add the directory part of "path" to "relativePath".
0020     if (!relativePath.isEmpty() && QFileInfo(relativePath).isRelative()) {
0021         result = dir.absoluteFilePath(relativePath);
0022     }
0023     return result;
0024 }
0025 
0026 KGrActorsTheme::KGrActorsTheme(const QByteArray &identifier, QObject *parent)
0027     :
0028     KGameTheme(identifier, parent)
0029 {
0030 }
0031 
0032 KGrActorsTheme::~KGrActorsTheme()
0033 {
0034 }
0035 
0036 bool KGrActorsTheme::readFromDesktopFile(const QString& path)
0037 {
0038     // Base-class call.
0039     if (!KGameTheme::readFromDesktopFile(path))
0040         return false;
0041 
0042     // Customized behaviour: interprete "Actors" key as "FileName" for SVG file.
0043     setGraphicsPath (absolutePath (path, customData(QStringLiteral("Actors"))));
0044     return true;
0045 }
0046 
0047 KGrSetTheme::KGrSetTheme(const QByteArray &identifier, QObject *parent)
0048     :
0049     KGameTheme(identifier, parent)
0050 {
0051 }
0052 
0053 KGrSetTheme::~KGrSetTheme()
0054 {
0055 }
0056 
0057 bool KGrSetTheme::readFromDesktopFile(const QString& path)
0058 {
0059     // Base-class call.
0060     if (!KGameTheme::readFromDesktopFile(path))
0061         return false;
0062 
0063     // Customized behaviour: interprete "Set" key as "FileName" for SVG file.
0064     setGraphicsPath (absolutePath (path, customData(QStringLiteral("Set"))));
0065     return true;
0066 }
0067 
0068 #include "moc_kgrthemetypes.cpp"