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:
Peter Lama
2017-09-16 11:08:38 -04:00
committed by Yorik van Havre
parent 412376ca3f
commit 556d68680e
5 changed files with 36 additions and 3 deletions

View File

@@ -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
*