Windows style, themes: Fix deprecation warnings

Fix:
qwindowstheme.cpp:287:77: warning: 'const QBrush& QPalette::background() const' is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
qwindowstheme.cpp:336:37: warning: 'const QBrush& QPalette::foreground() const' is deprecated: Use QPalette::windowText() instead [-Wdeprecated-declarations]
qwindowstheme.cpp:861:102: warning: 'static bool QPixmapCache::find(const QString&, QPixmap&)' is deprecated: Use bool find(const QString &, QPixmap *) instead [-Wdeprecated-declarations]
qwindowsvistastyle.cpp:635:56: warning: 'const QBrush& QPalette::background() const' is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
qwindowsvistastyle.cpp:707:60: warning: 'static bool QPixmapCache::find(const QString&, QPixmap&)' is deprecated: Use bool find(const QString &, QPixmap *) instead [-Wdeprecated-declarations]
qwindowsxpstyle.cpp:743:58: warning: 'const QMatrix& QPainter::deviceMatrix() const' is deprecated: Use deviceTransform() instead [-Wdeprecated-declarations]
qwindowsinputcontext.cpp:448:49: warning: 'const QBrush& QPalette::background() const' is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]

Change-Id: I00a52a27b066caeb135ad4124f71ef3e09beafbf
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
Friedemann Kleint 2019-02-05 16:29:01 +01:00 committed by Liang Qi
parent 27065bdc50
commit a6f25dedd8
4 changed files with 20 additions and 18 deletions

View File

@ -445,7 +445,7 @@ static inline QTextFormat standardFormat(StandardFormat format)
const QPalette palette = QGuiApplication::palette(); const QPalette palette = QGuiApplication::palette();
const QColor background = palette.text().color(); const QColor background = palette.text().color();
result.setBackground(QBrush(background)); result.setBackground(QBrush(background));
result.setForeground(palette.background()); result.setForeground(palette.window());
break; break;
} }
} }

View File

