Skip to content

Commit

Permalink
feats: add entry for return in remote view
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonflylee committed Aug 31, 2024
1 parent a878f04 commit b57f6e5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [next]

### Fixed

* disable update notify when user caneled
* decode danmaku failed
* filter missing when sync option off
* auto selected external subtitles

## [0.5.1]

### Add
Expand Down
2 changes: 2 additions & 0 deletions app/include/tab/remote_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class RemoteView : public AttachedView {

void push(const std::string& path);

void dismiss(std::function<void(void)> cb = [] {}) override;

private:
BRLS_BIND(RecyclingGrid, recycler, "remote/list");

Expand Down
4 changes: 4 additions & 0 deletions app/src/client/local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ Local::Local(const std::string& path) { root = path; }

std::vector<DirEntry> Local::list(const std::string& path) {
std::vector<DirEntry> s;
s.push_back({
.name = "..",
.type = EntryType::DIR,
});
auto it = fs::directory_iterator(path);
for (const auto& fp : it) {
DirEntry item;
Expand Down
7 changes: 6 additions & 1 deletion app/src/client/webdav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ std::vector<DirEntry> Webdav::list(const std::string& path) {

respElem = respElem->NextSiblingElement((nsPrefix + "response").c_str());

if (item.path.compare(path)) s.push_back(item);
s.push_back(item);
}

if (s.size() > 0) {
s[0].name = "..";
}

return s;
}

Expand Down
31 changes: 22 additions & 9 deletions app/src/tab/remote_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class RemotePlayer : public brls::Box {
void setList(const DirList& list, size_t index, RemoteView::Client c) {
// 播放列表
DirList urls;
for (size_t i = 0; i < list.size(); i++) {
for (size_t i = 1; i < list.size(); i++) {
auto& it = list.at(i);
if (it.type == remote::EntryType::VIDEO) {
if (i == index) index = urls.size();
Expand Down Expand Up @@ -179,6 +179,11 @@ class FileDataSource : public RecyclingGridDataSource {

void onItemSelected(brls::Box* recycler, size_t index) override {
auto& item = this->list.at(index);
if (index == 0) {
recycler->getParent()->dismiss();
return;
}

if (item.type == remote::EntryType::DIR) {
auto* view = dynamic_cast<RemoteView*>(recycler->getParent());
if (view) view->push(item.path);
Expand All @@ -193,6 +198,10 @@ class FileDataSource : public RecyclingGridDataSource {
return;
}

if (item.type == remote::EntryType::IMAGE) {
return;
}

if (item.type == remote::EntryType::PLAYLIST) {
RemotePlayer* view = new RemotePlayer(item);
MPVCore::instance().setUrl(item.url.empty() ? item.path : item.url, client->extraOption());
Expand Down Expand Up @@ -220,14 +229,7 @@ brls::View* RemoteView::getDefaultFocus() { return this->recycler; }

void RemoteView::onCreate() {
this->recycler->registerAction("hints/back"_i18n, brls::BUTTON_B, [this](...) {
if (this->stack.size() > 1) {
this->stack.pop_back();
this->load();
} else if (brls::Application::getInputType() == brls::InputType::TOUCH) {
this->dismiss();
} else {
AutoTabFrame::focus2Sidebar(this);
}
this->dismiss();
return true;
});

Expand All @@ -242,6 +244,17 @@ void RemoteView::push(const std::string& path) {
this->load();
}

void RemoteView::dismiss(std::function<void(void)> cb) {
if (this->stack.size() > 1) {
this->stack.pop_back();
this->load();
} else if (brls::Application::getInputType() == brls::InputType::TOUCH) {
brls::View::dismiss();
} else {
AutoTabFrame::focus2Sidebar(this);
}
}

void RemoteView::load() {
this->recycler->showSkeleton();
ASYNC_RETAIN
Expand Down

0 comments on commit b57f6e5

Please sign in to comment.