mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(widget): replace fontMetrics.width() when using Qt 5.13
This commit is contained in:
parent
fb3f44721e
commit
b45ba34be2
|
@ -36,8 +36,7 @@ CroppingLabel::CroppingLabel(QWidget* parent)
|
||||||
public:
|
public:
|
||||||
explicit LineEdit(QWidget* parent = nullptr)
|
explicit LineEdit(QWidget* parent = nullptr)
|
||||||
: QLineEdit(parent)
|
: QLineEdit(parent)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent* event) override
|
void keyPressEvent(QKeyEvent* event) override
|
||||||
|
@ -106,7 +105,11 @@ QSize CroppingLabel::sizeHint() const
|
||||||
|
|
||||||
QSize CroppingLabel::minimumSizeHint() const
|
QSize CroppingLabel::minimumSizeHint() const
|
||||||
{
|
{
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
||||||
|
return QSize(fontMetrics().horizontalAdvance("..."), QLabel::minimumSizeHint().height());
|
||||||
|
#else
|
||||||
return QSize(fontMetrics().width("..."), QLabel::minimumSizeHint().height());
|
return QSize(fontMetrics().width("..."), QLabel::minimumSizeHint().height());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CroppingLabel::mouseReleaseEvent(QMouseEvent* e)
|
void CroppingLabel::mouseReleaseEvent(QMouseEvent* e)
|
||||||
|
@ -171,7 +174,11 @@ void CroppingLabel::minimizeMaximumWidth()
|
||||||
{
|
{
|
||||||
// This function chooses the smallest possible maximum width.
|
// This function chooses the smallest possible maximum width.
|
||||||
// Text width + padding. Without padding, we'll have elipses.
|
// Text width + padding. Without padding, we'll have elipses.
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
|
||||||
|
setMaximumWidth(fontMetrics().horizontalAdvance(origText) + fontMetrics().horizontalAdvance("..."));
|
||||||
|
#else
|
||||||
setMaximumWidth(fontMetrics().width(origText) + fontMetrics().width("..."));
|
setMaximumWidth(fontMetrics().width(origText) + fontMetrics().width("..."));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CroppingLabel::editingFinished()
|
void CroppingLabel::editingFinished()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user