summaryrefslogtreecommitdiffstats
path: root/ksquirrel/sq_iconloader.cpp
blob: 91feec2f7eed10e716aa34d728121c697f7206ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/***************************************************************************
                          sq_iconloader.cpp  -  description
                             -------------------
    begin                : ??? Aug 20 2005
    copyright            : (C) 2005 by Baryshev Dmitry
    email                : ksquirrel.iv@gmail.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <kglobal.h>
#include <kiconloader.h>

#include "sq_iconloader.h"
#include "sq_iconloader_pixmaps.h"

SQ_IconLoader * SQ_IconLoader::m_instance = 0;

SQ_IconLoader::SQ_IconLoader(TQObject *tqparent) : TQObject(tqparent)
{
    m_instance = this;

    fillPixmaps();
}

SQ_IconLoader::~SQ_IconLoader()
{}

TQPixmap SQ_IconLoader::loadIcon(const TQString& name, KIcon::Group group, int size) const
{
    // try to load from installed icon theme
    TQPixmap p = KGlobal::iconLoader()->loadIcon(name, group, size, KIcon::DefaultState, 0, true);

    // requested pixmap not found, let's
    // try to find it in our pixmaps
    if(p.isNull())
    {
        if(name == "move_task_up")
            p = pixmap_up;
        else if(name == "move_task_down")
            p = pixmap_down;
        else if(name == "display" && size == 32)
            p = pixmap_display;
        else if(name == "folder" && size == 32)
            p = pixmap_folder;
        else if(name == "images" && size == 32)
            p = pixmap_images;
        else if(name == "binary" && size == 32)
            p = pixmap_binary;
        else if(name == "edit" && size == 32)
            p = pixmap_edit;
        else
            p = KGlobal::iconLoader()->loadIcon("unknown", group, size);
    }

    return p;
}

/*
 *  Internal. Load all pixmaps.
 */
void SQ_IconLoader::fillPixmaps()
{
    pixmap_up      = TQPixmap(xpm_up);
    pixmap_down    = TQPixmap(xpm_down);
    pixmap_display = TQPixmap(xpm_display);
    pixmap_folder  = TQPixmap(xpm_folder);
    pixmap_images  = TQPixmap(xpm_images);
    pixmap_binary  = TQPixmap(xpm_binary);
    pixmap_edit    = TQPixmap(xpm_edit);
}