2021-07-23 08:24:00 +01:00
|
|
|
/*
|
|
|
|
* options_tab.hpp
|
|
|
|
*
|
2023-04-08 12:42:22 +01:00
|
|
|
* Copyright (c) 2020-2023, DarkMatterCore <pabloacurielz@gmail.com>.
|
2021-07-23 08:24:00 +01:00
|
|
|
*
|
|
|
|
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
|
|
|
|
*
|
|
|
|
* nxdumptool 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.
|
|
|
|
*
|
|
|
|
* nxdumptool 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifndef __OPTIONS_TAB_HPP__
|
|
|
|
#define __OPTIONS_TAB_HPP__
|
|
|
|
|
|
|
|
#include <borealis.hpp>
|
|
|
|
|
2021-08-11 08:17:57 +01:00
|
|
|
#include "root_view.hpp"
|
2021-07-29 08:50:17 +01:00
|
|
|
|
2021-07-23 08:24:00 +01:00
|
|
|
namespace nxdt::views
|
|
|
|
{
|
2021-08-07 09:42:03 +01:00
|
|
|
/* Used in OptionsTabUpdateFileDialog and OptionsTabUpdateApplicationFrame to display the update progress. */
|
|
|
|
class OptionsTabUpdateProgress: public brls::View
|
2021-07-29 08:50:17 +01:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
brls::ProgressDisplay *progress_display = nullptr;
|
2021-08-07 09:42:03 +01:00
|
|
|
brls::Label *size_lbl = nullptr, *speed_eta_lbl = nullptr;
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-07-29 08:50:17 +01:00
|
|
|
std::string GetFormattedSizeString(double size);
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-07-29 08:50:17 +01:00
|
|
|
protected:
|
|
|
|
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;
|
|
|
|
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-07-29 08:50:17 +01:00
|
|
|
public:
|
2021-08-07 09:42:03 +01:00
|
|
|
OptionsTabUpdateProgress(void);
|
|
|
|
~OptionsTabUpdateProgress(void);
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-07-29 08:50:17 +01:00
|
|
|
void SetProgress(const nxdt::tasks::DownloadTaskProgress& progress);
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-07-29 08:50:17 +01:00
|
|
|
void willAppear(bool resetState = false) override;
|
|
|
|
void willDisappear(bool resetState = false) override;
|
|
|
|
};
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-07-29 08:50:17 +01:00
|
|
|
/* Update file dialog. */
|
|
|
|
class OptionsTabUpdateFileDialog: public brls::Dialog
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
nxdt::tasks::DownloadFileTask download_task;
|
|
|
|
std::string success_str;
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-07-29 08:50:17 +01:00
|
|
|
public:
|
|
|
|
OptionsTabUpdateFileDialog(std::string path, std::string url, bool force_https, std::string success_str);
|
2021-08-07 09:42:03 +01:00
|
|
|
};
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-08-07 09:42:03 +01:00
|
|
|
/* Update application frame. */
|
|
|
|
class OptionsTabUpdateApplicationFrame: public brls::StagedAppletFrame
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
nxdt::tasks::DownloadDataTask json_task;
|
|
|
|
char *json_buf = NULL;
|
|
|
|
size_t json_buf_size = 0;
|
|
|
|
UtilsGitHubReleaseJsonData json_data = {0};
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2022-07-14 11:28:40 +01:00
|
|
|
brls::Label *wait_lbl = nullptr; /// First stage.
|
2021-08-07 09:42:03 +01:00
|
|
|
brls::List *changelog_list = nullptr; /// Second stage.
|
|
|
|
OptionsTabUpdateProgress *update_progress = nullptr; /// Third stage.
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-08-07 09:42:03 +01:00
|
|
|
nxdt::tasks::DownloadFileTask nro_task;
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-08-07 09:42:03 +01:00
|
|
|
void DisplayChangelog(void);
|
|
|
|
void DisplayUpdateProgress(void);
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-08-07 09:42:03 +01:00
|
|
|
protected:
|
|
|
|
void layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) override;
|
2021-07-29 08:50:17 +01:00
|
|
|
bool onCancel(void) override;
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-08-07 09:42:03 +01:00
|
|
|
public:
|
|
|
|
OptionsTabUpdateApplicationFrame(void);
|
|
|
|
~OptionsTabUpdateApplicationFrame(void);
|
2021-07-29 08:50:17 +01:00
|
|
|
};
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-07-23 08:24:00 +01:00
|
|
|
class OptionsTab: public brls::List
|
|
|
|
{
|
2021-07-25 06:37:13 +01:00
|
|
|
private:
|
2021-08-11 08:17:57 +01:00
|
|
|
RootView *root_view = nullptr;
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-07-25 06:37:13 +01:00
|
|
|
bool display_notification = true;
|
|
|
|
brls::menu_timer_t notification_timer = 0.0f;
|
|
|
|
brls::menu_timer_ctx_entry_t notification_timer_ctx = {0};
|
2022-07-05 02:04:28 +01:00
|
|
|
|
2021-07-25 06:37:13 +01:00
|
|
|
void DisplayNotification(std::string str);
|
2021-07-23 08:24:00 +01:00
|
|
|
public:
|
2021-08-11 08:17:57 +01:00
|
|
|
OptionsTab(RootView *root_view);
|
2021-07-25 06:37:13 +01:00
|
|
|
~OptionsTab(void);
|
2021-07-23 08:24:00 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __OPTIONS_TAB_HPP__ */
|