Esempio n. 1
0
MusicaMetaData::MusicaMetaData(QString dir) : TagLib::FileRef(qstringToChar(dir))
{
    if(this == NULL)
        return;

    this->dir  = dir;
}
Esempio n. 2
0
// ----------------------------------------------------------------------------
// CReporterUtils::appendToLzo
// ----------------------------------------------------------------------------
bool CReporterUtils::appendToLzo(const QString &text, const QString &filePath)
{
    QFile tmpFile(richCoreTmpNoteFile);
    // Create local temp file, where comments are written.
    if (!tmpFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
          qDebug() << __PRETTY_FUNCTION__ << "Unable to open file:" << filePath;
          return false;
          }

    QTextStream out(&tmpFile);
    out << text;
    tmpFile.close();

    // Append to *.lzo.
    QString cmd = QString("/usr/bin/lzop -c %1 >> %2").arg(richCoreTmpNoteFile).arg(filePath) ;
    int res = system(qstringToChar(cmd));
    qDebug() << __PRETTY_FUNCTION__ << "System returned:"  << res;

    // Remove temp file.
    if (!tmpFile.remove()) {
        qDebug() << __PRETTY_FUNCTION__ << "Unable to remove file:" << richCoreTmpNoteFile;
    }
    return true;
}
Esempio n. 3
0
void MusicaMetaData::operator=(MusicaMetaData a)
{
    TagLib::FileRef fr(qstringToChar(a.dir));
    TagLib::FileRef::operator=(fr);
    this->dir = a.dir;
}
Esempio n. 4
0
void processesApplet::update() {

    QProcess top;
    QString program = "top";
    QStringList arguments;

    arguments.append("-b");
    arguments.append("-n");
    arguments.append("1");

    top.start(program, arguments);
    top.waitForFinished();

    QStringList linies = QString(top.readAllStandardOutput()).split("\n");
    QStringList procs;

    procs.append(linies.at(7));
    procs.append(linies.at(8));
    procs.append(linies.at(9));
    procs.append(linies.at(10));
    procs.append(linies.at(11));

    QStringList p1 = procs.at(0).split(QRegExp("\\s+"));
    QStringList p2 = procs.at(1).split(QRegExp("\\s+"));
    QStringList p3 = procs.at(2).split(QRegExp("\\s+"));
    QStringList p4 = procs.at(3).split(QRegExp("\\s+"));
    QStringList p5 = procs.at(4).split(QRegExp("\\s+"));

    if (p1.first() == "") p1.erase(p1.begin());
    if (p2.first() == "") p2.erase(p2.begin());
    if (p3.first() == "") p3.erase(p3.begin());
    if (p4.first() == "") p4.erase(p4.begin());
    if (p5.first() == "") p5.erase(p5.begin());

    g15r_clearScreen(canvas, 0);

    g15r_G15FPrint(canvas, (char *) "Process Monitor", 0, 0, 1, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 0);

    g15r_G15FPrint(canvas, qstringToChar(p1.at(0)), 0, 0, 0, G15_JUSTIFY_LEFT, G15_COLOR_BLACK, 2);
    g15r_G15FPrint(canvas, qstringToChar(p2.at(0)), 0, 0, 0, G15_JUSTIFY_LEFT, G15_COLOR_BLACK, 3);
    g15r_G15FPrint(canvas, qstringToChar(p3.at(0)), 0, 0, 0, G15_JUSTIFY_LEFT, G15_COLOR_BLACK, 4);
    g15r_G15FPrint(canvas, qstringToChar(p4.at(0)), 0, 0, 0, G15_JUSTIFY_LEFT, G15_COLOR_BLACK, 5);
    g15r_G15FPrint(canvas, qstringToChar(p5.at(0)), 0, 0, 0, G15_JUSTIFY_LEFT, G15_COLOR_BLACK, 6);

    g15r_G15FPrint(canvas, qstringToChar(p1.at(11)), 0, 0, 0, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 2);
    g15r_G15FPrint(canvas, qstringToChar(p2.at(11)), 0, 0, 0, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 3);
    g15r_G15FPrint(canvas, qstringToChar(p3.at(11)), 0, 0, 0, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 4);
    g15r_G15FPrint(canvas, qstringToChar(p4.at(11)), 0, 0, 0, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 5);
    g15r_G15FPrint(canvas, qstringToChar(p5.at(11)), 0, 0, 0, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 6);

    g15r_G15FPrint(canvas, qstringToChar(p1.at(9)), 0, 0, 0, G15_JUSTIFY_RIGHT, G15_COLOR_BLACK, 2);
    g15r_G15FPrint(canvas, qstringToChar(p2.at(9)), 0, 0, 0, G15_JUSTIFY_RIGHT, G15_COLOR_BLACK, 3);
    g15r_G15FPrint(canvas, qstringToChar(p3.at(9)), 0, 0, 0, G15_JUSTIFY_RIGHT, G15_COLOR_BLACK, 4);
    g15r_G15FPrint(canvas, qstringToChar(p4.at(9)), 0, 0, 0, G15_JUSTIFY_RIGHT, G15_COLOR_BLACK, 5);
    g15r_G15FPrint(canvas, qstringToChar(p5.at(9)), 0, 0, 0, G15_JUSTIFY_RIGHT, G15_COLOR_BLACK, 6);

    g15_send(fd, (char *) canvas->buffer, G15_BUFFER_LEN);
}
Esempio n. 5
0
void amarokApplet::update() {

    QDBusMessage m = QDBusMessage::createMethodCall((QString)"org.mpris.amarok",(QString)"/Player","",(QString)"GetStatus");
    QDBusReply<QRect> result = QDBusConnection::sessionBus().call(m);

    g15r_clearScreen(canvas, 0);

    if (!result.isValid()) {
        g15r_G15FPrint (canvas, (char *) "Amarok", 0, -4, G15_TEXT_HUGE, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 1);
        g15r_G15FPrint (canvas, (char *) "Not Running", 0, 0, G15_TEXT_HUGE, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 2);
    }
    else {

        int status = result.value().left();

        if (status == 2) g15r_G15FPrint (canvas, (char *) "Stopped", 0, 0, G15_TEXT_LARGE, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 2);

        else {

            m = QDBusMessage::createMethodCall((QString)"org.mpris.amarok",(QString)"/Player","",(QString)"GetMetadata");
            QVariantMap map = QDBusReply<QVariantMap>(QDBusConnection::sessionBus().call(m)).value();

            QString title = eliminarAccents(map.find("title").value().toString());
            QString artist = eliminarAccents(map.find("artist").value().toString());
            QString album = eliminarAccents(map.find("album").value().toString());
            QString year = map.find("year").value().toString();
            int length = map.find("mtime").value().toInt()/1000;


            m = QDBusMessage::createMethodCall((QString)"org.mpris.amarok",(QString)"/Player","",(QString)"PositionGet");
            QDBusReply<int> rpos = QDBusConnection::sessionBus().call(m);
            int position = rpos.value()/1000;

            int totm = length / 60;
            int tots = length % 60;
            int posm = position / 60;
            int poss = position % 60;


            int maxlen = std::max(title.length(), std::max(artist.length(), album.length()));
            int text_size = G15_TEXT_SMALL;

            if (maxlen <= 20) text_size = G15_TEXT_LARGE;
            else if (maxlen > 20 && maxlen <= 30) text_size = G15_TEXT_MED;
            else {
                if (title.length() > 40) title = title.right(title.length()-(poss % (title.length()-38)));
                if (artist.length() > 40) artist = artist.right(artist.length()-(poss % (artist.length()-38)));
                if (album.length() > 40) album = album.right(album.length()-(poss % (album.length()-38)));
            }

            QString strtemps;
            if (posm < 10) strtemps.append("0");
            strtemps.append(QString::number(posm));
            strtemps.append(":");
            if (poss < 10) strtemps.append("0");
            strtemps.append(QString::number(poss));

            strtemps.append("/");

            if (totm < 10) strtemps.append("0");
            strtemps.append(QString::number(totm));
            strtemps.append(":");
            if (tots < 10) strtemps.append("0");
            strtemps.append(QString::number(tots));


            int progress = float(position)/float(length)*160;

            g15r_G15FPrint (canvas, qstringToChar(title), 0, 0, text_size, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 0);
            g15r_G15FPrint (canvas, qstringToChar(artist), 0, 0, text_size, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 1);
            g15r_G15FPrint (canvas, qstringToChar(album), 0, 0, text_size, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 2);

            g15r_pixelBox(canvas, 0, 28, progress, 32, G15_COLOR_BLACK, 1, G15_PIXEL_FILL);
            g15r_pixelBox(canvas, progress, 28, 159, 32, G15_COLOR_BLACK, 1, G15_PIXEL_NOFILL);

            g15r_G15FPrint (canvas, qstringToChar(year), 4, 0, G15_TEXT_MED, G15_JUSTIFY_LEFT, G15_COLOR_BLACK, 5);
            g15r_G15FPrint (canvas, qstringToChar(strtemps), 0, 0, G15_TEXT_MED, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 5);
        }
    }

    g15_send(fd, (char *) canvas->buffer, G15_BUFFER_LEN);
}