Skip to content

Commit

Permalink
Merge branch 'master' into 2.0.1_release
Browse files Browse the repository at this point in the history
  • Loading branch information
u8sand committed Dec 28, 2014
2 parents ced3349 + 60ca7b8 commit 592b3ed
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ Makefile
*.kdev4
*.qm
*.out
.tags*
26 changes: 13 additions & 13 deletions src/mpvhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
104 changes: 72 additions & 32 deletions src/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

});
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/ui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ QSlider::handle:horizontal {
<x>0</x>
<y>0</y>
<width>580</width>
<height>26</height>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
Expand Down Expand Up @@ -1218,7 +1218,7 @@ QSlider::handle:horizontal {
<string>Show in &amp;Folder</string>
</property>
<property name="shortcut">
<string>Ctrl+G</string>
<string>Ctrl+E</string>
</property>
</action>
<action name="actionPlay_Next_File">
Expand Down Expand Up @@ -1600,7 +1600,7 @@ QSlider::handle:horizontal {
<string>Show &amp;Command Line</string>
</property>
<property name="shortcut">
<string>Ctrl+E</string>
<string>Ctrl+G</string>
</property>
</action>
<action name="action_Increase_Volume">
Expand Down
1 change: 1 addition & 0 deletions src/widgets/playlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ PlaylistWidget::PlaylistWidget(QWidget *parent) :
QListWidget(parent),
cItem()
{
setAttribute(Qt::WA_NoMousePropagation);
}

QAction *PlaylistWidget::addAction(const QString &text)
Expand Down

0 comments on commit 592b3ed

Please sign in to comment.