2014-11-13 01:04:59 +02:00
|
|
|
/* This file is part of the KDE libraries
|
2023-08-17 01:41:38 +03:00
|
|
|
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
2014-11-13 01:04:59 +02:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
2023-08-17 01:41:38 +03:00
|
|
|
License version 2, as published by the Free Software Foundation.
|
2014-11-13 01:04:59 +02:00
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KUITSEMANTICS_P_H
|
|
|
|
#define KUITSEMANTICS_P_H
|
|
|
|
|
|
|
|
#include <QString>
|
2023-08-17 18:16:18 +03:00
|
|
|
#include <QList>
|
2014-11-13 01:04:59 +02:00
|
|
|
|
2023-08-17 01:41:38 +03:00
|
|
|
struct KuitFormat
|
|
|
|
{
|
2023-08-17 14:33:44 +03:00
|
|
|
QString tag;
|
2023-08-17 01:41:38 +03:00
|
|
|
QString plain;
|
|
|
|
QString rich;
|
|
|
|
};
|
2014-11-13 01:04:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
* (used by KLocalizedString)
|
|
|
|
*
|
2023-08-18 20:04:16 +03:00
|
|
|
* KuitSemantics resolves semantic markup in user interface text into appropriate visual
|
|
|
|
* formatting.
|
2014-11-13 01:04:59 +02:00
|
|
|
*
|
2023-08-17 01:41:38 +03:00
|
|
|
* @author Ivailo Monev <xakepa10@gmail.com>
|
2014-11-13 01:04:59 +02:00
|
|
|
* @short class for formatting semantic markup in UI messages
|
|
|
|
*/
|
|
|
|
class KuitSemantics
|
|
|
|
{
|
2023-08-17 01:41:38 +03:00
|
|
|
public:
|
2014-11-13 01:04:59 +02:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param lang language to create the formatter for
|
|
|
|
*/
|
2023-08-17 01:41:38 +03:00
|
|
|
KuitSemantics(const QString &lang);
|
2014-11-13 01:04:59 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transforms the semantic markup in the given text into visual formatting.
|
|
|
|
* The appropriate visual formatting is decided based on the semantic
|
|
|
|
* context marker provided in the context string.
|
|
|
|
*
|
|
|
|
* @param text text containing the semantic markup
|
|
|
|
* @param ctxt context of the text
|
|
|
|
*/
|
2023-08-17 01:41:38 +03:00
|
|
|
QString format(const QString &text, const QString &ctxt) const;
|
2014-11-13 01:04:59 +02:00
|
|
|
|
2023-08-17 01:41:38 +03:00
|
|
|
private:
|
2023-08-17 14:33:44 +03:00
|
|
|
QList<KuitFormat> m_formats;
|
2023-08-17 19:43:51 +03:00
|
|
|
static const QLatin1String s_numargs;
|
2023-08-17 14:33:44 +03:00
|
|
|
static const QLatin1String s_numintg;
|
|
|
|
static const QLatin1String s_numreal;
|
|
|
|
static const QLatin1String s_title;
|
2014-11-13 01:04:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// Some stuff needed in klocalizedstring.cpp too.
|
2023-08-17 19:43:51 +03:00
|
|
|
#define KUIT_NUMARGS "numargs"
|
2014-11-13 01:04:59 +02:00
|
|
|
#define KUIT_NUMINTG "numintg"
|
|
|
|
#define KUIT_NUMREAL "numreal"
|
|
|
|
|
|
|
|
#endif
|