diff --git a/.gitignore b/.gitignore
index 55f8f185..f2a0e28e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ Makefile
*.kdev4
*.qm
*.out
+.tags*
diff --git a/src/mpvhandler.cpp b/src/mpvhandler.cpp
index 09e6df94..838ff0f8 100644
--- a/src/mpvhandler.cpp
+++ b/src/mpvhandler.cpp
@@ -563,16 +563,16 @@ void MpvHandler::LoadFileInfo()
// get length
double len;
mpv_get_property(mpv, "length", MPV_FORMAT_DOUBLE, &len);
- fileInfo.length = (int)len;
-
- fileInfo.video_params.codec = mpv_get_property_string(mpv, "video-codec");
- fileInfo.video_params.format = mpv_get_property_string(mpv, "video-format");
- fileInfo.video_params.bitrate = mpv_get_property_string(mpv, "video-bitrate");
- fileInfo.audio_params.codec = mpv_get_property_string(mpv, "audio-codec");
- fileInfo.audio_params.format = mpv_get_property_string(mpv, "audio-format");
- fileInfo.audio_params.bitrate = mpv_get_property_string(mpv, "audio-bitrate");
+ fileInfo.length = (int)len;
+
+ fileInfo.video_params.codec = mpv_get_property_string(mpv, "video-codec");
+ fileInfo.video_params.format = mpv_get_property_string(mpv, "video-format");
+ fileInfo.video_params.bitrate = mpv_get_property_string(mpv, "video-bitrate");
+ fileInfo.audio_params.codec = mpv_get_property_string(mpv, "audio-codec");
+ fileInfo.audio_params.format = mpv_get_property_string(mpv, "audio-format");
+ fileInfo.audio_params.bitrate = mpv_get_property_string(mpv, "audio-bitrate");
fileInfo.audio_params.samplerate = mpv_get_property_string(mpv, "audio-samplerate");
- fileInfo.audio_params.channels = mpv_get_property_string(mpv, "audio-channels");
+ fileInfo.audio_params.channels = mpv_get_property_string(mpv, "audio-channels");
LoadTracks();
LoadChapters();
@@ -689,10 +689,10 @@ void MpvHandler::LoadChapters()
void MpvHandler::LoadVideoParams()
{
- mpv_get_property(mpv, "width", MPV_FORMAT_INT64, &fileInfo.video_params.width);
- mpv_get_property(mpv, "height", MPV_FORMAT_INT64, &fileInfo.video_params.height);
- mpv_get_property(mpv, "dwidth", MPV_FORMAT_INT64, &fileInfo.video_params.dwidth);
- mpv_get_property(mpv, "dheight", MPV_FORMAT_INT64, &fileInfo.video_params.dheight);
+ mpv_get_property(mpv, "width", MPV_FORMAT_INT64, &fileInfo.video_params.width);
+ mpv_get_property(mpv, "height", MPV_FORMAT_INT64, &fileInfo.video_params.height);
+ mpv_get_property(mpv, "dwidth", MPV_FORMAT_INT64, &fileInfo.video_params.dwidth);
+ mpv_get_property(mpv, "dheight", MPV_FORMAT_INT64, &fileInfo.video_params.dheight);
mpv_get_property(mpv, "video-aspect", MPV_FORMAT_INT64, &fileInfo.video_params.aspect);
emit videoParamsChanged(fileInfo.video_params);
diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp
index 1a3d944c..b582c8fb 100644
--- a/src/ui/mainwindow.cpp
+++ b/src/ui/mainwindow.cpp
@@ -125,7 +125,7 @@ MainWindow::MainWindow(QWidget *parent):
else if(mpv->getPlayState() == Mpv::Paused)
sysTrayIcon->showMessage("Baka MPlayer", tr("Paused"), QSystemTrayIcon::NoIcon, 4000);
}
- mpv->PlayPause(ui->playlistWidget->CurrentItem());
+ TogglePlay();
}
});
@@ -641,7 +641,7 @@ MainWindow::MainWindow(QWidget *parent):
connect(ui->playButton, &QPushButton::clicked, // Playback: Play/pause button
[=]
{
- mpv->PlayPause(ui->playlistWidget->CurrentItem());
+ TogglePlay();
});
connect(ui->nextButton, &IndexButton::clicked, // Playback: Next button
@@ -659,8 +659,7 @@ MainWindow::MainWindow(QWidget *parent):
connect(ui->playlistButton, &QPushButton::clicked, // Playback: Clicked the playlist button
[=]
{
- // if the position is 0, playlist is hidden so show it
- ShowPlaylist(ui->splitter->position() == 0);
+ TogglePlaylist();
});
connect(ui->splitter, &CustomSplitter::positionChanged, // Splitter position changed
@@ -962,7 +961,7 @@ MainWindow::MainWindow(QWidget *parent):
connect(ui->action_Play, &QAction::triggered, // Playback -> (Play|Pause)
[=]
{
- mpv->PlayPause(ui->playlistWidget->CurrentItem());
+ TogglePlay();
});
connect(ui->action_Stop, &QAction::triggered, // Playback -> Stop
@@ -1513,33 +1512,54 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
// keyboard shortcuts
switch(event->key())
{
- case Qt::Key_Left:
- mpv->Seek(-5, true);
- break;
- case Qt::Key_Right:
- mpv->Seek(5, true);
- break;
- case Qt::Key_Up:
- if(ui->splitter->position() != 0)
- ui->playlistWidget->SelectItem(ui->playlistWidget->PreviousItem());
- break;
- case Qt::Key_Down:
- if(ui->splitter->position() != 0)
- ui->playlistWidget->SelectItem(ui->playlistWidget->NextItem());
- break;
- case Qt::Key_Return:
- if(ui->splitter->position() != 0)
- mpv->PlayFile(ui->playlistWidget->CurrentItem());
- break;
- case Qt::Key_Escape:
- if(isFullScreen()) // in fullscreen mode, escape will exit fullscreen
- FullScreen(false);
- else
- {
- mpv->Pause();
- setWindowState(windowState() | Qt::WindowMinimized);
- }
- break;
+ // Playback/Seeking
+ case Qt::Key_Left:
+ mpv->Seek(-5, true);
+ break;
+ case Qt::Key_Right:
+ mpv->Seek(5, true);
+ break;
+ // already exists as play/pause hotkey
+// case Qt::Key_Space:
+// TogglePlay();
+// break;
+
+ // Playlist Control
+ case Qt::Key_Up:
+ if(ui->splitter->position() != 0)
+ ui->playlistWidget->SelectItem(ui->playlistWidget->PreviousItem());
+ break;
+ case Qt::Key_Down:
+ if(ui->splitter->position() != 0)
+ ui->playlistWidget->SelectItem(ui->playlistWidget->NextItem());
+ break;
+ case Qt::Key_Return:
+ if(ui->splitter->position() != 0)
+ mpv->PlayFile(ui->playlistWidget->CurrentItem());
+ break;
+ case Qt::Key_Escape:
+ if(isFullScreen()) // in fullscreen mode, escape will exit fullscreen
+ FullScreen(false);
+ else
+ {
+ mpv->Pause();
+ setWindowState(windowState() | Qt::WindowMinimized);
+ }
+ break;
+
+ // MPlayer shortcuts
+ case Qt::Key_F:
+ FullScreen(!isFullScreen());
+ break;
+ case Qt::Key_Q:
+ close();
+ break;
+ case Qt::Key_V:
+ TogglePlaylist();
+ break;
+ case Qt::Key_S:
+ ToggleSubtitles();
+ break;
}
}
@@ -1635,6 +1655,26 @@ void MainWindow::FullScreen(bool fs)
}
}
+void MainWindow::TogglePlay() {
+ mpv->PlayPause(ui->playlistWidget->CurrentItem());
+}
+
+bool MainWindow::isPlaylistVisible() {
+ // if the position is 0, playlist is hidden
+ return ui->splitter->position() != 0;
+}
+
+void MainWindow::TogglePlaylist() {
+ ShowPlaylist(!isPlaylistVisible());
+}
+
+void MainWindow::ToggleSubtitles() {
+ if(mpv->getSubtitleVisibility())
+ mpv->ShowSubtitles(false);
+ else
+ mpv->ShowSubtitles(true);
+}
+
void MainWindow::ShowPlaylist(bool visible)
{
if(visible)
diff --git a/src/ui/mainwindow.h b/src/ui/mainwindow.h
index 3efda4b5..8afc7bb3 100644
--- a/src/ui/mainwindow.h
+++ b/src/ui/mainwindow.h
@@ -48,6 +48,10 @@ class MainWindow : public QMainWindow
void wheelEvent(QWheelEvent *event); // the mouse wheel is used
void keyPressEvent(QKeyEvent *event);
void SetPlaybackControls(bool enable); // macro to enable/disable playback controls
+ void TogglePlaylist(); // toggles playlist visibility
+ void TogglePlay(); // play/pause
+ void ToggleSubtitles(); // play/pause
+ bool isPlaylistVisible(); // is the playlist visible?
private slots:
void FullScreen(bool fs); // makes window fullscreen
diff --git a/src/ui/mainwindow.ui b/src/ui/mainwindow.ui
index 4eb025d3..f01fac06 100644
--- a/src/ui/mainwindow.ui
+++ b/src/ui/mainwindow.ui
@@ -976,7 +976,7 @@ QSlider::handle:horizontal {
0
0
580
- 26
+ 24