Changeset View
Changeset View
Standalone View
Standalone View
src/kmessagebox.cpp
Show First 20 Lines • Show All 273 Lines • ▼ Show 20 Line(s) | 271 | if (usingListWidget) { | |||
---|---|---|---|---|---|
274 | QListWidget *listWidget = new QListWidget(mainWidget); | 274 | QListWidget *listWidget = new QListWidget(mainWidget); | ||
275 | listWidget->addItems(strlist); | 275 | listWidget->addItems(strlist); | ||
276 | 276 | | |||
277 | QStyleOptionViewItem styleOption; | 277 | QStyleOptionViewItem styleOption; | ||
278 | styleOption.initFrom(listWidget); | 278 | styleOption.initFrom(listWidget); | ||
279 | QFontMetrics fm(styleOption.font); | 279 | QFontMetrics fm(styleOption.font); | ||
280 | int w = listWidget->width(); | 280 | int w = listWidget->width(); | ||
281 | for (const QString &str : strlist) { | 281 | for (const QString &str : strlist) { | ||
282 | w = qMax(w, fm.width(str)); | 282 | w = qMax(w, fm.boundingRect(str).width()); | ||
283 | } | 283 | } | ||
284 | const int borderWidth = listWidget->width() - listWidget->viewport()->width() + listWidget->verticalScrollBar()->height(); | 284 | const int borderWidth = listWidget->width() - listWidget->viewport()->width() + listWidget->verticalScrollBar()->height(); | ||
285 | w += borderWidth; | 285 | w += borderWidth; | ||
286 | if (w > desktop.width() * 0.85) { // limit listWidget size to 85% of screen width | 286 | if (w > desktop.width() * 0.85) { // limit listWidget size to 85% of screen width | ||
287 | w = qRound(desktop.width() * 0.85); | 287 | w = qRound(desktop.width() * 0.85); | ||
288 | } | 288 | } | ||
289 | listWidget->setMinimumWidth(w); | 289 | listWidget->setMinimumWidth(w); | ||
290 | 290 | | |||
▲ Show 20 Lines • Show All 873 Lines • Show Last 20 Lines |