ProjectExplorer: Add tool tip to ExecutableAspect

Because our project mode uses a fixed width for some reason, the file
path of an executable often does not fit on its label. Add a tool tip to
work around this.

Fixes: QTCREATORBUG-18991
Change-Id: I4ab7cd8812ae15bcef95c16a862361e24a28c259
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-07-23 13:44:11 +02:00
parent cb34f54aa0
commit 80716610c5
3 changed files with 12 additions and 1 deletions

View File

@@ -94,6 +94,7 @@ public:
QPixmap m_labelPixmap;
Utils::FilePath m_baseFileName;
bool m_readOnly = false;
bool m_showToolTipOnLabel = false;
};
class BaseIntegerAspectPrivate
@@ -176,6 +177,12 @@ void BaseStringAspect::setLabelPixmap(const QPixmap &labelPixmap)
d->m_label->setPixmap(labelPixmap);
}
void BaseStringAspect::setShowToolTipOnLabel(bool show)
{
d->m_showToolTipOnLabel = show;
update();
}
QString BaseStringAspect::labelText() const
{
return d->m_labelText;
@@ -334,8 +341,10 @@ void BaseStringAspect::update()
d->m_textEditDisplay->setEnabled(enabled);
}
if (d->m_labelDisplay)
if (d->m_labelDisplay) {
d->m_labelDisplay->setText(displayedString);
d->m_labelDisplay->setToolTip(d->m_showToolTipOnLabel ? displayedString : QString());
}
if (d->m_label) {
d->m_label->setText(d->m_labelText);

View File

@@ -109,6 +109,7 @@ public:
QString labelText() const;
void setLabelText(const QString &labelText);
void setLabelPixmap(const QPixmap &labelPixmap);
void setShowToolTipOnLabel(bool show);
void setDisplayFilter(const std::function<QString (const QString &)> &displayFilter);
void setPlaceHolderText(const QString &placeHolderText);

View File

@@ -470,6 +470,7 @@ void ExecutableAspect::setPlaceHolderText(const QString &placeHolderText)
void ExecutableAspect::setExecutable(const FilePath &executable)
{
m_executable.setValue(executable.toString());
m_executable.setShowToolTipOnLabel(true);
}
void ExecutableAspect::setSettingsKey(const QString &key)