Ejemplo n.º 1
0
bool PictureContent::loadPhoto(const QString & fileName, bool keepRatio, bool setName)
{
    dropNetworkConnection();
    delete m_photo;
    m_cachedPhoto = QPixmap();
    m_opaquePhoto = false;
    m_photo = 0;
    m_fileUrl = QString();
    m_netWidth = 0;
    m_netHeight = 0;

    m_photo = new CPixmap(fileName);
    if (m_photo->isNull()) {
        delete m_photo;
        m_photo = 0;
        return false;
    }

    m_opaquePhoto = !m_photo->hasAlpha();
    m_fileUrl = fileName;
    if (keepRatio)
        resetContentsRatio();
    if (setName) {
        QString string = QFileInfo(fileName).fileName().section('.', 0, 0);
        string = string.mid(0, 10);
        setFrameText(string + tr("..."));
    }
    applyPostLoadEffects();

    // notify image change
    emit contentChanged();
    return true;
}
Ejemplo n.º 2
0
bool PictureContent::loadPixmap(const QPixmap & pixmap, const QString & title)
{
    dropNetworkConnection();
    delete m_photo;
    m_cachedPhoto = QPixmap();
    m_opaquePhoto = false;
    m_photo = 0;
    m_fileUrl = QString();
    m_netWidth = 0;
    m_netHeight = 0;

    m_photo = new CPixmap(pixmap.toImage());
    m_opaquePhoto = !pixmap.hasAlpha();
    m_fileUrl = QString("data:/");
    resetContentsRatio();
    setFrameTextEnabled(!title.isEmpty());
    setFrameText(title);
    applyPostLoadEffects();

    // notify image change
    emit contentChanged();
    return true;
}