#include #include #include #include #include #include #include "helper.h" namespace Helper { QIcon iconFromQChar(const QChar &c, int pixelSize){ QPixmap pm(QSize(64,64)); QPainter p(&pm); QFont f = p.font(); f.setPixelSize(pixelSize); p.setFont(f); p.fillRect(pm.rect(), qApp->palette().color(QPalette::Window)); p.setBrush(QBrush(Qt::black)); p.drawText(pm.rect(), Qt::AlignCenter, c); return QIcon(pm); } QAction* createSeparator(QObject *parent){ QAction *a = new QAction(parent); a->setSeparator(true); return a; } quint64 lengthInSeconds(const QString &file){ TagLib::FileRef f(QString(file).toUtf8()); if(f.isNull()){ return 0; } TagLib::AudioProperties *props = f.audioProperties(); return props->lengthInSeconds(); } QColor colorFromLabel(QLabel *l){ QColor retval; const QPixmap *pm = l->pixmap(); if(pm){ QImage img = pm->toImage(); retval = img.pixelColor(0, 0); } return retval; } void fillLabel(QLabel *l, QColor c){ QPixmap newPm(l->sizeHint()); newPm.fill(c); l->setPixmap(newPm); } }