Compare commits

...

4 Commits

5 changed files with 27 additions and 6 deletions

View File

@ -29,6 +29,7 @@ public:
private slots:
void loadRunes();
void reloadClientRunes();
void setRunesEnabled(bool enabled);
void saveRunePageClient(int id, QString name, const RunePage& rp);

View File

@ -254,7 +254,7 @@ bool ClientAPI::editRunePage(const RunePage& page) {
qInfo().noquote() << "requeststr: " << requestdocstr;
QJsonDocument doc = request("lol-perks/v1/pages/" + QString::number(page.id), Method::PUT, requestdocstr);
if(doc.isEmpty()) return true; // ok
if(doc.isObject() && doc["isValid"].isBool() && doc["isValid"].toBool()) return true; // ok
// error
qWarning() << "error editing runepage: " << page.id << " " << doc.toJson();
@ -281,7 +281,7 @@ bool ClientAPI::createRunePage(const RunePage& page) {
qInfo() << "requeststr: " << requestdocstr;
QJsonDocument doc = request("lol-perks/v1/pages/", Method::POST, requestdocstr);
if(doc.isEmpty()) return true; // ok
if(doc.isObject() && doc["isValid"].isBool() && doc["isValid"].toBool()) return true; // ok
// error
qWarning() << "error creating runepage: " << page.name << " " << doc.toJson();

View File

@ -177,12 +177,14 @@ const RunePage& RuneEditor::getRunepage() {
runepage.selectedAspects.clear();
runepage.selectedAspects.resize(9, 0);
uint_fast8_t index = 0;
for(const RuneAspektButtonGroup* group : groups) {
if(!group) continue;
const QVector<int>& selected = group->getSelectedRunes();
for(uint32_t i = 0; i < group->getSize(); ++i) {
runepage.selectedAspects.push_back(selected.at(i));
runepage.selectedAspects.at(index) = (selected.at(i));
++index;
}
}

View File

@ -83,8 +83,7 @@ void RuneManager::loadRunes() {
this->ui->listaaRunes->setRuneInfos(runeInfo, runeStyles);
// load runepages
const std::vector<ClientAPI::RunePage> runePages = client->getAllRunePages();
ui->listClientRunes->loadRunePages(runePages);
reloadClientRunes();
// reload runepages - so they ids can get their names
reloadAARunes();
@ -106,6 +105,13 @@ void RuneManager::loadRunes() {
this->ui->btnRetry->setEnabled(true);
}
void RuneManager::reloadClientRunes() {
if(client) {
const std::vector<ClientAPI::RunePage> runePages = client->getAllRunePages();
ui->listClientRunes->loadRunePages(runePages);
}
}
void RuneManager::setRunesEnabled(bool enabled) {
this->ui->lblClientRunes->setEnabled(enabled);
@ -131,6 +137,7 @@ void RuneManager::saveRunePageClient(int id, QString name, const RunePage& rp) {
// TODO: some error occured
}
}
reloadClientRunes();
} catch(RestClient::WebException& e) {
qCritical() << "webexception: " << e.curlresponse;

View File

@ -8,6 +8,7 @@
#include <QTextStream>
#include "clipboardpopup.h"
#include "loadingwindow.h"
#include "runeeditor.h"
RunePageList::RunePageList(QWidget* parent) : QListWidget(parent), ui(new Ui::RunePageList) {
@ -106,12 +107,22 @@ void RunePageList::editCurrentItem() {
RunePage* rp = (RunePage*) item->data(RolePointer).toULongLong();
const uint32_t id = item->data(RoleId).toUInt();
RuneEditor re;
LoadingWindow lw;
lw.setText(RunePageList::tr("Loading runes"));
lw.setProgress(0.5f);
lw.show();
// make sure the Loading window is rendered
QApplication::processEvents();
RuneEditor re;
re.setName(item->text());
QApplication::processEvents();
re.setClient(*client);
QApplication::processEvents();
re.setRunepage(*rp);
lw.close();
int result = re.exec();
// check result - save