View Issue Details

IDProjectCategoryView StatusLast Update
0017038ScribusUser Interfacepublic2023-11-17 07:50
ReporterDarkoni Assigned To 
PrioritynormalSeveritytrivialReproducibilityalways
Status newResolutionopen 
PlatformLinuxOSFedoraOS Version38
Product Version1.7.0.svn 
Summary0017038: IconManager: No icon with name 'close' in icon cache.
DescriptionWhen the Scribus is started from command line, there are see warnings about missing icons:

"IconManager: No icon with name 'close' in icon cache."
"IconManager: No icon with name 'menu-down' in icon cache."
"IconManager: No icon with name 'dock-float' in icon cache."
"IconManager: No icon with name 'page-import' in icon cache."
"IconManager: No icon with name 'page-insert' in icon cache."
"IconManager: No icon with name 'page-duplicate' in icon cache."
"IconManager: No icon with name 'page-move' in icon cache."
"IconManager: No icon with name 'layer-move-up' in icon cache."
"IconManager: No icon with name 'layer-move-down' in icon cache."

Icon id and file for each icon are described in file /trunk/Scribus/resources/iconsets/1_7_0/1_7_0.xml

<icon id="layer-move-down" file="16/object-level-down.svg" />

I check and all reported icon files are present:

folder=/usr/local/share/scribus/icons/1_7_0
ls -al $folder/16/action-close.svg
ls -al $folder/16/action-menu-down.svg
ls -al $folder/16/action-window-float.svg
ls -al $folder/16/page-import.svg
ls -al $folder/16/page-insert.svg
ls -al $folder/16/page-duplicate.svg
ls -al $folder/16/page-move.svg
ls -al $folder/16/object-level-up.svg
ls -al $folder/16/object-level-down.svg

What is wrong and can that be easily fixed?
Steps To Reproducestart Scribus from command line
TagsNo tags attached.
PatchNo

Activities

nitramr

2023-11-11 11:15

developer   ~0050436

Hi Darkoni,

please, can you check what icon theme is set in application preferences? The old icon sets below 1.7.0 don't have these icons, and you will get a warning.

Darkoni

2023-11-11 12:00

reporter   ~0050437

Hi Nitramr,

Now I switched to Theme: Fusion and Icon Set: Scribus 1.7.0
(from Icon Set: Scribus 1.5.1 Dark)

I should see that I can change Icon Set by myself...

Although the icons are too small, at least they are visible now.

Many thanks for helping me out.

Darkoni

2023-11-11 12:11

reporter   ~0050438

What has been bothering me for some time is that there is too little width in the list where the Preference groups are listed.

1. Could a larger width be set by default?

2. Or for Scribus to remember how much the user has expanded the "Preferences" window?

Both options seem very desirable to me.

See screenshots.

PS: also, sometimes (when moving the Preferences window) the color of the selected Preferences group changes, so it cannot be read. Can that be arranged?
Scribus-Preferences.png (186,176 bytes)   
Scribus-Preferences.png (186,176 bytes)   

Darkoni

2023-11-11 12:17

reporter   ~0050439

And last thing that bothers me, when I start Scribus from command line on Fedora 38, I get:

$ scribus

