Target Selector: Fall back to built-in Desktop icon

If the style doesn't offer any icons that have at least 32 pixels

Change-Id: I840d73a0b4bdee695bb68df1c3973ee419db012e
Task-number: QTCREATORBUG-12832
Reviewed-by: Robert Loehning <robert.loehning@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Robert Loehning
2015-05-21 16:58:21 +02:00
committed by Daniel Teske
parent a19f9f683a
commit 661c68fffe
4 changed files with 16 additions and 0 deletions

View File

@@ -112,5 +112,6 @@
<file>images/info@2x.png</file>
<file>images/dark_fileicon.png</file>
<file>images/dark_foldericon.png</file>
<file>images/Desktop.png</file>
</qresource>
</RCC>

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -34,6 +34,7 @@
#include <coreplugin/coreconstants.h>
#include <utils/algorithm.h>
#include <utils/hostosinfo.h>
#include <utils/stylehelper.h>
@@ -336,6 +337,19 @@ QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QSty
return pixmap;
}
QIcon ManhattanStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
{
QIcon icon = QProxyStyle::standardIcon(standardIcon, option, widget);
if (standardIcon == QStyle::SP_ComputerIcon) {
// Ubuntu has in some versions a 16x16 icon, see QTCREATORBUG-12832
const QList<QSize> &sizes = icon.availableSizes();
if (Utils::allOf(sizes, [](const QSize &size) { return size.width() < 32;})) {
icon = QIcon(QLatin1String(":/core/images/Desktop.png"));
}
}
return icon;
}
int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
QStyleHintReturn *returnData) const
{

View File

@@ -56,6 +56,7 @@ public:
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = 0) const;
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0, const QWidget *widget = 0) const;
int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
QRect itemRect(QPainter *p, const QRect &r, int flags, bool enabled, const QPixmap *pixmap, const QString &text, int len = -1) const;
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const;