diff --git a/autotests/kpasswordlineedittest.cpp b/autotests/kpasswordlineedittest.cpp --- a/autotests/kpasswordlineedittest.cpp +++ b/autotests/kpasswordlineedittest.cpp @@ -38,7 +38,7 @@ QHBoxLayout *mainLayout = lineEdit.findChild(QStringLiteral("mainlayout")); QVERIFY(mainLayout); - QCOMPARE(mainLayout->margin(), 0); + QCOMPARE(mainLayout->contentsMargins(), QMargins(0, 0, 0, 0)); QLineEdit *edit = lineEdit.findChild(QStringLiteral("passwordlineedit")); QVERIFY(edit); diff --git a/autotests/ksqueezedtextlabelautotest.cpp b/autotests/ksqueezedtextlabelautotest.cpp --- a/autotests/ksqueezedtextlabelautotest.cpp +++ b/autotests/ksqueezedtextlabelautotest.cpp @@ -155,7 +155,7 @@ QCOMPARE(label->sizeHint().width(), 0); const QString text = QStringLiteral("Squeeze me"); - const int labelWidth = label->fontMetrics().width(text); // no chrome set + const int labelWidth = label->fontMetrics().boundingRect(text).width(); // no chrome set label->setText(text); QVERIFY(label->isSqueezed()); @@ -199,7 +199,7 @@ void KSqueezedTextLabelAutotest::testChrome_data() { const QFontMetrics fm(KSqueezedTextLabel().fontMetrics()); - const int xWidth = fm.width(QLatin1Char('x')) / 2; + const int xWidth = fm.horizontalAdvance(QLatin1Char('x')) / 2; QTest::addColumn("attribute"); QTest::addColumn("amount"); diff --git a/src/kassistantdialog.cpp b/src/kassistantdialog.cpp --- a/src/kassistantdialog.cpp +++ b/src/kassistantdialog.cpp @@ -49,7 +49,7 @@ QModelIndex currentIndex; do { currentIndex = nextIndex; - nextIndex = currentIndex.child(0, 0); + nextIndex = pageModel->index(0, 0, currentIndex); if (!nextIndex.isValid()) { nextIndex = currentIndex.sibling(currentIndex.row() + 1, 0); } diff --git a/src/kcapacitybar.cpp b/src/kcapacitybar.cpp --- a/src/kcapacitybar.cpp +++ b/src/kcapacitybar.cpp @@ -350,9 +350,7 @@ QSize KCapacityBar::minimumSizeHint() const { - int width = (d->drawTextMode == KCapacityBar::DrawTextInline) ? - fontMetrics().width(d->text) + ROUND_MARGIN * 2 : - fontMetrics().width(d->text); + int width = fontMetrics().boundingRect(d->text).width() + ((d->drawTextMode == KCapacityBar::DrawTextInline) ? ROUND_MARGIN * 2 : 0); int height = (d->drawTextMode == KCapacityBar::DrawTextInline) ? qMax(fontMetrics().height(), d->barHeight) : diff --git a/src/kcollapsiblegroupbox.cpp b/src/kcollapsiblegroupbox.cpp --- a/src/kcollapsiblegroupbox.cpp +++ b/src/kcollapsiblegroupbox.cpp @@ -285,15 +285,13 @@ void KCollapsibleGroupBox::resizeEvent(QResizeEvent *event) { - int top, left, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); + const QMargins margins = contentsMargins(); if (layout()) { //we don't want the layout trying to fit the current frame of the animation so always set it to the target height - layout()->setGeometry(QRect(left, top, width() - left - right, layout()->sizeHint().height())); + layout()->setGeometry(QRect(margins.left(), margins.top(), width() - margins.left() - margins.right(), layout()->sizeHint().height())); } - Q_UNUSED(bottom) QWidget::resizeEvent(event); } diff --git a/src/kcolorbutton.cpp b/src/kcolorbutton.cpp --- a/src/kcolorbutton.cpp +++ b/src/kcolorbutton.cpp @@ -294,7 +294,7 @@ { if ((e->buttons() & Qt::LeftButton) && (e->pos() - d->mPos).manhattanLength() > QApplication::startDragDistance()) { - _k_createDrag(color(), this)->start(); + _k_createDrag(color(), this)->exec(); setDown(false); } } diff --git a/src/kdatecombobox.cpp b/src/kdatecombobox.cpp --- a/src/kdatecombobox.cpp +++ b/src/kdatecombobox.cpp @@ -584,7 +584,7 @@ void KDateComboBox::wheelEvent(QWheelEvent *event) { QDate temp; - if (event->delta() < 0) { + if (event->angleDelta().y() < 0) { temp = d->m_date.addDays(-1); } else { temp = d->m_date.addDays(1); diff --git a/src/kdatepicker.cpp b/src/kdatepicker.cpp --- a/src/kdatepicker.cpp +++ b/src/kdatepicker.cpp @@ -608,7 +608,7 @@ // stolen from QToolButton QSize textSize = metrics.size(Qt::TextShowMnemonic, longestMonth); - textSize.setWidth(textSize.width() + metrics.width(QLatin1Char(' ')) * 2); + textSize.setWidth(textSize.width() + metrics.horizontalAdvance(QLatin1Char(' ')) * 2); int w = textSize.width(); int h = textSize.height(); opt.rect.setHeight(h); // PM_MenuButtonIndicator depends on the height diff --git a/src/kdatetable.cpp b/src/kdatetable.cpp --- a/src/kdatetable.cpp +++ b/src/kdatetable.cpp @@ -524,7 +524,7 @@ void KDateTable::wheelEvent(QWheelEvent *e) { - setDate(d->m_date.addMonths(-(int)(e->delta() / 120))); + setDate(d->m_date.addMonths(-(int)(e->angleDelta().y() / 120))); e->accept(); } diff --git a/src/kfontchooser.cpp b/src/kfontchooser.cpp --- a/src/kfontchooser.cpp +++ b/src/kfontchooser.cpp @@ -46,7 +46,7 @@ for (int i = 0; i < list->count(); i++) { int itemWidth = list->visualItemRect(list->item(i)).width(); // ...and add a space on both sides for not too tight look. - itemWidth += list->fontMetrics().width(QLatin1Char(' ')) * 2; + itemWidth += list->fontMetrics().horizontalAdvance(QLatin1Char(' ')) * 2; w = qMax(w, itemWidth); } if (w == 0) { diff --git a/src/kmessagebox.cpp b/src/kmessagebox.cpp --- a/src/kmessagebox.cpp +++ b/src/kmessagebox.cpp @@ -279,7 +279,7 @@ QFontMetrics fm(styleOption.font); int w = listWidget->width(); for (const QString &str : strlist) { - w = qMax(w, fm.width(str)); + w = qMax(w, fm.boundingRect(str).width()); } const int borderWidth = listWidget->width() - listWidget->viewport()->width() + listWidget->verticalScrollBar()->height(); w += borderWidth; diff --git a/src/kpixmapregionselectordialog.cpp b/src/kpixmapregionselectordialog.cpp --- a/src/kpixmapregionselectordialog.cpp +++ b/src/kpixmapregionselectordialog.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -49,10 +50,9 @@ { if (pixmapSelectorWidget) { //Set maximum size for picture - QDesktopWidget desktopWidget; - QRect screen = desktopWidget.availableGeometry(); + const QRect screenGeometry = pixmapSelectorWidget->screen()->availableGeometry(); pixmapSelectorWidget->setMaximumWidgetSize( - (int)(screen.width() * 4.0 / 5), (int)(screen.height() * 4.0 / 5)); + (int)(screenGeometry.width() * 4.0 / 5), (int)(screenGeometry.height() * 4.0 / 5)); } } }; diff --git a/src/kpopupframe.cpp b/src/kpopupframe.cpp --- a/src/kpopupframe.cpp +++ b/src/kpopupframe.cpp @@ -21,10 +21,11 @@ #include "kpopupframe.h" -#include #include #include +#include #include +#include class Q_DECL_HIDDEN KPopupFrame::KPopupFramePrivate { @@ -149,23 +150,26 @@ void KPopupFrame::popup(const QPoint &pos) { // Make sure the whole popup is visible. - QRect desktopGeometry = QApplication::desktop()->screenGeometry(pos); + QScreen *screen = QGuiApplication::screenAt(pos); int x = pos.x(); int y = pos.y(); int w = width(); int h = height(); - if (x + w > desktopGeometry.x() + desktopGeometry.width()) { - x = desktopGeometry.width() - w; - } - if (y + h > desktopGeometry.y() + desktopGeometry.height()) { - y = desktopGeometry.height() - h; - } - if (x < desktopGeometry.x()) { - x = 0; - } - if (y < desktopGeometry.y()) { - y = 0; + if (screen) { + const QRect desktopGeometry = screen->geometry(); + if (x + w > desktopGeometry.x() + desktopGeometry.width()) { + x = desktopGeometry.width() - w; + } + if (y + h > desktopGeometry.y() + desktopGeometry.height()) { + y = desktopGeometry.height() - h; + } + if (x < desktopGeometry.x()) { + x = 0; + } + if (y < desktopGeometry.y()) { + y = 0; + } } // Pop the thingy up. diff --git a/src/kruler.cpp b/src/kruler.cpp --- a/src/kruler.cpp +++ b/src/kruler.cpp @@ -396,7 +396,7 @@ QFont font = this->font(); font.setPointSize(LABEL_SIZE); QFontMetrics fm(font); - d->fontWidth = fm.width(d->endlabel); + d->fontWidth = fm.horizontalAdvance(d->endlabel); } update(contentsRect()); } @@ -686,7 +686,7 @@ #endif p.drawText(END_LABEL_X, END_LABEL_Y, d->endlabel); } - p.resetMatrix(); + p.resetTransform(); } // draw the tiny marks diff --git a/src/kselector.cpp b/src/kselector.cpp --- a/src/kselector.cpp +++ b/src/kselector.cpp @@ -168,7 +168,7 @@ void KSelector::wheelEvent(QWheelEvent *e) { - int val = value() + e->delta() / 120; + int val = value() + e->angleDelta().y() / 120; setSliderDown(true); setValue(val); setSliderDown(false); @@ -333,14 +333,14 @@ if (orientation() == Qt::Vertical) { int yPos = contentsRect().top() + painter->fontMetrics().ascent() + 2; int xPos = contentsRect().left() + (contentsRect().width() - - painter->fontMetrics().width(d->text2)) / 2; + painter->fontMetrics().horizontalAdvance(d->text2)) / 2; QPen pen(qGray(firstColor().rgb()) > 180 ? Qt::black : Qt::white); painter->setPen(pen); painter->drawText(xPos, yPos, d->text2); yPos = contentsRect().bottom() - painter->fontMetrics().descent() - 2; xPos = contentsRect().left() + (contentsRect().width() - - painter->fontMetrics().width(d->text1)) / 2; + painter->fontMetrics().horizontalAdvance(d->text1)) / 2; pen.setColor(qGray(secondColor().rgb()) > 180 ? Qt::black : Qt::white); painter->setPen(pen); painter->drawText(xPos, yPos, d->text1); @@ -354,7 +354,7 @@ pen.setColor(qGray(secondColor().rgb()) > 180 ? Qt::black : Qt::white); painter->setPen(pen); painter->drawText(contentsRect().right() - - painter->fontMetrics().width(d->text2) - 2, yPos, d->text2); + painter->fontMetrics().horizontalAdvance(d->text2) - 2, yPos, d->text2); } } diff --git a/src/ksqueezedtextlabel.cpp b/src/ksqueezedtextlabel.cpp --- a/src/ksqueezedtextlabel.cpp +++ b/src/ksqueezedtextlabel.cpp @@ -77,7 +77,7 @@ { int maxWidth = QApplication::desktop()->screenGeometry(this).width() * 3 / 4; QFontMetrics fm(fontMetrics()); - int textWidth = fm.width(d->fullText); + int textWidth = fm.boundingRect(d->fullText).width(); if (textWidth > maxWidth) { textWidth = maxWidth; } @@ -118,7 +118,7 @@ const auto textLines = d->fullText.split(QLatin1Char('\n')); squeezedLines.reserve(textLines.size()); for (const QString &line : textLines) { - int lineWidth = fm.width(line); + int lineWidth = fm.boundingRect(line).width(); if (lineWidth > labelWidth) { squeezed = true; squeezedLines << fm.elidedText(line, d->elideMode, labelWidth); @@ -145,7 +145,7 @@ if (frameWidth() == 0) { indent = 0; } else { - indent = fontMetrics().width(QLatin1Char('x')) / 2 - margin; + indent = fontMetrics().horizontalAdvance(QLatin1Char('x')) / 2 - margin; } } diff --git a/src/ktitlewidget.cpp b/src/ktitlewidget.cpp --- a/src/ktitlewidget.cpp +++ b/src/ktitlewidget.cpp @@ -134,7 +134,6 @@ // default image / text part start d->headerLayout = new QGridLayout(titleFrame); d->headerLayout->setColumnStretch(0, 1); - d->headerLayout->setMargin(6); d->headerLayout->setContentsMargins(0, 0, 0, 0); d->textLabel = new QLabel(titleFrame); diff --git a/src/kxyselector.cpp b/src/kxyselector.cpp --- a/src/kxyselector.cpp +++ b/src/kxyselector.cpp @@ -194,12 +194,7 @@ void KXYSelector::wheelEvent(QWheelEvent *e) { - if (e->orientation() == Qt::Horizontal) { - setValues(xValue() + e->delta() / 120, yValue()); - } else { - setValues(xValue(), yValue() + e->delta() / 120); - } - + setValues(xValue() + e->angleDelta().x() / 120, yValue() + e->angleDelta().y() / 120); emit valueChanged(d->xPos, d->yPos); }