Skip to content

Commit

Permalink
Update buttons on press
Browse files Browse the repository at this point in the history
  • Loading branch information
kraxarn committed May 1, 2020
1 parent 40f8e49 commit f897020
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,9 @@ QToolBar *MainWindow::createToolBar()
auto previous = toolBar->addAction(Icon::get("media-skip-backward"), "Previous");
playPause = toolBar->addAction(Icon::get("media-playback-start"), "Play");
QAction::connect(playPause, &QAction::triggered, [=](bool checked) {
auto status = playPause->iconText() == "Pause" ? spotify->pause() : spotify->resume();
current.isPlaying = !current.isPlaying;
refreshed(current);
auto status = playPause->iconText() == "Play" ? spotify->pause() : spotify->resume();
if (!status.isEmpty())
{
setStatus(QString("Failed to %1 playback: %2")
Expand Down Expand Up @@ -500,14 +502,19 @@ QToolBar *MainWindow::createToolBar()
shuffle = toolBar->addAction(Icon::get("media-playlist-shuffle"), "Shuffle");
shuffle->setCheckable(true);
QAction::connect(shuffle, &QAction::triggered, [=](bool checked) {
current.shuffle = !current.shuffle;
refreshed(current);
auto status = spotify->setShuffle(checked);
if (!status.isEmpty())
setStatus(QString("Failed to toggle shuffle: %1").arg(status), true);
});
repeat = toolBar->addAction(Icon::get("media-playlist-repeat"), "Repeat");
repeat->setCheckable(true);
QAction::connect(repeat, &QAction::triggered, [=](bool checked) {
auto status = spotify->setRepeat(checked ? "context" : "off");
auto repeatMode = QString(checked ? "context" : "off");
current.repeat = repeatMode;
refreshed(current);
auto status = spotify->setRepeat(repeatMode);
if (!status.isEmpty())
setStatus(QString("Failed to toggle repeat: %1").arg(status), true);
});
Expand Down

0 comments on commit f897020

Please sign in to comment.