00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00029
00030
00031
00033
00034
00035 #include <qimage.h>
00036 #include <qmime.h>
00037
00038
00039 #include "iconsets.h"
00040 #include "icons-shared.h"
00041
00045
00047 IconSets::~IconSets()
00049 {
00050 }
00051
00053 QIconSet IconSets::getIconSet(const IconSetID id)
00055 {
00056 initialize();
00057 QIconSet result;
00058
00059 if(id == Open)
00060 {
00061 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(OpenNormal)), QIconSet::Automatic);
00062 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(OpenActive)), QIconSet::Large, QIconSet::Active);
00063 result.setPixmap(QPixmap(QPixmap::fromMimeSource(factoryNames.at(OpenActive)).convertToImage().smoothScale(22, 22)), QIconSet::Small, QIconSet::Active);
00064 }
00065 else if(id == Save)
00066 {
00067 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(SaveNormal)), QIconSet::Automatic, QIconSet::Normal);
00068 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(SaveDisabled)), QIconSet::Automatic, QIconSet::Disabled);
00069 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(SaveActive)), QIconSet::Large, QIconSet::Active);
00070 result.setPixmap(QPixmap(QPixmap::fromMimeSource(factoryNames.at(SaveActive)).convertToImage().smoothScale(22, 22)), QIconSet::Small, QIconSet::Active);
00071 }
00072 else if(id == Prefs)
00073 {
00074 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(PrefsNormal)), QIconSet::Automatic);
00075 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(PrefsActive)), QIconSet::Large, QIconSet::Active);
00076 result.setPixmap(QPixmap(QPixmap::fromMimeSource(factoryNames.at(PrefsActive)).convertToImage().smoothScale(22, 22)), QIconSet::Small, QIconSet::Active);
00077 }
00078 else if(id == Image)
00079 {
00080 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(ImageNormal)), QIconSet::Automatic, QIconSet::Normal);
00081 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(ImageDisabled)), QIconSet::Automatic, QIconSet::Disabled);
00082 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(ImageActive)), QIconSet::Large, QIconSet::Active);
00083 result.setPixmap(QPixmap(QPixmap::fromMimeSource(factoryNames.at(ImageActive)).convertToImage().smoothScale(22, 22)), QIconSet::Small, QIconSet::Active);
00084 }
00085 else if(id == Help)
00086 {
00087 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(HelpNormal)), QIconSet::Automatic);
00088 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(HelpActive)), QIconSet::Large, QIconSet::Active);
00089 result.setPixmap(QPixmap(QPixmap::fromMimeSource(factoryNames.at(HelpActive)).convertToImage().smoothScale(22, 22)), QIconSet::Small, QIconSet::Active);
00090 }
00091 else if(id == WhatsThis)
00092 {
00093 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(WhatsThisNormal)), QIconSet::Automatic);
00094 result.setPixmap(QPixmap::fromMimeSource(factoryNames.at(WhatsThisActive)), QIconSet::Large, QIconSet::Active);
00095 result.setPixmap(QPixmap(QPixmap::fromMimeSource(factoryNames.at(WhatsThisActive)).convertToImage().smoothScale(22, 22)), QIconSet::Small, QIconSet::Active);
00096 }
00097
00098 return result;
00099 }
00100
00102 QString IconSets::factoryName(const IconSetID id)
00105 {
00106 return iconNames[id];
00107 }
00108
00112
00114 IconSets::IconSets()
00116 {
00117 }
00118
00120 void IconSets::initialize()
00125 {
00126 if(isInitialized)
00127 return;
00128 isInitialized = true;
00129
00131
00132 initPixmap((unsigned char*)open_normal_data, 32, 32, true, OpenNormal, "OpenNormal", Open);
00133 initPixmap((unsigned char*)open_active_data, 32, 32, true, OpenActive, "OpenActive");
00134
00135 initPixmap((unsigned char*)save_normal_data, 32, 32, true, SaveNormal, "SaveNormal", Save);
00136 initPixmap((unsigned char*)save_disabled_data, 32, 32, true, SaveDisabled, "SaveDisabled");
00137 initPixmap((unsigned char*)save_active_data, 32, 32, true, SaveActive, "SaveActive");
00138
00139 initPixmap((unsigned char*)prefs_normal_data, 32, 32, true, PrefsNormal, "PrefsNormal", Prefs);
00140 initPixmap((unsigned char*)prefs_active_data, 32, 32, true, PrefsActive, "PrefsActive");
00141
00142 initPixmap((unsigned char*)image_normal_data, 32, 32, true, ImageNormal, "ImageNormal", Image);
00143 initPixmap((unsigned char*)image_disabled_data, 32, 32, true, ImageDisabled, "ImageDisabled");
00144 initPixmap((unsigned char*)image_active_data, 32, 32, true, ImageActive, "ImageActive");
00145
00146 initPixmap((unsigned char*)help_normal_data, 32, 32, true, HelpNormal, "HelpNormal", Help);
00147 initPixmap((unsigned char*)help_active_data, 32, 32, true, HelpActive, "HelpActive");
00148
00149 initPixmap((unsigned char*)whatsthis_normal_data, 32, 32, true, WhatsThisNormal, "WhatsThisNormal", WhatsThis);
00150 initPixmap((unsigned char*)whatsthis_active_data, 32, 32, true, WhatsThisActive, "WhatsThisActive");
00151
00152 }
00153
00155 void IconSets::initPixmap(unsigned char* data, const int sizeX, const int sizeY, const bool alpha, const FactoryID id, const QString idString, const IconSetID iconID)
00158 {
00159 factoryNames.at(id) = idString;
00160
00161 QImage image(data, sizeX, sizeY, 32, 0, 0, QImage::BigEndian);
00162 image.setAlphaBuffer(alpha);
00163 QMimeSourceFactory::defaultFactory()->setPixmap(idString, QPixmap(image));
00164
00165 if(iconID != LastIcon)
00166 iconNames.at(iconID) = idString;
00167 }
00168
00172
00173 bool IconSets::isInitialized = false;
00174 std::vector<QString> IconSets::iconNames = std::vector<QString>(LastIcon);
00175 std::vector<QString> IconSets::factoryNames = std::vector<QString>(LastFactory);
00176