Progress: 25%.
This commit is contained in:
commit
2fd0d6d3d4
1 changed files with 917 additions and 0 deletions
69
mainscreen.h
Normal file
69
mainscreen.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#ifndef MAINSCREEN_H
|
||||
#define MAINSCREEN_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
#include <QUrlQuery>
|
||||
#include <ftxui/ftxui.hpp>
|
||||
#include <expected>
|
||||
#include <filesystem>
|
||||
#include <ftxui/component/component.hpp>
|
||||
#include <ftxui/component/screen_interactive.hpp>
|
||||
#include <ftxui/dom/elements.hpp>
|
||||
#include "torrentsession.h"
|
||||
|
||||
|
||||
|
||||
struct SearchItem {
|
||||
QString title;
|
||||
QUrl url;
|
||||
QString size;
|
||||
QString seeders;
|
||||
QString leechers;
|
||||
QString downloads;
|
||||
QString timestamp;
|
||||
QString magnet;
|
||||
void printData();
|
||||
};
|
||||
|
||||
class MainScreen : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class Tags {
|
||||
public:
|
||||
Tags() = delete;
|
||||
static std::string getTag(std::string file_name, std::string key);
|
||||
static void setTag(std::string file_name, std::string key, std::string value);
|
||||
static std::unordered_map<std::string, std::string> getAllTags(std::string file_name);
|
||||
|
||||
private:
|
||||
static QByteArray readFile(std::string file_name);
|
||||
static bool writeFile(std::string file_name, QByteArray data);
|
||||
};
|
||||
|
||||
QNetworkAccessManager *manager = nullptr;
|
||||
std::string tags_file_path = "";
|
||||
public:
|
||||
explicit MainScreen(std::string search_term = "", QObject *parent = nullptr);
|
||||
signals:
|
||||
private:
|
||||
void renderSearchPage(std::string search_term);
|
||||
void renderHomePage();
|
||||
std::vector<SearchItem> parseSearchPage(std::string html_page);
|
||||
std::vector<std::string> getStringEntries(std::vector<SearchItem> res);
|
||||
int displaySearchMenu(std::vector<SearchItem> res);
|
||||
int startDownloadIndex(std::vector<SearchItem> res, int index);
|
||||
std::expected<std::string,int> runBasicShell(SearchItem it);
|
||||
std::string stripForArgument(std::string command, int index);
|
||||
private slots:
|
||||
void renderSearchPage_(QNetworkReply *rep);
|
||||
};
|
||||
|
||||
#endif // MAINSCREEN_H
|
||||
Loading…
Reference in a new issue