new style for the progressbars, display more info
[case] / src / button.cpp
index d883c84..0f61a21 100644 (file)
@@ -19,8 +19,7 @@
 
 #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) :
@@ -30,23 +29,7 @@ Button::Button(const QString &name, QWidget *parent, const int maxWidth, const i
     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]);
 }