Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
pixel_map_generator.cpp File Reference
#include "pixel_map_generator.h"
#include <QApplication>
#include <QDomDocument>
#include <QFile>
#include <QPainter>
#include <QPalette>
#include <QSvgRenderer>
#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
Include dependency graph for pixel_map_generator.cpp:

Macros

#define DEFAULT_COLOR_UNREGISTERED   "#32c8ec";
#define DEFAULT_COLOR_REGISTERED   "#5ed900";
#define DEFAULT_COLOR_MODERATOR_LEFT   "#ffffff";
#define DEFAULT_COLOR_MODERATOR_RIGHT   "#000000";
#define DEFAULT_COLOR_ADMIN   "#ff2701";

Functions

static QPixmap loadSvg (const QString &svgPath, const QSize &size, bool expandOnly=false)
static QPixmap tryLoadImage (const QString &path, const QSize &size, bool expandOnly=false)
static void setAttrRecur (QDomElement &elem, const QString &tagName, const QString &attrName, const QString &idName, const QString &attrValue)
static QIcon loadAndColorSvg (const QString &iconPath, const QString &colorLeft, const std::optional< QString > &colorRight, const int minSize)
static QString getIconType (const bool isBuddy, const UserLevelFlags &userLevelFlags, const QString &privLevel)
QPixmap loadColorAdjustedPixmap (const QString &name)

Macro Definition Documentation

◆ DEFAULT_COLOR_ADMIN

#define DEFAULT_COLOR_ADMIN   "#ff2701";

◆ DEFAULT_COLOR_MODERATOR_LEFT

#define DEFAULT_COLOR_MODERATOR_LEFT   "#ffffff";

◆ DEFAULT_COLOR_MODERATOR_RIGHT

#define DEFAULT_COLOR_MODERATOR_RIGHT   "#000000";

◆ DEFAULT_COLOR_REGISTERED

#define DEFAULT_COLOR_REGISTERED   "#5ed900";

◆ DEFAULT_COLOR_UNREGISTERED

#define DEFAULT_COLOR_UNREGISTERED   "#32c8ec";

Function Documentation

◆ getIconType()

QString getIconType ( const bool isBuddy,
const UserLevelFlags & userLevelFlags,
const QString & privLevel )
static
Here is the caller graph for this function:

◆ loadAndColorSvg()

QIcon loadAndColorSvg ( const QString & iconPath,
const QString & colorLeft,
const std::optional< QString > & colorRight,
const int minSize )
static

Loads the usericon svg and fills in its colors. The image is kept as a QIcon to preserve the image quality.

Call icon.pixmap(w, h) in order to convert this icon into a pixmap with the given dimensions. Avoid scaling the pixmap in other ways, as that destroys image quality.

Parameters
minSizeIf the dimensions of the source svg is smaller than this, then it will be scaled up to this size
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadColorAdjustedPixmap()

QPixmap loadColorAdjustedPixmap ( const QString & name)
Here is the caller graph for this function:

◆ loadSvg()

QPixmap loadSvg ( const QString & svgPath,
const QSize & size,
bool expandOnly = false )
static

Loads in an svg from file and scales it without affecting image quality.

Parameters
svgPathThe path to the svg file, with file extension.
sizeThe desired size of the pixmap.
expandOnlyIf true, then keep the size of the initial pixmap to at least the svg size.
Returns
The svg loaded into a Pixmap with the given size, or an empty Pixmap if the loading failed.
Here is the caller graph for this function:

◆ setAttrRecur()

void setAttrRecur ( QDomElement & elem,
const QString & tagName,
const QString & attrName,
const QString & idName,
const QString & attrValue )
static

Updates tags in the svg

Parameters
elemThe svg
tagNametag with attribute to update
attrNameattribute to be updated
idNameid that the tag has to match
attrValuethe value to update the attribute to
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryLoadImage()

QPixmap tryLoadImage ( const QString & path,
const QSize & size,
bool expandOnly = false )
static

Try to load path image from non-SVG formats, otherwise fall back to SVG. This is to allow custom themes to support non-SVG format type overrides, since SVG requires custom loading.

Parameters
pathThe path to the file, with no file extension. File formats will be automatically detected.
sizeThe desired size of the pixmap.
expandOnlyIf true, then keep the size of the initial pixmap to at least the size (Only relevant if SVG).
Returns
The loaded image into a Pixmap with the given size, or an empty Pixmap if the loading failed.
Here is the call graph for this function:
Here is the caller graph for this function: