예제 #1
0
void CameraMainWindow::viewVideos()
{
    QMimeType m( QLatin1String( "video/mpeg" ));
    QContent a = m.application();
    if ( a.isValid() )
        a.execute();
}
예제 #2
0
/*!
    \reimp
*/
bool QFSContentEngine::execute( const QStringList &arguments ) const
{
#ifndef QTOPIA_CONTENT_INSTALLER
    if( role() == QContent::Application )
    {
        qLog(DocAPI) << "QFSContentEngine::execute" << Qtopia::dehyphenate(name()) << fileName() << arguments;

        Qtopia::execute( fileName(), arguments.count() ? arguments[0] : QString() );

        return true;
    }
    else
    {
        QContent app = mimeType().application();

        if ( app.isValid() )
        {
            app.execute( QStringList() << arguments << fileName() );

            return true;
        }
}
#else
    Q_UNUSED(arguments)
#endif

    return false;
}
예제 #3
0
void DocumentListSelectionPage::updateFinished()
{
    largeDocuments->clear();

    selectedSize = 0;
    selectedDocuments = 0;
    for (int i = 0; i < documents->count(); i++) {
        const QContent content = documents->content(i);
        if (content.size() >= field("documentsTypeSelectionPage_minimumSize").toInt() * 1024) {
            largeDocuments->add(content);

            selectedSize += content.size();
            selectedDocuments++;
        }
    }

    list->resizeColumnsToContents();
    list->setColumnWidth(0, list->viewport()->size().width() - list->columnWidth(1) - 10);
    list->setCurrentIndex(largeModel->index(0, 0));

    updateHeader();

    if (waitWidget) {
        delete waitWidget;
        waitWidget = 0;
    }
}
예제 #4
0
QContent *WheelBrowserScreen::readLauncherMenuItem(const QString &entry)
{
    QContent *applnk = 0;

    if (entry.right(8)==".desktop") {
        // There used to be a quick way to locate a .desktop file
        // Now we have to create a QContentSet and iterate over the items

        // The path to the apps folder (which only exists in the database)
        QString apps = Qtopia::qtopiaDir()+"apps/";
        // We need the full path to the entry to compare against the items we get from QContentSet
        QString entryPath = apps+entry;
        applnk = new QContent( entryPath, false );
        if ( applnk->id() == QContent::InvalidId ) {
            delete applnk;
            applnk = 0;
        }
    } else {
        QCategoryManager catman("Applications");
        if(catman.contains(entry))
        {
            applnk = new QContent();
            applnk->setName(catman.label(entry));
            applnk->setIcon(catman.iconFile(entry));
            applnk->setType("Folder/"+entry);
        }
        else
            applnk = NULL;
    }

    return applnk;
}
예제 #5
0
/*!
  Given an application binary name \a bin return the QContentId of the QContent record
  for that application.  If \a bin is the fully qualified path of an ordinary file the
  QContentId of that file will be returned.

  If \a bin does not refer to any application or file in the backing store then an
  InvalidId will be returned.

  Note that binary names are unique across Qtopia.
 */
