Пример #1
0
QContent QDocumentServerContentStore::contentFromFileName( const QString &fileName, LookupFlags lookup )
{
    if( fileName.isEmpty() )
        return QContent();

    QByteArray signature = "contentFromFileName(QString," + QByteArray::number( lookup, 2 ).rightJustified( 3, '0' ) + ')';

    QDocumentServerMessage response = d->callWithArgumentList( signature.constData(),
                                      QVariantList() << fileName );

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

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

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

        return content;
    }
    else if( response.type() == QDocumentServerMessage::ErrorMessage )
    {
        Q_ASSERT( response.arguments().count() == 1 );

        setErrorString( qvariant_cast< QString >( response.arguments().first() ) );
    }

    return QContent();
}
Пример #2
0
//TODO: reduce duplicated code
void HomescreenSettings::editSecondaryPhoto()
{
    QImageSourceSelectorDialog *dlg = new QImageSourceSelectorDialog( this );
    dlg->setMaximumImageSize( QApplication::desktop()->availableGeometry(1).size()  );
    dlg->setContent( secondaryHsImage );
    dlg->setModal( true );
    dlg->setWindowTitle( tr("Homescreen Photo") );
    if( QtopiaApplication::execDialog( dlg ) == QDialog::Accepted ) { 
        if (!dlg->content().isValid()) {
            secondaryHsImage = QContent();
            secondaryImage->setIcon(QIcon());
            secondaryImage->setText(tr("No image"));
            secondaryImageMode->setVisible(false);
            return;
        }
        
        secondaryHsImage = dlg->content();
        secondaryImage->setIcon(QIcon(secondaryHsImage.fileName()));
        secondaryImage->setText(QString());
        secondaryImageMode->setVisible(true);

        //BUG: shouldn't change files here (in case use cancels dialog)
        //     should only change document filename
        qLog(Resource) << "Selected Document:" << secondaryHsImage.fileName();
        // remove old image
        QFile::remove( HOMESCREEN_IMAGE_PATH2 );
        // check if the file is from a removable storage
        const QFileSystem *fs = QStorageMetaInfo::instance()->fileSystemOf(hsImage.fileName());
    
        if (fs && fs->isRemovable()) {
            qLog(Resource) << secondaryHsImage.fileName() << "is from a removable storage," << secondaryHsImage.media();    
            // check if the file has Distribute right
            QDrmContent imgContent( QDrmRights::Distribute, QDrmContent::NoLicenseOptions );
            if ( imgContent.requestLicense( secondaryHsImage ) ) {
                qLog(Resource) << "File has Distribute right";
                // save a copy
                QFile oldFile( secondaryHsImage.fileName() );
                if ( oldFile.copy( HOMESCREEN_IMAGE_PATH2 ) ) {
                    secondaryHsImage = QContent( HOMESCREEN_IMAGE_PATH2 );
                    qLog(Resource) << "Successfully copied" << secondaryHsImage.fileName() << "to" << HOMESCREEN_IMAGE_PATH2;
                } else {
                    qLog(Resource) << "Failed to copy" << secondaryHsImage.fileName() << ". Need to use as is.";
                }
            } else {
                qLog(Resource) << "File does not have Distribute right";
            }
        }
    }
    delete dlg;
}
Пример #3
0
bool QDocumentServerContentStore::removeContent( QContent *content )
{
    QDocumentServerMessage response = d->callWithArgumentList( "removeContent(QContentId)",
                                      QVariantList() << QVariant::fromValue( content->id() ) );

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

        if( qvariant_cast< bool >( response.arguments().first() ) )
        {
            *content = QContent();

            return true;
        }
    }
    else if( response.type() == QDocumentServerMessage::ErrorMessage )
    {
        Q_ASSERT( response.arguments().count() == 1 );

        setErrorString( qvariant_cast< QString >( response.arguments().first() ) );
    }

    return false;
}
Пример #4
0
/*!
    Displays a prompt informing the user that a rights have been received for content with the file names \a fileNames.

    The notification is only displayed for content if the arrival of the rights was unexpected.

    If rights are received for multiple files agreeing to view the content will display a list of the content, if the
    rights are for just one file it will be opened in the default application for its mime type.

    \sa notifyRightsObjectsReceived()
*/
void BSciPrompts::notifyContentAvailable( const QStringList &fileNames ) const
{
    QContentList unexpected;

    QDateTime now = QDateTime::currentDateTime();

    foreach( QString fileName, fileNames )
    {
        QContent content( QContent::execToContent( fileName ) );

        if( content.isNull() )
            unexpected.append( QContent( fileName ) );
        else if( content.lastUpdated().secsTo( now ) < 25 )
            QContent( fileName ).commit();
        else if( content.isValid() )
            unexpected.append( content );
    }
Пример #5
0
/*!
    Creates a new text document and displays the text editor.
*/
void NotesDemo::newDocument()
{
    // Set the current document to a new QContent, and set it's name and type.
    // We're just using the time and date for the name but another application
    // may want to prompt the user for a name, or use the first bit of text in
    // the document.
    currentDocument = QContent();

    currentDocument.setName( "Note " + QTimeString::localYMDHMS( QDateTime::currentDateTime() ) );
    currentDocument.setType( "text/plain" );

    // Display the editor.
    layout->setCurrentWidget( editor );
}
Пример #6
0
bool CameraMainWindow::delThumb(int th)
{
    switch(QMessageBox::warning(0, tr("Confirmation"),
            tr("<qt>Delete '%1'?</qt>", "%1 = file name").arg(picturefile[th].name()),
            QMessageBox::Yes,
            QMessageBox::No))
    {
        case QMessageBox::Yes:
            picturefile[th].removeFiles();

            for (int i = th; i < nthumb - 1; ++i ) {
                picturefile[i] = picturefile[i+1];
                thumb[i]->setIcon(thumb[i+1]->icon());
                thumb[i]->setEnabled(thumb[i+1]->isEnabled());
            }

            if (m_photoModel->rowCount() > nthumb) {
                picturefile[nthumb-1] = m_photoModel->content(nthumb);
                thumb[nthumb-1]->setIcon(QThumbnail(picturefile[nthumb-1].fileName()).pixmap(QSize(thumbw, thumbh)));
                thumb[nthumb-1]->setEnabled(true);
            } else {
                picturefile[nthumb-1] = QContent();
                thumb[nthumb-1]->setIcon(QIcon());
                thumb[nthumb-1]->setEnabled(false);
            }

            // Rhys Hack - if we have just deleted the last image and there
            // is no camera connected, then exit the application.  This
            // avoids a focus problem where it is impossible to exit with
            // the back button due to the focus being in a stupid place.
            if ( !camera->videocaptureview->available() &&
                 !(thumb[0]->isEnabled()) ) {
                close();
            }
            return true;
            break;
        default:
            //nothing
            break;
    }
    return false;
}
Пример #7
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();
}
Пример #8
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;
}
Пример #9
0
HomescreenSettings::HomescreenSettings(QWidget* parent, Qt::WFlags fl)
    : QDialog( parent, fl)
{
    setWindowTitle(tr("Homescreen"));

    connect( qApp, SIGNAL(appMessage(QString,QByteArray)),
            this, SLOT(appMessage(QString,QByteArray)) );
   
    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    QTabWidget *tabWidget = new QTabWidget(this);
    
    //appearance tab
    QWidget *appearance = new QWidget;
    QScrollArea *appearanceWrapper = new QScrollArea;
    appearanceWrapper->setFocusPolicy(Qt::NoFocus);
    appearanceWrapper->setFrameStyle(QFrame::NoFrame);
    appearanceWrapper->setWidget(appearance);
    appearanceWrapper->setWidgetResizable(true);
    appearanceWrapper->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 
    QFormLayout *appearanceLayout = new QFormLayout(appearance);
    
    QSettings config("Trolltech", "qpe");
    config.beginGroup( "HomeScreen" );
    QString hsImgName = config.value("HomeScreenPicture").toString();
    int hsDisplayMode = config.value("HomeScreenPictureMode", 0).toInt();

    image = new QPushButton();
    image->setIconSize(QSize(50,75));
    image->setMinimumHeight(80);

    imageMode = new QComboBox;
    imageMode->addItem(tr("Scale & Crop"));
    imageMode->addItem(tr("Stretch"));
    imageMode->addItem(tr("Tile"));
    imageMode->addItem(tr("Center"));
    imageMode->addItem(tr("Scale"));
    imageMode->setCurrentIndex(hsDisplayMode);
    
    hsImage = QContent(hsImgName);
    if (!hsImage.isValid()) {
        image->setText(tr("No image"));
        imageMode->setVisible(false);
    }
    else {
        image->setIcon(QIcon(hsImage.fileName()));
    }
    connect( image, SIGNAL(clicked()), this, SLOT(editPhoto()) );

    QVBoxLayout *imageLayout = new QVBoxLayout;
    imageLayout->setContentsMargins(0, 0, 0, 0);
    imageLayout->setSpacing(0);
    imageLayout->addWidget(image);
    imageLayout->addWidget(imageMode);
    appearanceLayout->addRow(tr("Image"), imageLayout);
    
    time = new QCheckBox(tr("Time"));
    date = new QCheckBox(tr("Date"));
    op = new QCheckBox(tr("Operator"));
    profile = new QCheckBox(tr("Profile"));
    location = new QCheckBox(tr("Location"));
    
    time->setCheckState(config.value("ShowTime", "true").toBool() ? Qt::Checked : Qt::Unchecked);
    date->setCheckState(config.value("ShowDate", "true").toBool() ? Qt::Checked : Qt::Unchecked);
    op->setCheckState(config.value("ShowOperator", "true").toBool() ? Qt::Checked : Qt::Unchecked);
    profile->setCheckState(config.value("ShowProfile", "true").toBool() ? Qt::Checked : Qt::Unchecked);
    location->setCheckState(config.value("ShowLocation", "true").toBool() ? Qt::Checked : Qt::Unchecked);
    
    QVBoxLayout *checkLayout = new QVBoxLayout;
    checkLayout->setContentsMargins(0, 0, 0, 0);
    checkLayout->setSpacing(0);
    checkLayout->addWidget(time);
    checkLayout->addWidget(date);
    checkLayout->addWidget(op);
    checkLayout->addWidget(profile);
    checkLayout->addWidget(location);
    
    appearanceLayout->addRow(tr("Display"), checkLayout);
    
    //idle tab
    QWidget *idle = new QWidget;
    QVBoxLayout *idleLayout = new QVBoxLayout(idle);
    
    QLabel *label = new QLabel(tr("Return to homescreen:"));
    
    QHBoxLayout *h1 = new QHBoxLayout;
    QHBoxLayout *h2 = new QHBoxLayout;
    QHBoxLayout *h3 = new QHBoxLayout;
    
    homeScreen = new QComboBox;
    homeScreen->addItem(tr("On display off"));
    homeScreen->addItem(tr("On suspend"));
    homeScreen->addItem(tr("Never"));
    label->setBuddy(homeScreen);
    connect(homeScreen, SIGNAL(activated(int)), this, SLOT(homeScreenActivated(int)));

    QString showHomeScreen = config.value("ShowHomeScreen", "Never").toString();
    if (showHomeScreen == "DisplayOff")
        homeScreen->setCurrentIndex(0);
    else if (showHomeScreen == "Suspend")
        homeScreen->setCurrentIndex(1);
    else
        homeScreen->setCurrentIndex(2);

    lock = new QCheckBox(tr("Lock keys"));
    lock->setCheckState(config.value("AutoKeyLock", false).toBool() ? Qt::Checked : Qt::Unchecked);
    lock->setEnabled(homeScreen->currentIndex() == homeScreen->count()-1 ? false : true);

    powerNote = new QLabel;
    powerNote->setWordWrap( true );
    QFont font = QApplication::font();
    font.setItalic( true );
    powerNote->setFont( font );
    homeScreenActivated( homeScreen->currentIndex() );

    screenSaver_vsi = new QValueSpaceItem( "/Hardware/ScreenSaver/State", this );
    connect( screenSaver_vsi, SIGNAL(contentsChanged()), this, SLOT(homeScreenActivated()) );
    h1->addSpacing(20);
    h1->addWidget(homeScreen);
    h2->addSpacing(20);
    h2->addWidget(lock);
    h3->addSpacing(20);
    h3->addWidget(powerNote);
    
    idleLayout->addWidget(label);
    idleLayout->addLayout(h1);
    idleLayout->addLayout(h2);
    idleLayout->addLayout(h3);
    idleLayout->addStretch(1);
    
    //secondary screen tab
    //TODO: reduce amount of duplicated code between tabs
    if (QApplication::desktop()->numScreens() > 1) {
        QWidget *secondary = new QWidget;
        QScrollArea *secondaryWrapper = new QScrollArea;
        secondaryWrapper->setFocusPolicy(Qt::NoFocus);
        secondaryWrapper->setFrameStyle(QFrame::NoFrame);
        secondaryWrapper->setWidget(secondary);
        secondaryWrapper->setWidgetResizable(true);
        secondaryWrapper->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 
        QFormLayout *secondaryLayout = new QFormLayout(secondary);
        
        hsImgName = config.value("SecondaryHomeScreenPicture").toString();
        hsDisplayMode = config.value("SecondaryHomeScreenPictureMode", 0).toInt();
            
        secondaryImage = new QPushButton();
        secondaryImage->setIconSize(QSize(50,75));
        secondaryImage->setMinimumHeight(80);

        secondaryImageMode = new QComboBox;
        secondaryImageMode->addItem(tr("Scale & Crop"));
        secondaryImageMode->addItem(tr("Stretch"));
        secondaryImageMode->addItem(tr("Tile"));
        secondaryImageMode->addItem(tr("Center"));
        secondaryImageMode->addItem(tr("Scale"));
        secondaryImageMode->setCurrentIndex(hsDisplayMode);
        
        secondaryHsImage = QContent(hsImgName);
        if (!secondaryHsImage.isValid()) {
            secondaryImage->setText(tr("No image"));
            secondaryImageMode->setVisible(false);
        }
        else {
            secondaryImage->setIcon(QIcon(secondaryHsImage.fileName()));
        }
        connect( secondaryImage, SIGNAL(clicked()), this, SLOT(editSecondaryPhoto()) );
    
        QVBoxLayout *secondaryImageLayout = new QVBoxLayout;
        secondaryImageLayout->setContentsMargins(0, 0, 0, 0);
        secondaryImageLayout->setSpacing(0);
        secondaryImageLayout->addWidget(secondaryImage);
        secondaryImageLayout->addWidget(secondaryImageMode);
        secondaryLayout->addRow(tr("Image"), secondaryImageLayout);
        
        tabWidget->addTab(secondaryWrapper, tr("Secondary","Secondary Display"));
    }
    
    tabWidget->insertTab(0, appearanceWrapper, tr("Appearance"));
    tabWidget->insertTab(1, idle, tr("Idle"));
    tabWidget->setCurrentIndex(0);
    
    layout->addWidget(tabWidget);

    QDrmContentPlugin::initialize();
}
Пример #10
0
QContent QDocumentServerContentStore::contentFromEngineType( const QString &engineType )
{
    return QContent( new QDocumentServerContentEngine( engineType ) );
}
Пример #11
0
/*!
    \fn QContentSetEngine::content( int index ) const

    Returns the content object at the given \a index in the set.
*/
QContent QContentSetEngine::content( int index ) const
{
    return index >= 0 && index < valueCount()
        ? value( index )
        : QContent();
}