#include <iostream>
-#define ICON_PATH QString("/usr/share/pixmaps/case/")
-#define ICON_SET "default"
+#include "utils.h"
Button::Button(const QString &name, QWidget *parent, const int maxWidth, const int maxHeight) :
setMaximumWidth(maxWidth);
setMaximumHeight(maxHeight);
- QImage iconImage(ICON_PATH + ICON_SET + "/" + name + ".xpm", "XPM");
- if (iconImage.isNull()) iconImage.load(ICON_PATH + ICON_SET + "/" + name + ".png", "PNG");
- if (iconImage.isNull()) iconImage.load(ICON_PATH + ICON_SET + "/" + name + ".gif", "GIF");
-
- iconImage = iconImage.convertToFormat(QImage::Format_Indexed8);
-
- QRgb buttonText = palette().color(QPalette::ButtonText).rgb();
- QRgb highlight = palette().color(QPalette::Highlight).rgb();
- QVector<QRgb> colorTable = iconImage.colorTable();
- for (QVector<QRgb>::iterator it = colorTable.begin(); it != colorTable.end(); ++it) {
- if ((*it & 0xFFFFFF) == 0xFFFFFF) *it = (*it & 0xFF000000) | buttonText;
- else if ((*it & 0xFFFFFF) == 0x0000FF) *it = (*it & 0xFF000000) | highlight;
- }
- iconImage.setColorTable(colorTable);
-
- icons[0] = QIcon(QPixmap::fromImage(iconImage));
- icons[1] = QIcon(QPixmap::fromImage(iconImage.mirrored(true, false)));
+ loadMiddleButtonIcons(palette(), name, icons[0], icons[1]);
setIcon(icons[0]);
}