Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add secondarySubVisibilityAct #564

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/basegui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,12 @@ void BaseGui::createActions() {
subVisibilityAct->setCheckable(true);
connect( subVisibilityAct, SIGNAL(toggled(bool)), core, SLOT(changeSubVisibility(bool)) );

#ifdef MPV_SUPPORT
secondarySubVisibilityAct = new MyAction(this, "secondary_sub_visibility");
secondarySubVisibilityAct->setCheckable(true);
connect( secondarySubVisibilityAct, SIGNAL(toggled(bool)), core, SLOT(changeSecondarySubVisibility(bool)) );
#endif

#ifdef FIND_SUBTITLES
showFindSubtitlesDialogAct = new MyAction( this, "show_find_sub_dialog" );
connect( showFindSubtitlesDialogAct, SIGNAL(triggered()),
Expand Down
3 changes: 3 additions & 0 deletions src/basegui.h
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,9 @@ protected slots:
MyAction * useCustomSubStyleAct;
MyAction * useForcedSubsOnlyAct;
MyAction * subVisibilityAct;
#ifdef MPV_SUPPORT
MyAction * secondarySubVisibilityAct;
#endif
#ifdef FIND_SUBTITLES
MyAction * showFindSubtitlesDialogAct;
MyAction * openUploadSubtitlesPageAct;//turbos
Expand Down
11 changes: 11 additions & 0 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3686,6 +3686,17 @@ void Core::changeSubVisibility(bool visible) {
displayMessage( tr("Subtitles off") );
}

#ifdef MPV_SUPPORT
void Core::changeSecondarySubVisibility(bool visible) {
qDebug("Core::changeSecondarySubVisibility: %d", visible);
pref->secondary_sub_visibility = visible;

if (proc->isRunning()) {
proc->setSecondarySubtitlesVisibility(pref->secondary_sub_visibility);
}
}
#endif

void Core::changeExternalSubFPS(int fps_id) {
qDebug("Core::setExternalSubFPS: %d", fps_id);
mset.external_subtitles_fps = fps_id;
Expand Down
4 changes: 3 additions & 1 deletion src/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,10 @@ public slots:
void incSubStep();
//! Select previous line in subtitle file
void decSubStep();

void changeSubVisibility(bool visible);
#ifdef MPV_SUPPORT
void changeSecondarySubVisibility(bool visible);
#endif

void changeExternalSubFPS(int fps_id);

Expand Down
7 changes: 7 additions & 0 deletions src/mplayeroptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,13 @@ void MplayerProcess::setSubtitlesVisibility(bool b) {
sendCommand(QString("sub_visibility %1").arg(b ? 1 : 0));
}

#ifdef MPV_SUPPORT
void MplayerProcess::setSecondarySubtitlesVisibility(bool /*value*/) {
/* Not supported */
showOSDText(tr("This option is not supported by MPlayer"), 3000, 1);
};
#endif

void MplayerProcess::seek(double secs, int mode, bool precise) {
QString s = QString("seek %1 %2").arg(secs).arg(mode);
if (precise) s += " 1"; else s += " -1";
Expand Down
3 changes: 3 additions & 0 deletions src/mplayerprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class MplayerProcess : public PlayerProcess
void setSecondarySubtitle(int /*ID*/) {};
void disableSecondarySubtitles() {};
void setSubtitlesVisibility(bool b);
#ifdef MPV_SUPPORT
void setSecondarySubtitlesVisibility(bool /*b*/);
#endif
void seek(double secs, int mode, bool precise);
void mute(bool b);
void setPause(bool b);
Expand Down
4 changes: 4 additions & 0 deletions src/mpvoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,10 @@ void MPVProcess::setSubtitlesVisibility(bool b) {
sendCommand(QString("no-osd set sub-visibility %1").arg(b ? "yes" : "no"));
}

void MPVProcess::setSecondarySubtitlesVisibility(bool b) {
sendCommand(QString("no-osd set secondary-sub-visibility %1").arg(b ? "yes" : "no"));
}

void MPVProcess::seek(double secs, int mode, bool precise) {
QString s = "seek " + QString::number(secs) + " ";
switch (mode) {
Expand Down
1 change: 1 addition & 0 deletions src/mpvprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class MPVProcess : public PlayerProcess
void setSecondarySubtitle(int ID);
void disableSecondarySubtitles();
void setSubtitlesVisibility(bool b);
void setSecondarySubtitlesVisibility(bool b);
void seek(double secs, int mode, bool precise);
void mute(bool b);
void setPause(bool b);
Expand Down
3 changes: 3 additions & 0 deletions src/playerprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ class PlayerProcess : public MyProcess
virtual void setSecondarySubtitle(int ID) = 0;
virtual void disableSecondarySubtitles() = 0;
virtual void setSubtitlesVisibility(bool b) = 0;
#ifdef MPV_SUPPORT
virtual void setSecondarySubtitlesVisibility(bool b) = 0;
#endif
virtual void seek(double secs, int mode, bool precise) = 0;
virtual void mute(bool b) = 0;
virtual void setPause(bool b) = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ class Preferences {
bool use_forced_subs_only;

bool sub_visibility;
#ifdef MPV_SUPPORT
bool secondary_sub_visibility;
#endif

bool subtitles_on_screenshots;

Expand Down