mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 04:49:47 -07:00
Add const to function signature
This commit is contained in:
parent
fea7a96e68
commit
9df67b52b8
4 changed files with 13 additions and 16 deletions
|
@ -29,8 +29,6 @@
|
||||||
|
|
||||||
#include "iconprovider.h"
|
#include "iconprovider.h"
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
IconProvider::IconProvider(QObject *parent)
|
IconProvider::IconProvider(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +55,7 @@ IconProvider *IconProvider::instance()
|
||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IconProvider::getIconPath(const QString &iconId)
|
QString IconProvider::getIconPath(const QString &iconId) const
|
||||||
{
|
{
|
||||||
return ":/icons/qbt-theme/" + iconId + ".png";
|
return ":/icons/qbt-theme/" + iconId + ".png";
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,7 @@
|
||||||
#define ICONPROVIDER_H
|
#define ICONPROVIDER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
class QString;
|
|
||||||
|
|
||||||
class IconProvider : public QObject
|
class IconProvider : public QObject
|
||||||
{
|
{
|
||||||
|
@ -43,7 +42,7 @@ public:
|
||||||
static void freeInstance();
|
static void freeInstance();
|
||||||
static IconProvider *instance();
|
static IconProvider *instance();
|
||||||
|
|
||||||
virtual QString getIconPath(const QString &iconId);
|
virtual QString getIconPath(const QString &iconId) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit IconProvider(QObject *parent = nullptr);
|
explicit IconProvider(QObject *parent = nullptr);
|
||||||
|
|
|
@ -57,12 +57,12 @@ GuiIconProvider *GuiIconProvider::instance()
|
||||||
return static_cast<GuiIconProvider *>(m_instance);
|
return static_cast<GuiIconProvider *>(m_instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon GuiIconProvider::getIcon(const QString &iconId)
|
QIcon GuiIconProvider::getIcon(const QString &iconId) const
|
||||||
{
|
{
|
||||||
return getIcon(iconId, iconId);
|
return getIcon(iconId, iconId);
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon GuiIconProvider::getIcon(const QString &iconId, const QString &fallback)
|
QIcon GuiIconProvider::getIcon(const QString &iconId, const QString &fallback) const
|
||||||
{
|
{
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
if (m_useSystemTheme) {
|
if (m_useSystemTheme) {
|
||||||
|
@ -78,7 +78,7 @@ QIcon GuiIconProvider::getIcon(const QString &iconId, const QString &fallback)
|
||||||
return QIcon(IconProvider::getIconPath(iconId));
|
return QIcon(IconProvider::getIconPath(iconId));
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon GuiIconProvider::getFlagIcon(const QString &countryIsoCode)
|
QIcon GuiIconProvider::getFlagIcon(const QString &countryIsoCode) const
|
||||||
{
|
{
|
||||||
if (countryIsoCode.isEmpty()) return QIcon();
|
if (countryIsoCode.isEmpty()) return QIcon();
|
||||||
return QIcon(":/icons/flags/" + countryIsoCode.toLower() + ".svg");
|
return QIcon(":/icons/flags/" + countryIsoCode.toLower() + ".svg");
|
||||||
|
@ -89,7 +89,7 @@ QIcon GuiIconProvider::getFlagIcon(const QString &countryIsoCode)
|
||||||
// Otherwise, the UI looks broken if the icon is not available
|
// Otherwise, the UI looks broken if the icon is not available
|
||||||
// in the correct size.
|
// in the correct size.
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
QIcon GuiIconProvider::generateDifferentSizes(const QIcon &icon)
|
QIcon GuiIconProvider::generateDifferentSizes(const QIcon &icon) const
|
||||||
{
|
{
|
||||||
// if icon is loaded from SVG format, it already contains all the required sizes and we shall not resize it
|
// if icon is loaded from SVG format, it already contains all the required sizes and we shall not resize it
|
||||||
// In that case it will be available in the following sizes:
|
// In that case it will be available in the following sizes:
|
||||||
|
@ -120,7 +120,7 @@ QIcon GuiIconProvider::generateDifferentSizes(const QIcon &icon)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QString GuiIconProvider::getIconPath(const QString &iconId)
|
QString GuiIconProvider::getIconPath(const QString &iconId) const
|
||||||
{
|
{
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
if (m_useSystemTheme) {
|
if (m_useSystemTheme) {
|
||||||
|
|
|
@ -43,10 +43,10 @@ public:
|
||||||
static void initInstance();
|
static void initInstance();
|
||||||
static GuiIconProvider *instance();
|
static GuiIconProvider *instance();
|
||||||
|
|
||||||
QIcon getIcon(const QString &iconId);
|
QIcon getIcon(const QString &iconId) const;
|
||||||
QIcon getIcon(const QString &iconId, const QString &fallback);
|
QIcon getIcon(const QString &iconId, const QString &fallback) const;
|
||||||
QIcon getFlagIcon(const QString &countryIsoCode);
|
QIcon getFlagIcon(const QString &countryIsoCode) const;
|
||||||
QString getIconPath(const QString &iconId);
|
QString getIconPath(const QString &iconId) const override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void configure();
|
void configure();
|
||||||
|
@ -55,7 +55,7 @@ private:
|
||||||
explicit GuiIconProvider(QObject *parent = nullptr);
|
explicit GuiIconProvider(QObject *parent = nullptr);
|
||||||
~GuiIconProvider();
|
~GuiIconProvider();
|
||||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
QIcon generateDifferentSizes(const QIcon &icon);
|
QIcon generateDifferentSizes(const QIcon &icon) const;
|
||||||
|
|
||||||
bool m_useSystemTheme;
|
bool m_useSystemTheme;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue