diff options
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qtreeview.cpp | 2 | ||||
-rw-r--r-- | src/widgets/itemviews/qtreeview_p.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 2 | ||||
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 21 | ||||
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 96 | ||||
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 27 | ||||
-rw-r--r-- | src/widgets/styles/qstylehelper.cpp | 1 |
7 files changed, 81 insertions, 70 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index a15e050939..70523815e8 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -3739,6 +3739,8 @@ QPair<int,int> QTreeViewPrivate::startAndEndColumns(const QRect &rect) const bool QTreeViewPrivate::hasVisibleChildren(const QModelIndex& parent) const { Q_Q(const QTreeView); + if (parent.flags() & Qt::ItemNeverHasChildren) + return false; if (model->hasChildren(parent)) { if (hiddenIndexes.isEmpty()) return true; diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h index a687d4665d..90e83cb58c 100644 --- a/src/widgets/itemviews/qtreeview_p.h +++ b/src/widgets/itemviews/qtreeview_p.h @@ -229,7 +229,7 @@ public: { viewItems[item].height = 0; } inline int accessibleTable2Index(const QModelIndex &index) const { - return (viewIndex(index) + (header ? 1 : 0)) * model->columnCount()+index.column() + 1; + return (viewIndex(index) + (header ? 1 : 0)) * model->columnCount()+index.column(); } // used for spanning rows diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 0ef6b1735b..c2308b780f 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -8259,7 +8259,7 @@ bool QWidget::event(QEvent *event) #ifndef QT_NO_PROPERTIES case QEvent::DynamicPropertyChange: { const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName(); - if (!qstrncmp(propName, "_q_customDpi", 12) && propName.length() == 13) { + if (propName.length() == 13 && !qstrncmp(propName, "_q_customDpi", 12)) { uint value = property(propName.constData()).toUInt(); if (!d->extra) d->createExtra(); diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 1af909a3cb..f7ae667a82 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1115,6 +1115,8 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTabV3 *opt, const QWidget QSize tabIconSize = opt->icon.actualSize(iconSize, (opt->state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled, (opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off ); + // High-dpi icons do not need adjustmet; make sure tabIconSize is not larger than iconSize + tabIconSize = QSize(qMin(tabIconSize.width(), iconSize.width()), qMin(tabIconSize.height(), iconSize.width())); *iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2, tabIconSize.width(), tabIconSize .height()); @@ -1236,8 +1238,11 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, state = QIcon::On; QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); - int labelWidth = pixmap.width(); - int labelHeight = pixmap.height(); + + int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio(); + int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio(); + int labelWidth = pixmapWidth; + int labelHeight = pixmapHeight; int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint() int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width(); if (!button->text.isEmpty()) @@ -1245,7 +1250,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2, textRect.y() + (textRect.height() - labelHeight) / 2, - pixmap.width(), pixmap.height()); + pixmapWidth, pixmapHeight); iconRect = visualRect(button->direction, textRect, iconRect); @@ -1517,9 +1522,9 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, if (!header->icon.isNull()) { QPixmap pixmap = header->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); - int pixw = pixmap.width(); + int pixw = pixmap.width() / pixmap.devicePixelRatio(); - QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size(), rect); + QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size() / pixmap.devicePixelRatio(), rect); QRect inter = aligned.intersected(rect); p->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width(), inter.height()); @@ -1574,7 +1579,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, mode = QIcon::Normal; pm = toolbutton->icon.pixmap(toolbutton->rect.size().boundedTo(toolbutton->iconSize), mode, state); - pmSize = pm.size(); + pmSize = pm.size() / pm.devicePixelRatio(); } if (toolbutton->toolButtonStyle != Qt::ToolButtonIconOnly) { @@ -1800,8 +1805,8 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, tr = cr; tr.adjust(4, 0, -8, 0); } else { - int iw = pm.width() + 4; - ih = pm.height(); + int iw = pm.width() / pm.devicePixelRatio() + 4; + ih = pm.height()/ pm.devicePixelRatio(); ir = QRect(cr.left() + 4, cr.top(), iw + 2, ih); tr = QRect(ir.right(), cr.top(), cr.width() - ir.right() - 4, cr.height()); } diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 652d092652..bfc22807a0 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -2798,53 +2798,6 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption painter->restore(); } - // draw handle - if ((option->subControls & SC_SliderHandle) ) { - QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); - if (!QPixmapCache::find(handlePixmapName, cache)) { - cache = styleCachePixmap(handle.size()); - cache.fill(Qt::transparent); - QRect pixmapRect(0, 0, handle.width(), handle.height()); - QPainter handlePainter(&cache); - QRect gradRect = pixmapRect.adjusted(2, 2, -2, -2); - - // gradient fill - QRect r = pixmapRect.adjusted(1, 1, -2, -2); - QLinearGradient gradient = qt_fusion_gradient(gradRect, d->buttonColor(option->palette),horizontal ? TopDown : FromLeft); - - handlePainter.setRenderHint(QPainter::Antialiasing, true); - handlePainter.translate(0.5, 0.5); - - handlePainter.setPen(Qt::NoPen); - handlePainter.setBrush(QColor(0, 0, 0, 40)); - handlePainter.drawRect(r.adjusted(-1, 2, 1, -2)); - - handlePainter.setPen(QPen(d->outline(option->palette))); - if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange) - handlePainter.setPen(QPen(d->highlightedOutline(option->palette))); - - handlePainter.setBrush(gradient); - handlePainter.drawRoundedRect(r, 2, 2); - handlePainter.setBrush(Qt::NoBrush); - handlePainter.setPen(d->innerContrastLine()); - handlePainter.drawRoundedRect(r.adjusted(1, 1, -1, -1), 2, 2); - - QColor cornerAlpha = outline.darker(120); - cornerAlpha.setAlpha(80); - - //handle shadow - handlePainter.setPen(shadowAlpha); - handlePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1), QPoint(r.right() - 2, r.bottom() + 1)); - handlePainter.drawLine(QPoint(r.right() + 1, r.bottom() - 3), QPoint(r.right() + 1, r.top() + 4)); - handlePainter.drawLine(QPoint(r.right() - 1, r.bottom()), QPoint(r.right() + 1, r.bottom() - 2)); - - handlePainter.end(); - QPixmapCache::insert(handlePixmapName, cache); - } - - painter->drawPixmap(handle.topLeft(), cache); - - } if (option->subControls & SC_SliderTickmarks) { painter->setPen(outline); int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); @@ -2900,6 +2853,53 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption v = nextInterval; } } + // draw handle + if ((option->subControls & SC_SliderHandle) ) { + QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); + if (!QPixmapCache::find(handlePixmapName, cache)) { + cache = styleCachePixmap(handle.size()); + cache.fill(Qt::transparent); + QRect pixmapRect(0, 0, handle.width(), handle.height()); + QPainter handlePainter(&cache); + QRect gradRect = pixmapRect.adjusted(2, 2, -2, -2); + + // gradient fill + QRect r = pixmapRect.adjusted(1, 1, -2, -2); + QLinearGradient gradient = qt_fusion_gradient(gradRect, d->buttonColor(option->palette),horizontal ? TopDown : FromLeft); + + handlePainter.setRenderHint(QPainter::Antialiasing, true); + handlePainter.translate(0.5, 0.5); + + handlePainter.setPen(Qt::NoPen); + handlePainter.setBrush(QColor(0, 0, 0, 40)); + handlePainter.drawRect(r.adjusted(-1, 2, 1, -2)); + + handlePainter.setPen(QPen(d->outline(option->palette))); + if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange) + handlePainter.setPen(QPen(d->highlightedOutline(option->palette))); + + handlePainter.setBrush(gradient); + handlePainter.drawRoundedRect(r, 2, 2); + handlePainter.setBrush(Qt::NoBrush); + handlePainter.setPen(d->innerContrastLine()); + handlePainter.drawRoundedRect(r.adjusted(1, 1, -1, -1), 2, 2); + + QColor cornerAlpha = outline.darker(120); + cornerAlpha.setAlpha(80); + + //handle shadow + handlePainter.setPen(shadowAlpha); + handlePainter.drawLine(QPoint(r.left() + 2, r.bottom() + 1), QPoint(r.right() - 2, r.bottom() + 1)); + handlePainter.drawLine(QPoint(r.right() + 1, r.bottom() - 3), QPoint(r.right() + 1, r.top() + 4)); + handlePainter.drawLine(QPoint(r.right() - 1, r.bottom()), QPoint(r.right() + 1, r.bottom() - 2)); + + handlePainter.end(); + QPixmapCache::insert(handlePixmapName, cache); + } + + painter->drawPixmap(handle.topLeft(), cache); + + } painter->setBrush(oldBrush); painter->setPen(oldPen); } @@ -2920,6 +2920,8 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption int QFusionStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const { switch (metric) { + case PM_SliderTickmarkOffset: + return 4; case PM_HeaderMargin: return 2; case PM_ToolTipLabelFrameWidth: diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 1ea0e27418..04fea3ec47 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -3336,9 +3336,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QPixmap pixmap = header->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), mode); QRect pixr = header->rect; - pixr.setY(header->rect.center().y() - (pixmap.height() - 1) / 2); + pixr.setY(header->rect.center().y() - (pixmap.height() / pixmap.devicePixelRatio() - 1) / 2); proxy()->drawItemPixmap(p, pixr, Qt::AlignVCenter, pixmap); - textr.translate(pixmap.width() + 2, 0); + textr.translate(pixmap.width() / pixmap.devicePixelRatio() + 2, 0); } p->setFont(qt_app_fonts_hash()->value("QSmallFont", QFont())); @@ -3392,15 +3392,15 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (tb->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { QMainWindow *mw = qobject_cast<QMainWindow *>(w->window()); if (mw && mw->unifiedTitleAndToolBarOnMac()) { - pr.setHeight(pixmap.size().height()); + pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio()); cr.adjust(0, pr.bottom() + 1, 0, 1); } else { - pr.setHeight(pixmap.size().height() + 6); + pr.setHeight(pixmap.size().height() / pixmap.devicePixelRatio() + 6); cr.adjust(0, pr.bottom(), 0, -3); } alignment |= Qt::AlignCenter; } else { - pr.setWidth(pixmap.width() + 8); + pr.setWidth(pixmap.width() / pixmap.devicePixelRatio() + 8); cr.adjust(pr.right(), 0, 0, 0); alignment |= Qt::AlignLeft | Qt::AlignVCenter; } @@ -3638,10 +3638,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (btn->state & State_On) state = QIcon::On; QPixmap pixmap = btn->icon.pixmap(btn->iconSize, mode, state); - contentW += pixmap.width() + QMacStylePrivate::PushButtonContentPadding; + int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio(); + int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio(); + contentW += pixmapWidth + QMacStylePrivate::PushButtonContentPadding; int iconLeftOffset = freeContentRect.x() + (freeContentRect.width() - contentW) / 2; - int iconTopOffset = freeContentRect.y() + (freeContentRect.height() - pixmap.height()) / 2; - QRect iconDestRect(iconLeftOffset, iconTopOffset, pixmap.width(), pixmap.height()); + int iconTopOffset = freeContentRect.y() + (freeContentRect.height() - pixmapHeight) / 2; + QRect iconDestRect(iconLeftOffset, iconTopOffset, pixmapWidth, pixmapHeight); QRect visualIconDestRect = visualRect(btn->direction, freeContentRect, iconDestRect); proxy()->drawItemPixmap(p, visualIconDestRect, Qt::AlignLeft | Qt::AlignVCenter, pixmap); int newOffset = iconDestRect.x() + iconDestRect.width() @@ -3999,7 +4001,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (!enabled) p->setPen(mi->palette.text().color()); else if (active) - p->setPen(QColor(Qt::white)); // QPalette's API is incomplete for this case + p->setPen(mi->palette.highlightedText().color()); else p->setPen(mi->palette.buttonText().color()); @@ -4070,8 +4072,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter iconSize = comboBox->iconSize(); } QPixmap pixmap = mi->icon.pixmap(iconSize, mode); - int pixw = pixmap.width(); - int pixh = pixmap.height(); + int pixw = pixmap.width() / pixmap.devicePixelRatio(); + int pixh = pixmap.height() / pixmap.devicePixelRatio(); QRect cr(xpos, contentRect.y(), checkcol, contentRect.height()); QRect pmr(0, 0, pixw, pixh); pmr.moveCenter(cr.center()); @@ -6353,6 +6355,7 @@ QIcon QMacStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *o QPixmap pixmap(QLatin1String(":/qt-project.org/styles/macstyle/images/toolbar-ext.png")); if (standardIcon == SP_ToolBarVerticalExtensionButton) { QPixmap pix2(pixmap.height(), pixmap.width()); + pix2.setDevicePixelRatio(pixmap.devicePixelRatio()); pix2.fill(Qt::transparent); QPainter p(&pix2); p.translate(pix2.width(), 0); @@ -6502,7 +6505,7 @@ void qt_mac_scale_region(QRegion *region, qreal scaleFactor) scaledRects.reserve(region->rects().count()); foreach (const QRect &rect, region->rects()) { - scaledRects.append(QRect(rect.topLeft(), rect.size() * scaleFactor)); + scaledRects.append(QRect(rect.topLeft() * scaleFactor, rect.size() * scaleFactor)); } region->setRects(&scaledRects[0], scaledRects.count()); } diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 33a422fdd4..fc73488154 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -92,7 +92,6 @@ bool isInstanceOf(QObject *obj, QAccessible::Role role) bool match = false; QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(obj); match = iface && iface->role() == role; - delete iface; return match; } |