QContentId QContent::execToContent( const QString& bin )
{
    QContent content = QContentStore::instance()->contentFromFileName( bin, QContentStore::Lookup );

    if( !content.isNull() )
        return content.id();
    else
        return QContent::InvalidId;
}
예제 #6
0
void ThumbnailDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    Q_ASSERT(index.isValid());
    const QContentSetModel *model = qobject_cast< const QContentSetModel * >( index.model() );
    Q_ASSERT(model);

    QStyleOptionViewItem opt = option;

    // set text alignment
    opt.displayAlignment = Qt::AlignCenter;

    // do layout
    QContent content = model->content( index );
    QPixmap pixmap;

    if( content.fileKnown() ) {
        pixmap = repository_->thumbnail( ThumbnailRequest( index, content.file(), option.decorationSize, content.lastUpdated() ) );
    }
    if( pixmap.isNull() ) {
        QIcon icon = qvariant_cast<QIcon>(model->data(index, Qt::DecorationRole));
        pixmap = icon.pixmap( option.decorationSize );
    }
    QRect pixmapRect = QRect(0, 0, option.decorationSize.width(),
                           option.decorationSize.height());

    QFontMetrics fontMetrics(opt.font);
    QString text = model->data(index, Qt::DisplayRole).toString();
    QRect textRect(0, 0, option.decorationSize.width(), fontMetrics.lineSpacing());

    QVariant value = model->data(index, Qt::CheckStateRole);
    QRect checkRect = check(opt, opt.rect, value);
    Qt::CheckState checkState = static_cast<Qt::CheckState>(value.toInt());

    doLayout(opt, &checkRect, &pixmapRect, &textRect, false);

    // draw the background color
    if (option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
        QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
                                  ? QPalette::Normal : QPalette::Disabled;
        painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight));
    } else {
        value = model->data(index, Qt::BackgroundColorRole);
        if (value.isValid() && qvariant_cast<QColor>(value).isValid())
            painter->fillRect(option.rect, qvariant_cast<QColor>(value));
    }

    // draw the item
    drawCheck(painter, opt, checkRect, checkState);
    drawDecoration(painter, opt, pixmapRect, pixmap);
    drawDisplay(painter, opt, textRect, text);
    drawFocus(painter, opt, textRect);
}
예제 #7
0
void DocumentListSelectionPage::cleanup()
{
    connect(documentsCleanupDialog->pushButton, SIGNAL(clicked()), this, SLOT(stopCleanup()));

    documentsCleanupDialog->progressBar->setRange(0, selectedSize);

    if (largeModel->rowCount() == 0)
        return;

    qLog(CleanupWizard) << "Deleting Documents...";
    for (int i = 0; i < largeModel->rowCount(); i++) {
        if (cleanupStopped)
            break;

        QModelIndex index = largeModel->index(i, 0);

        if (largeModel->data(index, Qt::CheckStateRole) == Qt::Checked) {
            QContent content = largeModel->content(index);

            documentsCleanupDialog->label->setText(tr("Deleting %1").arg(content.name()));

            qApp->processEvents();

            int contentSize = content.size();

            content.removeFiles();

            if (!content.isValid()) {
                documentsCleanupDialog->progressBar->setValue(
                    documentsCleanupDialog->progressBar->value() + contentSize);

                docDeleted++;
            }
        }
    }

    documentsCleanupDialog->pushButton->hide();
    if (cleanupStopped) {
        documentsCleanupDialog->label->setText(tr("Aborted"));
    } else {
        documentsCleanupDialog->progressBar->setValue(
            documentsCleanupDialog->progressBar->maximum());
        documentsCleanupDialog->label->setText(tr("Done"));
        documents->clear();
    }

    QTimer::singleShot(1000, documentsCleanupDialog, SLOT(close()));
    emit documentsDeleted(docDeleted, cleanupStopped);
}
예제 #8
0
/*!
  Returns the name of the name of the application that will be launched if the QContent is executed.

  If the QContent is an application this is the name of the binary, if it is a document it is the
  executable name of the application associated with the document MIME type.

  If the content is not an application and there is no associated application associated with its
  MIME type then a null string will be returned.

  \sa execute()
 */
QString QContent::executableName() const
{
    if( role() == Application )
    {
        return d->fileName();
    }
    else
    {
        QContent app = d->mimeType().application();
        if ( app.id() != InvalidId )
            return app.executableName();
        else
            return QString();
    }
}
예제 #9
0
/*
 * Respond to the documentSelected signal from the appSelector, by displaying
 * information about the selected application.
 */
void AppViewer::documentSelected( const QContent &appContent )
{
    appSelector->hide();
    if ( appContent.isValid() )
    {
        textArea->setHtml( getInformation( appContent ));
    }
    else
    {
        textArea->setHtml(
                tr( "<font color=\"#CC0000\">Could not find information about %1</font>" )
                .arg( appContent.name() ));
        qWarning() << "Application " << appContent.file() << " not found";
    }
}
예제 #10
0
void ApplicationLauncherView::launcherRightPressed(QContent lnk)
{
    if(!lnk.isValid())
        return;

    rightMenu->popup(QCursor::pos());
}
예제 #11
0
/*
 * Find information about an Application, including what other installed applications
 * there are which have binaries bigger or smaller than this one.
 * Pre-requisite - the appContent is valid, ie has a backing file.
 */
