diff --git a/src/kconfigdialog.cpp b/src/kconfigdialog.cpp --- a/src/kconfigdialog.cpp +++ b/src/kconfigdialog.cpp @@ -47,8 +47,7 @@ if (!name.isEmpty()) { openDialogs.insert(name, q); } else { - QString genericName; - genericName.sprintf("SettingsDialog-%p", static_cast(q)); + const QString genericName = QString::asprintf("SettingsDialog-%p", static_cast(q)); openDialogs.insert(genericName, q); q->setObjectName(genericName); } diff --git a/src/krecentfilesaction.cpp b/src/krecentfilesaction.cpp --- a/src/krecentfilesaction.cpp +++ b/src/krecentfilesaction.cpp @@ -31,7 +31,9 @@ #include #include #include +#include #include +#include #include #include @@ -122,19 +124,19 @@ // action titles to be bigger than that // Since we do not know in which screen we are going to show // we choose the min of all the screens - const QDesktopWidget desktopWidget; int maxWidthForTitles = INT_MAX; - for (int i = 0; i < desktopWidget.screenCount(); ++i) { - maxWidthForTitles = qMin(maxWidthForTitles, desktopWidget.availableGeometry(i).width() * 3 / 4); + const auto screens = QGuiApplication::screens(); + for (QScreen *screen : screens) { + maxWidthForTitles = qMin(maxWidthForTitles, screen->availableGeometry().width() * 3 / 4); } const QFontMetrics fontMetrics = QFontMetrics(QFont()); QString title = nameValue + QLatin1String(" [") + value + QLatin1Char(']'); - if (fontMetrics.width(title) > maxWidthForTitles) { + const int nameWidth = fontMetrics.boundingRect(title).width(); + if (nameWidth > maxWidthForTitles) { // If it does not fit, try to cut only the whole path, though if the // name is too long (more than 3/4 of the whole text) we cut it a bit too const int nameValueMaxWidth = maxWidthForTitles * 3 / 4; - const int nameWidth = fontMetrics.width(nameValue); QString cutNameValue, cutValue; if (nameWidth > nameValueMaxWidth) { cutNameValue = fontMetrics.elidedText(nameValue, Qt::ElideMiddle, nameValueMaxWidth); diff --git a/src/ktipdialog.cpp b/src/ktipdialog.cpp --- a/src/ktipdialog.cpp +++ b/src/ktipdialog.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -291,10 +292,12 @@ resize(520, 280); QSize sh = size(); - QRect rect = QApplication::desktop()->screenGeometry(QCursor::pos()); - - move(rect.x() + (rect.width() - sh.width()) / 2, - rect.y() + (rect.height() - sh.height()) / 2); + QScreen *screen = QGuiApplication::screenAt(QCursor::pos()); + if (screen) { + const QRect rect = screen->geometry(); + move(rect.x() + (rect.width() - sh.width()) / 2, + rect.y() + (rect.height() - sh.height()) / 2); + } } KSeparator *sep = new KSeparator(Qt::Horizontal);