forked from qt-creator/qt-creator
Change QLabel from StringAspect to ElidingLabel
ElidingLabel with elided mode set other than Qt::ElideNone will not show in case QFormLayout has QFormLayout::ExpandingFieldsGrow field growth policy Change-Id: I26db57fbeb2c921e054cf7dc18229ebddcb04530 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -639,11 +639,12 @@ public:
|
|||||||
std::function<QString(const QString &)> m_displayFilter;
|
std::function<QString(const QString &)> m_displayFilter;
|
||||||
std::unique_ptr<BoolAspect> m_checker;
|
std::unique_ptr<BoolAspect> m_checker;
|
||||||
|
|
||||||
|
Qt::TextElideMode m_elideMode = Qt::ElideNone;
|
||||||
QString m_placeHolderText;
|
QString m_placeHolderText;
|
||||||
QString m_historyCompleterKey;
|
QString m_historyCompleterKey;
|
||||||
PathChooser::Kind m_expectedKind = PathChooser::File;
|
PathChooser::Kind m_expectedKind = PathChooser::File;
|
||||||
EnvironmentChange m_environmentChange;
|
EnvironmentChange m_environmentChange;
|
||||||
QPointer<QLabel> m_labelDisplay;
|
QPointer<ElidingLabel> m_labelDisplay;
|
||||||
QPointer<FancyLineEdit> m_lineEditDisplay;
|
QPointer<FancyLineEdit> m_lineEditDisplay;
|
||||||
QPointer<PathChooser> m_pathChooserDisplay;
|
QPointer<PathChooser> m_pathChooserDisplay;
|
||||||
QPointer<QTextEdit> m_textEditDisplay;
|
QPointer<QTextEdit> m_textEditDisplay;
|
||||||
@@ -935,6 +936,16 @@ void StringAspect::setPlaceHolderText(const QString &placeHolderText)
|
|||||||
d->m_textEditDisplay->setPlaceholderText(placeHolderText);
|
d->m_textEditDisplay->setPlaceholderText(placeHolderText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Sets \a elideMode as label elide mode.
|
||||||
|
*/
|
||||||
|
void StringAspect::setElideMode(Qt::TextElideMode elideMode)
|
||||||
|
{
|
||||||
|
d->m_elideMode = elideMode;
|
||||||
|
if (d->m_labelDisplay)
|
||||||
|
d->m_labelDisplay->setElideMode(elideMode);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Sets \a historyCompleterKey as key for the history completer settings for
|
Sets \a historyCompleterKey as key for the history completer settings for
|
||||||
line edits and path chooser displays.
|
line edits and path chooser displays.
|
||||||
@@ -1144,7 +1155,8 @@ void StringAspect::addToLayout(LayoutBuilder &builder)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LabelDisplay:
|
case LabelDisplay:
|
||||||
d->m_labelDisplay = createSubWidget<QLabel>();
|
d->m_labelDisplay = createSubWidget<ElidingLabel>();
|
||||||
|
d->m_labelDisplay->setElideMode(d->m_elideMode);
|
||||||
d->m_labelDisplay->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
d->m_labelDisplay->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||||
d->m_labelDisplay->setText(displayedString);
|
d->m_labelDisplay->setText(displayedString);
|
||||||
d->m_labelDisplay->setToolTip(d->m_showToolTipOnLabel ? displayedString : toolTip());
|
d->m_labelDisplay->setToolTip(d->m_showToolTipOnLabel ? displayedString : toolTip());
|
||||||
|
|||||||
@@ -308,6 +308,7 @@ public:
|
|||||||
void setValidationFunction(const Utils::FancyLineEdit::ValidationFunction &validator);
|
void setValidationFunction(const Utils::FancyLineEdit::ValidationFunction &validator);
|
||||||
void setOpenTerminalHandler(const std::function<void()> &openTerminal);
|
void setOpenTerminalHandler(const std::function<void()> &openTerminal);
|
||||||
void setAutoApplyOnEditingFinished(bool applyOnEditingFinished);
|
void setAutoApplyOnEditingFinished(bool applyOnEditingFinished);
|
||||||
|
void setElideMode(Qt::TextElideMode elideMode);
|
||||||
|
|
||||||
void validateInput();
|
void validateInput();
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ static QLayout *createLayoutFromType(LayoutBuilder::LayoutType layoutType)
|
|||||||
switch (layoutType) {
|
switch (layoutType) {
|
||||||
case LayoutBuilder::FormLayout: {
|
case LayoutBuilder::FormLayout: {
|
||||||
auto formLayout = new QFormLayout;
|
auto formLayout = new QFormLayout;
|
||||||
formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||||
return formLayout;
|
return formLayout;
|
||||||
}
|
}
|
||||||
case LayoutBuilder::GridLayout: {
|
case LayoutBuilder::GridLayout: {
|
||||||
|
|||||||
Reference in New Issue
Block a user