Fixed little problem with BT AudioSink status
[someplayer] / src / trackrenderer.cpp
index 18aa89c..a09fee0 100644 (file)
@@ -32,15 +32,28 @@ TrackRenderer::TrackRenderer(QObject *parent) :
 {
        Config config;
        _icons_theme = config.getValue("ui/iconstheme").toString();
+       _apen = QPen(QColor::fromRgb(255, 255, 255, 128));
+       _spen = QPen(QColor::fromRgb(100, 150, 220));
+       _sspen = QPen(QColor::fromRgb(100, 220, 150));
+
+}
+
+void TrackRenderer::updateIcons() {
+       Config config;
+       _icons_theme = config.getValue("ui/iconstheme").toString();
 }
 
 void TrackRenderer::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
-       if (index.column() == 0) {
+       QString value = index.data().toString();
+       if (value.startsWith("##")) {
+               value.remove("##");
                int x1, y1, x2, y2;
                option.rect.getCoords(&x1, &y1, &x2, &y2);
-               painter->drawImage(x1, y1 + 5, QImage(":/icons/"+_icons_theme+"/more_l.png"));
+               QImage image(":/icons/"+_icons_theme+"/"+value);
+               x1 += (x2 - x1 - image.width())/2;
+               y1 += (y2 - y1 - image.width())/2;
+               painter->drawImage(x1, y1, image);
        } else {
-               QString value = index.data().toString();
                QStringList meta = value.split("#_#");
 
                QFont f = painter->font();
@@ -50,20 +63,13 @@ void TrackRenderer::paint(QPainter *painter, const QStyleOptionViewItem &option,
                option.rect.getCoords(&x1, &y1, &x2, &y2);
 
                QPen pen = painter->pen();
-               QPen npen (QColor::fromRgb(80, 130, 255, 50));
-               QPen apen (QColor::fromRgb(255, 255, 255, 128));
-               QPen spen (QColor::fromRgb(100, 150, 220));
-               QPen sspen (QColor::fromRgb(100, 220, 150));
-
                f.setBold(false);
-               painter->setPen(npen);
-               painter->drawLine(x1, y1, x2, y1);
                if (index.row() == _search_row) {
                        f.setBold(true);
-                       painter->setPen(sspen);
+                       painter->setPen(_sspen);
                } else if (index.row() == _active_row) {
                        f.setBold(true);
-                       painter->setPen(spen);
+                       painter->setPen(_spen);
                } else {
                        painter->setPen(pen);
                }
@@ -72,11 +78,9 @@ void TrackRenderer::paint(QPainter *painter, const QStyleOptionViewItem &option,
                fp.setBold(false);
                fp.setPointSize(f.pointSize()*3/4);
                painter->setFont(fp);
-               painter->setPen(apen);
+               painter->setPen(_apen);
                painter->drawText(x1+10, y1 + 3*(y2-y1)/5, (x2-x1)-100, 2*fp.pointSize(), Qt::AlignAbsolute, QString("%1 (%2)").arg(meta[2]).arg(meta[1]));
                painter->drawText(x2-60, y1 + 3*(y2-y1)/5, 55, 2*fp.pointSize(), Qt::AlignAbsolute, QString("%1").arg(meta[3]));
-               painter->setPen(npen);
-               painter->drawLine(x1, y2, x2, y2);
                painter->setFont(f);
                painter->setPen(pen);
        }
@@ -85,3 +89,25 @@ void TrackRenderer::paint(QPainter *painter, const QStyleOptionViewItem &option,
 QSize TrackRenderer::sizeHint(const QStyleOptionViewItem &/*option*/, const QModelIndex &/*index*/) const {
        return QSize(QApplication::desktop()->geometry().width(), 80);
 }
+
+void TrackRenderer::setActiveTrackColor(QString color) {
+       QColor c;
+       if (color == "blue") {
+               c = QColor::fromRgb(100, 150, 220);
+       } else if (color == "black") {
+               c = QColor::fromRgb(0, 0, 0);
+       } else if (color == "magenta") {
+               c = QColor::fromRgb(150, 80, 150);
+       } else if (color == "red") {
+               c = QColor::fromRgb(220, 100, 100);
+       } else if (color == "yellow") {
+               c = QColor::fromRgb(220, 220, 100);
+       } else if (color == "white") {
+               c = QColor::fromRgb(255, 255, 255);
+       } else if (color == "dark") {
+               c = QColor::fromRgb(70, 70, 70);
+       } else if (color == "light") {
+               c = QColor::fromRgb(200, 200, 200);
+       }
+       _spen = QPen(c);
+}