@ -284,24 +284,24 @@ static inline QPalette systemPalette()
result.setColor(QPalette::Link, Qt::blue); result.setColor(QPalette::Link, Qt::blue);
result.setColor(QPalette::LinkVisited, Qt::magenta); result.setColor(QPalette::LinkVisited, Qt::magenta);
result.setColor(QPalette::Inactive, QPalette::Button, result.button().color()); result.setColor(QPalette::Inactive, QPalette::Button, result.button().color());
result.setColor(QPalette::Inactive, QPalette::Window, result.background().color()); result.setColor(QPalette::Inactive, QPalette::Window, result.window().color());
result.setColor(QPalette::Inactive, QPalette::Light, result.light().color()); result.setColor(QPalette::Inactive, QPalette::Light, result.light().color());
result.setColor(QPalette::Inactive, QPalette::Dark, result.dark().color()); result.setColor(QPalette::Inactive, QPalette::Dark, result.dark().color());
if (result.midlight() == result.button()) if (result.midlight() == result.button())
result.setColor(QPalette::Midlight, result.button().color().lighter(110)); result.setColor(QPalette::Midlight, result.button().color().lighter(110));
if (result.background() != result.base()) { if (result.window() != result.base()) {
result.setColor(QPalette::Inactive, QPalette::Highlight, result.color(QPalette::Inactive, QPalette::Window)); result.setColor(QPalette::Inactive, QPalette::Highlight, result.color(QPalette::Inactive, QPalette::Window));
result.setColor(QPalette::Inactive, QPalette::HighlightedText, result.color(QPalette::Inactive, QPalette::Text)); result.setColor(QPalette::Inactive, QPalette::HighlightedText, result.color(QPalette::Inactive, QPalette::Text));
} }
const QColor disabled = const QColor disabled =
mixColors(result.foreground().color(), result.button().color()); mixColors(result.windowText().color(), result.button().color());
result.setColorGroup(QPalette::Disabled, result.foreground(), result.button(), result.setColorGroup(QPalette::Disabled, result.windowText(), result.button(),
result.light(), result.dark(), result.mid(), result.light(), result.dark(), result.mid(),
result.text(), result.brightText(), result.base(), result.text(), result.brightText(), result.base(),
result.background()); result.window());
result.setColor(QPalette::Disabled, QPalette::WindowText, disabled); result.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
result.setColor(QPalette::Disabled, QPalette::Text, disabled); result.setColor(QPalette::Disabled, QPalette::Text, disabled);
result.setColor(QPalette::Disabled, QPalette::ButtonText, disabled); result.setColor(QPalette::Disabled, QPalette::ButtonText, disabled);
@ -310,7 +310,7 @@ static inline QPalette systemPalette()
result.setColor(QPalette::Disabled, QPalette::HighlightedText, result.setColor(QPalette::Disabled, QPalette::HighlightedText,
getSysColor(COLOR_HIGHLIGHTTEXT)); getSysColor(COLOR_HIGHLIGHTTEXT));
result.setColor(QPalette::Disabled, QPalette::Base, result.setColor(QPalette::Disabled, QPalette::Base,
result.background().color()); result.window().color());
return result; return result;
} }
@ -333,7 +333,7 @@ static inline QPalette toolTipPalette(const QPalette &systemPalette)
result.setColor(QPalette::All, QPalette::ToolTipBase, tipBgColor); result.setColor(QPalette::All, QPalette::ToolTipBase, tipBgColor);
result.setColor(QPalette::All, QPalette::ToolTipText, tipTextColor); result.setColor(QPalette::All, QPalette::ToolTipText, tipTextColor);
const QColor disabled = const QColor disabled =
mixColors(result.foreground().color(), result.button().color()); mixColors(result.windowText().color(), result.button().color());
result.setColor(QPalette::Disabled, QPalette::WindowText, disabled); result.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
result.setColor(QPalette::Disabled, QPalette::Text, disabled); result.setColor(QPalette::Disabled, QPalette::Text, disabled);
result.setColor(QPalette::Disabled, QPalette::ToolTipText, disabled); result.setColor(QPalette::Disabled, QPalette::ToolTipText, disabled);
@ -858,7 +858,8 @@ QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon
int iIcon = (useDefaultFolderIcon && defaultFolderIIcon >= 0) ? defaultFolderIIcon int iIcon = (useDefaultFolderIcon && defaultFolderIIcon >= 0) ? defaultFolderIIcon
: **dirIconEntryCache.object(filePath); : **dirIconEntryCache.object(filePath);
if (iIcon) { if (iIcon) {
QPixmapCache::find(dirIconPixmapCacheKey(iIcon, iconSize, requestedImageListSize), pixmap); QPixmapCache::find(dirIconPixmapCacheKey(iIcon, iconSize, requestedImageListSize),
&pixmap);
if (pixmap.isNull()) // Let's keep both caches in sync if (pixmap.isNull()) // Let's keep both caches in sync
dirIconEntryCache.remove(filePath); dirIconEntryCache.remove(filePath);
else else
@ -889,7 +890,7 @@ QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon
//using the unique icon index provided by windows save us from duplicate keys //using the unique icon index provided by windows save us from duplicate keys
key = dirIconPixmapCacheKey(info.iIcon, iconSize, requestedImageListSize); key = dirIconPixmapCacheKey(info.iIcon, iconSize, requestedImageListSize);
QPixmapCache::find(key, pixmap); QPixmapCache::find(key, &pixmap);
if (!pixmap.isNull()) { if (!pixmap.isNull()) {
QMutexLocker locker(&mx); QMutexLocker locker(&mx);
dirIconEntryCache.insert(filePath, FakePointer<int>::create(info.iIcon)); dirIconEntryCache.insert(filePath, FakePointer<int>::create(info.iIcon));

View File

@ -632,7 +632,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
{ {
QPen pen = painter->pen(); QPen pen = painter->pen();
int margin = 3; int margin = 3;
painter->setPen(option->palette.background().color().darker(114)); painter->setPen(option->palette.window().color().darker(114));
if (option->state & State_Horizontal) { if (option->state & State_Horizontal) {
int x1 = option->rect.center().x(); int x1 = option->rect.center().x();
painter->drawLine(QPoint(x1, option->rect.top() + margin), QPoint(x1, option->rect.bottom() - margin)); painter->drawLine(QPoint(x1, option->rect.top() + margin), QPoint(x1, option->rect.bottom() - margin));
@ -704,7 +704,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
if (sectionSize.width() > 0 && sectionSize.height() > 0) { if (sectionSize.width() > 0 && sectionSize.height() > 0) {
QString key = QString::fromLatin1("qvdelegate-%1-%2-%3-%4-%5").arg(sectionSize.width()) QString key = QString::fromLatin1("qvdelegate-%1-%2-%3-%4-%5").arg(sectionSize.width())
.arg(sectionSize.height()).arg(selected).arg(active).arg(hover); .arg(sectionSize.height()).arg(selected).arg(active).arg(hover);
if (!QPixmapCache::find(key, pixmap)) { if (!QPixmapCache::find(key, &pixmap)) {
pixmap = QPixmap(sectionSize); pixmap = QPixmap(sectionSize);
pixmap.fill(Qt::transparent); pixmap.fill(Qt::transparent);
@ -1053,7 +1053,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
} }
QString name = QString::fromLatin1("qiprogress-%1-%2").arg(pixmapSize.width()).arg(pixmapSize.height()); QString name = QString::fromLatin1("qiprogress-%1-%2").arg(pixmapSize.width()).arg(pixmapSize.height());
QPixmap pixmap; QPixmap pixmap;
if (!QPixmapCache::find(name, pixmap)) { if (!QPixmapCache::find(name, &pixmap)) {
QImage image(pixmapSize, QImage::Format_ARGB32); QImage image(pixmapSize, QImage::Format_ARGB32);
image.fill(Qt::transparent); image.fill(Qt::transparent);
QPainter imagePainter(&image); QPainter imagePainter(&image);
@ -1363,7 +1363,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
case CE_ToolBar: case CE_ToolBar:
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) { if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
QPalette pal = option->palette; QPalette pal = option->palette;
pal.setColor(QPalette::Dark, option->palette.background().color().darker(130)); pal.setColor(QPalette::Dark, option->palette.window().color().darker(130));
QStyleOptionToolBar copyOpt = *toolbar; QStyleOptionToolBar copyOpt = *toolbar;
copyOpt.palette = pal; copyOpt.palette = pal;
QWindowsStyle::drawControl(element, &copyOpt, painter, widget); QWindowsStyle::drawControl(element, &copyOpt, painter, widget);
@ -1388,8 +1388,8 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
painter->translate(-rect.left() + 1, -rect.top()); painter->translate(-rect.left() + 1, -rect.top());
} }
painter->setBrush(option->palette.background().color().darker(110)); painter->setBrush(option->palette.window().color().darker(110));
painter->setPen(option->palette.background().color().darker(130)); painter->setPen(option->palette.window().color().darker(130));
painter->drawRect(rect.adjusted(0, 1, -1, -3)); painter->drawRect(rect.adjusted(0, 1, -1, -3));
int buttonMargin = 4; int buttonMargin = 4;

View File

@ -740,7 +740,8 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa
{ {
QPainter *painter = themeData.painter; QPainter *painter = themeData.painter;
const QPointF redirectionDelta(painter->deviceMatrix().dx(), painter->deviceMatrix().dy()); const auto deviceTransform = painter->deviceTransform();
const QPointF redirectionDelta(deviceTransform.dx(), deviceTransform.dy());
const QRect area = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect(); const QRect area = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect();
QRegion sysRgn = painter->paintEngine()->systemClip(); QRegion sysRgn = painter->paintEngine()->systemClip();
@ -835,7 +836,7 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
alphaType = data.alphaType; alphaType = data.alphaType;
potentialInvalidAlpha = data.hadInvalidAlpha; potentialInvalidAlpha = data.hadInvalidAlpha;
haveCachedPixmap = QPixmapCache::find(pixmapCacheKey, cachedPixmap); haveCachedPixmap = QPixmapCache::find(pixmapCacheKey, &cachedPixmap);
#ifdef DEBUG_XP_STYLE #ifdef DEBUG_XP_STYLE
char buf[25]; char buf[25];