View Issue Details

IDProjectCategoryView StatusLast Update
0017283ScribusGeneralpublic2024-10-07 05:25
Reporternitramr Assigned Tonitramr  
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
PlatformDesktop PCOSUbuntuOS Version24.04 64-bit
Product Version1.7.0.svn 
Target Version1.7.0Fixed in Version1.7.0.svn 
Summary0017283: Fixes for UI widgets
DescriptionThe attached patch includes the following fixes and improvements:

1. Switch
- Bug fix: toggle animation was strangely interrupted when toggle state changed during the animation

2. FontListModel
- Bug fix: Scribus crashes if font.scName is empty

3. IconManager
- Improvement: support for non-squared icons/images
- Improvement: Non-squared images have an auto aspect ratio scaling if one size is invalid (-1) or not specified

4. ColorListBox
- Bug fix: color box border was always black, even on dark UI. Now it uses the window text color

5. FormWidget
- Improvement: Support for Icon and Label at the same time
- Improvement: Separate position and visibility setting for the icon

6. SectionContainer
- Improvement: New configurable header style and size available
TagsNo tags attached.
PatchYes

Activities

nitramr

2024-10-04 21:31

developer  

fixes_2024-10-04_01.patch (24,779 bytes)   
Index: scribus/ui/widgets/switch.cpp
===================================================================
--- scribus/ui/widgets/switch.cpp	(Revision 26312)
+++ scribus/ui/widgets/switch.cpp	(Arbeitskopie)
@@ -64,16 +64,14 @@
 
 void Switch::animate(bool toggled)
 {
+	m_anim->stop();
+	m_anim->setDuration(120);
+	m_anim->setStartValue(position());
+
 	if (toggled)
-	{
-		m_anim->setStartValue(m_margin + m_radius);
 		m_anim->setEndValue(width() - m_radius - m_margin);
-	}
 	else
-	{
-		m_anim->setStartValue(position());
 		m_anim->setEndValue(m_margin + m_radius);
-	}
-	m_anim->setDuration(120);
+
 	m_anim->start();
 }
 Index: scribus/fontlistmodel.cpp
===================================================================
--- scribus/fontlistmodel.cpp	(Revision 26312)
+++ scribus/fontlistmodel.cpp	(Arbeitskopie)
@@ -198,6 +198,8 @@
 			case FontListModel::FontFile:
 				return font.fontPath();
 			case FontListModel::SortIndex:
+				if (font.scName().isEmpty())
+					return font.scName();
 				if (font.scName().at(0) == QChar('.'))
 					return font.scName().mid(1).toLower();
 				return font.scName().toLower();
Index: scribus/iconmanager.cpp
===================================================================
--- scribus/iconmanager.cpp	(Revision 26312)
+++ scribus/iconmanager.cpp	(Arbeitskopie)
@@ -81,10 +81,20 @@
 	return QIcon(loadPixmap(name, width));
 }
 
+QIcon IconManager::loadIcon(const QString &name, QSize size)
+{
+	return QIcon(loadPixmap(name, size));
+}
+
 QPixmap IconManager::loadPixmap(const QString &name, int width)
 {
-	QString cName = buildName(name, "icon_", QString::number(width));
+	return loadPixmap(name, QSize(width, width));
+}
 
+QPixmap IconManager::loadPixmap(const QString &name, QSize size)
+{
+	QString cName = buildName(name, "icon_", QString::number(size.width()) + "_" + QString::number(size.height()));
+
 	// Use icon from icon cache
 	if (m_pxCache.contains(cName))
 		return *m_pxCache[cName];
@@ -93,7 +103,7 @@
 	if (m_lookupTable.contains(name))
 	{
 		Item item = m_lookupTable[name];
-		m_pxCache.insert(cName, pixmapFromFile(item.filePath, item.color, width));
+		m_pxCache.insert(cName, pixmapFromFile(item.filePath, item.color, size));
 		return *m_pxCache[cName];
 	}
 
@@ -422,7 +432,7 @@
 }
 #endif
 
