void QvvMainWindow::slotThumbs() { opt_thumbs = ! opt_thumbs; if( opt_thumbs ) loadThumbs(); statusBar()->showMessage( opt_thumbs ? tr( "Thumbnails enabled" ) : tr( "Thumbnails disabled" ) ); };
/** * Thread routine. * Only loads thumbs if somethingTodo is true. **/ void DkThumbsLoader::run() { if (!mThumbs) return; for (;;) { if (mLoadAllThumbs && mNumFilesLoaded >= (int)mThumbs->size()) { qDebug() << "[thumbs] thinks he has finished..."; break; } mMutex.lock(); DkTimer dt; msleep(100); //QMutexLocker(&this->mutex); if (!mIsActive) { qDebug() << "thumbs loader stopped..."; mMutex.unlock(); break; } mMutex.unlock(); if (mSomethingTodo) loadThumbs(); } }
void CameraMainWindow::confirmSettings() { storagepath = settings->location->documentPath(); psize = settings->photo_size->currentIndex(); vsize = settings->video_size->currentIndex(); pquality = settings->photo_quality->value(); vquality = settings->video_quality->value(); vframerate = settings->video_framerate->value(); // save settings QSettings cfg("Trolltech","Camera"); cfg.beginGroup("General"); cfg.setValue("location",storagepath); cfg.endGroup(); cfg.beginGroup("Photo"); if(psize != -1) cfg.setValue("width",photo_size[psize].width()); cfg.setValue("quality",pquality); cfg.endGroup(); cfg.beginGroup("Video"); if(vsize != -1) cfg.setValue("width",video_size[vsize].width()); cfg.setValue("quality",vquality); cfg.setValue("framerate",vframerate); loadThumbs(); preview(); }
void CameraMainWindow::resizeEvent(QResizeEvent*) { thumbw = width()/5-4; thumbh = thumbw*3/4; camera->thumbs->setFixedHeight(thumbh+thmarg*2); loadThumbs( true ); }
/** * Thread routine. * Only loads thumbs if somethingTodo is true. **/ void DkThumbsLoader::run() { if (!thumbs) return; while (true) { if (loadAllThumbs && numFilesLoaded >= (int)thumbs->size()) { qDebug() << "[thumbs] thinks he has finished..."; break; } mutex.lock(); DkTimer dt; msleep(100); //QMutexLocker(&this->mutex); if (!isActive) { qDebug() << "thumbs loader stopped..."; mutex.unlock(); break; } mutex.unlock(); if (somethingTodo) loadThumbs(); } //// locate the current file //QStringList files = dir.entryList(DkImageLoader::fileFilters); //DkTimer dtt; //for (int idx = 0; idx < files.size(); idx++) { // QMutexLocker(&this->mutex); // if (!isActive) { // break; // } // QFileInfo cFile = QFileInfo(dir, files[idx]); // if (!cFile.exists() || !cFile.isReadable()) // continue; // QImage img = getThumbNailQt(cFile); // //QImage img = getThumbNailWin(cFile); // thumbs->push_back(DkThumbNail(cFile, img)); //} }
void QvvMainWindow::loadDir( QString path ) { QString last_path = cdir.absolutePath(); cdir.cd( path ); QString new_path = cdir.absolutePath(); setWindowTitle( QString() + " QVV " + QVV_VERSION + ": " + new_path ); QString save_item_name; if( tree->topLevelItemCount() > 0 ) save_item_name = tree->currentItem()->text( 1 ); QStringList filters; filters.append( QString( "*" ) ); QFileInfoList info_list = cdir.entryInfoList( filters ); QTreeWidgetItem *current = NULL; tree->clear(); for( int i = 0; i < info_list.count(); i++ ) { QFileInfo fi = info_list.at( i ); if( opt_dirs_only && ! fi.isDir() ) continue; if( fi.fileName() == "." ) continue; if( fi.fileName() == ".." ) continue; QString ext = "." + fi.suffix() + "."; if( ! fi.isDir() && extensions_filter.indexOf( ext.toUpper() ) < 0 ) continue; QString file_name = fi.fileName(); QTreeWidgetItem *item = new QTreeWidgetItem(); item->setText( 0, fi.isDir() ? ITEM_TYPE_DIR : "" ); item->setText( 1, file_name ); item->setText( 2, QVariant( fi.size() ).toString() ); item->setText( 3, fi.lastModified().toString( "yyyy-MM-dd hh:mm:ss" ) ); item->setTextAlignment( 2, Qt::AlignRight ); if( last_path == new_path + "/" + file_name ) current = item; tree->addTopLevelItem( item ); } if( current ) tree->setCurrentItem( current ); else { tree->setCurrentItem( tree->topLevelItem( 0 ) ); if( save_item_name != "" ) tree->findNext( save_item_name ); } statusBar()->showMessage( QString( tr( "Loaded items" ) ) + ": " + QVariant( tree->topLevelItemCount() ).toString() ); if( opt_thumbs ) loadThumbs(); tree->resizeColumnToContents( 2 ); tree->resizeColumnToContents( 3 ); };
CameraMainWindow::CameraMainWindow(QWidget *parent, Qt::WFlags f): QMainWindow(parent, f), settings( NULL ), settingsDialog( NULL ), psize( -1 ), vsize( -1 ), snapRequest( 0 ), videoOnSecondary(false), m_photoContentSet( QContentSet::Asynchronous ), m_photoModel( 0 ), m_contextMenuActive(false) { setWindowTitle(tr("Camera")); QtopiaApplication::setPowerConstraint(QtopiaApplication::DisableLightOff); picfile = Qtopia::tempDir() + "image.jpg"; QWidget *cameraWidget = new QWidget(this); camera = new Ui::CameraBase(); camera->setupUi(cameraWidget); setCentralWidget(cameraWidget); camcat = QLatin1String("Camera"); // Ensure the Camera system categoy exists QCategoryManager catman("Documents"); // For new code a more unique id should be used instead of using the untranslated text // eg. ensureSystemCategory("com.mycompany.myapp.mycategory", "My Category"); catman.ensureSystemCategory(camcat, camcat); new CameraService(this); camera->photo->setFocus(); connect(camera->photo, SIGNAL(clicked()), this, SLOT(takePhoto())); connect(camera->video, SIGNAL(clicked()), this, SLOT(toggleVideo())); refocusTimer = new QTimer(this); refocusTimer->setSingleShot(true); connect(refocusTimer, SIGNAL(timeout()), this, SLOT(takePhotoNow())); thumb[0] = camera->thumb1; thumb[1] = camera->thumb2; thumb[2] = camera->thumb3; thumb[3] = camera->thumb4; thumb[4] = camera->thumb5; cur_thumb = -1; // Load the allowable sizes from the camera hardware. photo_size = camera->videocaptureview->photoSizes(); video_size = camera->videocaptureview->videoSizes(); namehint=0; recording = false; if ( !video_supported ) { // Room for longer text camera->photo->setText(tr("Take Photo")); camera->video->setEnabled(false); camera->video->hide(); } if (QApplication::desktop()->numScreens() > 1) { // We have a secondary display - watch for the clamshell open/close clamshellVsi = new QValueSpaceItem("/Hardware/Devices/ClamshellOpen", this); connect(clamshellVsi, SIGNAL(contentsChanged()), this, SLOT(clamshellChanged())); if (!clamshellVsi->value().toBool()) { videoToScreen(1); } } m_photoContentSet.setCriteria( QContentFilter( QContent::Document ) & QContentFilter::category( QLatin1String( "Camera" ) ) & QContentFilter::mimeType( QLatin1String( "image/jpeg" ) ) ); m_photoContentSet.setSortCriteria( QContentSortCriteria( QContentSortCriteria::LastUpdated, Qt::DescendingOrder ) ); m_photoModel = new QContentSetModel( &m_photoContentSet, this ); connect( m_photoModel, SIGNAL(updateFinished()), this, SLOT(loadThumbs()) ); m_wait = new QWaitWidget(camera->videocaptureview); m_iswaiting = false; QTimer::singleShot(1, this, SLOT(delayedInit())); m_currzoom = 0; zoomActive = false; zoomTimer.setSingleShot(true); zoomTimer.setInterval(5000); connect(&zoomTimer, SIGNAL(timeout()), this, SLOT(hideZoom())); }
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(); }