Exemple #1
0
bool SwWindow::prepareImageForUpload(const QString& imgPath, bool isRAW, QString& caption)
{
    QImage image;

    if (isRAW)
    {
        qCDebug(KIPIPLUGINS_LOG) << "Get RAW preview " << imgPath;
        KDcraw::loadRawPreview(image, imgPath);
    }
    else
    {
        image.load(imgPath);
    }

    if (image.isNull())
        return false;

    // get temporary file name
    m_tmpPath = m_tmpDir + QFileInfo(imgPath).baseName().trimmed() + QString(".jpg");

    // rescale image if requested
    int maxDim = m_widget->m_dimensionSpB->value();

    if (m_widget->m_resizeChB->isChecked() && (image.width() > maxDim || image.height() > maxDim))
    {
        qCDebug(KIPIPLUGINS_LOG) << "Resizing to " << maxDim;
        image = image.scaled(maxDim, maxDim, Qt::KeepAspectRatio,
                                             Qt::SmoothTransformation);
    }

    qCDebug(KIPIPLUGINS_LOG) << "Saving to temp file: " << m_tmpPath;
    image.save(m_tmpPath, "JPEG", m_widget->m_imageQualitySpB->value());

    // copy meta data to temporary image
    KPMetadata meta;

    if (meta.load(imgPath))
    {
        caption = getImageCaption(meta);
        meta.setImageDimensions(image.size());
        meta.setImageProgramId("Kipi-plugins", kipiplugins_version);
        meta.save(m_tmpPath);
    }
    else
    {
        caption.clear();
    }

    return true;
}
Exemple #2
0
bool WMWindow::prepareImageForUpload(const QString& imgPath, QString& caption)
{
    QImage image;
    image.load(imgPath);


    if (image.isNull())
    {
        return false;
    }

    // get temporary file name
    m_tmpPath = m_tmpDir + QFileInfo(imgPath).baseName().trimmed() + ".jpg";

    // rescale image if requested
    int maxDim = m_widget->dimension();

    if (image.width() > maxDim || image.height() > maxDim)
    {
        kDebug() << "Resizing to " << maxDim;
        image = image.scaled(maxDim, maxDim, Qt::KeepAspectRatio,
                             Qt::SmoothTransformation);
    }

    kDebug() << "Saving to temp file: " << m_tmpPath;
    image.save(m_tmpPath, "JPEG", m_widget->quality());

    // copy meta data to temporary image
    KPMetadata meta;

    if (meta.load(imgPath))
    {
        caption = getImageCaption(imgPath);
        meta.setImageDimensions(image.size());
        meta.save(m_tmpPath);
    }
    else
    {
        caption.clear();
    }

    return true;
}
Exemple #3
0
void SwWindow::uploadNextPhoto()
{
    if (m_transferQueue.isEmpty())
    {
        // done!
        m_progressDlg->hide();

        if (m_imagesTotal > 0)
        {
            SwAlbum album = m_albumsList.at( m_widget->m_albumsCoB->currentIndex() );
            KMessageBox::information(this,
                i18n("Upload complete. Visit \"<a href=\"%1\">%2</a>\" to view the album online and invite people.",
                    album.albumUrl,
                    album.title),
                i18n("Upload complete"),
                QString(),
                KMessageBox::AllowLink
            );
        }

        return;
    }

    m_progressDlg->progressBar()->setMaximum(m_imagesTotal);
    m_progressDlg->progressBar()->setValue(m_imagesCount);

    QString imgPath = m_transferQueue.first().path();
    QString caption;
    bool    res;

    // check if we have to RAW file -> use preview image then
    bool isRAW = KPMetadata::isRawFile(QUrl::fromLocalFile(imgPath));

    if (isRAW || m_widget->m_resizeChB->isChecked())
    {
        if (!prepareImageForUpload(imgPath, isRAW, caption))
        {
            slotAddPhotoDone(666, i18n("Cannot open file"));
            return;
        }

        res = m_connector->addPhoto(m_tmpPath, m_currentAlbumID, caption);
    }
    else
    {
        KPMetadata meta;

        if (meta.load(imgPath))
            caption = getImageCaption(meta);
        else
            caption.clear();

        m_tmpPath.clear();
        res = m_connector->addPhoto(imgPath, m_currentAlbumID, caption);
    }

    if (!res)
    {
        slotAddPhotoDone(666, i18n("Cannot open file"));
        return;
    }

    m_progressDlg->setLabelText(i18n("Uploading file %1", m_transferQueue.first().path()));
}
int Snap2ChatAPIData::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 62)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 62;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< qint64*>(_v) = getAddedFriendsTimestamp(); break;
        case 1: *reinterpret_cast< int*>(_v) = getFriendRequests(); break;
        case 2: *reinterpret_cast< int*>(_v) = getUnopenedSnaps(); break;
        case 3: *reinterpret_cast< int*>(_v) = getTempID(); break;
        case 4: *reinterpret_cast< int*>(_v) = getUploadingSize(); break;
        case 5: *reinterpret_cast< int*>(_v) = getScore(); break;
        case 6: *reinterpret_cast< int*>(_v) = getBestFriendsCount(); break;
        case 7: *reinterpret_cast< int*>(_v) = getSnap_p(); break;
        case 8: *reinterpret_cast< int*>(_v) = getSentSnapsCount(); break;
        case 9: *reinterpret_cast< int*>(_v) = getReceivedSnapsCount(); break;
        case 10: *reinterpret_cast< int*>(_v) = getUnopenedSnapsCount(); break;
        case 11: *reinterpret_cast< bool*>(_v) = getIsInFriendChooser(); break;
        case 12: *reinterpret_cast< bool*>(_v) = getIsInCamera(); break;
        case 13: *reinterpret_cast< bool*>(_v) = getLogged(); break;
        case 14: *reinterpret_cast< bool*>(_v) = getLoading(); break;
        case 15: *reinterpret_cast< bool*>(_v) = getLoadingStories(); break;
        case 16: *reinterpret_cast< bool*>(_v) = getLoadingShoutbox(); break;
        case 17: *reinterpret_cast< bool*>(_v) = getSearchableByPhoneNumber(); break;
        case 18: *reinterpret_cast< bool*>(_v) = getImageCaption(); break;
        case 19: *reinterpret_cast< bool*>(_v) = getCanViewMatureContent(); break;
        case 20: *reinterpret_cast< QString*>(_v) = getStaticToken(); break;
        case 21: *reinterpret_cast< QString*>(_v) = getUsername(); break;
        case 22: *reinterpret_cast< QString*>(_v) = getAuth_token(); break;
        case 23: *reinterpret_cast< QString*>(_v) = getMobileNumber(); break;
        case 24: *reinterpret_cast< QString*>(_v) = getSnapchatNumber(); break;
        case 25: *reinterpret_cast< QString*>(_v) = getEmail(); break;
        case 26: *reinterpret_cast< QString*>(_v) = getNotificationSoundSetting(); break;
        case 27: *reinterpret_cast< QString*>(_v) = getStoryPrivacy(); break;
        case 28: *reinterpret_cast< QString*>(_v) = getHostName(); break;
        case 29: *reinterpret_cast< QString*>(_v) = getTitleBarColor(); break;
        case 30: *reinterpret_cast< QString*>(_v) = getBirthday(); break;
        case 31: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getFeedsDataModel(); break;
        case 32: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getUploadingDataModel(); break;
        case 33: *reinterpret_cast< bb::cascades::GroupDataModel**>(_v) = getStoriesDataModel(); break;
        case 34: *reinterpret_cast< bb::cascades::GroupDataModel**>(_v) = getFriendsDataModel(); break;
        case 35: *reinterpret_cast< bb::cascades::GroupDataModel**>(_v) = getAddedFriendsDataModel(); break;
        case 36: *reinterpret_cast< bb::cascades::GroupDataModel**>(_v) = getFriendRequestsDataModel(); break;
        case 37: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getShoutboxDataModel(); break;
        case 38: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getCurrentStoriesOverViewModel(); break;
        case 39: *reinterpret_cast< bb::cascades::ArrayDataModel**>(_v) = getCurrentStoryNotesDataModel(); break;
        }
        _id -= 40;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setAddedFriendsTimestamp(*reinterpret_cast< qint64*>(_v)); break;
        case 1: setFriendRequests(*reinterpret_cast< int*>(_v)); break;
        case 2: setUnopenedSnaps(*reinterpret_cast< int*>(_v)); break;
        case 3: setTempID(*reinterpret_cast< int*>(_v)); break;
        case 4: setUploadingSize(*reinterpret_cast< int*>(_v)); break;
        case 5: setScore(*reinterpret_cast< int*>(_v)); break;
        case 6: setBestFriendsCount(*reinterpret_cast< int*>(_v)); break;
        case 7: setSnap_p(*reinterpret_cast< int*>(_v)); break;
        case 8: setSentSnapsCount(*reinterpret_cast< int*>(_v)); break;
        case 9: setReceivedSnapsCount(*reinterpret_cast< int*>(_v)); break;
        case 10: setUnopenedSnapsCount(*reinterpret_cast< int*>(_v)); break;
        case 11: setIsInFriendChooser(*reinterpret_cast< bool*>(_v)); break;
        case 12: setIsInCamera(*reinterpret_cast< bool*>(_v)); break;
        case 13: setLogged(*reinterpret_cast< bool*>(_v)); break;
        case 14: setLoading(*reinterpret_cast< bool*>(_v)); break;
        case 15: setLoadingStories(*reinterpret_cast< bool*>(_v)); break;
        case 16: setLoadingShoutbox(*reinterpret_cast< bool*>(_v)); break;
        case 17: setSearchableByPhoneNumber(*reinterpret_cast< bool*>(_v)); break;
        case 18: setImageCaption(*reinterpret_cast< bool*>(_v)); break;
        case 19: setCanViewMatureContent(*reinterpret_cast< bool*>(_v)); break;
        case 20: setStaticToken(*reinterpret_cast< QString*>(_v)); break;
        case 21: setUsername(*reinterpret_cast< QString*>(_v)); break;
        case 22: setAuth_token(*reinterpret_cast< QString*>(_v)); break;
        case 23: setMobileNumber(*reinterpret_cast< QString*>(_v)); break;
        case 24: setSnapchatNumber(*reinterpret_cast< QString*>(_v)); break;
        case 25: setEmail(*reinterpret_cast< QString*>(_v)); break;
        case 26: setNotificationSoundSetting(*reinterpret_cast< QString*>(_v)); break;
        case 27: setStoryPrivacy(*reinterpret_cast< QString*>(_v)); break;
        case 28: setHostName(*reinterpret_cast< QString*>(_v)); break;
        case 29: setTitleBarColor(*reinterpret_cast< QString*>(_v)); break;
        case 30: setBirthday(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 40;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 40;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 40;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 40;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 40;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 40;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 40;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}