コード例 #1
0
void ActivityButton::setActive(bool isActive) {
    if (m_isActive == isActive) return;
    m_isActive = isActive;
    if (isActive) {
        connect (getMovie(), SIGNAL(frameChanged(int)),
            this, SLOT(updateIcon()), Qt::UniqueConnection);
    }
    else {
コード例 #2
0
QIcon getCurrentIcon() {
    QMovie* movie = getMovie();
    int idx = movie->currentFrameNumber();
    QString key = QString("%1").arg(idx);
    if (!icons.contains(key)) {
        QPixmap pm = movie->currentPixmap();
        QIcon retval(pm);
        icons[key] = retval;
    }
    return icons[key];
}
コード例 #3
0
void rottenTomatoes::finishedReply(QNetworkReply *pReply) {
    bool ok;

    QByteArray data = pReply->readAll();
    QVariantMap result = parser.parse (data, &ok).toMap();

    if (!ok) { qDebug() << "Paring JSON Failed"; }

    // Calculate the right number of pages, i.e. round to next integer, e.g. 1.2 is 2 pages.
    float cineTotalPagesf = (result["total"].toFloat() + 0.5) / 50;

    if (inTheaterMode) {
        // If we are working with inTheaters
        emit inTheaterResultsAvailable(result);

        // Calculate Total Pages
        inTheatersTotal = qRound(cineTotalPagesf);

        // qDebug() << "Total Movies: " << result["total"];
        // qDebug() << "Total No. Of Pages: " << cineTotalPages;
        // qDebug() << "Movies in List: " << result["movies"].toList().count();
        // qDebug() << "Synopsis: " << result["movies"].toList()[1].toMap()["synopsis"].toString();
        // qDebug() << "Ratings: " << result["movies"].toList()[1].toMap()["ratings"].toMap()["critics_rating"].toString();

        if (inTheatersCurrentPage < inTheatersTotal) {
            inTheatersCurrentPage++;
            getInTheater();
        } else {
            // Let the calling class know we are done
            emit finishedInTheater();
        }

    } else {
        // Movie search mode
        emit movieResultsAvailable(result);
        movieTotal = qRound(cineTotalPagesf);

        if (movieCurrentPage < movieTotal){
            movieCurrentPage++;
            getMovie(movieNameSearch);
        } else {
            // Let the calling class know we are done
            emit finishedMovie();
        }
    }
}
コード例 #4
0
    QString key = QString("%1").arg(idx);
    if (!icons.contains(key)) {
        QPixmap pm = movie->currentPixmap();
        QIcon retval(pm);
        icons[key] = retval;
    }
    return icons[key];
}

ActivityButton::ActivityButton(QString text, QWidget* parent)
: QPushButton(text, parent), m_isActive(false) {
    setIcon(QIcon(":/icons/inactive.png"));   
}

void ActivityButton::setActive(bool isActive) {
    if (m_isActive == isActive) return;
    m_isActive = isActive;
    if (isActive) {
        connect (getMovie(), SIGNAL(frameChanged(int)),
            this, SLOT(updateIcon()), Qt::UniqueConnection);
    }
    else {
        disconnect (getMovie(), 0, this, 0);
        setIcon(QIcon(":/icons/inactive.png"));
    }
}

void ActivityButton::updateIcon() {
    setIcon(getCurrentIcon());   
}