r24453 by jghali - #15294: If you change many times the color in "Insert Barcode" window, the window grows

scribus-commit scribus-commit at lists.scribus.net
Sun Feb 7 23:05:31 UTC 2021


Author: jghali
Date: Sun Feb  7 23:05:31 2021
New Revision: 24453

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24453
Log:
#15294: If you change many times the color in "Insert Barcode" window, the window grows

Modified:
    trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp

Modified: trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24453&path=/trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp	(original)
+++ trunk/Scribus/scribus/plugins/barcodegenerator/barcodegenerator.cpp	Sun Feb  7 23:05:31 2021
@@ -674,8 +674,20 @@
 
 void BarcodeGenerator::paintColorSample(QLabel *l, const ScColor & c)
 {
-	QRect rect = l->frameRect();
-	QPixmap pm(rect.width(), rect.height());
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+	QPixmap currentPixmap = l->pixmap(Qt::ReturnByValue);
+#else
+	QPixmap currentPixmap = *(l->pixmap());
+#endif
+	
+	double pixelRatio = l->devicePixelRatioF();
+	QSize pixmapSize(currentPixmap.width(), currentPixmap.height());
+	if (currentPixmap.isNull())
+	{
+		QRect rect = l->frameRect();
+		pixmapSize = QSize(rect.width() * pixelRatio, rect.height() * pixelRatio);
+	}
+	QPixmap pm(pixmapSize.width(), pixmapSize.height());
 	pm.fill(c.getRawRGBColor()); // brute force sc2qt color convert for preview
 	l->setPixmap(pm);
 }
@@ -685,6 +697,11 @@
 	ColorsAndFillsDialog d(this, &ScCore->primaryMainWindow()->doc->docGradients, ScCore->primaryMainWindow()->doc->PageColors, "", &ScCore->primaryMainWindow()->doc->docPatterns, ScCore->primaryMainWindow()->doc, ScCore->primaryMainWindow());
 	if (!d.exec())
 		return;
+
+	QString selectedColorName = d.selectedColorName();
+	if (selectedColorName == CommonStrings::None)
+		return;
+
 	bgColor = d.selectedColor();
 	ui.bgLabel->setToolTip(d.selectedColorName());
 	paintColorSample(ui.bgLabel, bgColor);
@@ -696,6 +713,11 @@
 	ColorsAndFillsDialog d(this, &ScCore->primaryMainWindow()->doc->docGradients, ScCore->primaryMainWindow()->doc->PageColors, "", &ScCore->primaryMainWindow()->doc->docPatterns, ScCore->primaryMainWindow()->doc, ScCore->primaryMainWindow());
 	if (!d.exec())
 		return;
+
+	QString selectedColorName = d.selectedColorName();
+	if (selectedColorName == CommonStrings::None)
+		return;
+
 	lnColor = d.selectedColor();
 	ui.linesLabel->setToolTip(d.selectedColorName());
 	paintColorSample(ui.linesLabel, lnColor);
@@ -707,6 +729,11 @@
 	ColorsAndFillsDialog d(this, &ScCore->primaryMainWindow()->doc->docGradients, ScCore->primaryMainWindow()->doc->PageColors, "", &ScCore->primaryMainWindow()->doc->docPatterns, ScCore->primaryMainWindow()->doc, ScCore->primaryMainWindow());
 	if (!d.exec())
 		return;
+
+	QString selectedColorName = d.selectedColorName();
+	if (selectedColorName == CommonStrings::None)
+		return;
+
 	txtColor = d.selectedColor();
 	ui.txtLabel->setToolTip(d.selectedColorName());
 	paintColorSample(ui.txtLabel, txtColor);




More information about the scribus-commit mailing list