libcalamares: deal with KF5 macro expansion

Since KF5 is not looked-for in the Qt6 build, mock up
a useless macro-expander in its place.
This commit is contained in:
Adriaan de Groot 2023-09-03 15:50:20 +02:00
parent e0b820abbc
commit cdb2eb8b9a
2 changed files with 48 additions and 0 deletions

View File

@ -11,6 +11,16 @@
#include "StringExpander.h"
#include "Logger.h"
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
// TODO: Qt6
KWordMacroExpander::~KWordMacroExpander() {};
bool
KWordMacroExpander::expandMacro( const QString& str, QStringList& ret )
{
return false;
}
#endif
namespace Calamares
{
namespace String

View File

@ -13,7 +13,44 @@
#include "DllMacro.h"
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#include <KMacroExpander>
#else
// TODO: Qt6
//
// Mock up part of KF6
#include <QHash>
#include <QString>
class KMacroExpanderBase
{
public:
QString expandMacrosShellQuote( const QString& c ) { return c; }
};
class KMacroExpander
{
public:
static QString expandMacros( const QString& source, const QHash< QString, QString > dict, char sep )
{
return source;
}
};
class KWordMacroExpander : public KMacroExpanderBase
{
public:
KWordMacroExpander( QChar c )
: m_escape( c )
{
}
virtual ~KWordMacroExpander();
virtual bool expandMacro( const QString& str, QStringList& ret );
void expandMacros( QString& s ) {}
QChar escapeChar() const { return m_escape; }
private:
QChar m_escape;
};
#endif
#include <QString>
#include <QStringList>
@ -25,6 +62,7 @@ namespace Calamares
namespace String
{
/** @brief Expand variables in a string against a dictionary.
*
* This class provides a convenience API for building up a dictionary