WARNING: YOUR CODE IS RELYING ON DEPRECATED FUNCTIONALITY IN THE JASPER
LIBRARY. THIS FUNCTIONALITY WILL BE REMOVED IN THE NEAR FUTURE. PLEASE
FIX THIS PROBLEM BEFORE YOUR CODE STOPS WORKING.
deprecation warning: use of jas_init is deprecated
warning: The application program did not set the memory limit for the JasPer library.
warning: The JasPer memory limit is being defaulted to a value that may be inappropriate for the system. If the default is too small, some reasonable encoding/decoding operations will fail. If the default is too large, security vulnerabilities will result (e.g., decoding a malicious image could exhaust all memory and crash the system.
warning: setting JasPer memory limit to 16780257280 bytes
WARNING: YOUR CODE IS RELYING ON DEPRECATED FUNCTIONALITY IN THE JASPER
LIBRARY. THIS FUNCTIONALITY WILL BE REMOVED IN THE NEAR FUTURE. PLEASE
FIX THIS PROBLEM BEFORE YOUR CODE STOPS WORKING.
deprecation warning: use of jas_cleanup is deprecated
sizeof(TrkHeader)=1000
ReaderWriterTF::writeObject

How to get rid of that warning?

Many thanks!

ale

2023-11-11 16:07

manager   ~0050440

grepping (searching of text in text files) the scribus source code for jas_init and jas_cleanup did not show any match.

it's probably a transitive dependency that will be fixed by the library used by scribus...

cbradney

2023-11-12 19:35

administrator   ~0050442

Last edited: 2023-11-12 19:36

I have checked the interface files for the preferences window and tab you showed. We are not forcing a colour, so I think its a problem with the theme you have and how it works with Qt.

I think the same for the list sizing. Its naturally larger here.. seen screenshot from a Fedora 38 VM I have

The Jasper thing must be Fedora related
image.png (101,557 bytes)   
image.png (101,557 bytes)   

Darkoni

2023-11-14 07:53

reporter   ~0050453

Hi CBradney,

On your screenshot i see nice icons - while i do not have those - only icon next to Colour Management is visible.

nitramr

2023-11-14 08:43

developer   ~0050454

@Darkoni, those icons in Craig's screenshot are from the 1.7.0 icons set. Your screenshot shows that you have selected the 1.5.1 icons. The dark icon set you selected is tinted a very light gray, which is why you don't see it in the interface. I think even if you switched to the second 1.5.1 icon set they would be more “visible”.

Darkoni

2023-11-14 12:59

reporter   ~0050457

Thanks - now everything is fine.

Maybe is there a way to control the size of icons?

To make icons a bit bigger, as on 3840 x 2160 pixels screen they look so tiny.

PS: when I am moving Properties window, the selection becomes dark blue, and then it is impossible to read a selection text.
As I already mentioned, I can live with that, but...

nitramr

2023-11-14 19:12

developer   ~0050461

Ok, I found something.

I started Scribus with an environment variable and set a scale factor (QT_SCALE_FACTOR=2) = 200%
This variable scales the whole UI by factor 2 and I recognized blurry icons. The icon manager didn't use the deviceScaleFactor correctly. The attached patch file fixes at least the render size of each icon.

@Darkoni did you set a fractional scale factor for your screens in Fedora settings? If yes, what is the factor?
imfix_2023-11-14_01.patch (709 bytes)   
Index: scribus/iconmanager.cpp
===================================================================
--- scribus/iconmanager.cpp	(Revision 25826)
+++ scribus/iconmanager.cpp	(Arbeitskopie)
@@ -394,11 +394,12 @@
 
 		QSvgRenderer svgRenderer(document.toByteArray());
 
-		QPixmap *iconPixmap = new QPixmap(svgRenderer.defaultSize());
+		QRect pxRect(0, 0, svgRenderer.defaultSize().width() * m_devicePixelRatio, svgRenderer.defaultSize().height() * m_devicePixelRatio);
+		QPixmap *iconPixmap = new QPixmap(pxRect.size());
 		iconPixmap->fill(Qt::transparent);
 
 		QPainter painter(iconPixmap);
-		svgRenderer.render(&painter);
+		svgRenderer.render(&painter, pxRect);
 		painter.end();
 
 		return iconPixmap;
imfix_2023-11-14_01.patch (709 bytes)   

cbradney

2023-11-14 21:43

administrator   ~0050463

Martin, should I commit that patch?

nitramr

2023-11-14 21:45

developer   ~0050464

@cbradney yes, please.

cbradney

2023-11-14 21:52

administrator   ~0050465

Done, r25827

Darkoni

2023-11-15 07:59

reporter   ~0050468

hi nitramr

I did not set a fractional scale factor for my screens in Fedora settings.

https://www.omglinux.com/how-to-enable-fractional-scaling-fedora/

And I am using MATE 1.26.1 Metacity (Marco), see screenfetch output

OS: Fedora 38 ThirtyEight
Kernel: x86_64 Linux 6.5.8-200.fc38.x86_64
Resolution: 7680x2160
DE: MATE 1.26.1
WM: Metacity (Marco)
WM Theme: GreenLaguna
GTK Theme: Green-Submarine [GTK2/3]
Icon Theme: menta
Font: Sans 15
CPU: AMD Ryzen 7 2700X Eight-Core @ 16x 3.7GHz
GPU: AMD Radeon RX 570 Series (polaris10, LLVM 16.0.6, DRM 3.54, 6.5.8-200.fc38.x86_64)
RAM: 25886MiB / 32005MiB

nitramr

2023-11-16 21:47

developer   ~0050475

Ok, I have an update.

Short version:
============
I rewrote some parts in the icon manager to support icon rendering in different sizes. It is tested on a Mac with retina display (2x) and on a full HD screen (1x).


Long version:
===========
Scribus has some icon size definitions in some UI widgets (scrAction for toolbar icons, prefDialog, etc.).
An icon cache is created once when the program starts. This contains all icons in their original size (e.g. 16 pixels). However, the toolbar expects 20 pixels and the settings dialog expects 32 pixels. As a result, some icons were simply displayed too small. With the current implementation, the rendered pixel graphics could only be scaled up afterwards, which led to blurring.
I implemented a new lookup table with icon meta information such as ID, color and file path. This is created instead of the cache when the program starts. When a widget requests an icon from the icon manager, it will be rendered at a specific size upon request. This is then stored in the cache. This allows the same SVG file with the same ID and color specifications to be rendered in different sizes. Now it works almost like old icon manager implementation before I implemented SVG support. Back to the roots!
fixes_2023-11-16_02.patch.txt (18,484 bytes)   
Index: scribus/iconmanager.cpp
===================================================================
--- scribus/iconmanager.cpp	(Revision 25832)
+++ scribus/iconmanager.cpp	(Arbeitskopie)
@@ -28,7 +28,6 @@
 
 #include "api/api_application.h"
 #include "iconmanager.h"
-#include "prefsmanager.h"
 #include "scpaths.h"
 
 IconManager* IconManager::m_instance = nullptr;
@@ -38,6 +37,7 @@
 {
 	m_splashScreenRect = QRect();
 	m_splashScreen = QPixmap();
+
 }
 
 IconManager& IconManager::instance()
@@ -46,10 +46,11 @@
 	return m_instance;
 }
 