QString AppViewer::getInformation( const QContent &appContent )
{
    QFileInfo fi( appContent.file() );
    QString info = tr( "Binary is: <b>%1</b><br>" ).arg( fi.fileName() );

    qint64 chosenAppSize = fi.size();
    info += tr( "Size is: <b>%1 bytes</b><br>" ).arg( chosenAppSize );

    enum Count { SMALL, LARGE };
    int qtopiaCounts[2] = { 0, 0 };
    int packageCounts[2] = { 0, 0 };
    int *currentCount;
    QStringList paths = Qtopia::installPaths();
    foreach ( QString p, paths )
    {
        QDir qDir( p + "bin" );
        qDebug( "Checking %s\n", qPrintable( qDir.path() ));
        if ( qDir.exists() )
        {
            QFileInfoList binaries = qDir.entryInfoList( QDir::Executable );
            currentCount = ( p == Qtopia::packagePath() ) ? packageCounts : qtopiaCounts;
            foreach ( QFileInfo f, binaries )
                if ( f.size() > chosenAppSize )
                    ++currentCount[LARGE];
                else
                    ++currentCount[SMALL];
        }
예제 #12
0
void TextViewer::documentSelected(const QContent & docContent)
{
    // make use of the document selected by the QDocumentSelector widget
    docSelector->hide();
    if (docContent.isValid()){
        QFile f(docContent.file());
        if (f.open(QIODevice::ReadOnly)){
            QTextStream fstream(&f);
            textArea->setHtml(fstream.readAll());
        }else{
            qWarning() << "Unable to read content from file" << docContent.file();
        }

    }else{
        qWarning()<< "Document " << docContent.file() << " is invalid";
    }
}
예제 #13
0
/*!
    Copies the contents of \a from to this QContent.

    Returns true is successful, otherwise false.
 */
bool QContent::copyContent(const QContent &from)
{
    QFile source( from.fileName() );

    if( source.copy( fileName() ) )
        return true;

    return false;
}
예제 #14
0
bool ScribbleArea::saveImage(const QString &fileName, const char *fileFormat)
{
    QImage visibleImage = image;
    if (visibleImage.save(fileName, fileFormat)) {
            // Create new doc link
        QContent lnk;
          // Perserve name and category
        lnk.setName(QFileInfo(fileName).baseName() );
          //   lnk.setCategories( _lnk.categories() );
        lnk.setFile( fileName );
        lnk.commit();

        modified = false;
        return true;
    } else {
        return false;
    }
}
예제 #15
0
/*!
    Displays a prompt informing the user that the \a content cannot be rendered due to invalid rights and that
    a preview will be rendered instead.
*/
void BSciPrompts::notifyUseEmbeddedPreview( const QContent &content ) const
{
    QString title   = tr( "Preview" );
    QString message = tr( "'%1' is inaccessible, a preview version will be opened instead.", "%1 = name of content" )
            .arg( content.name() );

    message = QString( "<qt>%1</qt>" ).arg( message );

    information( title, message );
}
예제 #16
0
void CameraMainWindow::loadThumbs( bool resized )
{
    int i = 0;
    showWaitScreen();
    for (; i < nthumb && i < m_photoModel->rowCount(); ++i)
    {
        QContent content = m_photoModel->content(i);
        if (resized || picturefile[i].id() != content.id() || picturefile[i].lastUpdated() != content.lastUpdated()) {
            picturefile[i] = content;

            thumb[i]->setIcon(QThumbnail(picturefile[i].fileName()).pixmap(QSize(thumbw, thumbh)));
            thumb[i]->setEnabled(true);
        }
    }

    for (; i < nthumb; ++i) {
        picturefile[i] = QContent();
        thumb[i]->setIcon(QIcon());
        thumb[i]->setEnabled(false);
    }

    if ( cur_thumb >= 0 )
        selectThumb(cur_thumb);

    if ( !camera->videocaptureview->available() ) {
        if(settings)
            a_timer->setVisible(false);
        camera->photo->setEnabled(false);
        camera->video->setEnabled(false);
        if (m_photoModel->rowCount() == 0) {
            thumb[0]->setEnabled(false);
        } else {
            thumb[0]->setFocus();
            thumb[0]->setEnabled(true);
        }
    }

    if(settings)
        updateActions();
    hideWaitScreen();
}
예제 #17
0
void Screenshot::saveScreenshot()
{
    QString format = "png";
    QString initialPath = QDir::currentPath() + tr("/untitled.") + format;
#ifdef Q_WS_QWS

    QString  fileName = "sc_" + QDateTime::currentDateTime().toString();
    fileName.replace(QRegExp("'"), "");
    fileName.replace(QRegExp(" "), "_");
    fileName.replace(QRegExp(":"), ".");
    fileName.replace(QRegExp(","), "");
    QString dirName = QDir::homePath() + "/Documents/image/png/";

    if ( !QDir( dirName).exists() ) {
        QDir homeDir(QDir::homePath());
        homeDir.mkpath("Documents/image/png");
    }
#else
    QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
                       initialPath,
                       tr("%1 Files (*.%2);;All Files (*)")
                       .arg(format.toUpper())
                       .arg(format));
    if (!fileName.isEmpty())
#endif
#ifdef Q_WS_QWS
    QString new_file = dirName+"/"+fileName+".png";
    originalPixmap.save(new_file, format.toAscii());
    QContent content;
    content.setName( fileName);
    content.setFile( new_file );
    content.commit();

#else
    originalPixmap.save(fileName, format.toAscii());
#endif


}
예제 #18
0
/*!
    Displays a prompt informing the user that \a permission render rights for \a content are installed but they
    will not become valid until after a future \a date.
*/
void BSciPrompts::notifyFutureRights( const QContent &content, const QDateTime &date, QDrmRights::Permission permission ) const
{
    QString title   = tr( "Content Unavailable" );
    QString message = tr( "The %1 for '%2' does not allow it to be accessed before %3.",
                          "%1 = play|display|execute|print|export license, "
                          "%2 = name of content, %3 = access date/time" )
            .arg( permissionString( permission ) )
            .arg( content.name() )
            .arg( date.toString() );

    message = QString( "<qt>%1</qt>" ).arg( message );

    information( title, message );
}
예제 #19
0
ImageIO::Status ImageIO::load( const QContent& lnk, int levels )
{
    static const int maxSize = 2097152;
    static const int maxArea = 1920000;
    _lnk = lnk;

    QImageReader reader( lnk.fileName() );

    _format = reader.format();

    QImage image;

    if( reader.supportsOption( QImageIOHandler::Size ) )
    {
        QSize size = reader.size();

        if( size.width() * size.height() > maxArea )
        {
            _status = SIZE_ERROR;

            return _status;
        }
    }
    else if( QFileInfo( lnk.file() ).size() > maxSize )
    {
        _status = SIZE_ERROR;

        return _status;
    }

    if( reader.read( &image ) )
        _status = load( image, levels );
    else
        _status = LOAD_ERROR;

    return _status;
}
예제 #20
0
void E2TaskManager::doUpdate()
{
    if(isVisible()) {
        m_taskList->clear();
        while(m_items.count()) {
            QPair<QTreeWidgetItem*,QContent*> p = m_items.takeFirst();
            delete p.second;
        }
        QStringList apps = m_appMonitor.runningApplications();

        QContentSet set(QContent::Application);
        for (int ii=0; ii < apps.count(); ii++) {
            QContent app = set.findExecutable(apps.at(ii));
            if(app.isValid()) {
                QStringList labels;
                labels << QString("") << app.name() << QString("");
                QTreeWidgetItem* item = new QTreeWidgetItem(labels);
                item->setCheckState(0,Qt::Unchecked);
                m_taskList->addTopLevelItem(item);
                m_items.append(qMakePair(item, new QContent(app)));
            }
        }
    }
}
예제 #21
0
QContent QDocumentServerContentStore::contentFromId( QContentId contentId )
{
    if( contentId == QContent::InvalidId )
        return QContent();

    QContent content = QContentCache::instance()->lookup( contentId );

    if( content.isNull() )
    {
        QDocumentServerMessage response = d->callWithArgumentList( "contentFromId(QContentId)",
                                          QVariantList() << QVariant::fromValue( contentId ) );

        if( response.type() == QDocumentServerMessage::ReplyMessage )
        {
            Q_ASSERT( response.arguments().count() == 1 );

            content = qvariant_cast< QContent >( response.arguments().first() );

            QContentCache::instance()->cache( content );
        }
    }

    return content;
}
예제 #22
0
/*!
    \reimp
*/
void BSciContentLicense::renderStateChanged( const QContent &content, QDrmContent::RenderState state )
{
    if( content.id() != m_content.id() )
        return;

    switch( state )
    {
    case QDrmContent::Started:
        startConstraintUpdates();
        break;
    case QDrmContent::Paused:
        pauseConstraintUpdates();
        break;
    case QDrmContent::Stopped:
        stopConstraintUpdates();
    }
}
예제 #23
0
QImage ExifContentPlugin::thumbnail( const QContent &content, const QSize &size, Qt::AspectRatioMode mode )
{
    QImage image;

    QIODevice *device = content.open();

    if (device) {
        QExifImageHeader exif;

        if (exif.loadFromJpeg(device)) {
            image = exif.thumbnail();

            if (!image.isNull() && size.isValid())
                image = image.scaled(size, mode, Qt::SmoothTransformation);
        }

        device->close();

        delete device;
    }

    return image;
}
예제 #24
0
/*!
    Notifies the user that the given \a content does not have valid rights to render with the given \a permission
    and that the content cannot be reactivated.  If \a permission is \c{QDrmRights::Unrestricted)} the user will
    be informed that the content must be opened in an application that support DRM content.  The message displayed
    will differ based on the \a reason the user was prompted to acquire new rights.
*/
void BSciPrompts::notifyCannotActivate( const QContent &content, QDrmRights::Permission permission, ActivationReason reason ) const
{
    QString title;
    QString message;

    if( permission == QDrmRights::Unrestricted )
    {
        title   = tr( "Content Unsupported" );
        message = tr( "'%1' cannot be opened in an application that doesn't support licensed content.",
                      "%1 = name of content" );
    }
    else
    {
        title   = tr( "Cannot activate" );

        switch( reason )
        {
        case Open:
            message = tr( "'%2' has no %1 and cannot be reactivated.",
                        "%1 = play|display|execute|print|export license, %2 = name of content" )
                    .arg( permissionString( permission ) );
            break;
        case Expired:
            message = tr( "The %1 for '%2' has expired and cannot be reactivated.",
                          "%1 = play|display|execute|print|export license, %2 = name of content" )
                    .arg( permissionString( permission ) );
            break;
        default:
            return;
        }
    }

    message = QString( "<qt>%1</qt>" ).arg( message.arg( content.name() ) );

    information( title, message );
}
예제 #25
0
/*!
    Constructs a QMimeType from the \l {QContent::}{type()} of \a lnk.
*/
QMimeType::QMimeType( const QContent& lnk )
{
    init(lnk.type());
}
예제 #26
0
void CameraMainWindow::delayedInit()
{
    settingsDialog = new QDialog( this );
    settingsDialog->setModal( true );
    settings = new Ui::CameraSettings();
    settings->setupUi( settingsDialog );
    settingsDialog->setObjectName( "settings" );    // To pick up correct help.
    connect( settings->photo_quality, SIGNAL(valueChanged(int)),
             settings->photo_quality_n, SLOT(setNum(int)) );
    QFileSystemFilter *fsf = new QFileSystemFilter;
    fsf->documents = QFileSystemFilter::Set;
    settings->location->setFilter(fsf);
    // load settings from config
    QSettings cfg("Trolltech","Camera");
    cfg.beginGroup("General");
    QString l = cfg.value("location").toString();
    if ( !l.isEmpty() )
        settings->location->setLocation(l);
    else
        settings->location->setLocation(QFileSystem::documentsFileSystem().documentsPath());
    storagepath = settings->location->documentPath();
    cfg.endGroup();
    cfg.beginGroup("Photo");
    int w;
    w = cfg.value("width",camera->videocaptureview->recommendedPhotoSize().width()).toInt();
    for (psize=0; psize<(int)photo_size.count()-1 && photo_size[psize].width() > w;)
        psize++;
    pquality = cfg.value("quality",settings->photo_quality->value()).toInt();
    cfg.endGroup();
    cfg.beginGroup("Video");
    w = cfg.value("width",camera->videocaptureview->recommendedVideoSize().width()).toInt();
    for (vsize=0; vsize<(int)video_size.count()-1 && video_size[vsize].width() > w;)
        vsize++;
    vquality = cfg.value("quality",settings->video_quality->value()).toInt();
    vframerate = cfg.value("framerate",settings->video_framerate->value()).toInt();

    for (int i=0; i<(int)photo_size.count(); i++) {
        settings->photo_size->addItem(tr("%1 x %2","picture size e.g. 640 x 480").arg(photo_size[i].width()).arg(photo_size[i].height()));
    }
    for (int i=0; i<(int)video_size.count(); i++) {
        settings->video_size->addItem(tr("%1 x %2","picture size e.g. 640 x 480").arg(video_size[i].width()).arg(video_size[i].height()));
    }

    QMimeType m( QLatin1String( "image/jpeg" ));
    QContent a = m.application();
    QIcon picViewIcon = a.icon();
    if ( picViewIcon.isNull() )
        picViewIcon = QIcon( QLatin1String( ":icon/view" ));

    if ( video_supported ) {
        // If video_supported is ever not a constant false then ensure
        // an application is available to handle it
        if ( a.isValid() )
        {
            a_vview = new QAction( QIcon(":image/"+a.iconName()), QString("%1...").arg(a.name()), this );
            connect( a_vview, SIGNAL(triggered()), this, SLOT(viewVideos()) );
        }
    } else {
        a_vview = 0;
    }

    a_pview = new QAction( QIcon(), tr( "View pictures" ), this );
    a_pview->setIcon(picViewIcon);
    connect( a_pview, SIGNAL(triggered()), this, SLOT(viewPictures()) );

    a_timer = new QAction( QIcon( ":icon/wait" ) , tr("Timer"), this );
    connect( a_timer, SIGNAL(triggered()), this, SLOT(takePhotoTimer()) );

    if(camera->videocaptureview->available())
    {
        a_settings = new QAction( QIcon( ":icon/settings" ) , tr("Settings..."), this );
        connect( a_settings, SIGNAL(triggered()), this, SLOT(doSettings()) );
    }

    a_th_edit = new QAction( QIcon(":icon/edit"), tr("Edit"), this );
    connect( a_th_edit, SIGNAL(triggered()), this, SLOT(editThumb()) );
    a_th_del = new QAction( QIcon(":icon/trash"), tr("Delete"), this );
    connect( a_th_del, SIGNAL(triggered()), this, SLOT(delThumb()) );
    a_th_add = new QAction( QIcon(":image/addressbook/AddressBook"), tr("Save to Contact..."), this );
    connect( a_th_add, SIGNAL(triggered()), this, SLOT(moveToContact()) );
    a_send = new QAction( QIcon( ":icon/beam" ), tr("Send to Contact..."), this );
    connect( a_send, SIGNAL(triggered()), this, SLOT(sendFile()) );

    a_zoom = new QAction( QIcon( ), tr("Zoom"), this);
    connect(a_zoom, SIGNAL(triggered()), this, SLOT(showZoom()));
    m_zoom = new QSlider(this);
    m_zoom->setSliderPosition(50);
    m_zoom->setOrientation(Qt::Horizontal);

    m_zoom->setRange(camera->videocaptureview->minZoom(),camera->videocaptureview->maxZoom());
    m_zoom->setValue(0);
    m_zoom->setGeometry(width()*1/5, height()*2/3, 60*width()/100, 40*height()/100);
    m_zoom->hide();

    connect(m_zoom, SIGNAL(valueChanged(int)), this, SLOT(zoomChanged(int)));

    QMenu *contextMenu = QSoftMenuBar::menuFor(this);
    if(camera->videocaptureview->available())
    {
        contextMenu->addAction( a_pview );
        if ( video_supported )
            contextMenu->addAction( a_vview );
        contextMenu->addAction( a_th_edit );
        contextMenu->addAction( a_th_del );
        contextMenu->addAction( a_th_add );
        contextMenu->addAction( a_timer );
        contextMenu->addAction( a_send );
        contextMenu->addAction( a_settings );
        contextMenu->addAction( a_zoom );
    }

    connect(contextMenu, SIGNAL(aboutToHide()),
            this, SLOT(contextMenuAboutToHide()));
    connect(contextMenu, SIGNAL(aboutToShow()),
            this, SLOT(contextMenuAboutToShow()));

    QSignalMapper* sm = new QSignalMapper(this);
    for (int i=0; i<nthumb; i++) {
        sm->setMapping(thumb[i],i);
        connect(thumb[i],SIGNAL(clicked()),sm,SLOT(map()));
        thumb[i]->installEventFilter(this);
    }
    connect(sm,SIGNAL(mapped(int)),this,SLOT(thumbClicked(int)));

    installEventFilter(camera->photo);
    installEventFilter(camera->video);
    camera->photo->installEventFilter(this);
    camera->video->installEventFilter(this);

    loadThumbs();
    preview();
}
예제 #27
0
/*!
    Loads a thumbnail representation of \a content.  The thumbnail will be scaled to \a size
    according to the given aspect ratio mode.
*/
QImage QContentStore::thumbnail(const QContent &content, const QSize &size, Qt::AspectRatioMode mode)
{
    QImage thumbnail;

    QString thumbPath = thumbnailPath(content.fileName());

    QFileInfo thumbInfo(thumbPath);

    if (thumbInfo.exists()) {
        if (thumbInfo.lastModified() > content.lastUpdated())
            thumbnail = readThumbnail(thumbPath, size, mode);
    } else {
        thumbnail = QContentFactory::thumbnail(content, size, mode);
    }

    if (thumbnail.isNull()) {
        if (QIODevice *device = content.open()) {
            QImageReader reader(device);

            if (reader.canRead()) {
                QSize scaledSize = reader.size();

                reader.setQuality(25);
                if (scaledSize.width() > 128 || scaledSize.height() > 128) {
                    scaledSize.scale(QSize(128, 128), Qt::KeepAspectRatio);

                    reader.setQuality( 49 ); // Otherwise Qt smooth scales
                    reader.setScaledSize(scaledSize);
                    reader.read(&thumbnail);

                    if (!thumbnail.isNull()) {
                        QImageWriter writer(thumbPath, QByteArray::fromRawData("PNG", 3));
                        writer.setQuality(25);
                        writer.write(thumbnail);

                        if (size.isValid())
                            thumbnail = thumbnail.scaled(size, mode);
                    }
                } else {
                    if (size.isValid()) {
                        scaledSize.scale(size, mode);
                        reader.setQuality( 49 ); // Otherwise Qt smooth scales
                        reader.setScaledSize(scaledSize);
                    }
                    reader.read(&thumbnail);
                }
            }

            delete device;
        }
    }

    if (thumbnail.isNull() && content.type().startsWith(m_audioPrefix)) {
        QDir dir = QFileInfo(content.fileName()).absoluteDir();

        foreach (const QString &fileName, m_folderThumbnails) {
            if (dir.exists(fileName)) {
                thumbnail = readThumbnail(dir.absoluteFilePath(fileName), size, mode);
                break;
            }
        }
    }
예제 #28
0
/*!
    Constructs a new WheelBrowserScreen instance with the given \a parent and
    widget \a flags.
*/
WheelBrowserScreen::WheelBrowserScreen(QWidget *parent, Qt::WFlags flags)
: QAbstractBrowserScreen(parent, flags),
  m_fillAlpha(0), m_hiding(false), m_wheel(0), m_fillTimeline(0)
{
    QPalette pal = palette();
    pal.setColor(QPalette::Window, QColor(100, 100, 100, 0));
    setPalette(pal);

    QVBoxLayout * layout = new QVBoxLayout(this);
    setLayout(layout);

    m_wheel = new QPixmapWheel(this);
    QFont f = font();
    f.setBold(true);
    m_wheel->setFont(f);
    m_wheel->setMaximumVisibleIcons(7);

    QObject::connect(m_wheel, SIGNAL(moveToCompleted()),
                     this, SLOT(moveToCompleted()));
    QObject::connect(m_wheel, SIGNAL(itemSelected(QString)),
                     this, SLOT(clicked(QString)));
    setFocusProxy(m_wheel);

    layout->addStretch(1);
    layout->addWidget(m_wheel, 5);
    layout->addStretch(1);

    m_data = new QPixmapWheelData;

    // Load apps
    QSettings cfg(Qtopia::defaultButtonsFile(), QSettings::IniFormat);
    cfg.beginGroup("Menu"); // No tr
    const int menur = cfg.value("Rows",3).toInt();
    const int menuc = cfg.value("Columns",3).toInt();
    QString menuKeyMap = cfg.value("Map","123456789").toString();

    for (int i = 0; i < menur*menuc; i++) {
        QChar key = menuKeyMap[i];
        QStringList entries = cfg.value(QString(key)).toStringList();

        if(!entries.isEmpty()) {
            QContent *app = readLauncherMenuItem(entries.first());

            if(app) {
                QString file = app->fileName();
                QString name = app->name();
                if(app->type().startsWith("Folder/") )
                    file = app->type();
                QPixmap pix = app->icon().pixmap(QSize(48, 48));
                if(file.isEmpty())
                    file = app->type();

                if(!file.isEmpty() && !name.isEmpty() && !pix.isNull()) {
                    m_data->appendItem(file, pix, name);
                }
                delete app;
            }
        }
    }

    m_fillTimeline = new QTimeLine(2000, this);
    QObject::connect(m_fillTimeline, SIGNAL(valueChanged(qreal)),
                     this, SLOT(timelineStep(qreal)));
}
예제 #29
0
/*!
    \reimp
*/
void BSciPreviewLicense::renderStateChanged( const QContent &content, QDrmContent::RenderState state )
{
    if( content.id() == m_content.id() )
        m_renderState = state;
}
예제 #30
0
void CameraMainWindow::takePhotoNow()
{
    QImage img = camera->videocaptureview->image();
    if ( snapRequest != 0 ) {
        // Rescale the image and pop it into a QDSData object
        QImage scaledimg = img.scaled( snap_max,
                                       Qt::KeepAspectRatio,
                                       Qt::SmoothTransformation);
        QByteArray savedImageData;
        {
            QDataStream stream( &savedImageData, QIODevice::WriteOnly );
            stream << QPixmap::fromImage( scaledimg );
        }
        QDSData snappedImage( savedImageData, QMimeType( "image/x-qpixmap" ) );

        // Send response with the data
        snapRequest->respond( snappedImage );

        // Reset snap mode
        setSnapMode( false );
        delete snapRequest;
        snapRequest = 0;

        // Finished serving QDS request so close the application
        close();
        hideWaitScreen();
    } else {
        showWaitScreen();
        QContent f;
        QList<QString> c;

        f.setType("image/jpeg");
        f.setName(tr("Photo, %1","date")
                .arg(QTimeString::localYMDHMS(QDateTime::currentDateTime(),QTimeString::Short)));
        f.setMedia( settings->location->documentPath() );

        c.append(camcat);
        f.setCategories(c);

        QIODevice*  contentDevice = f.open(QIODevice::WriteOnly);

        if (contentDevice != 0)
        {
            QImage  temp = img.convertToFormat(QImage::Format_RGB32);

            temp.save(contentDevice, "JPEG", pquality);

            contentDevice->close();

            f.commit();

            pushThumb(f, img);

            hideWaitScreen();

        }
        else
        {
            QString errorText = f.errorString();
            if (errorText.isEmpty())
                errorText = tr("Unknown error");

            QMessageBox::warning(0,
                                 tr("Error saving photo"),
                                 tr("Could not save photo: %1").arg(errorText));
        }
    }

    preview();
}