[qet] qet/qet: [4781] Minor fix : set a correct size of the pixmap displayed in the element properties widget

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 4781
Author:   blacksun
Date:     2016-11-15 17:27:41 +0100 (Tue, 15 Nov 2016)
Log Message:
-----------
Minor fix : set a correct size of the pixmap displayed in the element properties widget

Modified Paths:
--------------
    trunk/sources/ui/elementpropertieswidget.cpp

Modified: trunk/sources/ui/elementpropertieswidget.cpp
===================================================================
--- trunk/sources/ui/elementpropertieswidget.cpp	2016-11-15 10:18:32 UTC (rev 4780)
+++ trunk/sources/ui/elementpropertieswidget.cpp	2016-11-15 16:27:41 UTC (rev 4781)
@@ -276,19 +276,18 @@
 		description_string += QString(tr("Emplacement : %1\n")).arg(custom_element -> location().toString());
 	}
 
-	// widget himself
+		// widget himself
 	QWidget *general_widget = new QWidget (m_tab);
 	QVBoxLayout *vlayout_ = new QVBoxLayout (general_widget);
 	general_widget -> setLayout(vlayout_);
 
-	//widget for the text
+		//widget for the text
 	QLabel *label = new QLabel (description_string, general_widget);
 	label->setWordWrap(true);
 	vlayout_->addWidget(label);
 
-	//widget for the pixmap
+		//widget for the pixmap
 	QLabel *pix = new QLabel(general_widget);
-	pix->setPixmap(m_element->pixmap().scaled (34, 34, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
 	vlayout_->addWidget(pix, 0, Qt::AlignHCenter);
 	vlayout_ -> addStretch();
 
@@ -300,7 +299,21 @@
 	QHBoxLayout *hlayout_ = new QHBoxLayout;
 	hlayout_->addWidget(find_in_panel);
 	hlayout_->addWidget(edit_element);
+	vlayout_->addLayout(hlayout_);
 
-	vlayout_->addLayout(hlayout_);
+		//Set the maximum size of the pixmap to the minimum size of the layout
+	QPixmap pixmap = m_element->pixmap();
+	int margin = vlayout_->contentsMargins().left() + vlayout_->contentsMargins().right();
+	int widht_ = vlayout_->minimumSize().width()-margin;
+
+	if (pixmap.size().width() > widht_ || pixmap.size().height() > widht_)
+	{
+		pix->setPixmap(m_element->pixmap().scaled (widht_, widht_, Qt::KeepAspectRatio, Qt::SmoothTransformation));
+	}
+	else
+	{
+		pix->setPixmap(pixmap);
+	}
+
 	return general_widget;
 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/