-bool IconManager::setup(qreal devicePixelRatio)
+bool IconManager::setup()
 {
-	m_devicePixelRatio = devicePixelRatio;
 
+	m_devicePixelRatio = qApp->devicePixelRatio();
+
 	if (!initIconSets())
 	{
 		qWarning()<<"No icons found :(";
@@ -56,7 +57,7 @@
 		return false;
 	}
 
-	if (!createCache())
+	if (!createLookupTable())
 	{
 		qWarning()<<"Can't load icons from iconset.";
 		return false;
@@ -77,26 +78,34 @@
 
 QPixmap IconManager::loadPixmap(const QString &name, int width)
 {
-	if (m_pxCache.contains(name))
+	QString cName = buildName(name, "icon_", QString::number(width));
+
+	// Use icon from icon cache
+	if (m_pxCache.contains(cName))
+		return *m_pxCache[cName];
+
+	// Check in item cache
+	if (m_lookupTable.contains(name))
 	{
-		QPixmap pix = *m_pxCache[name];
-		if (width > -1)
-			pix = pix.scaledToWidth(width * m_devicePixelRatio, Qt::SmoothTransformation);
-		return pix;
+		Item item = m_lookupTable[name];
+		m_pxCache.insert(cName, pixmapFromFile(item.filePath, item.color, width));
+		return *m_pxCache[cName];
 	}
-	else
-	{
-		qWarning() << "IconManager: No icon with name '" + name + "' in icon cache.";
-		return QPixmap();
-	}
+
+	// Show error only if icon file doesn't exist!
+	qWarning() << QString("IconManager: No icon with name '%1' found in %2").arg(name, m_activeSetBasename) ;
+
+	return QPixmap();
 }
 
-void IconManager::addIcon(const QString &name, QPainterPath path)
+void IconManager::addIconFromPainterPath(const QString &name, QPainterPath path)
 {
-	if (!m_pxCache.contains(name))
+	QString bn = buildName(name, "path_");
+
+	if (!m_pxCache.contains(bn))
 	{
-		m_iconPaths.insert(name, &path);
-		m_pxCache.insert(name, renderPath(path));
+		m_iconPaths.insert(bn, &path);
+		m_pxCache.insert(bn, pixmapFromPainterPath(path));
 	}
 	else
 	{
@@ -114,72 +123,77 @@
 	return (baseColor().lightness() >= 128) ? true : false;
 }
 
-void IconManager::clearCache()
+void IconManager::rebuildCache()
 {
 	m_pxCache.clear();
-}
 
-void IconManager::rebuildCache()
-{
-	clearCache();
-
 	// add icons from icon set
-	if (!createCache())
+	if (!createLookupTable())
 	{
 		qWarning()<<"IconManager: Can't load icons from iconset.";
 	}
 
 	// add icons from path
-	renderIcons();
+	insertPathIconsToCache();
 }
 
-bool IconManager::createCache()
+bool IconManager::createLookupTable()
 {
-	QString iconSubdir(m_iconSets[m_activeSetBasename].path);
-	QString iconSetPath(QString("%1%2%3").arg(ScPaths::instance().iconDir(), iconSubdir, ".xml"));
-	QDomDocument document;
+		QString iconSubdir(m_iconSets[m_activeSetBasename].path);
+		QString iconSetPath(QString("%1%2%3").arg(ScPaths::instance().iconDir(), iconSubdir, ".xml"));
+		QDomDocument document;
 
-	if (!readXMLFile(iconSetPath, document, "xml"))
-		return false;
+		if (!readXMLFile(iconSetPath, document, "xml"))
+			return false;
 
-	QDomElement documentElement = document.documentElement();
-	QDomNodeList elements = documentElement.elementsByTagName( tagIcon );
+		m_lookupTable.clear();
 
-	for (int i = 0; i < elements.length(); i++)
-	{
-		QDomElement icon = elements.at(i).toElement();
+		QDomElement documentElement = document.documentElement();
+		QDomNodeList elements = documentElement.elementsByTagName( tagIcon );
 
-		QString iconPath = QString("%1%2%3").arg(ScPaths::instance().iconDir(), iconSubdir, "/" + icon.attribute("file"));
-		QString iconName = icon.attribute("id");
-		QColor iconColor = baseColor();
+		for (int i = 0; i < elements.length(); i++)
+		{
+			QDomElement icon = elements.at(i).toElement();
 
-		if (m_pxCache.contains(iconName))
-			continue;
+			QString iconPath = QString("%1%2%3").arg(ScPaths::instance().iconDir(), iconSubdir, "/" + icon.attribute("file"));
+			QString iconName = icon.attribute("id");
+			QColor iconColor = baseColor();
 
-		// if defined, override icon base color with color from iconset
-		if (iconsForDarkMode() && icon.hasAttribute(colorOnDark))
-		{
-			iconColor = parseColor(icon.attribute(colorOnDark));
+			if (m_lookupTable.contains(iconName))
+				continue;
+
+			// if defined, override icon base color with color from iconset
+			if (iconsForDarkMode() && icon.hasAttribute(colorOnDark))
+			{
+				iconColor = parseColor(icon.attribute(colorOnDark));
+			}
+			else if (!iconsForDarkMode() && icon.hasAttribute(colorOnLight))
+			{
+				iconColor = parseColor(icon.attribute(colorOnLight));
+			}
+
+			Item item;
+			item.name = iconName;
+			item.filePath = iconPath;
+			item.color = iconColor;
+
+			m_lookupTable.insert(iconName, item);
 		}
-		else if (!iconsForDarkMode() && icon.hasAttribute(colorOnLight))
-		{
-			iconColor = parseColor(icon.attribute(colorOnLight));
-		}
 
-		m_pxCache.insert(iconName, initPixmap(iconPath, iconColor));
-	}
-
-	return true;
+		return true;
 }
 
-void IconManager::renderIcons()
+void IconManager::insertPathIconsToCache()
 {
 	QMapIterator<QString, QPainterPath*> i(m_iconPaths);
 	while (i.hasNext())
 	{
 		i.next();
-		if (!m_pxCache.contains(i.key()))
-			m_pxCache.insert(i.key(), renderPath(*i.value()));
+
+		QString bn = buildName(i.key(), "path_");
+
+		if (!m_pxCache.contains(bn))
+			m_pxCache.insert(bn, pixmapFromPainterPath(*i.value()));
 	}
 }
 
@@ -206,7 +220,7 @@
 	{
 		QString styleImport = nodeStyle.childNodes().at(0).toText().data();
 
-		QRegularExpression rx_css("(.*?@import.*?')(.*?)('.*)");
+		static QRegularExpression rx_css("(.*?@import.*?')(.*?)('.*)");
 		QRegularExpressionMatch mImport = rx_css.match(styleImport);
 
 		// Check if stylesheet import is available
@@ -268,12 +282,12 @@
 	}
 
 	// Remove C-style comments /* */ or // from stylesheet
-	QRegularExpression rx_comments("(\\/\\*[\\s\\S]*?(.*?)\\*\\/)|(\\/\\/.*)");
+	static QRegularExpression rx_comments("(\\/\\*[\\s\\S]*?(.*?)\\*\\/)|(\\/\\/.*)");
 	styleString.remove(rx_comments);
 
 	// Group 1: tags, like ".onDark .success"
 	// Group 2: strings within {}
-	QRegularExpression rx_Settings("(.*?)\\s*{([^\\}]+)}");
+	static QRegularExpression rx_Settings("(.*?)\\s*{([^\\}]+)}");
 	QRegularExpressionMatchIterator i = rx_Settings.globalMatch(styleString);
 
 	while (i.hasNext())
@@ -287,7 +301,7 @@
 {
 	if (str.startsWith("rgba"))
 	{
-		QRegularExpression rx_rgba("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
+		static QRegularExpression rx_rgba("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
 		QRegularExpressionMatch mRGBA = rx_rgba.match(str);
 
 		if (mRGBA.hasMatch())
@@ -302,7 +316,7 @@
 	}
 	else if (str.startsWith("rgb"))
 	{
-		QRegularExpression rx_rgb("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
+		static QRegularExpression rx_rgb("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
 		QRegularExpressionMatch mRGB = rx_rgb.match(str);
 
 		if (mRGB.hasMatch())
@@ -316,7 +330,7 @@
 	}
 	else if (str.startsWith("hsva"))
 	{
-		QRegularExpression rx_hsva("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
+		static QRegularExpression rx_hsva("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
 		QRegularExpressionMatch mHSVA = rx_hsva.match(str);
 
 		if (mHSVA.hasMatch())
@@ -331,7 +345,7 @@
 	}
 	else if (str.startsWith("hsv"))
 	{
-		QRegularExpression rx_hsv("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
+		static QRegularExpression rx_hsv("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
 		QRegularExpressionMatch mHSV = rx_hsv.match(str);
 
 		if (mHSV.hasMatch())
@@ -345,7 +359,7 @@
 	}
 	else if (str.startsWith("hsla"))
 	{
-		QRegularExpression rx_hsla("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
+		static QRegularExpression rx_hsla("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
 		QRegularExpressionMatch mHSLA = rx_hsla.match(str);
 
 		if (mHSLA.hasMatch())
@@ -360,7 +374,7 @@
 	}
 	else if (str.startsWith("hsl"))
 	{
-		QRegularExpression rx_hsl("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
+		static QRegularExpression rx_hsl("\\(\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*,\\s*(\\d{1,3})\\s*\\)");
 		QRegularExpressionMatch mHSL = rx_hsl.match(str);
 
 		if (mHSL.hasMatch())
@@ -373,7 +387,7 @@
 	}
 	else
 	{
-		QRegularExpression rx("#?[0-9A-Fa-f]+");
+		static QRegularExpression rx("#?[0-9A-Fa-f]+");
 		QRegularExpressionMatch mHex = rx.match(str);
 
 		if (mHex.hasMatch())
@@ -382,10 +396,9 @@
 	return QColor();
 }
 
-QPixmap *IconManager::initPixmap(const QString filePath, QColor color)
+QPixmap *IconManager::pixmapFromFile(const QString filePath, QColor color, int width)
 {
 	QDomDocument document;
-
 	// Load SVG file
 	if (readXMLFile(filePath, document, "svg"))
 	{
@@ -394,24 +407,29 @@
 
 		QSvgRenderer svgRenderer(document.toByteArray());
 
-		QRect pxRect(0, 0, svgRenderer.defaultSize().width() * m_devicePixelRatio, svgRenderer.defaultSize().height() * m_devicePixelRatio);
-		QPixmap *iconPixmap = new QPixmap(pxRect.size());
+		QSize size = svgRenderer.defaultSize();
+		QPixmap *iconPixmap = new QPixmap(size * m_devicePixelRatio);
+		if (width > -1)
+		{
+			iconPixmap = new QPixmap(iconPixmap->scaledToWidth(width * m_devicePixelRatio, Qt::SmoothTransformation));
+			size = iconPixmap->size() / m_devicePixelRatio;
+		}
+		iconPixmap->setDevicePixelRatio(m_devicePixelRatio);
 		iconPixmap->fill(Qt::transparent);
 
 		QPainter painter(iconPixmap);
-		svgRenderer.render(&painter, pxRect);
+		svgRenderer.render(&painter, QRect(QPoint(0, 0), size));
 		painter.end();
 
 		return iconPixmap;
 	}
+
 	// Load any other file format
-	else
-	{
-		return new QPixmap(filePath);
-	}
+	return new QPixmap(filePath);
+
 }
 
-QPixmap *IconManager::renderPath(QPainterPath path)
+QPixmap *IconManager::pixmapFromPainterPath(QPainterPath path)
 {
 	QSize size(path.boundingRect().width(), path.boundingRect().height());
 	QPixmap pixmap(size);
@@ -426,40 +444,20 @@
 	return new QPixmap(pixmap);
 }
 
-bool IconManager::readXMLFile(QString filePath, QDomDocument &document, QString fileExtension)
+QString IconManager::buildName(const QString &name, const QString &prefix, const QString &suffix) const
 {
+	return prefix + name + suffix;
+}
 
-//    QFileInfo file(filePath);
-//    QFile dataFile(file.absoluteFilePath());
-//    if (!dataFile.exists())
-//        return false;
-//    if (!dataFile.open(QIODevice::ReadOnly))
-//        return false;
-//    QTextStream ts(&dataFile);
-//    ts.setEncoding(QStringConverter::Utf8); // --> Qt6
-//    //ts.setCodec(QTextCodec::codecForName("UTF-8")); // --> Qt5
-//    QString errorMsg;
-//    int eline;
-//    int ecol;
-//    document = QDomDocument( QString(file.baseName()));
-//    QString data(ts.readAll());
-//    dataFile.close();
 
-//    if (!document.setContent( data, &errorMsg, &eline, &ecol))
-//    {
-//        qDebug()<<data<<errorMsg<<eline<<ecol;
-//        if (data.contains("404 not found", Qt::CaseInsensitive))
-//            qDebug()<<"File not found on server";
-//        else
-//            qDebug()<<"Could not open file"<<dataFile.fileName();
-//        return false;
-//    }
 
-//    return true;
-
+bool IconManager::readXMLFile(QString filePath, QDomDocument &document, QString fileExtension)
+{
 	QFileInfo fileInfo(filePath);
 	if (fileInfo.completeSuffix() != fileExtension)
+	{
 		return false;
+	}
 
 	QFile inFile( filePath );
 	if (!inFile.open(QIODevice::ReadOnly | QIODevice::Text))
@@ -479,14 +477,6 @@
 	return true;
 }
 
-//void IconManager::tintPixmap(QPixmap &pixmap, QColor color)
-//{
-//    //QPixmap pm = pixmap;
-//    QPainter painter(&pixmap);
-//    painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
-//    painter.fillRect(pixmap.rect(), color);
-//    painter.end();
-//}
 
 bool IconManager::initIconSets()
 {
@@ -644,13 +634,16 @@
 	if (QFile::exists(iconFilePath))
 		return iconFilePath;
 
-	QString iconFilePath2(QString("%1%2%3").arg(ScPaths::instance().iconDir(), primaryIconSubdir, name));
-	if (QFile::exists(iconFilePath2))
-		return iconFilePath2;
+	qWarning("pathForIcon: Unable to load icon %s: File not found", iconFilePath.toLatin1().constData());
+	iconFilePath = QString("%1%2%3").arg(ScPaths::instance().iconDir(), primaryIconSubdir, name);
 
+	if (QFile::exists(iconFilePath))
+	{
+		return iconFilePath;
+	}
+#ifdef WANT_DEBUG
 	qWarning("pathForIcon: Unable to load icon %s: File not found", iconFilePath.toLatin1().constData());
-	qWarning("pathForIcon: Unable to load icon %s: File not found", iconFilePath2.toLatin1().constData());
-
+#endif
 	return QString();
 }
 
Index: scribus/iconmanager.h
===================================================================
--- scribus/iconmanager.h	(Revision 25832)
+++ scribus/iconmanager.h	(Arbeitskopie)
@@ -46,18 +46,15 @@
 	void setIconsForDarkMode(bool forDarkMode);
 	QColor baseColor() const;
 	bool iconsForDarkMode() const;
+	bool setup();
 
-	void clearCache();
 	void rebuildCache();
-	bool createCache();
 
-	bool setup(qreal devicePixelRatio);
-
 	QCursor loadCursor(const QString& name, int hotX = -1, int hotY = -1, int width = -1);
 	QIcon loadIcon(const QString& name, int width = -1);
 	QPixmap loadPixmap(const QString& name, int width = -1);
 
-	void addIcon(const QString & name, QPainterPath path);
+	void addIconFromPainterPath(const QString & name, QPainterPath path);
 
 	bool setActiveFromPrefs(const QString& prefsSet);
 	QString activeSetBasename() { return m_activeSetBasename; }
@@ -76,6 +73,12 @@
 
 private:
 
+	struct Item {
+		QString name;
+		QColor color;
+		QString filePath;
+	};
+
 	IconManager(QObject *parent = nullptr);
 	~IconManager() = default;
 
@@ -83,6 +86,7 @@
 
 	QMap<QString, ScIconSetData> m_iconSets;
 	QMap<QString, QPainterPath*> m_iconPaths;
+	QMap<QString, Item> m_lookupTable;
 	ScPixmapCache<QString> m_pxCache;
 	QString m_activeSetBasename;
 	QString m_activeSetVersion;
@@ -93,15 +97,16 @@
 	qreal m_devicePixelRatio { 1.0 };
 
 	bool initIconSets();
-	void readIconConfigFiles();
+	bool createLookupTable();
+	bool readXMLFile(QString filePath, QDomDocument &document, QString fileExtension);
 
-	QPixmap *initPixmap(const QString filePath, QColor color);
-	QPixmap *renderPath(QPainterPath path);
-	void renderIcons();
+	QPixmap *pixmapFromFile(const QString filePath, QColor color, int width = -1);
+	QPixmap *pixmapFromPainterPath(QPainterPath path);
 
-	bool readXMLFile(QString filePath, QDomDocument &document, QString fileExtension);
-//    void tintPixmap(QPixmap &pixmap, QColor color);
+	QString buildName(const QString &name, const QString &prefix = "", const QString &suffix = "") const;
 
+	void insertPathIconsToCache();
+	void readIconConfigFiles();
 	void applyColors(QDomDocument &doc, QString fileName, QColor color);
 	void applyInlineStyleToElement(const QDomElement &elem, QMap<QString, QString> *styles);
 	void parseStyleSheet(QString styleString, QMap<QString, QString> *styles);
Index: scribus/scraction.cpp
===================================================================
--- scribus/scraction.cpp	(Revision 25832)
+++ scribus/scraction.cpp	(Arbeitskopie)
@@ -283,7 +283,7 @@
 
 	if (!m_iconPath16.isEmpty())
 	{
-		QPixmap pix = iconManager.loadPixmap(m_iconPath16);
+		QPixmap pix = iconManager.loadPixmap(m_iconPath16, 16);
 		if (!pix.isNull())
 			newIcon.addPixmap(pix, QIcon::Normal, QIcon::On);
 	}
@@ -290,7 +290,7 @@
 
 	if (!m_iconPath22.isEmpty())
 	{
-		QPixmap pix = iconManager.loadPixmap(m_iconPath22);
+		QPixmap pix = iconManager.loadPixmap(m_iconPath22, 20);
 		if (!pix.isNull())
 			newIcon.addPixmap(pix, QIcon::Normal, QIcon::On);
 	}
Index: scribus/scribusapp.cpp
===================================================================
--- scribus/scribusapp.cpp	(Revision 25832)
+++ scribus/scribusapp.cpp	(Arbeitskopie)
@@ -561,7 +561,8 @@
 void ScribusQApp::changeIconSet(const QString& newIconSet)
 {
 	IconManager& iconManager = IconManager::instance();
-	iconManager.clearCache();
+	//iconManager.clearCache();
+	iconManager.rebuildCache();
 	iconManager.setActiveFromPrefs(newIconSet);
 	emit iconSetChanged();
 }
Index: scribus/scribuscore.cpp
===================================================================
--- scribus/scribuscore.cpp	(Revision 25832)
+++ scribus/scribuscore.cpp	(Arbeitskopie)
@@ -178,8 +178,7 @@
 	CommonStrings::languageChange();
 	LanguageManager::instance()->languageChange();
 
-	qreal devicePixelRatio = QApplication::primaryScreen()->devicePixelRatio();
-	if (!m_iconManager.setup(devicePixelRatio))
+	if (!m_iconManager.setup())
 		return EXIT_FAILURE;
 
 	// FIXME: Splash needs the prefs loaded by initDefaults() to know if it must force the image to grayscale
Index: scribus/ui/preferencesdialog.cpp
===================================================================
--- scribus/ui/preferencesdialog.cpp	(Revision 25832)
+++ scribus/ui/preferencesdialog.cpp	(Arbeitskopie)
@@ -239,7 +239,7 @@
 	preferencesTypeList->setDragEnabled(false);
 	preferencesTypeList->setViewMode(QListView::ListMode);
 	preferencesTypeList->setFlow(QListView::TopToBottom);
-	preferencesTypeList->setIconSize(QSize(32,32));
+	preferencesTypeList->setIconSize(QSize(16,16));
 	preferencesTypeList->setSortingEnabled(false);
 	preferencesTypeList->setWrapping(false);
 	preferencesTypeList->setWordWrap(true);
@@ -255,7 +255,7 @@
 void PreferencesDialog::addWidget(Prefs_Pane* tab)
 {
 	//TODO: Can we avoid using this name and duplicating strings by getting it from the tab UIs
-	QListWidgetItem* newItem = new QListWidgetItem(IconManager::instance().loadIcon(tab->icon()), tab->caption(), preferencesTypeList);
+	QListWidgetItem* newItem = new QListWidgetItem(IconManager::instance().loadIcon(tab->icon(), 16), tab->caption(), preferencesTypeList);
 	newItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
 	int i = prefsStackWidget->addWidget(tab);
 	stackWidgetMap.insert(newItem, i);

fixes_2023-11-16_02.patch.txt (18,484 bytes)   
unnamed.png (702,555 bytes)   
unnamed.png (702,555 bytes)   

ale

2023-11-17 06:40

manager   ~0050477

Last edited: 2023-11-17 07:50

nice, thanks!
the icons at the top of the text properties palette were blurring me a bit...

Issue History

Date Modified Username Field Change
2023-11-02 08:48 Darkoni New Issue
2023-11-11 11:15 nitramr Note Added: 0050436
2023-11-11 11:15 nitramr File Added: Bildschirmfoto vom 2023-11-11 12-11-59.png
2023-11-11 12:00 Darkoni Note Added: 0050437
2023-11-11 12:11 Darkoni Note Added: 0050438
2023-11-11 12:11 Darkoni File Added: Scribus-Theme-Fusion-Icon-Set-Scribus-1-7-0.png
2023-11-11 12:11 Darkoni File Added: Scribus-Theme-Fusion-Icon-Set-Scribus-1-5-1-Dark.png
2023-11-11 12:11 Darkoni File Added: Scribus-Preferences.png
2023-11-11 12:11 Darkoni File Added: Scribus-Preferences-unreadable-color.png
2023-11-11 12:17 Darkoni Note Added: 0050439
2023-11-11 16:07 ale Note Added: 0050440
2023-11-12 19:35 cbradney Note Added: 0050442
2023-11-12 19:35 cbradney File Added: image.png
2023-11-12 19:36 cbradney Note Edited: 0050442
2023-11-14 07:53 Darkoni Note Added: 0050453
2023-11-14 08:43 nitramr Note Added: 0050454
2023-11-14 12:59 Darkoni Note Added: 0050457
2023-11-14 12:59 Darkoni File Added: Scribus - Preferences - User Interface.png
2023-11-14 19:12 nitramr Note Added: 0050461
2023-11-14 19:12 nitramr File Added: imfix_2023-11-14_01.patch
2023-11-14 21:43 cbradney Note Added: 0050463
2023-11-14 21:45 nitramr Note Added: 0050464
2023-11-14 21:52 cbradney Note Added: 0050465
2023-11-15 07:59 Darkoni Note Added: 0050468
2023-11-16 21:47 nitramr Note Added: 0050475
2023-11-16 21:47 nitramr File Added: fixes_2023-11-16_02.patch.txt
2023-11-16 21:47 nitramr File Added: unnamed.png
2023-11-17 06:40 ale Note Added: 0050477
2023-11-17 07:50 ale Note Edited: 0050477