mirror of
https://github.com/rock88/moonlight-nx
synced 2024-11-10 06:14:15 +00:00
Fix clean_container func
This commit is contained in:
parent
aba1576fb8
commit
ce1ded332c
5 changed files with 4 additions and 20 deletions
|
@ -12,12 +12,7 @@ AppListWindow::AppListWindow(Widget *parent, const std::string &address): Conten
|
|||
}
|
||||
|
||||
void AppListWindow::window_appear() {
|
||||
for (auto button: m_app_buttons) {
|
||||
if (container()->child_index(button) != -1) {
|
||||
container()->remove_child(button);
|
||||
}
|
||||
}
|
||||
m_app_buttons.clear();
|
||||
clean_container();
|
||||
|
||||
auto loader = add<LoadingOverlay>();
|
||||
|
||||
|
@ -30,7 +25,6 @@ void AppListWindow::window_appear() {
|
|||
|
||||
while (app != NULL) {
|
||||
auto button = container()->add<AppButton>(m_address, *app, currentGame);
|
||||
m_app_buttons.push_back(button);
|
||||
button->set_callback([this, app] {
|
||||
run_game(app->id);
|
||||
});
|
||||
|
|
|
@ -13,5 +13,4 @@ public:
|
|||
private:
|
||||
std::string m_address;
|
||||
PAPP_LIST m_app_list;
|
||||
std::vector<nanogui::Widget *> m_app_buttons;
|
||||
};
|
||||
|
|
|
@ -25,7 +25,8 @@ public:
|
|||
}
|
||||
|
||||
void clean_container() {
|
||||
for (auto child: m_container->children()) {
|
||||
auto children = m_container->children();
|
||||
for (auto child: children) {
|
||||
if (m_container->child_index(child) != -1) {
|
||||
m_container->remove_child(child);
|
||||
}
|
||||
|
|
|
@ -16,19 +16,13 @@ LogsWindow::LogsWindow(Widget *parent): ContentWindow(parent, "Logs") {
|
|||
}
|
||||
|
||||
void LogsWindow::reload() {
|
||||
for (auto label: m_labels) {
|
||||
if (container()->child_index(label) != -1) {
|
||||
container()->remove_child(label);
|
||||
}
|
||||
}
|
||||
m_labels.clear();
|
||||
clean_container();
|
||||
|
||||
Data data = Data::read_from_file(Settings::settings()->log_path());
|
||||
|
||||
if (data.is_empty()) {
|
||||
auto label = container()->add<Label>("No logs...");
|
||||
label->set_fixed_width(container()->width());
|
||||
m_labels.push_back(label);
|
||||
} else {
|
||||
std::stringstream stream((char *)data.bytes());
|
||||
std::string string;
|
||||
|
@ -50,7 +44,6 @@ void LogsWindow::reload() {
|
|||
for (auto log: logs) {
|
||||
auto label = container()->add<Label>(log);
|
||||
label->set_selectable(true);
|
||||
m_labels.push_back(label);
|
||||
}
|
||||
}
|
||||
perform_layout();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "ContentWindow.hpp"
|
||||
#include <vector>
|
||||
#pragma once
|
||||
|
||||
class LogsWindow: public ContentWindow {
|
||||
|
@ -8,6 +7,4 @@ public:
|
|||
|
||||
private:
|
||||
void reload();
|
||||
|
||||
std::vector<nanogui::Widget *> m_labels;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue