void MainWindow::callSlot(QString text) { ui.scrollArea->setWidget(new QWidget()); QWidget* camera = CameraFactory::CreateCamera(); if(text == QStringLiteral("全屏显示")) { CameraFactory::SetLBScreen(QStringLiteral("屏幕恢复")); camera->setParent(this); camera->setWindowFlags(Qt::Window); camera->showFullScreen(); camera->setFocus(); } else { CameraFactory::SetLBScreen(QStringLiteral("全屏显示")); ui.scrollArea->setWidget(camera); camera->setFocus(); //camera->setParent(ui.scrollArea); //camera->show(); //camera->setFocus(); } connect(camera, SIGNAL(backSignal()), this, SLOT(reportSlot())); connect(camera, SIGNAL(imageSignal(QString)), this, SLOT(loadNewImage(QString))); connect(camera, SIGNAL(fullScreenSignal(QString)), this, SLOT(fullScreenSlot(QString))); }
void MainWindow::cameraSlot() { QWidget* camera = CameraFactory::CreateCamera(); ui.scrollArea->setWidget(camera); WidgetFactory::SetCurrentWidget(WidgetFactory::Camera); camera->setFocus(); connect(camera, SIGNAL(backSignal()), this, SLOT(reportSlot())); connect(camera, SIGNAL(imageSignal(QString)), this, SLOT(loadNewImage(QString))); connect(camera, SIGNAL(fullScreenSignal(QString)), this, SLOT(fullScreenSlot(QString))); }
int Cache::prefetch(cache_key_t key) { // if(need_free()) // free_some_lru(); if(key.first == FIM_STDIN_IMAGE_NAME) return 0;// just a fix in the case the browser is still lame if(is_in_cache(key)) return 0; if(!loadNewImage(key)) return -1; setGlobalVariable(FIM_VID_CACHED_IMAGES,cached_elements()); setGlobalVariable(FIM_VID_CACHE_STATUS,getReport().c_str()); return 0; // return getCachedImage(key)?0:-1; }
Image * Cache::useCachedImage(cache_key_t key) { /* * the calling function needs an image, so calls this method. * if we already have the desired image and it is already used, * a clone is built and returned. * * if we have an unused master, we return it. * * then declare this image as used and increase a relative counter. * * a freeImage action will do the converse operation (and delete). * if the image is not already cached, it is loaded, if possible. * * so, if there is no such image, NULL is returned * */ #ifdef FIM_CACHE_DEBUG std::cout << " useCachedImage(\""<<key.first<<","<<key.second<<"\")\n"; #endif Image * image=NULL; if(!is_in_cache(key)) { /* * no Image cached at all for this filename * */ image = loadNewImage(key); if(!image)return NULL; // bad luck! usageCounter[key]=1; setGlobalVariable(FIM_VID_CACHE_STATUS,getReport().c_str()); return image; // usageCounter[key]=0; } else { /* * at least one copy of this filename image is in cache * */ image=getCachedImage(key);// in this way we update the LRU cache :) if(!image) { // critical error #ifdef FIM_CACHE_DEBUG cout << "critical internal cache error!\n"; #endif setGlobalVariable(FIM_VID_CACHE_STATUS,getReport().c_str()); return NULL; } if( used_image( key ) ) { // if the image was already used, cloning occurs // image = image->getClone(); // EVIL !! try { #ifdef FIM_CACHE_DEBUG Image * oi=image; #endif image = new Image(*image); // cloning #ifdef FIM_CACHE_DEBUG std::cout << " cloned image: \"" <<image->getName()<< "\" "<< image << " from \""<<oi->getName() <<"\" " << oi << "\n"; #endif } catch(FimException e) { /* we will survive :P */ image = NULL; /* we make sure no taint remains */ // if( e != FIM_E_NO_IMAGE )throw FIM_E_TRAGIC; /* hope this never occurs :P */ } if(!image)return NULL; //means that cloning failed. clone_pool.insert(image); // we have a clone cloneUsageCounter[image]=1; } lru_touch( key ); // if loading and eventual cloning succeeded, we count the image as used of course usageCounter[key]++; setGlobalVariable(FIM_VID_CACHE_STATUS,getReport().c_str()); return image; //so, it could be a clone.. } }