Esempio n. 1
0
VolumePopupButton::VolumePopupButton( QWidget * parent, PlayerManager *mgr ) :
    QToolButton( parent ),
    m_prevVolume(0.0),
    m_curVolume(0.0),
    player(mgr)
{
    //create the volume popup
    m_volumeMenu = new QMenu( this );

    KVBox *mainBox = new KVBox( this );

    m_volumeLabel= new QLabel( mainBox );
    m_volumeLabel->setAlignment( Qt::AlignHCenter );

    KHBox *sliderBox = new KHBox( mainBox );
    m_volumeSlider = new VolumeSlider( 100, sliderBox, false );
    m_volumeSlider->setFixedHeight( 170 );
    mainBox->setMargin( 0 );
    mainBox->setSpacing( 0 );
    sliderBox->setSpacing( 0 );
    sliderBox->setMargin( 0 );
    mainBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
    sliderBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );

    QWidgetAction *sliderActionWidget = new QWidgetAction( this );
    sliderActionWidget->setDefaultWidget( mainBox );

    // volumeChanged is a customSignal, is not emited by setValue()
    connect( m_volumeSlider, SIGNAL(volumeChanged(float)), player, SLOT(setVolume(float)) );

    QToolBar *muteBar = new QToolBar( QString(), mainBox );
    muteBar->setContentsMargins( 0, 0, 0, 0 );
    muteBar->setIconSize( QSize( 16, 16 ) );

    // our popup's mute-toggle  button
    m_muteAction = new QAction( KIcon( "audio-volume-muted" ), QString(), muteBar );
    m_muteAction->setToolTip( i18n( "Mute/Unmute" ) );

    connect( m_muteAction, SIGNAL(triggered(bool)), this, SLOT(slotToggleMute(bool)) );
    connect( player, SIGNAL(mutedChanged(bool)), this, SLOT(slotMuteStateChanged(bool)) );

    m_volumeMenu->addAction( sliderActionWidget );
    muteBar->addAction( m_muteAction );

    /* set icon and label to match create state of AudioOutput, as the
     * desired volume value is not available yet (because the player
     * object is not set up yet.) Someone must call PlayerManager::setVolume()
     * later.
     */
    slotVolumeChanged( 1.0 );

    // let player notify us when volume changes
    connect( player, SIGNAL(volumeChanged(float)), this, SLOT(slotVolumeChanged(float)) );
}
TimelineWidget::TimelineWidget(QWidget* parent) :
    QWidget(parent),
    m_timelineView(NULL),
    m_timeRate(1.0),
    m_paused(true)
{
    m_timelineView = new TimelineView(this);
    connect(m_timelineView, SIGNAL(currentTimeChanged(double)), this, SIGNAL(currentTimeChanged(double)));
    
    QWidget* controls = new QWidget(this);
    controls->setContentsMargins(0, 0, 0, 0);
    QHBoxLayout* controlsLayout = new QHBoxLayout(controls);
    
    QLabel* zoomLabel = new QLabel(controls);
    zoomLabel->setText("Zoom: "
                       "<a href=\"0.04167\">1h</a> "
                       "<a href=\"0.08333\">6h</a> "
                       "<a href=\"0.5\">12h</a> "
                       "<a href=\"1\">1d</a> "
                       "<a href=\"5\">5d</a> "
                       "<a href=\"10\">10d</a> "
                       "<a href=\"30\">1m</a> "
                       "<a href=\"180\">6m</a> "
                       "<a href=\"365\">1y</a> "
                       "<a href=\"all\">all</a>");

    QToolBar* toolbar = new QToolBar(controls);
    toolbar->setIconSize(QSize(24, 24));
    toolbar->setMaximumHeight(24);
    toolbar->setMovable(false);
    toolbar->setFloatable(false);
    toolbar->setContentsMargins(0, 0, 0, 0);
    
    QAction* reverseTimeAction = new QAction(QIcon(":/icons/timeline-reverse.png"),
                                             tr("Reverse time"), toolbar);
    QAction* slowTimeAction = new QAction(QIcon(":/icons/timeline-slower.png"),
                                          tr("10x slower"), toolbar);
    QAction* halfTimeAction = new QAction(QIcon(":/icons/timeline-half.png"),
                                          tr("2x slower"), toolbar);
    QAction* pauseAction = new QAction(QIcon(":/icons/timeline-pause.png"),
                                       tr("Pause time"), toolbar);
    QAction* realTimeAction = new QAction(QIcon(":/icons/timeline-realtime.png"),
                                          tr("Real time"), toolbar);
    QAction* doubleTimeAction = new QAction(QIcon(":/icons/timeline-double.png"),
                                            tr("2x faster"), toolbar);
    QAction* fastTimeAction = new QAction(QIcon(":/icons/timeline-faster.png"),
                                          tr("10x faster"), toolbar);
    
    connect(reverseTimeAction, SIGNAL(triggered()), this, SLOT(reverseTime()));
    toolbar->addAction(reverseTimeAction);
    
    connect(slowTimeAction, SIGNAL(triggered()), this, SLOT(slowerTime()));
    toolbar->addAction(slowTimeAction);
    
    connect(halfTimeAction, SIGNAL(triggered()), this, SLOT(halfTime()));
    toolbar->addAction(halfTimeAction);
    
    connect(pauseAction, SIGNAL(triggered()), this, SLOT(togglePaused()));
    toolbar->addAction(pauseAction);
    
    connect(realTimeAction, SIGNAL(triggered()), this, SLOT(realTime()));
    toolbar->addAction(realTimeAction);
    
    connect(doubleTimeAction, SIGNAL(triggered()), this, SLOT(doubleTime()));
    toolbar->addAction(doubleTimeAction);
    
    connect(fastTimeAction, SIGNAL(triggered()), this, SLOT(fasterTime()));
    toolbar->addAction(fastTimeAction);
    
    
    controlsLayout->addWidget(toolbar);
    
    controlsLayout->addStretch(1);
    controlsLayout->addWidget(zoomLabel);
    controls->setLayout(controlsLayout);
    
    connect(zoomLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(setZoom(const QString&)));
    
    QVBoxLayout* layout = new QVBoxLayout(this);
    
    layout->addWidget(m_timelineView);
    layout->addWidget(controls);
    //layout->addLayout(controlsLayout);
    layout->setContentsMargins(0, 0, 0, 0);
    
    this->setLayout(layout);
    this->show();
    
    m_timelineView->setTimeRange(0.0, 5.0);
}
QToolBar* specActionLibrary::toolBar(QWidget* target)
{
	QToolBar* bar = new QToolBar(target) ;
	bar->setContentsMargins(0, 0, 0, 0) ;
	bar->setIconSize(QSize(20, 20)) ;

	specView* view = dynamic_cast<specView*>(target) ;
	specDataView*   dataView   = dynamic_cast<specDataView*>(target) ;
	specMetaView*   metaView   = dynamic_cast<specMetaView*>(target) ;
	specLogView*    logView    = dynamic_cast<specLogView*>(target) ;
	specPlot*       plot       = dynamic_cast<specPlot*>(target) ;
	specPlotWidget* plotWidget = dynamic_cast<specPlotWidget*>(target) ;

	if(view && view->model())
	{
		addParent(view) ;
		addParent(view->model()) ;
		addNewAction(bar, new specAddFolderAction(target)) ;
		if(metaView)
			addNewAction(bar, new specNewMetaItemAction(target));
		else
		{
			addNewAction(bar, new specImportSpecAction(target)) ;
			addNewAction(bar, new specTreeAction(target)) ;
			addNewAction(bar, new specFlattenTreeAction(target)) ;
		}
		if(dataView || metaView)
			addNewAction(bar, new specAddSVGItemAction(target)) ;
		addNewAction(bar, new genericExportAction(target)) ;
		bar->addSeparator() ;
		addNewAction(bar, new specCopyAction(target)) ;
		if(dataView || metaView)
			addNewAction(bar, new matrixExportAction(target)) ;
		addNewAction(bar, new specCutAction(target)) ;
		addNewAction(bar, new specPasteAction(target)) ;
		addNewAction(bar, new specDeleteAction(target)) ;
		bar->addSeparator() ;
		if(metaView || logView)
		{
			bar->addAction(undoAction(view)) ;
			bar->addAction(redoAction(view)) ;
			bar->addSeparator() ;
		}
		if(dataView)
		{
			addNewAction(bar, new toggle3DPlotAction(target)) ;
			addNewAction(bar, new specMergeAction(target)) ;
			addNewAction(bar, new specTiltMatrixAction(target)) ;
			addNewAction(bar, new specDescriptorEditAction(target)) ;
			bar->addSeparator() ;
			addNewAction(bar, new specRemoveDataAction(target)) ;
			addNewAction(bar, new specAverageDataAction(target)) ;
			addNewAction(bar, new specSpectrumCalculatorAction(target)) ;
			addNewAction(bar, new specNormalizeAction(target)) ;
		}
		addNewAction(bar, new specItemPropertiesAction(target)) ;
		addNewAction(bar, new specSetMultilineAction(target)) ;
		if(metaView)
		{
			addNewAction(bar, new specAddConnectionsAction(target)) ;
			addNewAction(bar, new specSelectConnectedAction(target)) ;
			addNewAction(bar, new specAddFitAction(target)) ;
			addNewAction(bar, new specRemoveFitAction(target)) ;
			addNewAction(bar, new specToggleFitStyleAction(target));
			addNewAction(bar, new specConductFitAction(target)) ;
		}
		if(logView)
			addNewAction(bar, new specDescriptorEditAction(target)) ;
		bar->addSeparator() ;
		if(dataView || metaView)
			addNewAction(bar, new changePlotStyleAction(target)) ;
		bar->setWindowTitle(tr("Items toolbar"));
	}

	if(plot)
	{
		addParent(plot);
		addNewAction(bar, new specTitleAction(target)) ;
		addNewAction(bar, new specXLabelAction(target)) ;
		addNewAction(bar, new specYLabelAction(target)) ;
		bar->addActions(plot->actions());
		bar->setWindowTitle(tr("Plot toolbar"));
	}

	if(plotWidget)
	{
		delete bar ;
		bar = plotWidget->createToolbar() ;
		bar-> addSeparator() ;
		bar-> addAction(purgeUndoAction) ;
		bar-> addSeparator() ;
		bar-> addAction(undoAction(this)) ;
		bar-> addAction(redoAction(this)) ;
		bar->setWindowTitle(tr("Main toolbar"));
	}

	return bar ;
}
Esempio n. 4
0
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);
}