X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fuisupport%2Ficon.h;h=d4f84cb4b7b619e54297c85accbadcb35f0841f5;hp=4cecb2add7d7725a5edbb0931bb2422b22242170;hb=45645a28bdc5b6c1052b3e4cebf8cc80832d205a;hpb=76db8cdfbeffaaba359c8e80cf2146da9e9e7f8a diff --git a/src/uisupport/icon.h b/src/uisupport/icon.h index 4cecb2ad..d4f84cb4 100644 --- a/src/uisupport/icon.h +++ b/src/uisupport/icon.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2013 by the Quassel Project * + * Copyright (C) 2005-2019 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -18,40 +18,43 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#ifndef ICON_H_ -#define ICON_H_ +#pragma once -#ifndef HAVE_KDE +#include "uisupport-export.h" -#include +#include -/// A very thin wrapper around QIcon -/** This wrapper class allows us to load an icon by its theme name rather than its full file name. - * The overloaded ctor uses IconLoader to locate an icon with this basename in the current theme - * or in Qt Resources. +#include +#include + +namespace icon { + +/** + * Gets an icon from the current icon theme. + * + * If the theme does not provide the icon, tries to load the icon from the + * fallback path, if given. + * + * If no icon can be found, a warning is displayed and a null icon returned. + * + * @param iconName Icon name + * @param fallbackPath Full path to a fallback icon + * @returns The requested icon, if available */ -class Icon : public QIcon -{ -public: - Icon(); - explicit Icon(const QString &iconName); - explicit Icon(const QIcon ©); - - Icon &operator=(const Icon &other); -}; - - -#else /* HAVE_KDE */ -#include -class Icon : public KIcon -{ -public: - inline Icon() : KIcon() {}; - inline explicit Icon(const QString &iconName) : KIcon(iconName) {}; - inline explicit Icon(const QIcon ©) : KIcon(copy) {}; -}; - - -#endif /* HAVE_KDE */ +UISUPPORT_EXPORT QIcon get(const QString& iconName, const QString& fallbackPath = {}); + +/** + * Gets an icon from the current icon theme. + * + * If the theme does not provide any of the given icon names, tries to load the + * icon from the fallback path, if given. + * + * If no icon can be found, a warning is displayed and a null icon returned. + * + * @param iconNames List of icon names (first match wins) + * @param fallbackPath Full path to a fallback icon + * @returns The requested icon, if available + */ +UISUPPORT_EXPORT QIcon get(const std::vector& iconNames, const QString& fallbackPath = {}); -#endif +} // namespace icon