1 // case - file manager for N900
2 // Copyright (C) 2010 Lukas Hrazky <lukkash@email.cz>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 void themeImage(const QPalette &p, QImage &image, const bool inverse) {
22 image = image.convertToFormat(QImage::Format_Indexed8);
24 QRgb highlight = p.highlight().color().rgb();
27 second = p.text().color().rgb();
29 second = p.buttonText().color().rgb();
32 QVector<QRgb> colorTable = image.colorTable();
33 for (QVector<QRgb>::iterator it = colorTable.begin(); it != colorTable.end(); ++it) {
34 if ((*it & 0xFFFFFF) == 0xFFFFFF) *it = (*it & 0xFF000000) | second;
35 else if ((*it & 0xFFFFFF) == 0x0000FF) *it = (*it & 0xFF000000) | highlight;
37 image.setColorTable(colorTable);
41 bool loadOperationIcons(const QPalette &p, const QString &name, QPixmap &normal, QPixmap &inverse) {
42 QImage iconImage(ICON_PATH + ICON_SET + "/" + name + ".xpm", "XPM");
43 if (iconImage.isNull()) iconImage.load(ICON_PATH + ICON_SET + "/" + name + ".png", "PNG");
44 if (iconImage.isNull()) iconImage.load(ICON_PATH + ICON_SET + "/" + name + ".gif", "GIF");
46 QImage inverseIconImage = iconImage;
48 themeImage(p, iconImage, false);
49 themeImage(p, inverseIconImage, true);
51 normal = QPixmap::fromImage(iconImage);
52 inverse = QPixmap::fromImage(inverseIconImage);
57 bool loadMiddleButtonIcons(const QPalette &p, const QString &name, QIcon &normal, QIcon &mirrored) {
58 QImage iconImage(ICON_PATH + ICON_SET + "/" + name + ".xpm", "XPM");
59 if (iconImage.isNull()) iconImage.load(ICON_PATH + ICON_SET + "/" + name + ".png", "PNG");
60 if (iconImage.isNull()) iconImage.load(ICON_PATH + ICON_SET + "/" + name + ".gif", "GIF");
62 themeImage(p, iconImage, false);
64 normal = QIcon(QPixmap::fromImage(iconImage));
65 mirrored = QIcon(QPixmap::fromImage(iconImage.mirrored(true, false)));