mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kdeui: use foreach() for iterations in KIconLoader
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
9c4a2560c4
commit
0fc795f6a3
2 changed files with 78 additions and 84 deletions
|
@ -431,7 +431,7 @@ void KIconLoader::reconfigure(const QString &_appname, KStandardDirs *_dirs)
|
||||||
|
|
||||||
void KIconLoaderPrivate::init( const QString &_appname, KStandardDirs *_dirs)
|
void KIconLoaderPrivate::init( const QString &_appname, KStandardDirs *_dirs)
|
||||||
{
|
{
|
||||||
extraDesktopIconsLoaded=false;
|
extraDesktopIconsLoaded = false;
|
||||||
mIconThemeInited = false;
|
mIconThemeInited = false;
|
||||||
mpThemeRoot = 0;
|
mpThemeRoot = 0;
|
||||||
|
|
||||||
|
@ -606,7 +606,7 @@ void KIconLoaderPrivate::addThemeByName(const QString &themename, const QString
|
||||||
delete theme;
|
delete theme;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
KIconThemeNode *n = new KIconThemeNode(theme);
|
KIconThemeNode* n = new KIconThemeNode(theme);
|
||||||
mThemesInTree.append(themename + appname);
|
mThemesInTree.append(themename + appname);
|
||||||
links.append(n);
|
links.append(n);
|
||||||
addInheritedThemes(n, appname);
|
addInheritedThemes(n, appname);
|
||||||
|
@ -614,7 +614,9 @@ void KIconLoaderPrivate::addThemeByName(const QString &themename, const QString
|
||||||
|
|
||||||
void KIconLoader::addExtraDesktopThemes()
|
void KIconLoader::addExtraDesktopThemes()
|
||||||
{
|
{
|
||||||
if ( d->extraDesktopIconsLoaded ) return;
|
if (d->extraDesktopIconsLoaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
d->initIconThemes();
|
d->initIconThemes();
|
||||||
|
|
||||||
|
@ -622,27 +624,23 @@ void KIconLoader::addExtraDesktopThemes()
|
||||||
const QStringList icnlibs = KGlobal::dirs()->resourceDirs("icon");
|
const QStringList icnlibs = KGlobal::dirs()->resourceDirs("icon");
|
||||||
QStringList::ConstIterator it;
|
QStringList::ConstIterator it;
|
||||||
char buf[1000];
|
char buf[1000];
|
||||||
int r;
|
foreach (const QString &it, icnlibs) {
|
||||||
for (it=icnlibs.begin(); it!=icnlibs.end(); ++it)
|
QDir dir(it);
|
||||||
{
|
|
||||||
QDir dir(*it);
|
|
||||||
if (!dir.exists())
|
if (!dir.exists())
|
||||||
continue;
|
continue;
|
||||||
const QStringList lst = dir.entryList(QStringList( "default.*" ), QDir::Dirs);
|
const QStringList lst = dir.entryList(QStringList( "default.*" ), QDir::Dirs);
|
||||||
QStringList::ConstIterator it2;
|
foreach (const QString &it2, lst) {
|
||||||
for (it2=lst.begin(); it2!=lst.end(); ++it2)
|
if (!KStandardDirs::exists(it + it2 + "/index.theme")) {
|
||||||
{
|
|
||||||
if (!KStandardDirs::exists(*it + *it2 + "/index.theme"))
|
|
||||||
continue;
|
continue;
|
||||||
r=readlink( QFile::encodeName(*it + *it2) , buf, sizeof(buf)-1);
|
}
|
||||||
if ( r>0 )
|
const int r = readlink(QFile::encodeName(it + it2), buf, sizeof(buf) - 1);
|
||||||
{
|
if (r > 0) {
|
||||||
buf[r]=0;
|
buf[r] = 0;
|
||||||
const QDir dir2( buf );
|
const QDir dir2(buf);
|
||||||
QString themeName=dir2.dirName();
|
const QString themeName = dir2.dirName();
|
||||||
|
if (!list.contains(themeName)) {
|
||||||
if (!list.contains(themeName))
|
|
||||||
list.append(themeName);
|
list.append(themeName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1263,19 +1261,17 @@ QStringList KIconLoader::queryIconsByContext(int group_or_size,
|
||||||
// Eliminate duplicate entries (same icon in different directories)
|
// Eliminate duplicate entries (same icon in different directories)
|
||||||
QString name;
|
QString name;
|
||||||
QStringList res2, entries;
|
QStringList res2, entries;
|
||||||
QStringList::ConstIterator it;
|
foreach (const QString &it, result) {
|
||||||
for (it=result.constBegin(); it!=result.constEnd(); ++it)
|
const int n = it.lastIndexOf('/');
|
||||||
{
|
if (n == -1) {
|
||||||
int n = (*it).lastIndexOf('/');
|
name = it;
|
||||||
if (n == -1)
|
} else {
|
||||||
name = *it;
|
name = it.mid(n + 1);
|
||||||
else
|
}
|
||||||
name = (*it).mid(n+1);
|
|
||||||
name = d->removeIconExtension(name);
|
name = d->removeIconExtension(name);
|
||||||
if (!entries.contains(name))
|
if (!entries.contains(name)) {
|
||||||
{
|
|
||||||
entries += name;
|
entries += name;
|
||||||
res2 += *it;
|
res2 += it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res2;
|
return res2;
|
||||||
|
@ -1306,19 +1302,17 @@ QStringList KIconLoader::queryIcons(int group_or_size, KIconLoader::Context cont
|
||||||
// Eliminate duplicate entries (same icon in different directories)
|
// Eliminate duplicate entries (same icon in different directories)
|
||||||
QString name;
|
QString name;
|
||||||
QStringList res2, entries;
|
QStringList res2, entries;
|
||||||
QStringList::ConstIterator it;
|
foreach (const QString &it, result) {
|
||||||
for (it=result.constBegin(); it!=result.constEnd(); ++it)
|
const int n = it.lastIndexOf('/');
|
||||||
{
|
if (n == -1) {
|
||||||
int n = (*it).lastIndexOf('/');
|
name = it;
|
||||||
if (n == -1)
|
} else {
|
||||||
name = *it;
|
name = it.mid(n+1);
|
||||||
else
|
}
|
||||||
name = (*it).mid(n+1);
|
|
||||||
name = d->removeIconExtension(name);
|
name = d->removeIconExtension(name);
|
||||||
if (!entries.contains(name))
|
if (!entries.contains(name)) {
|
||||||
{
|
|
||||||
entries += name;
|
entries += name;
|
||||||
res2 += *it;
|
res2 += it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res2;
|
return res2;
|
||||||
|
@ -1357,39 +1351,39 @@ bool KIconLoader::alphaBlending(KIconLoader::Group group) const
|
||||||
|
|
||||||
// Easy access functions
|
// Easy access functions
|
||||||
|
|
||||||
QPixmap DesktopIcon(const QString& name, int force_size, int state, const QStringList &overlays)
|
QPixmap DesktopIcon(const QString &name, int force_size, int state, const QStringList &overlays)
|
||||||
{
|
{
|
||||||
KIconLoader *loader = KIconLoader::global();
|
KIconLoader* loader = KIconLoader::global();
|
||||||
return loader->loadIcon(name, KIconLoader::Desktop, force_size, state, overlays);
|
return loader->loadIcon(name, KIconLoader::Desktop, force_size, state, overlays);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap BarIcon(const QString& name, int force_size, int state, const QStringList &overlays)
|
QPixmap BarIcon(const QString &name, int force_size, int state, const QStringList &overlays)
|
||||||
{
|
{
|
||||||
KIconLoader *loader = KIconLoader::global();
|
KIconLoader* loader = KIconLoader::global();
|
||||||
return loader->loadIcon(name, KIconLoader::Toolbar, force_size, state, overlays);
|
return loader->loadIcon(name, KIconLoader::Toolbar, force_size, state, overlays);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap SmallIcon(const QString& name, int force_size, int state, const QStringList &overlays)
|
QPixmap SmallIcon(const QString &name, int force_size, int state, const QStringList &overlays)
|
||||||
{
|
{
|
||||||
KIconLoader *loader = KIconLoader::global();
|
KIconLoader* loader = KIconLoader::global();
|
||||||
return loader->loadIcon(name, KIconLoader::Small, force_size, state, overlays);
|
return loader->loadIcon(name, KIconLoader::Small, force_size, state, overlays);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap MainBarIcon(const QString& name, int force_size, int state, const QStringList &overlays)
|
QPixmap MainBarIcon(const QString &name, int force_size, int state, const QStringList &overlays)
|
||||||
{
|
{
|
||||||
KIconLoader *loader = KIconLoader::global();
|
KIconLoader* loader = KIconLoader::global();
|
||||||
return loader->loadIcon(name, KIconLoader::MainToolbar, force_size, state, overlays);
|
return loader->loadIcon(name, KIconLoader::MainToolbar, force_size, state, overlays);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap UserIcon(const QString& name, int state, const QStringList &overlays)
|
QPixmap UserIcon(const QString &name, int state, const QStringList &overlays)
|
||||||
{
|
{
|
||||||
KIconLoader *loader = KIconLoader::global();
|
KIconLoader* loader = KIconLoader::global();
|
||||||
return loader->loadIcon(name, KIconLoader::User, 0, state, overlays);
|
return loader->loadIcon(name, KIconLoader::User, 0, state, overlays);
|
||||||
}
|
}
|
||||||
|
|
||||||
int IconSize(KIconLoader::Group group)
|
int IconSize(KIconLoader::Group group)
|
||||||
{
|
{
|
||||||
KIconLoader *loader = KIconLoader::global();
|
KIconLoader* loader = KIconLoader::global();
|
||||||
return loader->currentSize(group);
|
return loader->currentSize(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1426,7 +1420,7 @@ void KIconLoader::newIconLoader()
|
||||||
KIconTheme::reconfigure();
|
KIconTheme::reconfigure();
|
||||||
}
|
}
|
||||||
|
|
||||||
reconfigure( objectName(), d->mpDirs );
|
reconfigure(objectName(), d->mpDirs);
|
||||||
emit iconLoaderSettingsChanged();
|
emit iconLoaderSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,11 +111,11 @@ public:
|
||||||
*/
|
*/
|
||||||
enum Group {
|
enum Group {
|
||||||
/// No group
|
/// No group
|
||||||
NoGroup=-1,
|
NoGroup = -1,
|
||||||
/// Desktop icons
|
/// Desktop icons
|
||||||
Desktop=0,
|
Desktop = 0,
|
||||||
/// First group
|
/// First group
|
||||||
FirstGroup=0,
|
FirstGroup = 0,
|
||||||
/// Toolbar icons
|
/// Toolbar icons
|
||||||
Toolbar,
|
Toolbar,
|
||||||
/// Main toolbar icons
|
/// Main toolbar icons
|
||||||
|
@ -137,17 +137,17 @@ public:
|
||||||
*/
|
*/
|
||||||
enum StdSizes {
|
enum StdSizes {
|
||||||
/// small icons for menu entries
|
/// small icons for menu entries
|
||||||
SizeSmall=16,
|
SizeSmall = 16,
|
||||||
/// slightly larger small icons for toolbars, panels, etc
|
/// slightly larger small icons for toolbars, panels, etc
|
||||||
SizeSmallMedium=22,
|
SizeSmallMedium = 22,
|
||||||
/// medium sized icons for the desktop
|
/// medium sized icons for the desktop
|
||||||
SizeMedium=32,
|
SizeMedium = 32,
|
||||||
/// large sized icons for the panel
|
/// large sized icons for the panel
|
||||||
SizeLarge=48,
|
SizeLarge = 48,
|
||||||
/// huge sized icons for iconviews
|
/// huge sized icons for iconviews
|
||||||
SizeHuge=64,
|
SizeHuge = 64,
|
||||||
/// enormous sized icons for iconviews
|
/// enormous sized icons for iconviews
|
||||||
SizeEnormous=128
|
SizeEnormous = 128
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,7 +172,7 @@ public:
|
||||||
* iconloader object yourself. That one is the current KComponentData's
|
* iconloader object yourself. That one is the current KComponentData's
|
||||||
* (typically KApplication's) iconloader.
|
* (typically KApplication's) iconloader.
|
||||||
*/
|
*/
|
||||||
explicit KIconLoader(const QString& appname=QString(), KStandardDirs *dirs = 0, QObject* parent = 0);
|
explicit KIconLoader(const QString &appname = QString(), KStandardDirs *dirs = nullptr, QObject *parent = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an iconloader.
|
* Constructs an iconloader.
|
||||||
|
@ -183,7 +183,7 @@ public:
|
||||||
* iconloader object yourself. That one is the current KComponentData's
|
* iconloader object yourself. That one is the current KComponentData's
|
||||||
* (typically KApplication's) iconloader.
|
* (typically KApplication's) iconloader.
|
||||||
*/
|
*/
|
||||||
explicit KIconLoader(const KComponentData &componentData, QObject* parent = 0);
|
explicit KIconLoader(const KComponentData &componentData, QObject *parent = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cleanup
|
* Cleanup
|
||||||
|
@ -200,7 +200,7 @@ public:
|
||||||
* Adds @p appname to the list of application specific directories.
|
* Adds @p appname to the list of application specific directories.
|
||||||
* @param appname The application name.
|
* @param appname The application name.
|
||||||
*/
|
*/
|
||||||
void addAppDir(const QString& appname);
|
void addAppDir(const QString &appname);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads an icon. It will try very hard to find an icon which is
|
* Loads an icon. It will try very hard to find an icon which is
|
||||||
|
@ -230,10 +230,10 @@ public:
|
||||||
* @return the QPixmap. Can be null when not found, depending on
|
* @return the QPixmap. Can be null when not found, depending on
|
||||||
* @p canReturnNull.
|
* @p canReturnNull.
|
||||||
*/
|
*/
|
||||||
QPixmap loadIcon(const QString& name, KIconLoader::Group group, int size=0,
|
QPixmap loadIcon(const QString &name, KIconLoader::Group group, int size = 0,
|
||||||
int state=KIconLoader::DefaultState, const QStringList &overlays = QStringList(),
|
int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList(),
|
||||||
QString *path_store=0L,
|
QString *path_store = nullptr,
|
||||||
bool canReturnNull=false) const;
|
bool canReturnNull = false) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads an icon for a mimetype.
|
* Loads an icon for a mimetype.
|
||||||
|
@ -253,9 +253,9 @@ public:
|
||||||
* @return the QPixmap. Can not be null, the
|
* @return the QPixmap. Can not be null, the
|
||||||
* "unknown" pixmap is returned when no appropriate icon has been found.
|
* "unknown" pixmap is returned when no appropriate icon has been found.
|
||||||
*/
|
*/
|
||||||
QPixmap loadMimeTypeIcon( const QString& iconName, KIconLoader::Group group, int size=0,
|
QPixmap loadMimeTypeIcon(const QString &iconName, KIconLoader::Group group, int size = 0,
|
||||||
int state=KIconLoader::DefaultState, const QStringList &overlays = QStringList(),
|
int state = KIconLoader::DefaultState, const QStringList &overlays = QStringList(),
|
||||||
QString *path_store=0 ) const;
|
QString *path_store = nullptr) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the path of an icon.
|
* Returns the path of an icon.
|
||||||
|
@ -271,8 +271,8 @@ public:
|
||||||
* @return the path of an icon, can be null or the "unknown" icon when
|
* @return the path of an icon, can be null or the "unknown" icon when
|
||||||
* not found, depending on @p canReturnNull.
|
* not found, depending on @p canReturnNull.
|
||||||
*/
|
*/
|
||||||
QString iconPath(const QString& name, int group_or_size,
|
QString iconPath(const QString &name, int group_or_size,
|
||||||
bool canReturnNull=false) const;
|
bool canReturnNull = false) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads an animated icon as a series of still frames.
|
* Loads an animated icon as a series of still frames.
|
||||||
|
@ -283,7 +283,7 @@ public:
|
||||||
* @return A QStringList containing the absolute path of all the frames
|
* @return A QStringList containing the absolute path of all the frames
|
||||||
* making up the animation.
|
* making up the animation.
|
||||||
*/
|
*/
|
||||||
QStringList loadAnimated(const QString& name, KIconLoader::Group group, int size=0) const;
|
QStringList loadAnimated(const QString &name, KIconLoader::Group group, int size = 0) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries all available icons for a specific group, having a specific
|
* Queries all available icons for a specific group, having a specific
|
||||||
|
@ -295,7 +295,7 @@ public:
|
||||||
* @param context The icon context.
|
* @param context The icon context.
|
||||||
* @return a list of all icons
|
* @return a list of all icons
|
||||||
*/
|
*/
|
||||||
QStringList queryIcons(int group_or_size, KIconLoader::Context context=KIconLoader::Any) const;
|
QStringList queryIcons(int group_or_size, KIconLoader::Context context = KIconLoader::Any) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queries all available icons for a specific context.
|
* Queries all available icons for a specific context.
|
||||||
|
@ -309,12 +309,12 @@ public:
|
||||||
* available for that context
|
* available for that context
|
||||||
*/
|
*/
|
||||||
QStringList queryIconsByContext(int group_or_size,
|
QStringList queryIconsByContext(int group_or_size,
|
||||||
KIconLoader::Context context=KIconLoader::Any) const;
|
KIconLoader::Context context = KIconLoader::Any) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
bool hasContext( KIconLoader::Context context ) const;
|
bool hasContext(KIconLoader::Context context) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all icons (*.png or *.xpm extension) in the
|
* Returns a list of all icons (*.png or *.xpm extension) in the
|
||||||
|
@ -322,7 +322,7 @@ public:
|
||||||
* @param iconsDir the directory to search in
|
* @param iconsDir the directory to search in
|
||||||
* @return A QStringList containing the icon paths
|
* @return A QStringList containing the icon paths
|
||||||
*/
|
*/
|
||||||
QStringList queryIconsByDir( const QString& iconsDir ) const;
|
QStringList queryIconsByDir(const QString &iconsDir) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current size of the icon group.
|
* Returns the current size of the icon group.
|
||||||
|
@ -342,13 +342,13 @@ public:
|
||||||
* therefore it's not recommended to store the pointer anywhere.
|
* therefore it's not recommended to store the pointer anywhere.
|
||||||
* @return a pointer to the current theme. 0 if no theme set.
|
* @return a pointer to the current theme. 0 if no theme set.
|
||||||
*/
|
*/
|
||||||
KIconTheme *theme() const;
|
KIconTheme* theme() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to the KIconEffect object used by the icon loader.
|
* Returns a pointer to the KIconEffect object used by the icon loader.
|
||||||
* @return the KIconEffect.
|
* @return the KIconEffect.
|
||||||
*/
|
*/
|
||||||
KIconEffect *iconEffect() const;
|
KIconEffect* iconEffect() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by KComponentData::newIconLoader to reconfigure the icon loader.
|
* Called by KComponentData::newIconLoader to reconfigure the icon loader.
|
||||||
|
@ -356,7 +356,7 @@ public:
|
||||||
* @param _dirs the new standard directories. If 0, the directories
|
* @param _dirs the new standard directories. If 0, the directories
|
||||||
* from KGlobal will be taken.
|
* from KGlobal will be taken.
|
||||||
*/
|
*/
|
||||||
void reconfigure( const QString& _appname, KStandardDirs *_dirs );
|
void reconfigure(const QString &_appname, KStandardDirs *_dirs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the unknown icon. An icon that is used when no other icon
|
* Returns the unknown icon. An icon that is used when no other icon
|
||||||
|
@ -395,7 +395,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state = KIconLoader::DefaultState) const;
|
void drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state = KIconLoader::DefaultState) const;
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Re-initialize the global icon loader
|
* Re-initialize the global icon loader
|
||||||
*/
|
*/
|
||||||
|
@ -407,7 +407,7 @@ Q_SIGNALS:
|
||||||
*/
|
*/
|
||||||
void iconLoaderSettingsChanged();
|
void iconLoaderSettingsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// @internal the data object
|
// @internal the data object
|
||||||
KIconLoaderPrivate *d;
|
KIconLoaderPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue