Example #1
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;
}
Example #2
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();
}