KGuiAddons
kcountryflagemojiiconengine.cpp
21 // The way this was set up by unicode is actually pretty smart. Country flags are based on their two character
22 // country codes within a given range of code points. And even better, the offset inside the range is the same
23 // as the offset inside ASCII. Meaning the offset of 'A' from 0 is the same as the offset of π¦ in the
24 // flag codepoint range. The way a flag is then denoted is e.g. <SURROGATEPAIR>π¦<SURROGATEPAIR>πΉ resulting in
30 static constexpr auto offsetCodePointA = 'A'_L1.unicode(); // offset from 0, the flag code points have the same offsets
45 // Region flags work much the same as country flags but with a slightly different format in a slightly different
46 // code point region. Specifically they use ISO 3166-2 as input (e.g. GB-SCT for Scotland). It all happens in
47 // the Unicode Block βTagsβ (starting at U+E0000) wherein it functions the same as the country codes do in their
48 // block. The offsets inside the block are the same as the ascii offsets and the emoji is constructed by combining
49 // the off set code points of the incoming region tag. They are prefixed with U+1F3F4 π΄ WAVING BLACK FLAG
57 static constexpr auto flagCodePointStart = 0xDC41; // U+E0041 (Tag Latin Capital Letter A) - NB: we are in UTF-16
58 static constexpr auto offsetCodePointA = 'A'_L1.unicode(); // offset from 0, the flag code points have the same offsets
67 static const auto cancelTag = QString().append(QChar(surrogatePairCodePoint)).append(QChar(0xDC7F));
78 , m_emoji(regionOrCountry.contains("-"_L1) ? makeRegionEmoji(regionOrCountry) : makeCountryEmoji(regionOrCountry))
103void KCountryFlagEmojiIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)
120 // when the delta is too large we'll chop the pixel size in half and hope the delta comes within a more reasonable range the next loop run
131 painter->setPen(qGuiApp->palette().color(QPalette::WindowText)); // in case we render the letters in absence of a flag
132 // Confusingly the pixelSize for drawing must actually be without DPR but the rect calculation above
139QPixmap KCountryFlagEmojiIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
144QPixmap KCountryFlagEmojiIconEngine::scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale)
bool isNull() override
Check whether the internal emoji unicode sequence is null This does not necessarily mean that the pix...
Definition kcountryflagemojiiconengine.cpp:156
static void setGlobalDefaultFont(const QFont &font)
Set the Global Default Font object This is primarily useful for platform themes that wish to force a ...
Definition kcountryflagemojiiconengine.cpp:161
KCountryFlagEmojiIconEngine(const QString ®ionOrCountry)
Construct a new KCountryFlagEmojiIconEngine object Please note that regional flag support can be spot...
Definition kcountryflagemojiiconengine.cpp:86
KI18NLOCALEDATA_EXPORT KCountry country(const char *ianaId)
Mode
State
qreal devicePixelRatioF() const const
QPaintDevice * device() const const
void drawText(const QPoint &position, const QString &text)
void setFont(const QFont &font)
void setPen(Qt::PenStyle style)
WindowText
void fill(const QColor &color)
void setDevicePixelRatio(qreal scaleFactor)
int height() const const
int width() const const
qreal height() const const
qreal width() const const
QString & append(QChar ch)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
void reserve(qsizetype size)
qsizetype size() const const
const QChar * unicode() const const
AlignCenter
transparent
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 10 2024 11:48:59 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 10 2024 11:48:59 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.