desktop: better handling of progress dialog width

We shouldn't need to manually set it, but it appears we do. To avoid
constant resizing, let's only grow it - and let's set the size before we
update the text.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2018-06-16 12:54:12 +09:00
parent 3f012f4bdb
commit b9318a9ab1

View file

@ -77,10 +77,13 @@ extern "C" int updateProgress(const char *text)
if (verbose)
qDebug() << "git storage:" << text;
if (progressDialog) {
// apparently we don't always get enough space to show the full label
// so let's manually make enough space (but don't shrink the existing size)
int width = QFontMetrics(qApp->font()).width(text) + 100;
if (width > progressDialog->width())
progressDialog->resize(width + 20, progressDialog->height());
progressDialog->setLabelText(text);
progressDialog->setValue(++progressCounter);
int width = QFontMetrics(qApp->font()).width(text) + 100;
progressDialog->resize(width, progressDialog->height());
if (progressCounter == 100)
progressCounter = 0; // yes this is silly, but we really don't know how long it will take
}