Replaced show-more button by infinite scrolling. fixes #83
This commit is contained in:
@@ -15,6 +15,7 @@ add_executable(lms
|
||||
ui/admin/UserView.cpp
|
||||
ui/admin/UsersView.cpp
|
||||
ui/common/AuthModeModel.cpp
|
||||
ui/common/LoadingIndicator.cpp
|
||||
ui/common/Validators.cpp
|
||||
ui/explore/ArtistListHelpers.cpp
|
||||
ui/explore/ArtistView.cpp
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <Wt/WAnchor.h>
|
||||
#include <Wt/WEnvironment.h>
|
||||
#include <Wt/WLineEdit.h>
|
||||
#include <Wt/WPushButton.h>
|
||||
#include <Wt/WServer.h>
|
||||
#include <Wt/WStackedWidget.h>
|
||||
#include <Wt/WText.h>
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "utils/Service.hpp"
|
||||
#include "utils/String.hpp"
|
||||
|
||||
#include "common/LoadingIndicator.hpp"
|
||||
#include "resource/ImageResource.hpp"
|
||||
#include "LmsApplication.hpp"
|
||||
#include "MediaPlayer.hpp"
|
||||
@@ -66,10 +67,12 @@ PlayQueue::PlayQueue()
|
||||
|
||||
_entriesContainer = bindNew<Wt::WContainerWidget>("entries");
|
||||
|
||||
_showMore = bindNew<Wt::WPushButton>("show-more", Wt::WString::tr("Lms.Explore.show-more"));
|
||||
_showMore->setHidden(true);
|
||||
_showMore->clicked().connect([=]
|
||||
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
||||
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
||||
{
|
||||
if (!visible)
|
||||
return;
|
||||
|
||||
addSome();
|
||||
updateCurrentTrack(true);
|
||||
});
|
||||
@@ -202,7 +205,7 @@ PlayQueue::clearTracks()
|
||||
getTrackList().modify()->clear();
|
||||
}
|
||||
|
||||
_showMore->setHidden(true);
|
||||
_loadingIndicator->setHidden(true);
|
||||
_entriesContainer->clear();
|
||||
updateInfo();
|
||||
}
|
||||
@@ -447,7 +450,7 @@ PlayQueue::addSome()
|
||||
|
||||
}
|
||||
|
||||
_showMore->setHidden(static_cast<std::size_t>(_entriesContainer->count()) >= tracklist->getCount());
|
||||
_loadingIndicator->setHidden(static_cast<std::size_t>(_entriesContainer->count()) >= tracklist->getCount());
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <optional>
|
||||
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WPushButton.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WText.h>
|
||||
|
||||
@@ -84,7 +83,7 @@ class PlayQueue : public Wt::WTemplate
|
||||
bool _mediaPlayerSettingsLoaded {};
|
||||
Database::IdType _tracklistId {};
|
||||
Wt::WContainerWidget* _entriesContainer {};
|
||||
Wt::WPushButton* _showMore {};
|
||||
Wt::WTemplate* _loadingIndicator {};
|
||||
Wt::WText* _nbTracks {};
|
||||
Wt::WText* _repeatBtn {};
|
||||
Wt::WText* _radioBtn {};
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 "LoadingIndicator.hpp"
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
std::unique_ptr<Wt::WTemplate>
|
||||
createLoadingIndicator()
|
||||
{
|
||||
auto res {std::make_unique<Wt::WTemplate>(Wt::WString::tr("Lms.LoadingIndicator.template"))};
|
||||
|
||||
res->addFunction("tr", &Wt::WTemplate::Functions::tr);
|
||||
res->setScrollVisibilityMargin(200);
|
||||
res->setScrollVisibilityEnabled(true);
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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 <Wt/WTemplate.h>
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
std::unique_ptr<Wt::WTemplate> createLoadingIndicator();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "database/TrackList.hpp"
|
||||
#include "utils/Logger.hpp"
|
||||
|
||||
#include "common/LoadingIndicator.hpp"
|
||||
#include "ArtistListHelpers.hpp"
|
||||
#include "LmsApplication.hpp"
|
||||
#include "Filters.hpp"
|
||||
@@ -76,9 +77,12 @@ Artists::Artists(Filters* filters)
|
||||
|
||||
_container = bindNew<Wt::WContainerWidget>("artists");
|
||||
|
||||
_showMore = bindNew<Wt::WPushButton>("show-more", Wt::WString::tr("Lms.Explore.show-more"));
|
||||
_showMore->clicked().connect([=]
|
||||
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
||||
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
||||
{
|
||||
if (!visible)
|
||||
return;
|
||||
|
||||
addSome();
|
||||
});
|
||||
|
||||
@@ -203,7 +207,7 @@ Artists::addSome()
|
||||
_container->addWidget(ArtistListHelpers::createEntry(artist));
|
||||
}
|
||||
|
||||
_showMore->setHidden(!moreResults);
|
||||
_loadingIndicator->setHidden(!moreResults);
|
||||
}
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
|
||||
#include <Wt/WComboBox.h>
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WPushButton.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
#include <Wt/WSignal.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
|
||||
@@ -67,15 +65,15 @@ class Artists : public Wt::WTemplate
|
||||
{
|
||||
{Mode::Random, batchSize * 4},
|
||||
{Mode::RecentlyPlayed, batchSize * 4},
|
||||
{Mode::RecentlyAdded, batchSize * 2},
|
||||
{Mode::MostPlayed, batchSize * 2},
|
||||
{Mode::RecentlyAdded, batchSize * 4},
|
||||
{Mode::MostPlayed, batchSize * 4},
|
||||
{Mode::All, batchSize * 50},
|
||||
};
|
||||
|
||||
Mode _mode {defaultMode};
|
||||
std::vector<Database::IdType> _randomArtists;
|
||||
Filters* _filters {};
|
||||
Wt::WPushButton* _showMore {};
|
||||
Wt::WTemplate* _loadingIndicator {};
|
||||
Wt::WContainerWidget* _container {};
|
||||
Wt::WComboBox* _linkType {};
|
||||
};
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "utils/Logger.hpp"
|
||||
#include "utils/String.hpp"
|
||||
|
||||
#include "common/LoadingIndicator.hpp"
|
||||
#include "resource/ImageResource.hpp"
|
||||
#include "ReleaseListHelpers.hpp"
|
||||
#include "Filters.hpp"
|
||||
@@ -79,9 +80,12 @@ _filters {filters}
|
||||
|
||||
_container = bindNew<Wt::WContainerWidget>("releases");
|
||||
|
||||
_showMore = bindNew<Wt::WPushButton>("show-more", Wt::WString::tr("Lms.Explore.show-more"));
|
||||
_showMore->clicked().connect([this]
|
||||
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
||||
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
||||
{
|
||||
if (!visible)
|
||||
return;
|
||||
|
||||
addSome();
|
||||
});
|
||||
|
||||
@@ -118,7 +122,7 @@ Releases::addSome()
|
||||
_container->addWidget(ReleaseListHelpers::createEntry(release));
|
||||
}
|
||||
|
||||
_showMore->setHidden(!moreResults);
|
||||
_loadingIndicator->setHidden(!moreResults);
|
||||
}
|
||||
|
||||
std::vector<Database::Release::pointer>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <optional>
|
||||
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WPushButton.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
@@ -57,19 +56,21 @@ class Releases : public Wt::WTemplate
|
||||
|
||||
void refreshView();
|
||||
void refreshView(Mode mode);
|
||||
|
||||
void addSome();
|
||||
std::vector<Wt::Dbo::ptr<Database::Release>> getReleases(std::optional<Database::Range> range, bool& moreResults);
|
||||
std::vector<Wt::Dbo::ptr<Database::Release>> getRandomReleases(std::optional<Database::Range> range, bool& moreResults);
|
||||
std::vector<Database::IdType> getAllReleases();
|
||||
|
||||
static constexpr Mode defaultMode {Mode::Random};
|
||||
static constexpr std::size_t batchSize {18};
|
||||
static constexpr std::size_t maxItemsPerLine {6};
|
||||
static constexpr std::size_t batchSize {maxItemsPerLine * 3};
|
||||
static inline std::unordered_map<Mode, std::optional<std::size_t>> maxItemsPerMode
|
||||
{
|
||||
{Mode::Random, batchSize * 6},
|
||||
{Mode::RecentlyPlayed, batchSize * 3},
|
||||
{Mode::RecentlyAdded, batchSize * 2},
|
||||
{Mode::MostPlayed, batchSize * 2},
|
||||
{Mode::Random, batchSize * 10},
|
||||
{Mode::RecentlyPlayed, batchSize * 10},
|
||||
{Mode::RecentlyAdded, batchSize * 10},
|
||||
{Mode::MostPlayed, batchSize * 10},
|
||||
{Mode::All, batchSize * 30},
|
||||
};
|
||||
|
||||
@@ -77,7 +78,7 @@ class Releases : public Wt::WTemplate
|
||||
Filters* _filters {};
|
||||
std::vector<Database::IdType> _randomReleases;
|
||||
Wt::WContainerWidget* _container {};
|
||||
Wt::WPushButton* _showMore {};
|
||||
Wt::WTemplate* _loadingIndicator {};
|
||||
};
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "resource/ImageResource.hpp"
|
||||
|
||||
#include "common/LoadingIndicator.hpp"
|
||||
#include "Filters.hpp"
|
||||
#include "LmsApplication.hpp"
|
||||
#include "MediaPlayer.hpp"
|
||||
@@ -83,9 +84,12 @@ _filters {filters}
|
||||
|
||||
_tracksContainer = bindNew<Wt::WContainerWidget>("tracks");
|
||||
|
||||
_showMore = bindNew<Wt::WPushButton>("show-more", Wt::WString::tr("Lms.Explore.show-more"));
|
||||
_showMore->clicked().connect([this]
|
||||
_loadingIndicator = bindWidget<Wt::WTemplate>("loading-indicator", createLoadingIndicator());
|
||||
_loadingIndicator->scrollVisibilityChanged().connect([this](bool visible)
|
||||
{
|
||||
if (!visible)
|
||||
return;
|
||||
|
||||
addSome();
|
||||
});
|
||||
|
||||
@@ -206,7 +210,7 @@ Tracks::addSome()
|
||||
_tracksContainer->addWidget(TrackListHelpers::createEntry(track));
|
||||
}
|
||||
|
||||
_showMore->setHidden(!moreResults);
|
||||
_loadingIndicator->setHidden(!moreResults);
|
||||
}
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include <optional>
|
||||
|
||||
#include <Wt/WContainerWidget.h>
|
||||
#include <Wt/WLineEdit.h>
|
||||
#include <Wt/WPushButton.h>
|
||||
#include <Wt/WTemplate.h>
|
||||
|
||||
#include "database/Types.hpp"
|
||||
@@ -78,8 +76,7 @@ class Tracks : public Wt::WTemplate
|
||||
Filters* _filters {};
|
||||
std::vector<Database::IdType> _randomTracks;
|
||||
Wt::WContainerWidget* _tracksContainer {};
|
||||
Wt::WPushButton* _showMore {};
|
||||
Wt::WLineEdit* _search {};
|
||||
Wt::WTemplate* _loadingIndicator {};
|
||||
};
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
Reference in New Issue
Block a user