Commit 9dfdbdac authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Utils: StyleHelper::dpiSpecificPixmap > ::dpiSpecificImageFile



Letting that helper function return a file name is more flexible than
returning a QPixmap.

Change-Id: I4634e4e795eec029608c8e65c1a0e8afff870a91
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: default avatarAlessandro Portale <alessandro.portale@digia.com>
parent 38f206b1
...@@ -522,25 +522,17 @@ QLinearGradient StyleHelper::statusBarGradient(const QRect &statusBarRect) ...@@ -522,25 +522,17 @@ QLinearGradient StyleHelper::statusBarGradient(const QRect &statusBarRect)
return grad; return grad;
} }
QPixmap StyleHelper::dpiSpecificPixmap(const QString &fileName) QString StyleHelper::dpiSpecificImageFile(const QString &fileName)
{ {
QString pixmapFileName = fileName;
qreal pixmapDevicePixelRatio = 1.0;
// See QIcon::addFile() // See QIcon::addFile()
if (qApp->devicePixelRatio() > 1.0) { if (qApp->devicePixelRatio() > 1.0) {
const QFileInfo fi(fileName); const QFileInfo fi(fileName);
const QString at2xfileName = fi.path() + QLatin1Char('/') const QString at2xfileName = fi.path() + QLatin1Char('/')
+ fi.completeBaseName() + QStringLiteral("@2x.") + fi.suffix(); + fi.completeBaseName() + QStringLiteral("@2x.") + fi.suffix();
if (QFile::exists(at2xfileName)) { if (QFile::exists(at2xfileName))
pixmapFileName = at2xfileName; return at2xfileName;
pixmapDevicePixelRatio = 2.0;
}
} }
return fileName;
QPixmap result(pixmapFileName);
result.setDevicePixelRatio(pixmapDevicePixelRatio);
return result;
} }
} // namespace Utils } // namespace Utils
...@@ -93,7 +93,7 @@ public: ...@@ -93,7 +93,7 @@ public:
static void tintImage(QImage &img, const QColor &tintColor); static void tintImage(QImage &img, const QColor &tintColor);
static QLinearGradient statusBarGradient(const QRect &statusBarRect); static QLinearGradient statusBarGradient(const QRect &statusBarRect);
static QPixmap dpiSpecificPixmap(const QString &fileName); static QString dpiSpecificImageFile(const QString &fileName);
private: private:
static QColor m_baseColor; static QColor m_baseColor;
......
...@@ -569,7 +569,7 @@ void FindToolBar::updateIcons() ...@@ -569,7 +569,7 @@ void FindToolBar::updateIcons()
bool preserveCase = effectiveFlags & FindPreserveCase; bool preserveCase = effectiveFlags & FindPreserveCase;
if (!casesensitive && !wholewords && !regexp && !preserveCase) { if (!casesensitive && !wholewords && !regexp && !preserveCase) {
m_ui.findEdit->setButtonPixmap(Utils::FancyLineEdit::Left, m_ui.findEdit->setButtonPixmap(Utils::FancyLineEdit::Left,
Utils::StyleHelper::dpiSpecificPixmap(QLatin1Literal(Core::Constants::ICON_MAGNIFIER))); Utils::StyleHelper::dpiSpecificImageFile(QLatin1Literal(Core::Constants::ICON_MAGNIFIER)));
} else { } else {
m_ui.findEdit->setButtonPixmap(Utils::FancyLineEdit::Left, m_ui.findEdit->setButtonPixmap(Utils::FancyLineEdit::Left,
IFindFilter::pixmapForFindFlags(effectiveFlags)); IFindFilter::pixmapForFindFlags(effectiveFlags));
......
...@@ -248,7 +248,7 @@ LocatorWidget::LocatorWidget(Locator *qop) : ...@@ -248,7 +248,7 @@ LocatorWidget::LocatorWidget(Locator *qop) :
layout->addWidget(m_fileLineEdit); layout->addWidget(m_fileLineEdit);
setWindowIcon(QIcon(QLatin1String(":/locator/images/locator.png"))); setWindowIcon(QIcon(QLatin1String(":/locator/images/locator.png")));
const QPixmap image = Utils::StyleHelper::dpiSpecificPixmap(QLatin1String(Core::Constants::ICON_MAGNIFIER)); const QPixmap image = Utils::StyleHelper::dpiSpecificImageFile(QLatin1String(Core::Constants::ICON_MAGNIFIER));
m_fileLineEdit->setFiltering(true); m_fileLineEdit->setFiltering(true);
m_fileLineEdit->setButtonPixmap(Utils::FancyLineEdit::Left, image); m_fileLineEdit->setButtonPixmap(Utils::FancyLineEdit::Left, image);
m_fileLineEdit->setButtonToolTip(Utils::FancyLineEdit::Left, tr("Options")); m_fileLineEdit->setButtonToolTip(Utils::FancyLineEdit::Left, tr("Options"));
......
...@@ -130,8 +130,8 @@ public: ...@@ -130,8 +130,8 @@ public:
}; };
ManhattanStylePrivate::ManhattanStylePrivate() : ManhattanStylePrivate::ManhattanStylePrivate() :
lineeditImage(Utils::StyleHelper::dpiSpecificPixmap(QStringLiteral(":/core/images/inputfield.png")).toImage()), lineeditImage(Utils::StyleHelper::dpiSpecificImageFile(QStringLiteral(":/core/images/inputfield.png"))),
lineeditImage_disabled(Utils::StyleHelper::dpiSpecificPixmap(QStringLiteral(":/core/images/inputfield_disabled.png")).toImage()), lineeditImage_disabled(Utils::StyleHelper::dpiSpecificImageFile(QStringLiteral(":/core/images/inputfield_disabled.png"))),
extButtonPixmap(QLatin1String(":/core/images/extension.png")), extButtonPixmap(QLatin1String(":/core/images/extension.png")),
closeButtonPixmap(QLatin1String(Core::Constants::ICON_CLOSE)) closeButtonPixmap(QLatin1String(Core::Constants::ICON_CLOSE))
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment