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; }
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; } }
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 }
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(); }