[vlc-devel] [PATCH 10/10] Updated QT Synchronization GUI - set secondary subtitle synchronization
Roland Bewick
roland.bewick at gmail.com
Sun May 5 12:01:50 CEST 2019
---
modules/gui/qt/components/extended_panels.cpp | 42 +++++++++++++++----
modules/gui/qt/components/extended_panels.hpp | 2 +
.../gui/qt/components/player_controller.cpp | 12 +++++-
.../gui/qt/components/player_controller.hpp | 4 ++
.../gui/qt/components/player_controller_p.hpp | 1 +
5 files changed, 51 insertions(+), 10 deletions(-)
diff --git a/modules/gui/qt/components/extended_panels.cpp b/modules/gui/qt/components/extended_panels.cpp
index 6f603eb17c..f25bcdce6b 100644
--- a/modules/gui/qt/components/extended_panels.cpp
+++ b/modules/gui/qt/components/extended_panels.cpp
@@ -1399,16 +1399,25 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent )
subsBox = new QGroupBox( qtr( "Subtitles/Video" ) );
QGridLayout *subsLayout = new QGridLayout( subsBox );
- QLabel *subsLabel = new QLabel;
- subsLabel->setText( qtr( "Subtitle track synchronization:" ) );
- subsLayout->addWidget( subsLabel, 0, 0, 1, 1 );
+ QGroupBox *subsTrackSyncBox = new QGroupBox( qtr( "Subtitle track synchronization" ) );
+ QGridLayout *synchronizationLayout = new QGridLayout( subsTrackSyncBox );
- subsSpin = new SyncWidget( this );
- subsLayout->addWidget( subsSpin, 0, 2, 1, 1 );
+ for( int i = 0; i < 2; i++ )
+ {
+ QLabel *subsLabel = new QLabel;
+ subsLabel->setText( qtr( i == 0 ? "Primary subtitle Track:" : "Secondary subtitle track:" ) );
+ synchronizationLayout->addWidget( subsLabel, i, 0, 1, 1 );
+ SyncWidget **p_subsSpin = i == 0 ? &subsSpin : &secondarySubsSpin;
+
+ *p_subsSpin = new SyncWidget( this );
+ synchronizationLayout->addWidget( *p_subsSpin, i, 2, 1, 1 );
+ }
+
+ subsLayout->addWidget( subsTrackSyncBox, 0, 0, 2, 5 );
QLabel *subSpeedLabel = new QLabel;
subSpeedLabel->setText( qtr( "Subtitle speed:" ) );
- subsLayout->addWidget( subSpeedLabel, 1, 0, 1, 1 );
+ subsLayout->addWidget( subSpeedLabel, 2, 0, 1, 1 );
subSpeedSpin = new QDoubleSpinBox;
subSpeedSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
@@ -1418,11 +1427,11 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent )
subSpeedSpin->setSingleStep( 0.2 );
subSpeedSpin->setSuffix( " fps" );
subSpeedSpin->setButtonSymbols( QDoubleSpinBox::PlusMinus );
- subsLayout->addWidget( subSpeedSpin, 1, 2, 1, 1 );
+ subsLayout->addWidget( subSpeedSpin, 2, 2, 1, 1 );
QLabel *subDurationLabel = new QLabel;
subDurationLabel->setText( qtr( "Subtitle duration factor:" ) );
- subsLayout->addWidget( subDurationLabel, 2, 0, 1, 1 );
+ subsLayout->addWidget( subDurationLabel, 3, 0, 1, 1 );
subDurationSpin = new QDoubleSpinBox;
subDurationSpin->setAlignment( Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter );
@@ -1431,7 +1440,7 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent )
subDurationSpin->setMaximum( 20 );
subDurationSpin->setSingleStep( 0.2 );
subDurationSpin->setButtonSymbols( QDoubleSpinBox::PlusMinus );
- subsLayout->addWidget( subDurationSpin, 2, 2, 1, 1 );
+ subsLayout->addWidget( subDurationSpin, 3, 2, 1, 1 );
mainLayout->addWidget( subsBox, 2, 0, 2, 5 );
@@ -1442,6 +1451,7 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent )
/* Various Connects */
connect( AVSpin, &SyncWidget::valueChanged, this, &SyncControls::advanceAudio ) ;
connect( subsSpin, &SyncWidget::valueChanged, this, &SyncControls::advanceSubs ) ;
+ connect( secondarySubsSpin, &SyncWidget::valueChanged, this, &SyncControls::advanceSecondarySubs ) ;
connect( subSpeedSpin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &SyncControls::adjustSubsSpeed);
connect( subDurationSpin, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &SyncControls::adjustSubsDuration);
@@ -1450,6 +1460,11 @@ SyncControls::SyncControls( intf_thread_t *_p_intf, QWidget *_parent )
subsSpin->setValue(secf_from_vlc_tick(value));
b_userAction = true;
});
+ connect( THEMIM, &PlayerController::secondarySubtitleDelayChanged, [this](vlc_tick_t value) {
+ b_userAction = false;
+ secondarySubsSpin->setValue(secf_from_vlc_tick(value));
+ b_userAction = true;
+ });
connect( THEMIM, &PlayerController::audioDelayChanged, [this](vlc_tick_t value) {
b_userAction = false;
AVSpin->setValue(secf_from_vlc_tick(value));
@@ -1513,6 +1528,15 @@ void SyncControls::advanceSubs( double f_advance )
}
}
+void SyncControls::advanceSecondarySubs( double f_advance )
+{
+ if( THEMIM->getInput() && b_userAction )
+ {
+ vlc_tick_t i_delay = vlc_tick_from_sec( f_advance );
+ THEMIM->setSecondarySubtitleDelay( i_delay );
+ }
+}
+
void SyncControls::adjustSubsSpeed( double f_fps )
{
if( THEMIM->getInput() && b_userAction )
diff --git a/modules/gui/qt/components/extended_panels.hpp b/modules/gui/qt/components/extended_panels.hpp
index a96240d67a..a06704bbcb 100644
--- a/modules/gui/qt/components/extended_panels.hpp
+++ b/modules/gui/qt/components/extended_panels.hpp
@@ -248,6 +248,7 @@ private:
intf_thread_t *p_intf;
SyncWidget *AVSpin;
SyncWidget *subsSpin;
+ SyncWidget *secondarySubsSpin;
QDoubleSpinBox *subSpeedSpin;
QDoubleSpinBox *subDurationSpin;
QVLCFloat m_SubsDelayCfgFactor;
@@ -265,6 +266,7 @@ public slots:
private slots:
void advanceAudio( double );
void advanceSubs( double );
+ void advanceSecondarySubs( double );
void adjustSubsSpeed( double );
void adjustSubsDuration( double );
};
diff --git a/modules/gui/qt/components/player_controller.cpp b/modules/gui/qt/components/player_controller.cpp
index dfaf07dccd..9d5c27478b 100644
--- a/modules/gui/qt/components/player_controller.cpp
+++ b/modules/gui/qt/components/player_controller.cpp
@@ -600,7 +600,8 @@ static void on_player_subtitle_delay_changed(vlc_player_t *, vlc_tick_t new_dela
}
else
{
- // TODO: Support dual subtitles
+ that->m_secondarySubtitleDelay = new_delay;
+ emit that->q_func()->secondarySubtitleDelayChanged( new_delay );
}
});
}
@@ -1057,6 +1058,14 @@ void PlayerController::setSubtitleDelay(VLCTick delay)
VLC_PLAYER_WHENCE_ABSOLUTE, false );
}
+void PlayerController::setSecondarySubtitleDelay(VLCTick delay)
+{
+ Q_D(PlayerController);
+ vlc_player_locker lock{ d->m_player };
+ vlc_player_SetSubtitleDelay( d->m_player, delay,
+ VLC_PLAYER_WHENCE_ABSOLUTE, true );
+}
+
void PlayerController::setSubtitleFPS(float fps)
{
Q_D(PlayerController);
@@ -1480,6 +1489,7 @@ PRIMITIVETYPE_GETTER(float, getPosition, m_position)
PRIMITIVETYPE_GETTER(VLCTick, getLength, m_length)
PRIMITIVETYPE_GETTER(VLCTick, getAudioDelay, m_audioDelay)
PRIMITIVETYPE_GETTER(VLCTick, getSubtitleDelay, m_subtitleDelay)
+PRIMITIVETYPE_GETTER(VLCTick, getSecondarySubtitleDelay, m_secondarySubtitleDelay)
PRIMITIVETYPE_GETTER(bool, isSeekable, m_capabilities & VLC_INPUT_CAPABILITIES_SEEKABLE)
PRIMITIVETYPE_GETTER(bool, isRewindable, m_capabilities & VLC_INPUT_CAPABILITIES_REWINDABLE)
PRIMITIVETYPE_GETTER(bool, isPausable, m_capabilities & VLC_INPUT_CAPABILITIES_PAUSEABLE)
diff --git a/modules/gui/qt/components/player_controller.hpp b/modules/gui/qt/components/player_controller.hpp
index cdf7c8129d..0cd43451f8 100644
--- a/modules/gui/qt/components/player_controller.hpp
+++ b/modules/gui/qt/components/player_controller.hpp
@@ -124,6 +124,7 @@ public:
Q_PROPERTY(VLCTick audioDelay READ getAudioDelay WRITE setAudioDelay NOTIFY audioDelayChanged)
Q_PROPERTY(VLCTick subtitleDelay READ getSubtitleDelay WRITE setSubtitleDelay NOTIFY subtitleDelayChanged)
+ Q_PROPERTY(VLCTick secondarySubtitleDelay READ getSecondarySubtitleDelay WRITE setSecondarySubtitleDelay NOTIFY secondarySubtitleDelayChanged)
Q_PROPERTY(float subtitleFPS READ getSubtitleFPS WRITE setSubtitleFPS NOTIFY subtitleFPSChanged)
//title/chapters/menu
@@ -268,7 +269,9 @@ public slots:
VLCTick getAudioDelay() const;
void setAudioDelay( VLCTick );
VLCTick getSubtitleDelay() const;
+ VLCTick getSecondarySubtitleDelay() const;
void setSubtitleDelay( VLCTick );
+ void setSecondarySubtitleDelay( VLCTick );
float getSubtitleFPS( ) const;
void setSubtitleFPS( float );
@@ -352,6 +355,7 @@ signals:
//tracks
void audioDelayChanged(VLCTick);
void subtitleDelayChanged(VLCTick);
+ void secondarySubtitleDelayChanged(VLCTick);
void subtitleFPSChanged(float);
//title/chapters/menu
diff --git a/modules/gui/qt/components/player_controller_p.hpp b/modules/gui/qt/components/player_controller_p.hpp
index 3a52205aa2..3781b6dee6 100644
--- a/modules/gui/qt/components/player_controller_p.hpp
+++ b/modules/gui/qt/components/player_controller_p.hpp
@@ -91,6 +91,7 @@ public:
VLCTick m_audioDelay = 0;
VLCTick m_subtitleDelay = 0;
+ VLCTick m_secondarySubtitleDelay = 0;
float m_subtitleFPS = 1.0;
//title/chapters/menu
--
2.17.1
More information about the vlc-devel
mailing list