mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Minor fix : set a correct size of the pixmap displayed in the element properties widget
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4781 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -276,19 +276,18 @@ QWidget *ElementPropertiesWidget::generalWidget()
|
|||||||
description_string += QString(tr("Emplacement : %1\n")).arg(custom_element -> location().toString());
|
description_string += QString(tr("Emplacement : %1\n")).arg(custom_element -> location().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// widget himself
|
// widget himself
|
||||||
QWidget *general_widget = new QWidget (m_tab);
|
QWidget *general_widget = new QWidget (m_tab);
|
||||||
QVBoxLayout *vlayout_ = new QVBoxLayout (general_widget);
|
QVBoxLayout *vlayout_ = new QVBoxLayout (general_widget);
|
||||||
general_widget -> setLayout(vlayout_);
|
general_widget -> setLayout(vlayout_);
|
||||||
|
|
||||||
//widget for the text
|
//widget for the text
|
||||||
QLabel *label = new QLabel (description_string, general_widget);
|
QLabel *label = new QLabel (description_string, general_widget);
|
||||||
label->setWordWrap(true);
|
label->setWordWrap(true);
|
||||||
vlayout_->addWidget(label);
|
vlayout_->addWidget(label);
|
||||||
|
|
||||||
//widget for the pixmap
|
//widget for the pixmap
|
||||||
QLabel *pix = new QLabel(general_widget);
|
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_->addWidget(pix, 0, Qt::AlignHCenter);
|
||||||
vlayout_ -> addStretch();
|
vlayout_ -> addStretch();
|
||||||
|
|
||||||
@@ -300,7 +299,21 @@ QWidget *ElementPropertiesWidget::generalWidget()
|
|||||||
QHBoxLayout *hlayout_ = new QHBoxLayout;
|
QHBoxLayout *hlayout_ = new QHBoxLayout;
|
||||||
hlayout_->addWidget(find_in_panel);
|
hlayout_->addWidget(find_in_panel);
|
||||||
hlayout_->addWidget(edit_element);
|
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;
|
return general_widget;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user