Fix macOS button layout in property editor
The size of the "..." button calculated by QMacStyle was not correct, causing other widgets in the layout to be clipped. Also, set the size of all "..." buttons the same way.
This commit is contained in:
committed by
Yorik van Havre
parent
9d81b1ec7b
commit
991573f1fc
@@ -36,6 +36,7 @@
|
||||
# include <QRadioButton>
|
||||
# include <QStyle>
|
||||
# include <QUrl>
|
||||
# include <QResizeEvent>
|
||||
#endif
|
||||
|
||||
#include <Base/Parameter.h>
|
||||
@@ -589,7 +590,7 @@ FileChooser::FileChooser ( QWidget * parent )
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout( this );
|
||||
layout->setMargin( 0 );
|
||||
layout->setSpacing( 6 );
|
||||
layout->setSpacing( 2 );
|
||||
|
||||
lineEdit = new QLineEdit ( this );
|
||||
completer = new QCompleter ( this );
|
||||
@@ -607,7 +608,11 @@ FileChooser::FileChooser ( QWidget * parent )
|
||||
connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(editingFinished()));
|
||||
|
||||
button = new QPushButton(QLatin1String("..."), this);
|
||||
button->setFixedWidth(2*button->fontMetrics().width(QLatin1String(" ... ")));
|
||||
|
||||
#if defined (Q_OS_MAC)
|
||||
button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // layout size from QMacStyle was not correct
|
||||
#endif
|
||||
|
||||
layout->addWidget(button);
|
||||
|
||||
connect( button, SIGNAL(clicked()), this, SLOT(chooseFile()));
|
||||
@@ -619,6 +624,12 @@ FileChooser::~FileChooser()
|
||||
{
|
||||
}
|
||||
|
||||
void FileChooser::resizeEvent(QResizeEvent* e)
|
||||
{
|
||||
button->setFixedWidth(e->size().height());
|
||||
button->setFixedHeight(e->size().height());
|
||||
}
|
||||
|
||||
/**
|
||||
* \property FileChooser::fileName
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user