Added track duration in various relevant place in the UI. #15

This commit is contained in:
emeric
2020-01-08 13:34:42 +01:00
parent 88c5475149
commit 5478406553
10 changed files with 151 additions and 14 deletions
+2
View File
@@ -94,6 +94,8 @@ lms_SOURCES = \
$(srcdir)/ui/PlayHistoryView.hpp \
$(srcdir)/ui/SettingsView.cpp \
$(srcdir)/ui/SettingsView.hpp \
$(srcdir)/ui/TrackStringUtils.cpp \
$(srcdir)/ui/TrackStringUtils.hpp \
$(srcdir)/ui/admin/DatabaseSettingsView.cpp \
$(srcdir)/ui/admin/DatabaseSettingsView.hpp \
$(srcdir)/ui/admin/DatabaseStatus.cpp \
+3
View File
@@ -30,6 +30,7 @@
#include "utils/Logger.hpp"
#include "utils/Service.hpp"
#include "utils/Utils.hpp"
#include "TrackStringUtils.hpp"
#include "LmsApplication.hpp"
namespace UserInterface {
@@ -373,6 +374,8 @@ PlayQueue::addSome()
entry->bindWidget("release", LmsApplication::createReleaseAnchor(track->getRelease()));
}
entry->bindString("duration", trackDurationToString(track->getDuration()), Wt::TextFormat::Plain);
Wt::WText* playBtn = entry->bindNew<Wt::WText>("play-btn", Wt::WString::tr("Lms.PlayQueue.template.play-btn"), Wt::TextFormat::XHTML);
playBtn->clicked().connect(std::bind([=]
{
+37
View File
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2020 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TrackStringUtils.hpp"
#include <iomanip>
#include <sstream>
std::string
trackDurationToString(std::chrono::milliseconds msDuration)
{
const std::chrono::seconds duration {std::chrono::duration_cast<std::chrono::seconds>(msDuration)};
std::ostringstream oss;
oss << std::setfill('0') << std::setw(2) << (duration.count() / 60)
<< ":"
<< std::setfill('0') << std::setw(2) << duration.count() % 60;
return oss.str();
}
+27
View File
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2020 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <chrono>
#include <string>
std::string
trackDurationToString(std::chrono::milliseconds msDuration);
+4 -1
View File
@@ -33,9 +33,10 @@
#include "resource/ImageResource.hpp"
#include "Filters.hpp"
#include "LmsApplication.hpp"
#include "LmsApplicationException.hpp"
#include "Filters.hpp"
#include "TrackStringUtils.hpp"
using namespace Database;
@@ -203,6 +204,8 @@ Release::refresh()
tracksAdd.emit({trackId});
}));
entry->bindString("duration", trackDurationToString(track->getDuration()), Wt::TextFormat::Plain);
LmsApp->getEvents().trackLoaded.connect(entry, [=] (Database::IdType loadedTrackId, bool /*play*/)
{
entry->toggleStyleClass("Lms-explore-release-entry-playing", loadedTrackId == trackId);
+4 -1
View File
@@ -32,8 +32,9 @@
#include "resource/ImageResource.hpp"
#include "LmsApplication.hpp"
#include "Filters.hpp"
#include "LmsApplication.hpp"
#include "TrackStringUtils.hpp"
using namespace Database;
@@ -145,6 +146,8 @@ Tracks::addSome()
entry->bindWidget("release", LmsApplication::createReleaseAnchor(track->getRelease()));
}
entry->bindString("duration", trackDurationToString(track->getDuration()), Wt::TextFormat::Plain);
Wt::WText* playBtn = entry->bindNew<Wt::WText>("play-btn", Wt::WString::tr("Lms.Explore.template.play-btn"), Wt::TextFormat::XHTML);
playBtn->clicked().connect(std::bind([=]
{