generated from WerWolv/Tesla-Template
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgui_main.cpp
More file actions
61 lines (50 loc) · 1.68 KB
/
gui_main.cpp
File metadata and controls
61 lines (50 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Copyright (c) 2020 Behemoth
*
* This file is part of ShareNX.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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 <http://www.gnu.org/licenses/>.
*/
#include "gui_main.hpp"
#include <string>
#include "elm_qr.hpp"
#include "gui_error.hpp"
#include "upload.hpp"
MainGui::MainGui(const CapsAlbumFileId &file_id, const u8 *rgba_buffer)
: fileId(file_id) {
img = new ImageItem(file_id, rgba_buffer);
}
MainGui::~MainGui() {}
tsl::elm::Element *MainGui::createUI() {
auto rootFrame = new tsl::elm::OverlayFrame("ShareNX \uE134", VERSION);
auto list = new tsl::elm::List();
list->addItem(this->img);
auto qr = new ElmQr();
auto button = new tsl::elm::ListItem("Upload");
button->setClickListener([this, qr](u64 keys) {
if (keys & HidNpadButton_A && !this->uploaded) {
auto [result, url] = web::UploadImage(this->fileId);
this->uploaded = true;
this->img->setUrl(url);
if (result) {
qr->generateQrCode(url);
}
return true;
}
return false;
});
list->addItem(button);
list->addItem(qr);
rootFrame->setContent(list);
return rootFrame;
}