Browse Source

Merge pull request #4900

Pavel Karelin (1):
      chore: Elide text for CallConfirmWidget
pull/4897/head
sudden6 8 years ago
parent
commit
c4fb495eb6
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
  1. 19
      src/widget/tool/callconfirmwidget.cpp

19
src/widget/tool/callconfirmwidget.cpp

@ -29,6 +29,7 @@ @@ -29,6 +29,7 @@
#include <QPushButton>
#include <QRect>
#include <QVBoxLayout>
#include <QFontMetrics>
#include <assert.h>
/**
@ -67,9 +68,21 @@ CallConfirmWidget::CallConfirmWidget(const QWidget* anchor) @@ -67,9 +68,21 @@ CallConfirmWidget::CallConfirmWidget(const QWidget* anchor)
QVBoxLayout* layout = new QVBoxLayout(this);
QLabel* callLabel = new QLabel(QObject::tr("Incoming call..."), this);
callLabel->setStyleSheet("color: white");
callLabel->setWordWrap(true);
callLabel->setStyleSheet("QLabel{color: white;} QToolTip{color: black;}");
callLabel->setAlignment(Qt::AlignHCenter);
callLabel->setToolTip(callLabel->text());
// Note: At the moment this may not work properly. For languages written
// from right to left, there is no translation for the phrase "Incoming call...".
// In this situation, the phrase "Incoming call..." looks as "...oming call..."
Qt::TextElideMode elideMode = (QGuiApplication::layoutDirection() == Qt::LeftToRight)
? Qt::ElideRight : Qt::ElideLeft;
int marginSize = 12;
QFontMetrics fontMetrics(callLabel->font());
QString elidedText = fontMetrics.elidedText(callLabel->text(), elideMode,
rectW - marginSize * 2 - 4);
callLabel->setText(elidedText);
QDialogButtonBox* buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
QPushButton *accept = new QPushButton(this), *reject = new QPushButton(this);
accept->setFlat(true);
@ -87,7 +100,7 @@ CallConfirmWidget::CallConfirmWidget(const QWidget* anchor) @@ -87,7 +100,7 @@ CallConfirmWidget::CallConfirmWidget(const QWidget* anchor)
connect(buttonBox, &QDialogButtonBox::accepted, this, &CallConfirmWidget::accepted);
connect(buttonBox, &QDialogButtonBox::rejected, this, &CallConfirmWidget::rejected);
layout->setMargin(12);
layout->setMargin(marginSize);
layout->addSpacing(spikeH);
layout->addWidget(callLabel);
layout->addWidget(buttonBox);

Loading…
Cancel
Save