-QPixmap *IconManager::pixmapFromFile(const QString filePath, QColor color, int width)
+QPixmap *IconManager::pixmapFromFile(const QString filePath, QColor color, QSize size)
 {
 	QDomDocument document;
 	// Load SVG file
@@ -433,13 +443,37 @@
 
 		QSvgRenderer svgRenderer(document.toByteArray());
 
-		QSize size = (width > -1) ? QSize(width, width) : svgRenderer.defaultSize();
-		QPixmap *iconPixmap = new QPixmap(size * m_devicePixelRatio);
+		double svgWidth = svgRenderer.defaultSize().width();
+		double svgHeight = svgRenderer.defaultSize().height();
+		double width = (size.width() > 0) ?  size.width() : svgWidth;
+		double height = (size.height() > 0) ?  size.height() : svgHeight;
+
+		QSize newSize(QSize(width, height));
+
+		// invalid width
+		if (size.width() < 1)
+		{
+			double scaleFactor = (svgHeight > height) ? svgHeight / height : height / svgHeight;
+			newSize.setWidth(svgWidth * scaleFactor);
+		}
+
+		// invalid height
+		if (size.height() < 1)
+		{
+			double scaleFactor = (svgWidth > width) ? svgWidth / width : width / svgWidth;
+			newSize.setHeight(svgHeight * scaleFactor);
+		}
+
+		// something goes wrong and we fallback to original SVG size
+		if (!newSize.isValid())
+			newSize = svgRenderer.defaultSize();
+
+		QPixmap *iconPixmap = new QPixmap(newSize * m_devicePixelRatio);
 		iconPixmap->setDevicePixelRatio(m_devicePixelRatio);
 		iconPixmap->fill(Qt::transparent);
 
 		QPainter painter(iconPixmap);
-		svgRenderer.render(&painter, QRect(QPoint(0, 0), size));
+		svgRenderer.render(&painter, QRect(QPoint(0, 0), newSize));
 		painter.end();
 
 		return iconPixmap;
@@ -452,8 +486,9 @@
 
 QPixmap *IconManager::pixmapFromPainterPath(QPainterPath path)
 {
-	QSize size(path.boundingRect().width(), path.boundingRect().height());
-	QPixmap pixmap(size);
+	QSize size(path.boundingRect().size().toSize());
+	QPixmap pixmap(size * m_devicePixelRatio);
+	pixmap.setDevicePixelRatio(m_devicePixelRatio);
 	pixmap.fill(Qt::transparent);
 	QPainter painter(&pixmap);
 	painter.setRenderHint(QPainter::Antialiasing, true);
Index: scribus/iconmanager.h
===================================================================
--- scribus/iconmanager.h	(Revision 26312)
+++ scribus/iconmanager.h	(Arbeitskopie)
@@ -52,7 +52,9 @@
 
 	QCursor loadCursor(const QString& name, int hotX = -1, int hotY = -1, int width = -1);
 	QIcon loadIcon(const QString& name, int width = -1);
+	QIcon loadIcon(const QString& name, QSize size);
 	QPixmap loadPixmap(const QString& name, int width = -1);
+	QPixmap loadPixmap(const QString& name, QSize size);
 
 	void addIconFromPainterPath(const QString & name, QPainterPath path);
 
@@ -100,7 +102,7 @@
 	bool createLookupTable();
 	bool readXMLFile(QString filePath, QDomDocument &document, QString fileExtension);
 
-	QPixmap *pixmapFromFile(const QString filePath, QColor color, int width = -1);
+	QPixmap *pixmapFromFile(const QString filePath, QColor color, QSize size);
 	QPixmap *pixmapFromPainterPath(QPainterPath path);
 
 	QString buildName(const QString &name, const QString &prefix = "", const QString &suffix = "") const;
Index: scribus/ui/colorlistbox.cpp
===================================================================
--- scribus/ui/colorlistbox.cpp	(Revision 26312)
+++ scribus/ui/colorlistbox.cpp	(Arbeitskopie)
@@ -26,6 +26,7 @@
 #include "scribusapp.h"
 #include "scribusdoc.h"
 #include "util_color.h"
+#include "util_gui.h"
 
 class SCRIBUS_API ColorSmallItemDelegate : public ScListBoxPixmap<15, 15>
 {
@@ -79,12 +80,8 @@
 	{
 		ColorPixmapValue item(data.value<ColorPixmapValue>());
 		QColor rgb = ScColorEngine::getDisplayColor(item.m_color, item.m_doc);
-		pPixmap->fill(rgb);
 		QPainter painter(pPixmap);
-		painter.setBrush(Qt::NoBrush);
-		QPen b(Qt::black, 1);
-		painter.setPen(b);
-		painter.drawRect(0, 0, 15, 15);
+		drawColorBox(&painter, QRect(0, 0, pPixmap->width(), pPixmap->height()), rgb);
 		painter.end();
 	}
 }
@@ -97,7 +94,9 @@
 	{
 		ColorPixmapValue item(data.value<ColorPixmapValue>());
 		QColor rgb = ScColorEngine::getDisplayColor(item.m_color, item.m_doc);
-		pPixmap->fill(rgb);
+		QPainter painter(pPixmap);
+		drawColorBox(&painter, QRect(0, 0, pPixmap->width(), pPixmap->height()), rgb);
+		painter.end();
 	}
 }
 
@@ -110,15 +109,10 @@
 
 	if (data.canConvert<ColorPixmapValue>())
 	{
-		ColorPixmapValue item(data.value<ColorPixmapValue>());
-		
+		ColorPixmapValue item(data.value<ColorPixmapValue>());		
 		QColor rgb = ScColorEngine::getDisplayColor(item.m_color, item.m_doc);
-		smallPix.fill(rgb);
 		QPainter painter(&smallPix);
-		painter.setBrush(Qt::NoBrush);
-		QPen b(Qt::black, 1);
-		painter.setPen(b);
-		painter.drawRect(0, 0, 15, 15);
+		drawColorBox(&painter, QRect(0, 0, smallPix.width(), smallPix.height()), rgb);
 		painter.end();
 		
 		paintAlert(smallPix, *pPixmap, 0, 0);
 	Index: scribus/ui/widgets/form_widget.cpp
===================================================================
--- scribus/ui/widgets/form_widget.cpp	(Revision 26312)
+++ scribus/ui/widgets/form_widget.cpp	(Arbeitskopie)
@@ -12,11 +12,9 @@
 FormWidget::FormWidget(QWidget *parent)
 	: QWidget(parent)
 {
-	QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Minimum);
 	m_font = this->font();
-	m_devicePixelRatio = qApp->devicePixelRatio();
 
-	setSizePolicy(policy);
+	setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
 	calculateFrame();
 
 }
@@ -29,8 +27,13 @@
 
 QSize FormWidget::minimumSizeHint() const
 {
-	int w = 0, h = 0;
-	labelSize(w,h);
+	int l = 0;
+	int t = 0;
+	int r = 0;
+	int b = 0;
+	int w = 0;
+	int h = 0;
+	labelSize(l, t, r, b, w, h);
 
 	return QSize(w, h).expandedTo(QWidget::minimumSizeHint());
 }
@@ -43,26 +46,15 @@
 
 void FormWidget::calculateFrame()
 {
+	int l = 0;
+	int t = 0;
+	int r = 0;
+	int b = 0;
+	int w = 0;
+	int h = 0;
+	labelSize(l, t, r, b, w, h);
+	setContentsMargins(l, t, r, b);
 
-	int w, h;
-	labelSize(w,h);
-
-	switch (m_position)
-	{
-		case Left:
-			setContentsMargins(w, 0, 0, 0);
-			break;
-		case Right:
-			setContentsMargins(0, 0, w, 0);
-			break;
-		case Top:
-			setContentsMargins(0, h, 0, 0);
-			break;
-		case Bottom:
-			setContentsMargins(0, 0, 0, h);
-			break;
-	}
-
 	update();
 }
 
@@ -71,7 +63,7 @@
 	m_shortcutId = 0;
 	m_hasShortcut = false;
 
-	if (hasPixmap() || m_label.isEmpty() || m_labelVisibility == false)
+	if (m_label.isEmpty() || m_labelVisibility == false)
 		return;
 
 	if (!m_label.contains(QLatin1Char('&')))
@@ -93,7 +85,7 @@
 {
 	QWidget::paintEvent(e);
 
-	if (!labelVisibility()) return;
+	if (!labelVisibility() && !iconVisibility()) return;
 
 	QPainter painter(this);
 	painter.setRenderHint(QPainter::Antialiasing, true);
@@ -111,67 +103,85 @@
 	painter.setPen(pen);
 	painter.setFont(tmpFont);
 
-	QRect r = rect();
+	QRect rLabel = rect();
+	QRect rIcon = rect();
 	QPixmap pix = m_pixmap;
+	pix.setDevicePixelRatio(devicePixelRatio());
+	QRect rWidgets = contentsRect();
 
-	if (hasPixmap() && pix.size() != m_pixmapSize)
-		pix = pix.scaled(m_pixmapSize * m_devicePixelRatio, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+	// painter.setBrush(Qt::NoBrush);
+	// painter.setPen(Qt::magenta);
+	// painter.drawRect(rect());
+	// painter.setPen(Qt::blue);
+	// painter.drawRect(rWidgets);
 
+	if (canUsePixmap() && pix.size() != m_pixmapSize)
+		pix = pix.scaled(m_pixmapSize * devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+
 	if (!isEnabled())
 		pix = style->generatedIconPixmap(QIcon::Disabled, pix, &opt);
 
+	if (canUsePixmap())
+	{
+		rIcon = QRect(0, 0, m_pixmap.deviceIndependentSize().width(), m_pixmap.deviceIndependentSize().height());
+		rIcon.moveCenter(rWidgets.center());
 
-	switch (m_position){
-	case Left:
-		if (hasPixmap())
-		{
-			r= QRect (0, (height() - m_pixmap.height()) / 2, m_pixmap.width(), m_pixmap.height());
-			style->drawItemPixmap(&painter, r, align, pix);
-
+		switch (m_iconPosition){
+		default:
+		case Left:
+			rIcon.moveLeft(0);
+			rLabel = rLabel.adjusted(rIcon.width() + m_space, 0, 0, 0);
+			break;
+		case Right:
+			rIcon.moveRight(width());
+			rLabel = rLabel.adjusted(0, 0, -rIcon.width() - m_space, 0);
+			break;
+		case Top:
+			rIcon.moveTop(0);
+			rLabel = rLabel.adjusted(0, rIcon.height() + m_space, 0, 0);
+			break;
+		case Bottom:
+			rIcon.moveBottom(height());
+			rLabel = rLabel.adjusted(0, 0, 0, -rIcon.height() - m_space);
+			break;
 		}
-		else
-			style->drawItemText(&painter, r, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, opt.palette, isEnabled(), m_label, foregroundRole());
 
-		break;
-	case Right:
-		if (hasPixmap())
-		{
-			r= QRect (width() - m_pixmap.width(), (height() - m_pixmap.height()) / 2, m_pixmap.width(), m_pixmap.height());
-			style->drawItemPixmap(&painter, r, align, pix);
-		}
-		else
-			style->drawItemText(&painter, r, Qt::AlignRight | Qt::AlignVCenter | Qt::TextShowMnemonic, opt.palette, isEnabled(), m_label, foregroundRole());
+		style->drawItemPixmap(&painter, rIcon, align, pix);
 
-		break;
-	case Top:
-		if (hasPixmap())
-		{
-			r= QRect ((width() - m_pixmap.width()) / 2, 0, m_pixmap.width(), m_pixmap.height());
-			style->drawItemPixmap(&painter, r, align, pix);
-		}
-		else
-			style->drawItemText(&painter, r, Qt::AlignHCenter | Qt::AlignTop | Qt::TextShowMnemonic, opt.palette, isEnabled(), m_label, foregroundRole());
+		// painter.setBrush(Qt::NoBrush);
+		// painter.setPen(Qt::red);
+		// painter.drawRect(rIcon);
+	}
 
-		break;
-	case Bottom:
-		if (hasPixmap())
-		{
-			r= QRect ((width() - m_pixmap.width()) / 2, height() - m_pixmap.height(), m_pixmap.width(), m_pixmap.height());
-			style->drawItemPixmap(&painter, r, align, pix);
+	if (canUseLabel())
+	{
+		switch (m_position){
+		case Left:
+			style->drawItemText(&painter, rLabel, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, opt.palette, isEnabled(), m_label, foregroundRole());
+			break;
+		case Right:
+			style->drawItemText(&painter, rLabel, Qt::AlignRight | Qt::AlignVCenter | Qt::TextShowMnemonic, opt.palette, isEnabled(), m_label, foregroundRole());
+			break;
+		case Top:
+			style->drawItemText(&painter, rLabel, Qt::AlignHCenter | Qt::AlignTop | Qt::TextShowMnemonic, opt.palette, isEnabled(), m_label, foregroundRole());
+			break;
+		case Bottom:
+			style->drawItemText(&painter, rLabel, Qt::AlignHCenter | Qt::AlignBottom | Qt::TextShowMnemonic, opt.palette, isEnabled(), m_label, foregroundRole());
+			break;
 		}
-		else
-			style->drawItemText(&painter, r, Qt::AlignHCenter | Qt::AlignBottom | Qt::TextShowMnemonic, opt.palette, isEnabled(), m_label, foregroundRole());
 
-		break;
+		// painter.setBrush(Qt::NoBrush);
+		// painter.setPen(Qt::green);
+		// painter.drawRect(rLabel);
 	}
 
 }
 
 bool FormWidget::event(QEvent *e)
-{
-	QEvent::Type type = e->type();
+{	
 
 #ifndef EXCLUDE_FOR_DESIGNER_PLUGIN
+	QEvent::Type type = e->type();
 	if (type == QEvent::Shortcut && this->layout()->count() > 0) {
 		QShortcutEvent *se = static_cast<QShortcutEvent *>(e);
 		if (se->shortcutId() == m_shortcutId) {
@@ -243,53 +253,89 @@
  * ********************************************************************************* */
 
 
-void FormWidget::labelSize(int &w, int &h) const
+void FormWidget::labelSize(int &l, int &t, int &r, int &b, int &w, int &h) const
 {   
+	l = 0;
+	t = 0;
+	r = 0;
+	b = 0;
 	w = 0;
 	h = 0;
 
-	if (hasPixmap())
+	if (canUsePixmap())
 	{
-        	w = m_pixmapSize.width() * m_devicePixelRatio + m_space;
-        	h = m_pixmapSize.height() * m_devicePixelRatio + m_space;
-	}
-	else
-	{
+		int iconWidth = m_pixmapSize.width() + m_space;
+		int iconHeight = m_pixmapSize.height() + m_space;
 
-		if ((m_label.isEmpty() && m_preserveLabelSpace == false) || m_labelVisibility == false)
+		w += iconWidth;
+		h += iconHeight;
+
+		switch (m_iconPosition)
 		{
-			w = 0;
-			h = 0;
+		case Left:
+			l += iconWidth;
+			break;
+		case Right:
+			r += iconWidth;
+			break;
+		case Top:
+			t += iconHeight;
+			break;
+		case Bottom:
+			b += iconHeight;
+			break;
 		}
-		else
-		{
-			QFont tmpFont(m_font);
-			if (m_useSmallFont)
-				tmpFont.setPointSize(smallFontSize());
 
-			QFontMetrics metrics(tmpFont);
-			QString label = m_label;
+	}
 
-			// calculate width without hidden "&"
-			if (m_hasShortcut)
+	if (canUseLabel())
+	{
+		QFont tmpFont(m_font);
+		if (m_useSmallFont)
+			tmpFont.setPointSize(smallFontSize());
+
+		QFontMetrics metrics(tmpFont);
+		QString label = m_label;
+
+		// calculate width without hidden "&"
+		if (m_hasShortcut)
+		{
+			int pos = 0;
+			while ( pos < m_label.size())
 			{
-				int pos = 0;
-				while ( pos < m_label.size())
-				{
-					int index = label.indexOf(QLatin1String("&"), pos);
+				int index = label.indexOf(QLatin1String("&"), pos);
 
-					if (pos == index)
-						label = label.replace(index, 1, "");
+				if (pos == index)
+					label = label.replace(index, 1, "");
 
-					pos++;
-				}
+				pos++;
 			}
+		}
 
-			w = metrics.horizontalAdvance(label) + metrics.horizontalAdvance(QLatin1Char(' ')) + m_space;
-			h = metrics.height() + m_space;
+		int labelWidth = metrics.horizontalAdvance(label) + metrics.horizontalAdvance(QLatin1Char(' ')) + m_space;
+		int labelHeight = metrics.height() + m_space;
 
+		w += labelWidth;
+		h += labelHeight;
+
+		switch (m_position)
+		{
+			case Left:
+				l += labelWidth;
+				break;
+			case Right:
+				r += labelWidth;
+				break;
+			case Top:				
+				t += labelHeight;
+				break;
+			case Bottom:				
+				b += labelHeight;
+				break;
 		}
+
 	}
+
 }
 
 int FormWidget::smallFontSize() const
@@ -338,6 +384,12 @@
 	calculateFrame();
 }
 
+void FormWidget::setIconDirection(LabelPosition direction)
+{
+	m_iconPosition = direction;
+	calculateFrame();
+}
+
 void FormWidget::setFont(QFont font)
 {
 	m_font = font;
@@ -359,7 +411,6 @@
 void FormWidget::setPixmap(QPixmap icon)
 {
 	m_pixmap = icon;
-	updateShortcut();
 	calculateFrame();
 
 }
@@ -370,6 +421,12 @@
 	calculateFrame();
 }
 
+void FormWidget::setIconVisibility(bool visible)
+{
+	m_iconVisibility = visible;
+	calculateFrame();
+}
+
 void FormWidget::addWidget(QWidget* widget)
 {
 	if (layout() != nullptr)
Index: scribus/ui/widgets/form_widget.h
===================================================================
--- scribus/ui/widgets/form_widget.h	(Revision 26312)
+++ scribus/ui/widgets/form_widget.h	(Arbeitskopie)
@@ -15,17 +15,19 @@
 class FormWidget : public QWidget
 {
 	Q_OBJECT
-	Q_CLASSINFO("Version", "1.1.0")
+	Q_CLASSINFO("Version", "1.2.0")
 
 	Q_PROPERTY(QString label READ text WRITE setText)
 	Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
 	Q_PROPERTY(QSize pixmapSize READ pixmapSize WRITE setPixmapSize)
 	Q_PROPERTY(LabelPosition direction READ direction WRITE setDirection)
+	Q_PROPERTY(LabelPosition iconDirection READ iconDirection WRITE setIconDirection)
 	Q_PROPERTY(QFont font READ font WRITE setFont STORED true)
 	Q_PROPERTY(bool useSmallFont READ useSmallFont WRITE setUseSmallFont)
 	Q_PROPERTY(int space READ space WRITE setSpace)
 	Q_PROPERTY(bool preserveLabelSpace READ preserveLabelSpace WRITE setPreserveLabelSpace)
 	Q_PROPERTY(bool labelVisibility READ labelVisibility WRITE setLabelVisibility)
+	Q_PROPERTY(bool iconVisibility READ iconVisibility WRITE setIconVisibility)
 
 
 public:
@@ -43,6 +45,9 @@
 	void setLabelVisibility(bool visible);
 	bool labelVisibility() { return m_labelVisibility; };
 
+	void setIconVisibility(bool visible);
+	bool iconVisibility() const { return m_iconVisibility; };
+
 	void setPreserveLabelSpace(bool preserveSpace);
 	bool preserveLabelSpace() { return m_preserveLabelSpace; };
 
@@ -49,6 +54,9 @@
 	void setDirection(FormWidget::LabelPosition direction);
 	FormWidget::LabelPosition direction() { return m_position; };
 
+	void setIconDirection(FormWidget::LabelPosition direction);
+	FormWidget::LabelPosition iconDirection() { return m_iconPosition; };
+
 	void setFont(QFont font);
 	QFont font() { return m_font; };
 
@@ -66,7 +74,8 @@
 	void setPixmapSize(QSize size);
 	QSize pixmapSize() { return m_pixmapSize; };
 
-	bool hasPixmap() const { return !m_pixmap.isNull(); };
+	bool canUsePixmap() const { return (!m_pixmap.isNull() && m_iconVisibility); };
+	bool canUseLabel() const { return (!m_label.isEmpty() && m_labelVisibility) || (m_preserveLabelSpace && m_labelVisibility); };
 
 	void addWidget(QWidget* widget);
 
@@ -76,21 +85,22 @@
 
 private:
 	LabelPosition m_position {LabelPosition::Bottom};
+	LabelPosition m_iconPosition {LabelPosition::Left};
 	int m_space {4};
 	QSize m_pixmapSize {QSize(16,16)};
 	QString m_label {"Label"};
 	QFont m_font;
 	QPixmap m_pixmap {QPixmap()};
+	bool m_iconVisibility {true};
 	bool m_preserveLabelSpace {false};
 	bool m_labelVisibility {true};
 	bool m_hasShortcut {false};
 	int m_shortcutId {0};
-	qreal m_devicePixelRatio {1.0};
 	bool m_useSmallFont {true};
 
 	void calculateFrame();
 	void updateShortcut();
-	void labelSize(int &w, int &h) const;
+	void labelSize(int &l, int &t, int &r, int &b, int &w, int &h) const;
 };
 
 
Index: scribus/ui/widgets/section_container.cpp
===================================================================
--- scribus/ui/widgets/section_container.cpp	(Revision 26312)
+++ scribus/ui/widgets/section_container.cpp	(Arbeitskopie)
@@ -109,6 +109,57 @@
 	return m_hasStyle;
 }
 
+void SectionContainer::setHeaderType(SectionContainerHeader::HeaderType type)
+{
+	header->m_headerType = type;
+
+	QFont fnt = font();
+
+	if (type == SectionContainerHeader::Header)
+		fnt.setBold(true);
+
+	header->labelTitle->setFont(fnt);
+
+	update();
+}
+
+SectionContainerHeader::HeaderType SectionContainer::headerType() const
+{
+	return header->m_headerType;
+}
+
+void SectionContainer::setHeaderSize(SectionContainerHeader::HeaderSize size)
+{
+	int pt = 4;
+	int pb = 4;
+
+	switch (size)
+	{
+	case SectionContainerHeader::Large:
+		pt = 8;
+		pb = 4;
+
+		break;
+	case SectionContainerHeader::Condensed:
+		pt = 2;
+		pb = 2;
+		break;
+	default:
+	case SectionContainerHeader::Normal:
+		break;
+	}
+
+	header->m_headerSize = size;
+	header->layoutHeader->setContentsMargins(4, pt, 4, pb);
+	header->setFixedHeight(header->buttonCollapse->height() + pt + pb);
+
+}
+
+SectionContainerHeader::HeaderSize SectionContainer::headerSize() const
+{
+	return header->m_headerSize;
+}
+
 void SectionContainer::setCanSaveState(bool saveState)
 {
 	m_canSaveState = saveState;
@@ -375,13 +426,13 @@
 		return;
 
 	int lineWidth = 1;
-	QColor bottomLineColor(palette().color(QPalette::Dark));
+	QColor bottomLineColor(palette().color(QPalette::Mid));
 
 	QPainter painter(this);
 
 	// Bottom Line
 	painter.setPen(QPen(bottomLineColor, lineWidth));
-	painter.drawLine(8, this->height() - lineWidth, this->width() - 8,
+	painter.drawLine(0, this->height() - lineWidth, this->width(),
 					 this->height() - lineWidth);
 }
 
@@ -439,7 +490,6 @@
 SectionContainerHeader::SectionContainerHeader(QString title, QWidget *parent) : QWidget(parent)
 {
 	int padding = 6;
-	m_hasStyle = true;
 
 	layoutHeader = new QHBoxLayout;
 	layoutHeaderPrefix = new QHBoxLayout;
@@ -493,39 +543,41 @@
 {
 	Q_UNUSED(event)
 
-	if (!m_hasStyle)
-		return;
-
 	int lineWidth = 1;
-	//	QColor topLineColor( palette().color(QPalette::Mid) );
-	QColor bottomLineColor(palette().color(QPalette::Dark));
+	int headerHeight = this->height();
+	QColor bottomLineColor(palette().color(QPalette::Mid));
+	QRect headerRect(0, 0, this->width(), headerHeight - lineWidth);
 
+	QPainter painter(this);
+	painter.setPen(Qt::NoPen);
+
+	if (m_hasStyle)
+	{
+
 #ifndef EXCLUDE_FOR_DESIGNER_PLUGIN
-	QColor bgColor = colorByRole(QPalette::WindowText, 0.07, isEnabled());
+		QColor bgColor = colorByRole(QPalette::WindowText, 0.16, isEnabled());
+
+		if (m_headerType == SectionContainerHeader::Subheader)
+			bgColor = colorByRole(QPalette::WindowText, 0.08, isEnabled());
 #else
-	QColor bgColor(palette().color(QPalette::WindowText));
-	bgColor.setAlphaF(0.07f);
+		QColor bgColor(palette().color(QPalette::WindowText));
+		bgColor.setAlphaF(0.16f);
+
+		if (m_headerType == SectionContainerHeader::Subheader)
+			bgColor.setAlphaF(0.08f);
 #endif
 
-	int headerHeight = this->height();
-	QRect headerRect(0, 0, this->width(), headerHeight - lineWidth);
+		painter.setBrush(bgColor);
+		painter.drawRect(headerRect);
+	}
 
-	QPainter painter(this);
-
-	painter.setPen(Qt::NoPen);
-	painter.setBrush(bgColor);
-	painter.drawRect(headerRect);
-
 	painter.setBrush(Qt::NoBrush);
 
-	// Top Line
-	//	painter.setPen( QPen(topLineColor, lineWidth) );
-	//	painter.drawLine( 0, 0,this->width(), 0 );
-
 	// Bottom Line
 	painter.setPen(QPen(bottomLineColor, lineWidth));
 	painter.drawLine(0, headerHeight - lineWidth, this->width(),
 					 headerHeight - lineWidth);
+	painter.end();
 }
 
 void SectionContainerHeader::mousePressEvent(QMouseEvent *mouseEvent)
Index: scribus/ui/widgets/section_container.h
===================================================================
--- scribus/ui/widgets/section_container.h	(Revision 26312)
+++ scribus/ui/widgets/section_container.h	(Arbeitskopie)
@@ -23,6 +23,20 @@
 	friend class SectionContainer;
 
 public:
+
+	enum HeaderType {
+		Header = 1,
+		Subheader = 2
+	};
+	Q_ENUM(HeaderType)
+
+	enum HeaderSize {
+		Normal = 0,
+		Large = 1,
+		Condensed = 2
+	};
+	Q_ENUM(HeaderSize)
+
 	SectionContainerHeader(QWidget *parent = nullptr);
 	SectionContainerHeader(QString title, QWidget *parent = nullptr);
 
@@ -35,6 +49,8 @@
 
 	QLabel* labelTitle { nullptr };
 
+	HeaderType m_headerType = {HeaderType::Subheader};
+	HeaderSize m_headerSize = {HeaderSize::Normal};
 	bool m_hasStyle { true };
 
 protected:
@@ -55,12 +71,13 @@
 class SectionContainer : public QWidget
 {
 	Q_OBJECT
-	Q_CLASSINFO("Version", "1.0.0")
+	Q_CLASSINFO("Version", "1.1.0")
 
 	Q_PROPERTY(QString title READ text WRITE setText)
 	Q_PROPERTY(bool isCollapsible READ isCollapsible WRITE setIsCollapsible)
 	Q_PROPERTY(bool isCollapsed READ isCollapsed WRITE setIsCollapsed)
 	Q_PROPERTY(bool hasStyle READ hasStyle WRITE setHasStyle)
+	Q_PROPERTY(SectionContainerHeader::HeaderType headerType READ headerType WRITE setHeaderType)
 
 
 public:
@@ -76,6 +93,12 @@
 	void setHasStyle(bool hasStyle);
 	bool hasStyle() const;
 
+	void setHeaderType(SectionContainerHeader::HeaderType type);
+	SectionContainerHeader::HeaderType headerType() const;
+
+	void setHeaderSize(SectionContainerHeader::HeaderSize size);
+	SectionContainerHeader::HeaderSize headerSize() const;
+
 	void setCanSaveState(bool saveState);
 	bool canSaveState();
 
fixes_2024-10-04_01.patch (24,779 bytes)   

Issue History

Date Modified Username Field Change
2024-10-04 21:31 nitramr New Issue
2024-10-04 21:31 nitramr File Added: fixes_2024-10-04_01.patch
2024-10-07 05:25 cbradney Assigned To => nitramr
2024-10-07 05:25 cbradney Status new => resolved
2024-10-07 05:25 cbradney Resolution open => fixed
2024-10-07 05:25 cbradney Fixed in Version => 1.7.0.svn