All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
ef997f2259
commit
9fe130cd73
@@ -20,19 +20,19 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
# include <QApplication>
|
||||
# include <QBitmap>
|
||||
# include <QDir>
|
||||
# include <QFile>
|
||||
# include <QFileInfo>
|
||||
# include <QMap>
|
||||
# include <QImageReader>
|
||||
# include <QPainter>
|
||||
# include <QPalette>
|
||||
# include <QScreen>
|
||||
# include <QString>
|
||||
# include <QSvgRenderer>
|
||||
# include <QStyleOption>
|
||||
#include <QApplication>
|
||||
#include <QBitmap>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QMap>
|
||||
#include <QImageReader>
|
||||
#include <QPainter>
|
||||
#include <QPalette>
|
||||
#include <QScreen>
|
||||
#include <QString>
|
||||
#include <QSvgRenderer>
|
||||
#include <QStyleOption>
|
||||
|
||||
#include <string>
|
||||
#include <Inventor/fields/SoSFImage.h>
|
||||
@@ -45,7 +45,8 @@
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
namespace Gui {
|
||||
namespace Gui
|
||||
{
|
||||
class BitmapFactoryInstP
|
||||
{
|
||||
public:
|
||||
@@ -53,16 +54,15 @@ public:
|
||||
|
||||
bool useIconTheme;
|
||||
};
|
||||
}
|
||||
} // namespace Gui
|
||||
|
||||
BitmapFactoryInst* BitmapFactoryInst::_pcSingleton = nullptr;
|
||||
|
||||
BitmapFactoryInst& BitmapFactoryInst::instance()
|
||||
{
|
||||
if (!_pcSingleton)
|
||||
{
|
||||
if (!_pcSingleton) {
|
||||
_pcSingleton = new BitmapFactoryInst;
|
||||
std::map<std::string,std::string>::const_iterator it;
|
||||
std::map<std::string, std::string>::const_iterator it;
|
||||
it = App::GetApplication().Config().find("ProgramIcons");
|
||||
if (it != App::GetApplication().Config().end()) {
|
||||
QString home = QString::fromStdString(App::Application::getHomePath());
|
||||
@@ -72,8 +72,12 @@ BitmapFactoryInst& BitmapFactoryInst::instance()
|
||||
}
|
||||
_pcSingleton->addPath(path);
|
||||
}
|
||||
_pcSingleton->addPath(QStringLiteral("%1/icons").arg(QString::fromStdString(App::Application::getHomePath())));
|
||||
_pcSingleton->addPath(QStringLiteral("%1/icons").arg(QString::fromStdString(App::Application::getUserAppDataDir())));
|
||||
_pcSingleton->addPath(
|
||||
QStringLiteral("%1/icons").arg(QString::fromStdString(App::Application::getHomePath()))
|
||||
);
|
||||
_pcSingleton->addPath(
|
||||
QStringLiteral("%1/icons").arg(QString::fromStdString(App::Application::getUserAppDataDir()))
|
||||
);
|
||||
_pcSingleton->addPath(QLatin1String(":/icons/"));
|
||||
_pcSingleton->addPath(QLatin1String(":/Icons/"));
|
||||
}
|
||||
@@ -81,10 +85,11 @@ BitmapFactoryInst& BitmapFactoryInst::instance()
|
||||
return *_pcSingleton;
|
||||
}
|
||||
|
||||
void BitmapFactoryInst::destruct ()
|
||||
void BitmapFactoryInst::destruct()
|
||||
{
|
||||
if (_pcSingleton)
|
||||
delete _pcSingleton;
|
||||
if (_pcSingleton) {
|
||||
delete _pcSingleton;
|
||||
}
|
||||
_pcSingleton = nullptr;
|
||||
}
|
||||
|
||||
@@ -103,18 +108,20 @@ BitmapFactoryInst::~BitmapFactoryInst()
|
||||
|
||||
void BitmapFactoryInst::restoreCustomPaths()
|
||||
{
|
||||
Base::Reference<ParameterGrp> group = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Bitmaps");
|
||||
Base::Reference<ParameterGrp> group = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Bitmaps"
|
||||
);
|
||||
std::vector<std::string> paths = group->GetASCIIs("CustomPath");
|
||||
for (auto & path : paths) {
|
||||
for (auto& path : paths) {
|
||||
addPath(QString::fromUtf8(path.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void Gui::BitmapFactoryInst::configureUseIconTheme()
|
||||
{
|
||||
Base::Reference<ParameterGrp> group = App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Bitmaps/Theme");
|
||||
Base::Reference<ParameterGrp> group = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Bitmaps/Theme"
|
||||
);
|
||||
|
||||
d->useIconTheme = group->GetBool("UseIconTheme", group->GetBool("ThemeSearchPaths", false));
|
||||
}
|
||||
@@ -143,8 +150,9 @@ QStringList BitmapFactoryInst::findIconFiles() const
|
||||
{
|
||||
QStringList files, filters;
|
||||
QList<QByteArray> formats = QImageReader::supportedImageFormats();
|
||||
for (QList<QByteArray>::iterator it = formats.begin(); it != formats.end(); ++it)
|
||||
for (QList<QByteArray>::iterator it = formats.begin(); it != formats.end(); ++it) {
|
||||
filters << QStringLiteral("*.%1").arg(QString::fromLatin1(*it).toLower());
|
||||
}
|
||||
|
||||
QStringList paths = QDir::searchPaths(QStringLiteral("icons"));
|
||||
paths.removeDuplicates();
|
||||
@@ -152,8 +160,9 @@ QStringList BitmapFactoryInst::findIconFiles() const
|
||||
QDir d(*pt);
|
||||
d.setNameFilters(filters);
|
||||
QFileInfoList fi = d.entryInfoList();
|
||||
for (QFileInfoList::iterator it = fi.begin(); it != fi.end(); ++it)
|
||||
for (QFileInfoList::iterator it = fi.begin(); it != fi.end(); ++it) {
|
||||
files << it->absoluteFilePath();
|
||||
}
|
||||
}
|
||||
|
||||
files.removeDuplicates();
|
||||
@@ -185,8 +194,9 @@ QIcon BitmapFactoryInst::iconFromTheme(const char* name, const QIcon& fallback)
|
||||
QIcon icon = QIcon::fromTheme(iconName, fallback);
|
||||
if (icon.isNull()) {
|
||||
QPixmap px = pixmap(name);
|
||||
if (!px.isNull())
|
||||
if (!px.isNull()) {
|
||||
icon.addPixmap(px);
|
||||
}
|
||||
}
|
||||
|
||||
return icon;
|
||||
@@ -201,7 +211,7 @@ bool BitmapFactoryInst::loadPixmap(const QString& filename, QPixmap& icon) const
|
||||
QFile svgFile(fi.filePath());
|
||||
if (svgFile.open(QFile::ReadOnly | QFile::Text)) {
|
||||
QByteArray content = svgFile.readAll();
|
||||
icon = pixmapFromSvg(content, QSize(64,64));
|
||||
icon = pixmapFromSvg(content, QSize(64, 64));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -221,7 +231,8 @@ QIcon Gui::BitmapFactoryInst::iconFromDefaultTheme(const char* name, const QIcon
|
||||
if (!px.isNull()) {
|
||||
icon.addPixmap(px);
|
||||
return icon;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
@@ -230,13 +241,15 @@ QIcon Gui::BitmapFactoryInst::iconFromDefaultTheme(const char* name, const QIcon
|
||||
|
||||
QPixmap BitmapFactoryInst::pixmap(const char* name) const
|
||||
{
|
||||
if (!name || *name == '\0')
|
||||
if (!name || *name == '\0') {
|
||||
return {};
|
||||
}
|
||||
|
||||
// as very first test check whether the pixmap is in the cache
|
||||
QMap<std::string, QPixmap>::Iterator it = d->xpmCache.find(name);
|
||||
if (it != d->xpmCache.end())
|
||||
if (it != d->xpmCache.end()) {
|
||||
return it.value();
|
||||
}
|
||||
|
||||
QPixmap icon;
|
||||
|
||||
@@ -247,14 +260,16 @@ QPixmap BitmapFactoryInst::pixmap(const char* name) const
|
||||
// try to find it in the 'icons' search paths
|
||||
if (icon.isNull()) {
|
||||
QList<QByteArray> formats = QImageReader::supportedImageFormats();
|
||||
formats.prepend("SVG"); // check first for SVG to use special import mechanism
|
||||
formats.prepend("SVG"); // check first for SVG to use special import mechanism
|
||||
|
||||
QString fileName = QStringLiteral("icons:") + fn;
|
||||
if (!loadPixmap(fileName, icon)) {
|
||||
// Go through supported file formats
|
||||
for (QList<QByteArray>::iterator fm = formats.begin(); fm != formats.end(); ++fm) {
|
||||
QString path = QStringLiteral("%1.%2").arg(fileName,
|
||||
QString::fromLatin1((*fm).toLower().constData()));
|
||||
QString path = QStringLiteral("%1.%2").arg(
|
||||
fileName,
|
||||
QString::fromLatin1((*fm).toLower().constData())
|
||||
);
|
||||
if (loadPixmap(path, icon)) {
|
||||
break;
|
||||
}
|
||||
@@ -271,17 +286,21 @@ QPixmap BitmapFactoryInst::pixmap(const char* name) const
|
||||
return QPixmap(Gui::BitmapFactory().pixmapFromSvg("help-browser", QSize(16, 16)));
|
||||
}
|
||||
|
||||
QPixmap BitmapFactoryInst::pixmapFromSvg(const char* name, const QSizeF& size,
|
||||
const ColorMap& colorMapping) const
|
||||
QPixmap BitmapFactoryInst::pixmapFromSvg(
|
||||
const char* name,
|
||||
const QSizeF& size,
|
||||
const ColorMap& colorMapping
|
||||
) const
|
||||
{
|
||||
static qreal dpr = getMaximumDPR();
|
||||
|
||||
|
||||
// If an absolute path is given
|
||||
QPixmap icon;
|
||||
QString iconPath;
|
||||
QString fn = QString::fromUtf8(name);
|
||||
if (QFile(fn).exists())
|
||||
if (QFile(fn).exists()) {
|
||||
iconPath = fn;
|
||||
}
|
||||
|
||||
// try to find it in the 'icons' search paths
|
||||
if (iconPath.isEmpty()) {
|
||||
@@ -314,15 +333,18 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const char* name, const QSizeF& size,
|
||||
return icon;
|
||||
}
|
||||
|
||||
QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& originalContents, const QSizeF& size,
|
||||
const ColorMap& colorMapping) const
|
||||
QPixmap BitmapFactoryInst::pixmapFromSvg(
|
||||
const QByteArray& originalContents,
|
||||
const QSizeF& size,
|
||||
const ColorMap& colorMapping
|
||||
) const
|
||||
{
|
||||
QString stringContents = QString::fromUtf8(originalContents);
|
||||
for ( const auto &colorToColor : colorMapping ) {
|
||||
for (const auto& colorToColor : colorMapping) {
|
||||
ulong fromColor = colorToColor.first;
|
||||
ulong toColor = colorToColor.second;
|
||||
QString fromColorString = QStringLiteral("#%1").arg(fromColor, 6, 16, QChar::fromLatin1('0'));
|
||||
QString toColorString = QStringLiteral("#%1").arg(toColor, 6, 16, QChar::fromLatin1('0'));
|
||||
QString fromColorString = QStringLiteral("#%1").arg(fromColor, 6, 16, QChar::fromLatin1('0'));
|
||||
QString toColorString = QStringLiteral("#%1").arg(toColor, 6, 16, QChar::fromLatin1('0'));
|
||||
stringContents = stringContents.replace(fromColorString, toColorString);
|
||||
}
|
||||
QByteArray contents = stringContents.toUtf8();
|
||||
@@ -346,10 +368,12 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& originalContents, con
|
||||
QStringList BitmapFactoryInst::pixmapNames() const
|
||||
{
|
||||
QStringList names;
|
||||
for (QMap<std::string, QPixmap>::Iterator It = d->xpmCache.begin(); It != d->xpmCache.end(); ++It) {
|
||||
for (QMap<std::string, QPixmap>::Iterator It = d->xpmCache.begin(); It != d->xpmCache.end();
|
||||
++It) {
|
||||
QString item = QString::fromUtf8(It.key().c_str());
|
||||
if (!names.contains(item))
|
||||
if (!names.contains(item)) {
|
||||
names << item;
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
@@ -357,56 +381,58 @@ QStringList BitmapFactoryInst::pixmapNames() const
|
||||
QPixmap BitmapFactoryInst::resize(int w, int h, const QPixmap& p, Qt::BGMode bgmode) const
|
||||
{
|
||||
if (bgmode == Qt::TransparentMode) {
|
||||
if (p.width() == 0 || p.height() == 0)
|
||||
if (p.width() == 0 || p.height() == 0) {
|
||||
w = 1;
|
||||
}
|
||||
|
||||
QPixmap pix = p;
|
||||
int x = pix.width () > w ? 0 : (w - pix.width ())/2;
|
||||
int y = pix.height() > h ? 0 : (h - pix.height())/2;
|
||||
int x = pix.width() > w ? 0 : (w - pix.width()) / 2;
|
||||
int y = pix.height() > h ? 0 : (h - pix.height()) / 2;
|
||||
|
||||
if (x == 0 && y == 0)
|
||||
if (x == 0 && y == 0) {
|
||||
return pix;
|
||||
}
|
||||
|
||||
QPixmap pm (w,h);
|
||||
QBitmap mask (w,h);
|
||||
QPixmap pm(w, h);
|
||||
QBitmap mask(w, h);
|
||||
mask.fill(Qt::color0);
|
||||
|
||||
QBitmap bm = pix.mask();
|
||||
if (!bm.isNull())
|
||||
{
|
||||
if (!bm.isNull()) {
|
||||
QPainter painter(&mask);
|
||||
painter.drawPixmap(QPoint(x, y), bm, QRect(0, 0, pix.width(), pix.height()));
|
||||
pm.setMask(mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
pm.setMask(mask);
|
||||
pm = fillRect(x, y, pix.width(), pix.height(), pm, Qt::OpaqueMode);
|
||||
}
|
||||
|
||||
QPainter pt;
|
||||
pt.begin( &pm );
|
||||
pt.begin(&pm);
|
||||
pt.drawPixmap(x, y, pix);
|
||||
pt.end();
|
||||
return pm;
|
||||
} else { // Qt::OpaqueMode
|
||||
}
|
||||
else { // Qt::OpaqueMode
|
||||
QPixmap pix = p;
|
||||
|
||||
if (pix.width() == 0 || pix.height() == 0)
|
||||
return pix; // do not resize a null pixmap
|
||||
if (pix.width() == 0 || pix.height() == 0) {
|
||||
return pix; // do not resize a null pixmap
|
||||
}
|
||||
|
||||
QPalette pal = qApp->palette();
|
||||
QColor dl = pal.color(QPalette::Disabled, QPalette::Light);
|
||||
QColor dt = pal.color(QPalette::Disabled, QPalette::Text);
|
||||
|
||||
QPixmap pm(w,h);
|
||||
QPixmap pm(w, h);
|
||||
pm.fill(dl);
|
||||
|
||||
QPainter pt;
|
||||
pt.begin( &pm );
|
||||
pt.setPen( dl );
|
||||
pt.begin(&pm);
|
||||
pt.setPen(dl);
|
||||
pt.drawPixmap(1, 1, pix);
|
||||
pt.setPen( dt );
|
||||
pt.setPen(dt);
|
||||
pt.drawPixmap(0, 0, pix);
|
||||
pt.end();
|
||||
return pm;
|
||||
@@ -416,18 +442,21 @@ QPixmap BitmapFactoryInst::resize(int w, int h, const QPixmap& p, Qt::BGMode bgm
|
||||
QPixmap BitmapFactoryInst::fillRect(int x, int y, int w, int h, const QPixmap& p, Qt::BGMode bgmode) const
|
||||
{
|
||||
QBitmap b = p.mask();
|
||||
if (b.isNull())
|
||||
return p; // sorry, but cannot do anything
|
||||
if (b.isNull()) {
|
||||
return p; // sorry, but cannot do anything
|
||||
}
|
||||
|
||||
QPixmap pix = p;
|
||||
|
||||
// modify the mask
|
||||
QPainter pt;
|
||||
pt.begin(&b);
|
||||
if (bgmode == Qt::OpaqueMode)
|
||||
pt.fillRect(x, y, w, h, Qt::color1); // make opaque
|
||||
else // Qt::TransparentMode
|
||||
pt.fillRect(x, y, w, h, Qt::color0); // make transparent
|
||||
if (bgmode == Qt::OpaqueMode) {
|
||||
pt.fillRect(x, y, w, h, Qt::color1); // make opaque
|
||||
}
|
||||
else { // Qt::TransparentMode
|
||||
pt.fillRect(x, y, w, h, Qt::color0); // make transparent
|
||||
}
|
||||
pt.end();
|
||||
|
||||
pix.setMask(b);
|
||||
@@ -446,19 +475,20 @@ QPixmap BitmapFactoryInst::merge(const QPixmap& p1, const QPixmap& p2, bool vert
|
||||
// get the size for the new pixmap
|
||||
if (vertical) {
|
||||
y = p1.height();
|
||||
width = qMax( p1.width(), p2.width() );
|
||||
width = qMax(p1.width(), p2.width());
|
||||
height = p1.height() + p2.height();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
x = p1.width();
|
||||
width = p1.width() + p2.width();
|
||||
height = qMax( p1.height(), p2.height() );
|
||||
width = p1.width() + p2.width();
|
||||
height = qMax(p1.height(), p2.height());
|
||||
}
|
||||
|
||||
QPixmap res( width, height );
|
||||
QBitmap mask( width, height );
|
||||
QPixmap res(width, height);
|
||||
QBitmap mask(width, height);
|
||||
QBitmap mask1 = p1.mask();
|
||||
QBitmap mask2 = p2.mask();
|
||||
mask.fill( Qt::color0 );
|
||||
mask.fill(Qt::color0);
|
||||
|
||||
auto* pt1 = new QPainter(&res);
|
||||
pt1->drawPixmap(0, 0, p1);
|
||||
@@ -481,27 +511,26 @@ QPixmap BitmapFactoryInst::merge(const QPixmap& p1, const QPixmap& p2, Position
|
||||
qreal dpr1 = p1.devicePixelRatio();
|
||||
qreal dpr2 = p2.devicePixelRatio();
|
||||
|
||||
switch (pos)
|
||||
{
|
||||
case TopLeft:
|
||||
break;
|
||||
case TopRight:
|
||||
x = p1.width ()/dpr1 - p2.width ()/dpr2;
|
||||
break;
|
||||
case BottomLeft:
|
||||
y = p1.height()/dpr1 - p2.height()/dpr2;
|
||||
break;
|
||||
case BottomRight:
|
||||
x = p1.width ()/dpr1 - p2.width ()/dpr2;
|
||||
y = p1.height()/dpr1 - p2.height()/dpr2;
|
||||
break;
|
||||
switch (pos) {
|
||||
case TopLeft:
|
||||
break;
|
||||
case TopRight:
|
||||
x = p1.width() / dpr1 - p2.width() / dpr2;
|
||||
break;
|
||||
case BottomLeft:
|
||||
y = p1.height() / dpr1 - p2.height() / dpr2;
|
||||
break;
|
||||
case BottomRight:
|
||||
x = p1.width() / dpr1 - p2.width() / dpr2;
|
||||
y = p1.height() / dpr1 - p2.height() / dpr2;
|
||||
break;
|
||||
}
|
||||
|
||||
QPixmap p = p1;
|
||||
p = fillRect(x, y, p2.width(), p2.height(), p, Qt::OpaqueMode);
|
||||
|
||||
QPainter pt;
|
||||
pt.begin( &p );
|
||||
pt.begin(&p);
|
||||
pt.setPen(Qt::NoPen);
|
||||
pt.drawRect(x, y, p2.width(), p2.height());
|
||||
pt.drawPixmap(x, y, p2);
|
||||
@@ -578,44 +607,39 @@ void BitmapFactoryInst::convert(const QImage& p, SoSFImage& img) const
|
||||
for (int y = 0; y < height; y++) {
|
||||
unsigned char* line = &bytes[width * numcomponents * (height - (y + 1))];
|
||||
for (int x = 0; x < width; x++) {
|
||||
QColor col = p.pixelColor(x,y);
|
||||
QColor col = p.pixelColor(x, y);
|
||||
switch (depth) {
|
||||
default:
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
case 1: {
|
||||
QRgb rgb = col.rgb();
|
||||
line[0] = qGray(rgb);
|
||||
} break;
|
||||
case 2:
|
||||
{
|
||||
} break;
|
||||
case 2: {
|
||||
QRgb rgb = col.rgba();
|
||||
line[0] = qGray(rgb);
|
||||
line[1] = qAlpha(rgb);
|
||||
} break;
|
||||
case 3:
|
||||
{
|
||||
} break;
|
||||
case 3: {
|
||||
QRgb rgb = col.rgb();
|
||||
line[0] = qRed(rgb);
|
||||
line[1] = qGreen(rgb);
|
||||
line[2] = qBlue(rgb);
|
||||
} break;
|
||||
case 4:
|
||||
{
|
||||
} break;
|
||||
case 4: {
|
||||
QRgb rgb = col.rgba();
|
||||
line[0] = qRed(rgb);
|
||||
line[1] = qGreen(rgb);
|
||||
line[2] = qBlue(rgb);
|
||||
line[3] = qAlpha(rgb);
|
||||
} break;
|
||||
case 8:
|
||||
{
|
||||
} break;
|
||||
case 8: {
|
||||
QRgba64 rgb = col.rgba64();
|
||||
line[0] = qRed(rgb);
|
||||
line[1] = qGreen(rgb);
|
||||
line[2] = qBlue(rgb);
|
||||
line[3] = qAlpha(rgb);
|
||||
} break;
|
||||
} break;
|
||||
}
|
||||
|
||||
line += numcomponents;
|
||||
@@ -630,36 +654,34 @@ void BitmapFactoryInst::convert(const SoSFImage& p, QImage& img) const
|
||||
SbVec2s size;
|
||||
int numcomponents;
|
||||
|
||||
const unsigned char * bytes = p.getValue(size, numcomponents);
|
||||
if (!bytes)
|
||||
const unsigned char* bytes = p.getValue(size, numcomponents);
|
||||
if (!bytes) {
|
||||
return;
|
||||
}
|
||||
|
||||
int width = (int)size[0];
|
||||
int width = (int)size[0];
|
||||
int height = (int)size[1];
|
||||
|
||||
img = QImage(width, height, QImage::Format_RGB32);
|
||||
QRgb * bits = (QRgb*) img.bits();
|
||||
QRgb* bits = (QRgb*)img.bits();
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
const unsigned char * line = &bytes[width*numcomponents*(height-(y+1))];
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
switch (numcomponents)
|
||||
{
|
||||
default:
|
||||
case 1:
|
||||
*bits++ = qRgb(line[0], line[0], line[0]);
|
||||
break;
|
||||
case 2:
|
||||
*bits++ = qRgba(line[0], line[0], line[0], line[1]);
|
||||
break;
|
||||
case 3:
|
||||
*bits++ = qRgb(line[0], line[1], line[2]);
|
||||
break;
|
||||
case 4:
|
||||
*bits++ = qRgba(line[0], line[1], line[2], line[3]);
|
||||
break;
|
||||
for (int y = 0; y < height; y++) {
|
||||
const unsigned char* line = &bytes[width * numcomponents * (height - (y + 1))];
|
||||
for (int x = 0; x < width; x++) {
|
||||
switch (numcomponents) {
|
||||
default:
|
||||
case 1:
|
||||
*bits++ = qRgb(line[0], line[0], line[0]);
|
||||
break;
|
||||
case 2:
|
||||
*bits++ = qRgba(line[0], line[0], line[0], line[1]);
|
||||
break;
|
||||
case 3:
|
||||
*bits++ = qRgb(line[0], line[1], line[2]);
|
||||
break;
|
||||
case 4:
|
||||
*bits++ = qRgba(line[0], line[1], line[2], line[3]);
|
||||
break;
|
||||
}
|
||||
|
||||
line += numcomponents;
|
||||
@@ -667,17 +689,27 @@ void BitmapFactoryInst::convert(const SoSFImage& p, QImage& img) const
|
||||
}
|
||||
}
|
||||
|
||||
QIcon BitmapFactoryInst::mergePixmap (const QIcon &base, const QPixmap &px, Gui::BitmapFactoryInst::Position position)
|
||||
QIcon BitmapFactoryInst::mergePixmap(
|
||||
const QIcon& base,
|
||||
const QPixmap& px,
|
||||
Gui::BitmapFactoryInst::Position position
|
||||
)
|
||||
{
|
||||
QIcon overlayedIcon;
|
||||
|
||||
int w = QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize);
|
||||
|
||||
overlayedIcon.addPixmap(Gui::BitmapFactory().merge(base.pixmap(w, w, QIcon::Normal, QIcon::Off),
|
||||
px,position), QIcon::Normal, QIcon::Off);
|
||||
overlayedIcon.addPixmap(
|
||||
Gui::BitmapFactory().merge(base.pixmap(w, w, QIcon::Normal, QIcon::Off), px, position),
|
||||
QIcon::Normal,
|
||||
QIcon::Off
|
||||
);
|
||||
|
||||
overlayedIcon.addPixmap(Gui::BitmapFactory().merge(base.pixmap(w, w, QIcon::Normal, QIcon::On ),
|
||||
px,position), QIcon::Normal, QIcon::Off);
|
||||
overlayedIcon.addPixmap(
|
||||
Gui::BitmapFactory().merge(base.pixmap(w, w, QIcon::Normal, QIcon::On), px, position),
|
||||
QIcon::Normal,
|
||||
QIcon::Off
|
||||
);
|
||||
|
||||
return overlayedIcon;
|
||||
}
|
||||
@@ -686,7 +718,7 @@ qreal BitmapFactoryInst::getMaximumDPR()
|
||||
{
|
||||
qreal dpr = 1.0F;
|
||||
|
||||
for (QScreen* screen: QGuiApplication::screens()) {
|
||||
for (QScreen* screen : QGuiApplication::screens()) {
|
||||
dpr = std::max(screen->devicePixelRatio(), dpr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user