void ImageView::resizeEvent(QResizeEvent *event) { QGraphicsView::resizeEvent(event); if (m_autoZoomFit) zoomFit(); }
void ImageView::setImage(QImage image, bool show) { if(show && (gifMovie_ || isSVG)) { // a gif animation or SVG file was shown before scene_->clear(); isSVG = false; if(gifMovie_) { // should be deleted explicitly delete gifMovie_; gifMovie_ = nullptr; } // recreate the rect item imageItem_ = new QGraphicsRectItem(); imageItem_->hide(); imageItem_->setPen(QPen(Qt::NoPen)); scene_->addItem(imageItem_); } image_ = image; if(image.isNull()) { imageItem_->hide(); imageItem_->setBrush(QBrush()); scene_->setSceneRect(0, 0, 0, 0); } else { if(show) { imageItem_->setRect(0, 0, image_.width(), image_.height()); imageItem_->setBrush(image_); imageItem_->show(); } scene_->setSceneRect(0, 0, image_.width(), image_.height()); } if(autoZoomFit_) zoomFit(); queueGenerateCache(); }
void IPImageViewer::resizeEvent(QResizeEvent *) { if(_zoomFitMode) { zoomFit(); emit zoomChanged(zoomFactor()); } }
void GeneralViewer::switchToNextPlane() { getViewerState().mSliceRenderConfig.plane = NextCartesianPlane( getViewerState().mSliceRenderConfig.plane ); zoomFit(); //TODO remove notifyAboutSettingsChange(); update(); }
void GeneralViewer::setCurrentViewPlane( CartesianPlanes aPlane ) { getViewerState().mSliceRenderConfig.plane = aPlane; zoomFit(); //TODO remove notifyAboutSettingsChange(); update(); }
///// resetView ////////////////////////////////////////////////////////////// void GLView::resetView(const bool update) /// Resets translation/orientation/zoom of the scene. { centerView(false); resetOrientation(false); zoomFit(); // calls setModified() if(update) updateGL(); }
void IPImageViewer::showEvent(QShowEvent *) { //updateImage(); if(_zoomFitMode) { zoomFit(); emit zoomChanged(zoomFactor()); } }
///// updateProjection //////////////////////////////////////////////////////// void GLView::updateProjection() /// Checks whether the projection type changed and does the necessary updating. { if(currentPerspectiveProjection == baseParameters.perspectiveProjection) return; resizeGL(width(), height()); zoomFit(); currentPerspectiveProjection = baseParameters.perspectiveProjection; }
//------------------------------------------------------------------------------ void ptImageView::receiveImage(uint, TThumbPtr AImage8) { FFilenameCurrent = FFilenameNext; FFilenameNext.clear(); FImage = AImage8; if (FZoomMode == ptZoomMode_Fit) zoomFit(false); else zoomTo(FZoomFactor, true); FStatusOverlay->stop(); }
void ImageView::setImage(const QImage &image) { reset(); if (image.format() == QImage::Format_Indexed8) m_image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); else m_image = image; m_item = new QGraphicsRectItem(); m_item->setRect(0, 0, m_image.width(), m_image.height()); m_item->setBrush(m_image); m_item->setPen(Qt::NoPen); m_scene->addItem(m_item); m_scene->setSceneRect(0, 0, m_image.width(), m_image.height()); if (m_autoZoomFit) zoomFit(); queueGenerateCache(); }
void ImageView::setSVG(QString fileName) { image_ = QImage(fileName); // for tracking position and dimensions if(image_.isNull()) { if(imageItem_) { imageItem_->hide(); imageItem_->setBrush(QBrush()); } scene_->setSceneRect(0, 0, 0, 0); } else { scene_->clear(); imageItem_ = nullptr; isSVG = true; QGraphicsSvgItem *svgItem = new QGraphicsSvgItem(fileName); scene_->addItem(svgItem); scene_->setSceneRect(svgItem->boundingRect()); } if(autoZoomFit_) zoomFit(); queueGenerateCache(); // deletes the cache timer in this case }
void ImageView::setGifAnimation(QString fileName) { /* the built-in gif reader gives the first frame, which won't be shown but is used for tracking position and dimensions */ image_ = QImage(fileName); if(image_.isNull()) { if(imageItem_) { imageItem_->hide(); imageItem_->setBrush(QBrush()); } scene_->setSceneRect(0, 0, 0, 0); } else { scene_->clear(); imageItem_ = nullptr; // it's deleted by clear(); if(gifMovie_) { delete gifMovie_; gifMovie_ = nullptr; } QPixmap pix(image_.size()); pix.fill(Qt::transparent); QGraphicsItem *gifItem = new QGraphicsPixmapItem(pix); QLabel *gifLabel = new QLabel(); gifMovie_ = new QMovie(fileName); QGraphicsProxyWidget* gifWidget = new QGraphicsProxyWidget(gifItem); gifLabel->setAttribute(Qt::WA_NoSystemBackground); gifLabel->setMovie(gifMovie_); gifWidget->setWidget(gifLabel); gifMovie_->start(); scene_->addItem(gifItem); scene_->setSceneRect(gifItem->boundingRect()); } if(autoZoomFit_) zoomFit(); queueGenerateCache(); // deletes the cache timer in this case }
Window::Window(const QStringList& files) : m_board(0) { setAcceptDrops(true); resize(640, 480); // Add statusbar m_slider = new ZoomSlider(this); statusBar()->addPermanentWidget(m_slider); m_completed = new QProgressBar(this); m_completed->setRange(0, 100); m_completed->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum); statusBar()->addPermanentWidget(m_completed); statusBar()->setMinimumHeight(statusBar()->sizeHint().height()); m_slider->hide(); m_completed->hide(); // Add contents m_board = new Board(this); connect(m_board, &Board::completionChanged, m_completed, &QProgressBar::setValue); connect(m_board, &Board::finished, this, &Window::gameFinished); connect(m_board, &Board::clearMessage, statusBar(), &QStatusBar::clearMessage); connect(m_board, &Board::showMessage, statusBar(), &QStatusBar::showMessage); connect(m_board, &Board::zoomChanged, m_slider, &ZoomSlider::setValue); connect(m_slider, &ZoomSlider::valueChanged, m_board, &Board::zoom); setCentralWidget(m_board); // Add menus QMenu* menu; menu = menuBar()->addMenu(tr("&Game")); QAction* choose_action = menu->addAction(tr("&Choose..."), this, SLOT(chooseGame())); choose_action->setShortcuts(QList<QKeySequence>() << QKeySequence::New << QKeySequence::Open); menu->addSeparator(); QAction* retrieve_pieces_action = menu->addAction(tr("&Retrieve Pieces"), m_board, SLOT(retrievePieces()), tr("Ctrl+R")); retrieve_pieces_action->setEnabled(false); connect(m_board, &Board::retrievePiecesAvailable, retrieve_pieces_action, &QAction::setEnabled); menu->addSeparator(); QAction* quit_action = menu->addAction(tr("&Quit"), this, SLOT(close()), QKeySequence::Quit); quit_action->setMenuRole(QAction::QuitRole); menu = menuBar()->addMenu(tr("&View")); QAction* zoom_in_action = menu->addAction(tr("Zoom &In"), m_board, SLOT(zoomIn()), tr("+")); zoom_in_action->setEnabled(false); connect(m_board, &Board::zoomInAvailable, zoom_in_action, &QAction::setEnabled); QAction* zoom_out_action = menu->addAction(tr("Zoom &Out"), m_board, SLOT(zoomOut()), tr("-")); zoom_out_action->setEnabled(false); connect(m_board, &Board::zoomOutAvailable, zoom_out_action, &QAction::setEnabled); m_zoom_fit_action = menu->addAction(tr("Best &Fit"), m_board, SLOT(zoomFit())); m_zoom_fit_action->setEnabled(false); menu->addSeparator(); m_toggle_overview_action = menu->addAction(tr("Show O&verview"), m_board, SLOT(toggleOverview()), tr("Tab")); m_toggle_overview_action->setCheckable(true); m_toggle_overview_action->setEnabled(false); connect(m_board, &Board::overviewToggled, m_toggle_overview_action, &QAction::setChecked); menu->addSeparator(); QAction* fullscreen_action = menu->addAction(tr("F&ullscreen")); connect(fullscreen_action, &QAction::toggled, this, &Window::setFullScreen); fullscreen_action->setCheckable(true); #if !defined(Q_OS_MAC) fullscreen_action->setShortcut(tr("F11")); #else fullscreen_action->setShortcut(tr("Ctrl+F")); #endif menu = menuBar()->addMenu(tr("&Settings")); menu->addAction(tr("&Appearance..."), this, SLOT(showAppearance())); menu->addAction(tr("&Language..."), this, SLOT(setLocale())); menu = menuBar()->addMenu(tr("&Help")); menu->addAction(tr("&Controls"), this, SLOT(showControls()), QKeySequence::HelpContents); menu->addSeparator(); QAction* about_action = menu->addAction(tr("&About"), this, SLOT(showAbout())); about_action->setMenuRole(QAction::AboutRole); QAction* about_qt_action = menu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); about_qt_action->setMenuRole(QAction::AboutQtRole); // Restore geometry QSettings settings; if (settings.contains("Geometry")) { restoreGeometry(settings.value("Geometry").toByteArray()); } else { resize(settings.value("Size", QSize(1024, 768)).toSize()); settings.remove("Size"); } // Start or load a game show(); chooseGame(files); // Create auto-save timer QTimer* timer = new QTimer(this); connect(timer, &QTimer::timeout, m_board, &Board::saveGame); timer->start(300000); }
/*! Creates a \c ptImageView instance. \param parent The image view’s parent widget. */ ptImageView::ptImageView(QWidget *AParent): QGraphicsView(AParent), MinZoom(0.05), MaxZoom(4.0), MaxImageSize(std::numeric_limits<int>::max()), // Cache is split 60/40 between thumbnail list and image view FThumbGen(Settings->GetInt("FileMgrThumbCacheSize")*1024*1024 * 0.4, 1) { Q_ASSERT_X(Theme != nullptr, __PRETTY_FUNCTION__, "ptTheme pointer is null."); Q_ASSERT_X(Settings != nullptr, __PRETTY_FUNCTION__, "ptSettings pointer is null."); ZoomFactors << MinZoom << 0.08 << 0.10 << 0.15 << 0.20 << 0.25 << 0.33 << 0.50 << 0.66 << 1.00 << 1.50 << 2.00 << 3.00 << MaxZoom; this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setFocusPolicy(Qt::NoFocus); FThumbGen.connectBroadcast(this, SLOT(receiveImage(uint,TThumbPtr))); // Layout to always fill the complete image pane with ViewWindow FParentLayout = new QGridLayout(AParent); FParentLayout->setContentsMargins(9,9,9,9); FParentLayout->setSpacing(0); FParentLayout->addWidget(this); this->setStyleSheet("QGraphicsView { border: none; }"); // We create a Graphicsscene and connect it. FScene = new QGraphicsScene(0, 0, 0, 0, this); this->setScene(FScene); // Init FPixmapItem = FScene->addPixmap(QPixmap()); FPixmapItem->setPos(0,0); FZoomMode = ptZoomMode_Fit; FZoomFactor = 1.0; FZoom = 100; FDragDelta = new QLine(); FLeftMousePressed = false; FZoomSizeOverlay = new ptReportOverlay(this, "", QColor(75,150,255), QColor(190,220,255), 1000, Qt::AlignRight, 20); FStatusOverlay = new ptReportOverlay(this, "", QColor(), QColor(), 0, Qt::AlignLeft, 20); FStatusOverlay->setColors(QColor(75,150,255), QColor(190,220,255)); // blue FStatusOverlay->setDuration(0); // timer for decoupling the mouse wheel FResizeTimeOut = 50; FResizeTimer = new QTimer(this); FResizeTimer->setSingleShot(1); connect(FResizeTimer,SIGNAL(timeout()), this,SLOT(resizeTimerExpired())); FResizeEventTimer.setSingleShot(true); FResizeEventTimer.setInterval(100); connect(&FResizeEventTimer, SIGNAL(timeout()), this, SLOT(zoomFit())); //------------------------------------- // Create actions for context menu FZoomInAction = new QAction(tr("Zoom &in") + "\t" + tr("1"), this); FZoomInAction->setIcon(QIcon(QString::fromUtf8(":/dark/icons/zoom-in.png"))); connect(FZoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn())); FZoom100Action = new QAction(tr("Zoom &100%") + "\t" + tr("2"), this); FZoom100Action->setIcon(QIcon(QString::fromUtf8(":/dark/icons/zoom-original.png"))); connect(FZoom100Action, SIGNAL(triggered()), this, SLOT(zoom100())); FZoomOutAction = new QAction(tr("Zoom &out") + "\t" + tr("3"), this); FZoomOutAction->setIcon(QIcon(QString::fromUtf8(":/dark/icons/zoom-out.png"))); connect(FZoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut())); FZoomFitAction = new QAction(tr("Zoom &fit") + "\t" + tr("4"), this); FZoomFitAction->setIcon(QIcon(QString::fromUtf8(":/dark/icons/zoom-fit.png"))); connect(FZoomFitAction, SIGNAL(triggered()), this, SLOT(zoomFit())); }
int main(int argc, char *argv[]) { SDL_Surface *screen = NULL, *image = NULL, *scaledImage = NULL, *name = NULL; SDL_Rect picturePortion; TTF_Font *font = NULL; double scale = 1.0; int currentImageNumber = 1, showFileName = TRUE, runSlideShow = FALSE, isRunning = TRUE; SDL_TimerID slideShowTimer = 0; // Process command line if (argc < 2) { fprintf(stderr, "\n" " imgv v%s. Syntax: imgv <image files>\n\n" " Hotkeys:\n" " 'f' fit to screen\n" " 'z' zoom at pixel level\n" " 'i' zoom in 'o' zoom out\n" " 'l' rotate left 'r' rotate right\n" " 'n' next image 'p' previous image\n" " 'd' show / hide file name\n" " 's' start / stop slide show\n" " 'arrows' pan 'ESC' quit\n\n", VERSION); exit(0); } screen = initScreen(); font = TTF_OpenFont("font.ttf", 11); if (font == (TTF_Font *) (NULL)) { font = TTF_OpenFont("/usr/share/imgv/font.ttf", 11); } if (font == (TTF_Font *) (NULL)) { font = TTF_OpenFont("/usr/share/fonts/ttf-dejavu/DejaVuSans.ttf", 11); } picturePortion.w = SCREENWIDTH; picturePortion.h = SCREENHEIGHT; image = loadImage(argv[1]); if (image->w < SCREENWIDTH && image->h < SCREENHEIGHT) { scaledImage = zoom100(image, &picturePortion, &scale); } else { scaledImage = zoomFit(image, &picturePortion, &scale); } name = drawFileName(argv[currentImageNumber], font, runSlideShow); drawImage(scaledImage, &picturePortion, screen, name); do { SDL_Event event; if (SDL_WaitEvent(&event) && event.type == SDL_KEYDOWN) { switch (event.key.keysym.sym) { case SDLK_LEFT: // PAN LEFT pan(scaledImage, &picturePortion, -PANSTEP, 0); break; case SDLK_RIGHT: // PAN RIGHT pan(scaledImage, &picturePortion, PANSTEP, 0); break; case SDLK_UP: // PAN UP pan(scaledImage, &picturePortion, 0, -PANSTEP); break; case SDLK_DOWN: // PAN DOWN pan(scaledImage, &picturePortion, 0, PANSTEP); break; case SDLK_i: // ZOOM IN SDL_FreeSurface(scaledImage); scaledImage = zoomIn(image, &picturePortion, &scale); break; case SDLK_o: // ZOOM OUT SDL_FreeSurface(scaledImage); scaledImage = zoomOut(image, &picturePortion, &scale); break; case SDLK_f: // ZOOM TO FIT SCREEN SDL_FreeSurface(scaledImage); scaledImage = zoomFit(image, &picturePortion, &scale); break; case SDLK_z: // ZOOM TO ORIGINAL SIZE SDL_FreeSurface(scaledImage); scaledImage = zoom100(image, &picturePortion, &scale); break; case SDLK_l: // ROTATE LEFT { SDL_FreeSurface(scaledImage); SDL_Surface *tmp = rotateSurface90Degrees(image, 3); SDL_FreeSurface(image); image = tmp; scaledImage = zoomSurface(image, scale, scale, SMOOTHING_ON); int x = picturePortion.x; picturePortion.x = picturePortion.y + SCREENHEIGHT/2 - SCREENWIDTH/2; picturePortion.y = scaledImage->h - x - SCREENHEIGHT/2 - SCREENWIDTH/2; pan(scaledImage, &picturePortion, 0, 0); } break; case SDLK_r: // ROTATE RIGHT { SDL_FreeSurface(scaledImage); SDL_Surface *tmp = rotateSurface90Degrees(image, 1); SDL_FreeSurface(image); image = tmp; scaledImage = zoomSurface(image, scale, scale, SMOOTHING_ON); int x = picturePortion.x; picturePortion.x = scaledImage->w - picturePortion.y - SCREENWIDTH/2 - SCREENHEIGHT/2; picturePortion.y = x + SCREENWIDTH/2 - SCREENHEIGHT/2; pan(scaledImage, &picturePortion, 0, 0); } break; case SDLK_n: // NEXT IMAGE if (currentImageNumber < argc-1) { ++currentImageNumber; SDL_FreeSurface(image); SDL_FreeSurface(scaledImage); SDL_FreeSurface(name); image = loadImage(argv[currentImageNumber]); if (image->w < SCREENWIDTH && image->h < SCREENHEIGHT) { scaledImage = zoom100(image, &picturePortion, &scale); } else { scaledImage = zoomFit(image, &picturePortion, &scale); } name = drawFileName(argv[currentImageNumber], font, runSlideShow); } else { if (runSlideShow) { SDL_RemoveTimer(slideShowTimer); runSlideShow = FALSE; name = drawFileName(argv[currentImageNumber], font, runSlideShow); } } break; case SDLK_p: // PREVIOUS IMAGE if (currentImageNumber > 1) { --currentImageNumber; SDL_FreeSurface(image); SDL_FreeSurface(scaledImage); SDL_FreeSurface(name); image = loadImage(argv[currentImageNumber]); if (image->w < SCREENWIDTH && image->h < SCREENHEIGHT) { scaledImage = zoom100(image, &picturePortion, &scale); } else { scaledImage = zoomFit(image, &picturePortion, &scale); } name = drawFileName(argv[currentImageNumber], font, runSlideShow); } break; case SDLK_s: // START / STOP SLIDESHOW runSlideShow = 1 - runSlideShow; name = drawFileName(argv[currentImageNumber], font, runSlideShow); if (runSlideShow) { slideShowTimer = SDL_AddTimer(SLIDESHOWTIMEOUT, timerCallback, NULL); } else { SDL_RemoveTimer(slideShowTimer); } break; case SDLK_d: // SHOW / HIDE FILENAME showFileName = 1 - showFileName; break; case SDLK_ESCAPE: // QUIT case SDLK_q: isRunning = FALSE; break; default: break; } // end of switch (event.key.keysym.sym) } // end of if(SDL_WaitEvent()) drawImage(scaledImage, &picturePortion, screen, showFileName ? name : 0); } while(isRunning); // end of do SDL_FreeSurface(image); SDL_FreeSurface(scaledImage); SDL_FreeSurface(screen); TTF_CloseFont(font); TTF_Quit(); SDL_Quit(); return 0; }
void SVPlotMainWindow::SVPlotMainWindowPrivate::setupActions() { // // "File"-menu // actionNew = new QAction("&New", mw); actionNew->setIcon(QIcon(":icons/document-new.png")); actionNew->setShortcut(QKeySequence::New); connect(actionNew, SIGNAL(triggered()), mw, SLOT(newSubWindow())); actionLoad = new QAction("&Open", mw); actionLoad->setIcon(QIcon(":icons/document-open.png")); actionLoad->setShortcut(QKeySequence::Open); connect(actionLoad, SIGNAL(triggered()), mw, SLOT(load())); actionPrint = new QAction("&Print", mw); actionPrint->setIcon(QIcon(":icons/document-print.png")); actionPrint->setShortcut(QKeySequence::Print); actionPrint->setEnabled(false); connect(actionPrint, SIGNAL(triggered()), mw, SLOT(print())); actionQuit = new QAction("&Quit", mw); #if QT_VERSION >= 0x040600 actionQuit->setShortcut(QKeySequence::Quit); #else actionQuit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); #endif connect(actionQuit, SIGNAL(triggered()), mw, SLOT(close())); // // "Plot"-menu // actionZoomFit = new QAction("Fit to Window", mw); actionZoomFit->setIcon(QIcon(":icons/zoom-fit-best.png")); actionZoomFit->setEnabled(false); connect(actionZoomFit, SIGNAL(triggered()), mw, SLOT(zoomFit())); actionZoom = new QAction("&Zoom", mw); actionZoom->setIcon(QIcon(":icons/page-zoom.png")); actionZoom->setCheckable(true); actionZoom->setEnabled(false); connect(actionZoom, SIGNAL(toggled(bool)), mw, SLOT(setZoomEnabled(bool))); actionMove = new QAction("&Move", mw); actionMove->setIcon(QIcon(":icons/input-mouse.png")); actionMove->setCheckable(true); actionMove->setChecked(false); actionMove->setEnabled(false); connect(actionMove, SIGNAL(toggled(bool)), mw, SLOT(setMoveEnabled(bool))); actionZoom->setChecked(true); actionGroupZoomMove = new QActionGroup(mw); actionGroupZoomMove->addAction(actionZoom); actionGroupZoomMove->addAction(actionMove); // // "Window"-menu // actionPreviousPlot = new QAction("&Previous Plot", mw); actionPreviousPlot->setShortcut(QKeySequence::PreviousChild); connect(actionPreviousPlot, SIGNAL(triggered()), mdiArea, SLOT(activatePreviousSubWindow())); actionNextPlot = new QAction("&Next Plot", mw); actionNextPlot->setShortcut(QKeySequence::NextChild); connect(actionNextPlot, SIGNAL(triggered()), mdiArea, SLOT(activateNextSubWindow())); actionCascadePlots = new QAction("C&ascade Plots", mw); connect(actionCascadePlots, SIGNAL(triggered()), mdiArea, SLOT(cascadeSubWindows())); actionTilePlots = new QAction("&Tile Plots", mw); connect(actionTilePlots, SIGNAL(triggered()), mdiArea, SLOT(tileSubWindows())); actionClosePlot = new QAction("&Close Current Plot", mw); actionClosePlot->setShortcut(QKeySequence::Close); connect(actionClosePlot, SIGNAL(triggered()), mdiArea, SLOT(closeActiveSubWindow())); actionCloseAllPlots = new QAction("Close &All Plots", mw); connect(actionCloseAllPlots, SIGNAL(triggered()), mdiArea, SLOT(closeAllSubWindows())); // // "Help"-menu // actionAbout = new QAction("&About", mw); connect(actionAbout, SIGNAL(triggered()), mw, SLOT(about())); }
Player::Player(QWidget *parent) : QWidget(parent) , m_position(0) , m_isMeltedPlaying(-1) , m_zoomToggleFactor(Settings.playerZoom() == 0.0f? 1.0f : Settings.playerZoom()) , m_pauseAfterOpen(false) , m_monitorScreen(-1) , m_currentTransport(0) { setObjectName("Player"); Mlt::Controller::singleton(); setupActions(this); m_playIcon = actionPlay->icon(); m_pauseIcon = actionPause->icon(); // Create a layout. QVBoxLayout *vlayout = new QVBoxLayout(this); vlayout->setObjectName("playerLayout"); vlayout->setContentsMargins(0, 0, 0, 0); vlayout->setSpacing(4); // Add tab bar to indicate/select what is playing: clip, playlist, timeline. m_tabs = new QTabBar; m_tabs->setShape(QTabBar::RoundedSouth); m_tabs->addTab(tr("Source")); m_tabs->addTab(tr("Program")); m_tabs->setTabEnabled(ProgramTabIndex, false); QHBoxLayout* tabLayout = new QHBoxLayout; tabLayout->addWidget(m_tabs); tabLayout->addStretch(); connect(m_tabs, SIGNAL(tabBarClicked(int)), SLOT(onTabBarClicked(int))); // Add the layouts for managing video view, scroll bars, and audio controls. m_videoLayout = new QHBoxLayout; m_videoLayout->setSpacing(4); m_videoLayout->setContentsMargins(0, 0, 0, 0); vlayout->addLayout(m_videoLayout, 10); vlayout->addStretch(); m_videoScrollWidget = new QWidget; m_videoLayout->addWidget(m_videoScrollWidget, 10); m_videoLayout->addStretch(); QGridLayout* glayout = new QGridLayout(m_videoScrollWidget); glayout->setSpacing(0); glayout->setContentsMargins(0, 0, 0, 0); // Add the video widgets. m_videoWidget = QWidget::createWindowContainer(qobject_cast<QWindow*>(MLT.videoWidget())); m_videoWidget->setMinimumSize(QSize(320, 180)); glayout->addWidget(m_videoWidget, 0, 0); m_verticalScroll = new QScrollBar(Qt::Vertical); glayout->addWidget(m_verticalScroll, 0, 1); m_verticalScroll->hide(); m_horizontalScroll = new QScrollBar(Qt::Horizontal); glayout->addWidget(m_horizontalScroll, 1, 0); m_horizontalScroll->hide(); // Add the volume and signal level meter m_volumePopup = new QFrame(this, Qt::Popup); QVBoxLayout *volumeLayoutV = new QVBoxLayout(m_volumePopup); volumeLayoutV->setContentsMargins(0, 0, 0, 0); volumeLayoutV->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding)); QBoxLayout *volumeLayoutH = new QHBoxLayout; volumeLayoutH->setSpacing(0); volumeLayoutH->setContentsMargins(0, 0, 0, 0); volumeLayoutH->addWidget(new AudioScale); m_volumeSlider = new QSlider(Qt::Vertical); m_volumeSlider->setFocusPolicy(Qt::NoFocus); m_volumeSlider->setMinimumHeight(VOLUME_SLIDER_HEIGHT); m_volumeSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); volumeLayoutH->addWidget(m_volumeSlider); volumeLayoutV->addLayout(volumeLayoutH); m_volumeSlider->setRange(0, 99); m_volumeSlider->setValue(Settings.playerVolume()); onVolumeChanged(m_volumeSlider->value()); m_savedVolume = MLT.volume(); m_volumeSlider->setToolTip(tr("Adjust the audio volume")); connect(m_volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(onVolumeChanged(int))); // Add mute-volume buttons layout #ifdef Q_OS_MAC if (Settings.theme() == "system") volumeLayoutH = new QVBoxLayout; else #endif volumeLayoutH = new QHBoxLayout; volumeLayoutH->setContentsMargins(0, 0, 0, 0); volumeLayoutH->setSpacing(0); volumeLayoutV->addLayout(volumeLayoutH); // Add mute button QPushButton* muteButton = new QPushButton(this); muteButton->setFocusPolicy(Qt::NoFocus); muteButton->setObjectName(QString::fromUtf8("muteButton")); muteButton->setIcon(QIcon::fromTheme("dialog-cancel", QIcon(":/icons/oxygen/16x16/actions/dialog-cancel.png"))); muteButton->setToolTip(tr("Silence the audio")); muteButton->setCheckable(true); muteButton->setChecked(Settings.playerMuted()); onMuteButtonToggled(Settings.playerMuted()); volumeLayoutH->addWidget(muteButton); connect(muteButton, SIGNAL(toggled(bool)), this, SLOT(onMuteButtonToggled(bool))); // This hack realizes the volume popup geometry for on_actionVolume_triggered(). m_volumePopup->show(); m_volumePopup->hide(); // Add the scrub bar. m_scrubber = new ScrubBar(this); m_scrubber->setFocusPolicy(Qt::NoFocus); m_scrubber->setObjectName("scrubBar"); m_scrubber->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); vlayout->addWidget(m_scrubber); // Add toolbar for transport controls. QToolBar* toolbar = new QToolBar(tr("Transport Controls"), this); int s = style()->pixelMetric(QStyle::PM_SmallIconSize); toolbar->setIconSize(QSize(s, s)); toolbar->setContentsMargins(0, 0, 0, 0); QWidget *spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); m_positionSpinner = new TimeSpinBox(this); m_positionSpinner->setToolTip(tr("Current position")); m_positionSpinner->setEnabled(false); m_positionSpinner->setKeyboardTracking(false); m_durationLabel = new QLabel(this); m_durationLabel->setToolTip(tr("Total Duration")); m_durationLabel->setText(" / 00:00:00:00"); m_durationLabel->setFixedWidth(m_positionSpinner->width()); m_inPointLabel = new QLabel(this); m_inPointLabel->setText("--:--:--:--"); m_inPointLabel->setToolTip(tr("In Point")); m_inPointLabel->setFixedWidth(m_inPointLabel->width()); m_selectedLabel = new QLabel(this); m_selectedLabel->setText("--:--:--:--"); m_selectedLabel->setToolTip(tr("Selected Duration")); m_selectedLabel->setFixedWidth(m_selectedLabel->width()); toolbar->addWidget(m_positionSpinner); toolbar->addWidget(m_durationLabel); toolbar->addWidget(spacer); toolbar->addAction(actionSkipPrevious); toolbar->addAction(actionRewind); toolbar->addAction(actionPlay); toolbar->addAction(actionFastForward); toolbar->addAction(actionSkipNext); // Add zoom button to toolbar. m_zoomButton = new QToolButton; QMenu* zoomMenu = new QMenu(this); m_zoomFitAction = zoomMenu->addAction( QIcon::fromTheme("zoom-fit-best", QIcon(":/icons/oxygen/32x32/actions/zoom-fit-best")), tr("Zoom Fit"), this, SLOT(zoomFit())); m_zoomOriginalAction = zoomMenu->addAction( QIcon::fromTheme("zoom-original", QIcon(":/icons/oxygen/32x32/actions/zoom-original")), tr("Zoom 100%"), this, SLOT(zoomOriginal())); m_zoomOutAction = zoomMenu->addAction( QIcon::fromTheme("zoom-out", QIcon(":/icons/oxygen/32x32/actions/zoom-out")), tr("Zoom 50%"), this, SLOT(zoomOut())); m_zoomInAction = zoomMenu->addAction( QIcon::fromTheme("zoom-in", QIcon(":/icons/oxygen/32x32/actions/zoom-in")), tr("Zoom 200%"), this, SLOT(zoomIn())); connect(m_zoomButton, SIGNAL(toggled(bool)), SLOT(toggleZoom(bool))); m_zoomButton->setMenu(zoomMenu); m_zoomButton->setPopupMode(QToolButton::MenuButtonPopup); m_zoomButton->setCheckable(true); m_zoomButton->setToolTip(tr("Toggle zoom")); toolbar->addWidget(m_zoomButton); toolbar->addAction(actionVolume); m_volumeWidget = toolbar->widgetForAction(actionVolume); // Add in-point and selected duration labels to toolbar. spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); toolbar->addWidget(spacer); toolbar->addWidget(m_inPointLabel); toolbar->addWidget(m_selectedLabel); vlayout->addWidget(toolbar); vlayout->addLayout(tabLayout); connect(MLT.videoWidget(), SIGNAL(frameDisplayed(const SharedFrame&)), this, SLOT(onFrameDisplayed(const SharedFrame&))); connect(actionPlay, SIGNAL(triggered()), this, SLOT(togglePlayPaused())); connect(actionPause, SIGNAL(triggered()), this, SLOT(pause())); connect(actionFastForward, SIGNAL(triggered()), this, SLOT(fastForward())); connect(actionRewind, SIGNAL(triggered()), this, SLOT(rewind())); connect(m_scrubber, SIGNAL(seeked(int)), this, SLOT(seek(int))); connect(m_scrubber, SIGNAL(inChanged(int)), this, SLOT(onInChanged(int))); connect(m_scrubber, SIGNAL(outChanged(int)), this, SLOT(onOutChanged(int))); connect(m_positionSpinner, SIGNAL(valueChanged(int)), this, SLOT(seek(int))); connect(m_positionSpinner, SIGNAL(editingFinished()), this, SLOT(setFocus())); connect(this, SIGNAL(endOfStream()), this, SLOT(pause())); connect(this, SIGNAL(zoomChanged(float)), MLT.videoWidget(), SLOT(setZoom(float))); connect(m_horizontalScroll, SIGNAL(valueChanged(int)), MLT.videoWidget(), SLOT(setOffsetX(int))); connect(m_verticalScroll, SIGNAL(valueChanged(int)), MLT.videoWidget(), SLOT(setOffsetY(int))); setFocusPolicy(Qt::StrongFocus); }
void SVImageMainWindow::SVImageMainWindowPrivate::setupActions() { // // "File"-menu // actionLoad = new QAction("&Open", mw); actionLoad->setIcon(QIcon(":icons/document-open.png")); actionLoad->setShortcut(QKeySequence::Open); connect(actionLoad, SIGNAL(triggered()), mw, SLOT(load())); actionReload = new QAction("&Reload", mw); actionReload->setIcon(QIcon(":icons/view-refresh.png")); actionReload->setShortcut(QKeySequence::Refresh); actionReload->setEnabled(false); connect(actionReload, SIGNAL(triggered()), mw, SLOT(reload())); actionPrint = new QAction("&Print", mw); actionPrint->setIcon(QIcon(":icons/document-print.png")); actionPrint->setShortcut(QKeySequence::Print); actionPrint->setEnabled(false); connect(actionPrint, SIGNAL(triggered()), mw, SLOT(print())); actionQuit = new QAction("&Quit", mw); #if QT_VERSION >= 0x040600 actionQuit->setShortcut(QKeySequence::Quit); #else actionQuit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); #endif connect(actionQuit, SIGNAL(triggered()), mw, SLOT(close())); // // "Plot"-menu // actionZoomFit = new QAction("Fit to Window", mw); actionZoomFit->setIcon(QIcon(":icons/zoom-fit-best.png")); actionZoomFit->setEnabled(false); connect(actionZoomFit, SIGNAL(triggered()), mw, SLOT(zoomFit())); actionZoom = new QAction("&Zoom", mw); actionZoom->setIcon(QIcon(":icons/page-zoom.png")); actionZoom->setCheckable(true); actionZoom->setEnabled(false); connect(actionZoom, SIGNAL(toggled(bool)), mw, SLOT(setZoomEnabled(bool))); actionMove = new QAction("&Move", mw); actionMove->setIcon(QIcon(":icons/input-mouse.png")); actionMove->setCheckable(true); actionMove->setChecked(false); actionMove->setEnabled(false); connect(actionMove, SIGNAL(toggled(bool)), mw, SLOT(setMoveEnabled(bool))); actionZoom->setChecked(true); // // "Go"-menu // actionGoFirst = new QAction("&First", mw); actionGoFirst->setShortcut(QKeySequence::MoveToStartOfLine); actionGoFirst->setEnabled(false); connect(actionGoFirst, SIGNAL(triggered()), mw, SLOT(goFirst())); actionGoPrevious = new QAction("&Previous", mw); actionGoPrevious->setShortcut(QKeySequence::MoveToPreviousPage); actionGoPrevious->setIcon(mw->style()->standardIcon(QStyle::SP_MediaSkipBackward)); actionGoPrevious->setEnabled(false); connect(actionGoPrevious, SIGNAL(triggered()), mw, SLOT(goPrevious())); actionGoNext = new QAction("&Next", mw); actionGoNext->setShortcut(QKeySequence::MoveToNextPage); actionGoNext->setIcon(mw->style()->standardIcon(QStyle::SP_MediaSkipForward)); actionGoNext->setEnabled(false); connect(actionGoNext, SIGNAL(triggered()), mw, SLOT(goNext())); actionGoLast = new QAction("&Last", mw); actionGoLast->setShortcut(QKeySequence::MoveToEndOfLine); actionGoLast->setEnabled(false); connect(actionGoLast, SIGNAL(triggered()), mw, SLOT(goLast())); actionWatchLatest = new QAction("&Watch Latest", mw); actionWatchLatest->setCheckable(true); actionWatchLatest->setChecked(false); actionWatchLatest->setEnabled(false); connect(actionWatchLatest, SIGNAL(toggled(bool)), mw, SLOT(setWatchLatest(bool))); // // "Tools"-menu // actionMaskNew = new QAction("&New", mw); actionMaskNew->setEnabled(false); connect(actionMaskNew, SIGNAL(triggered()), mw, SLOT(newMask())); actionMaskLoad = new QAction("&Open", mw); actionMaskLoad->setEnabled(false); connect(actionMaskLoad, SIGNAL(triggered()), mw, SLOT(loadMask())); actionMaskSaveAs = new QAction("&Save As ...", mw); actionMaskSaveAs->setEnabled(false); connect(actionMaskSaveAs, SIGNAL(triggered()), mw, SLOT(saveMaskAs())); actionMaskByThreshold = new QAction("By Threshold ...", mw); actionMaskByThreshold->setEnabled(false); connect(actionMaskByThreshold, SIGNAL(triggered()), mw, SLOT(setMaskByThreshold())); actionMaskAddPoint = new QAction("Add pixel", mw); actionMaskAddPoint->setCheckable(true); actionMaskAddPoint->setChecked(false); actionMaskAddPoint->setEnabled(false); connect(actionMaskAddPoint, SIGNAL(toggled(bool)), mw, SLOT(setMaskAddPointsEnabled(bool))); actionMaskAddPolygon = new QAction("Add polygon", mw); actionMaskAddPolygon->setCheckable(true); actionMaskAddPolygon->setChecked(false); actionMaskAddPolygon->setEnabled(false); connect(actionMaskAddPolygon, SIGNAL(toggled(bool)), mw, SLOT(setMaskAddPolygonEnabled(bool))); actionMaskRemovePoint = new QAction("Remove pixel", mw); actionMaskRemovePoint->setCheckable(true); actionMaskRemovePoint->setChecked(false); actionMaskRemovePoint->setEnabled(false); connect(actionMaskRemovePoint, SIGNAL(toggled(bool)), mw, SLOT(setMaskRemovePointsEnabled(bool))); actionMaskRemovePolygon = new QAction("Remove polygon", mw); actionMaskRemovePolygon->setCheckable(true); actionMaskRemovePolygon->setChecked(false); actionMaskRemovePolygon->setEnabled(false); connect(actionMaskRemovePolygon, SIGNAL(toggled(bool)), mw, SLOT(setMaskRemovePolygonEnabled(bool))); // // "Window"-menu // actionPreviousPlot = new QAction("&Previous Image", mw); actionPreviousPlot->setShortcut(QKeySequence::PreviousChild); connect(actionPreviousPlot, SIGNAL(triggered()), mdiArea, SLOT(activatePreviousSubWindow())); actionNextPlot = new QAction("&Next Image", mw); actionNextPlot->setShortcut(QKeySequence::NextChild); connect(actionNextPlot, SIGNAL(triggered()), mdiArea, SLOT(activateNextSubWindow())); actionCascadePlots = new QAction("C&ascade Images", mw); connect(actionCascadePlots, SIGNAL(triggered()), mdiArea, SLOT(cascadeSubWindows())); actionTilePlots = new QAction("&Tile Images", mw); connect(actionTilePlots, SIGNAL(triggered()), mdiArea, SLOT(tileSubWindows())); actionClosePlot = new QAction("&Close Current Image", mw); actionClosePlot->setShortcut(QKeySequence::Close); connect(actionClosePlot, SIGNAL(triggered()), mdiArea, SLOT(closeActiveSubWindow())); actionCloseAllPlots = new QAction("Close &All Images", mw); connect(actionCloseAllPlots, SIGNAL(triggered()), mdiArea, SLOT(closeAllSubWindows())); // // "Help"-menu // actionAbout = new QAction("&About", mw); connect(actionAbout, SIGNAL(triggered()), mw, SLOT(about())); actionGroupPlotPicker = new QActionGroup(mw); actionGroupPlotPicker->addAction(actionZoom); actionGroupPlotPicker->addAction(actionMove); actionGroupPlotPicker->addAction(actionMaskAddPoint); actionGroupPlotPicker->addAction(actionMaskAddPolygon); actionGroupPlotPicker->addAction(actionMaskRemovePoint); actionGroupPlotPicker->addAction(actionMaskRemovePolygon); }
void MainWindow::setupConnections() { // Importing connect(importButton, SIGNAL(clicked()), this, SLOT(launchImageImport())); connect(filedata, SIGNAL(imagesImported()), aListWidget, SLOT(populate())); connect(filedata, SIGNAL(imagesImported()), bListWidget, SLOT(populate())); connect(filedata, SIGNAL(imagesImported()), vectorListWidget, SLOT(populate())); connect(filedata, SIGNAL(imagesImported()), this, SLOT(notifyFolderChange())); connect(filedata, SIGNAL(vectorListUpdated()), vectorListWidget, SLOT(update())); // Image selection connect(aListWidget, SIGNAL(fileClicked(int)), this, SLOT(pivAclicked(int))); connect(bListWidget, SIGNAL(fileClicked(int)), this, SLOT(pivBclicked(int))); connect(vectorListWidget, SIGNAL(fileClicked(int)), this, SLOT(vectorClicked(int))); connect(forwardButton, SIGNAL(clicked()), this, SLOT(forwardOne())); connect(backButton, SIGNAL(clicked()), this, SLOT(backwardOne())); // Image/vector viewing connect(zoomInButton, SIGNAL(clicked()), pivDisplay, SLOT(zoomIn())); connect(zoomOutButton, SIGNAL(clicked()), pivDisplay, SLOT(zoomOut())); connect(zoomFitButton, SIGNAL(clicked()), pivDisplay, SLOT(zoomFit())); // The following should be moved into settings connect(vectorToggle, SIGNAL(toggled(bool)), pivDisplay, SLOT(vectorsToggled(bool))); // connect(colourButtonFiltered, SIGNAL(clicked()), this, SLOT(chooseFilteredColour())); connect(colourButtonUnfiltered, SIGNAL(clicked()), this, SLOT(chooseUnfilteredColour())); connect(scaleSpin, SIGNAL(valueChanged(double)), settings, SLOT(setVectorScale(double))); connect(subSpin, SIGNAL(valueChanged(double)), settings, SLOT(setVectorSub(double))); connect(settings, SIGNAL(vectorSettingChanged()), pivDisplay, SLOT(vectorsChanged())); // Masking connect(maskButton, SIGNAL(clicked()), maskButton, SLOT(showMenu())); connect(filedata,SIGNAL(imagesImported()), maskDropDown, SLOT(imageLoaded())); connect(maskDropDown, SIGNAL(importMaskClicked()), filedata, SLOT(importMask())); connect(filedata, SIGNAL(maskLoaded()), maskDropDown, SLOT(maskLoaded())); connect(maskDropDown, SIGNAL(gridToggled(bool)), pivDisplay, SLOT(maskToggled(bool))); connect(maskDropDown, SIGNAL(clearMask(bool)), settings, SLOT(setIsMask(bool))); // Process tab connect(hSizeCombo, SIGNAL(activated(int)), settings, SLOT(setIntLengthX(int))); connect(vSizeCombo, SIGNAL(activated(int)), settings, SLOT(setIntLengthY(int))); connect(hSpaceSpin, SIGNAL(valueChanged(int)), settings, SLOT(setDeltaX(int))); connect(vSpaceSpin, SIGNAL(valueChanged(int)), settings, SLOT(setDeltaY(int))); // Filter tab connect(globalRangeCheck, SIGNAL(toggled(bool)), this, SLOT(filterChanged())); connect(minUedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues())); connect(maxUedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues())); connect(minVedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues())); connect(maxVedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues())); connect(globalStDevCheck, SIGNAL(toggled(bool)), this, SLOT(filterChanged())); connect(nStdDevSpin, SIGNAL(valueChanged(double)), this, SLOT(setFilterValues())); connect(localCheck, SIGNAL(toggled(bool)), this, SLOT(filterChanged())); connect(localMethodCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilterValues())); connect(localNxNCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilterValues())); connect(localUedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues())); connect(localVedit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues())); connect(interpolateCheck, SIGNAL(toggled(bool)), this, SLOT(filterChanged())); connect(interpolateMethodCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilterValues())); connect(interpolateNxNCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilterValues())); connect(smoothCheck, SIGNAL(toggled(bool)), this, SLOT(filterChanged())); connect(smoothRadiusEdit, SIGNAL(textChanged(QString)), this, SLOT(setFilterValues())); connect(smoothNxNCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilterValues())); // DoingPIV connect(outputFolderEdit, SIGNAL(textEdited(QString)), this, SLOT(setOutput())); connect(outputFolderButton, SIGNAL(clicked()), this, SLOT(chooseOutputFolder())); connect(outputFormatCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(setOutput())); connect(correlateButton, SIGNAL(clicked()), process, SLOT(processCurrentImagePair())); connect(process, SIGNAL(currentProcessed()), pivDisplay, SLOT(displayCurrent())); connect(process, SIGNAL(currentProcessed()), output, SLOT(outputCurrent())); connect(filterButton, SIGNAL(clicked()), analysis, SLOT(filterCurrent())); connect(analysis, SIGNAL(currentFiltered()), pivDisplay, SLOT(displayCurrent())); connect(analysis, SIGNAL(currentFiltered()), output, SLOT(outputCurrent())); connect(batchButton, SIGNAL(clicked()), process, SLOT(launchBatchWindow())); connect(process, SIGNAL(batchProcessed()), this, SLOT(batchDone())); connect(pivDisplay, SIGNAL(mouseMoved(QPointF)), this, SLOT(updatePositionLabel(QPointF))); // Data Quality connect(filterSNRCheck, SIGNAL(toggled(bool)), this, SLOT(qualityChanged())); connect(snrEdit, SIGNAL(textEdited(QString)), this, SLOT(qualityChanged())); connect(filterIntCheck, SIGNAL(toggled(bool)), this, SLOT(qualityChanged())); connect(intensityEdit, SIGNAL(textEdited(QString)), this, SLOT(qualityChanged())); }