From 226c031ecf5223b4dbd8055cdb35b52091ca9189 Mon Sep 17 00:00:00 2001 From: mrbesen Date: Sun, 28 Aug 2022 01:43:14 +0200 Subject: [PATCH] Tooltip for champrows --- include/champrow.h | 2 +- include/stagesettings.h | 2 +- src/championsearch.cpp | 8 ++++---- src/champrow.cpp | 10 +++++++--- src/stagesettings.cpp | 6 +++--- ts/de_DE.ts | 14 ++++++++++++++ ts/en.ts | 14 ++++++++++++++ 7 files changed, 44 insertions(+), 12 deletions(-) diff --git a/include/champrow.h b/include/champrow.h index d3c2530..d5497a7 100644 --- a/include/champrow.h +++ b/include/champrow.h @@ -10,7 +10,7 @@ public: explicit ChampRow(QListWidget *parent = nullptr); ~ChampRow(); - void setChamp(const std::string& name, uint32_t id, QPixmap icon); + void setChamp(const DataDragon::ChampData& cd, QPixmap icon); QString getChamp() const; uint32_t getChampID() const; QPixmap getIcon(); diff --git a/include/stagesettings.h b/include/stagesettings.h index 77c5a96..4b233d1 100644 --- a/include/stagesettings.h +++ b/include/stagesettings.h @@ -36,7 +36,7 @@ public: void setChampions(const std::vector& champs); void setDataDragon(DataDragon* dd); - void addChamp(const std::string& champname, uint32_t id, QPixmap icon); + void addChamp(const DataDragon::ChampData& cd, QPixmap icon); void loadConfig(Config::StageConfig& c); diff --git a/src/championsearch.cpp b/src/championsearch.cpp index 7b80399..4148353 100644 --- a/src/championsearch.cpp +++ b/src/championsearch.cpp @@ -22,15 +22,15 @@ ChampRow* ChampionSearch::getSearchResult() { void ChampionSearch::searchChanged(QString str) { Log::info << "champion search: " << str.toStdString(); - auto champs = dd->getMatchingChamp(str.toStdString()); + const std::vector champs = dd->getMatchingChamp(str.toStdString()); Log::info << "found " << champs.size() << " champs"; clear(); - for(auto it : champs) { - dd->getImageAsnyc(it->id, [this, it](QPixmap img) { + for(auto cd : champs) { + dd->getImageAsnyc(cd->id, [this, cd](QPixmap img) { auto cr = new ChampRow(); - cr->setChamp(it->name, it->key, img); + cr->setChamp(*cd, img); ui->championList->addItem(cr); }); } diff --git a/src/champrow.cpp b/src/champrow.cpp index a3d7d90..c3810b3 100644 --- a/src/champrow.cpp +++ b/src/champrow.cpp @@ -6,11 +6,15 @@ ChampRow::ChampRow(QListWidget* parent) : QListWidgetItem(parent) { ChampRow::~ChampRow() { } -void ChampRow::setChamp(const std::string& name, uint32_t id, QPixmap icon) { - setText(QString::fromStdString(name)); - champid = id; +void ChampRow::setChamp(const DataDragon::ChampData& cd, QPixmap icon) { + setText(QString::fromStdString(cd.name)); + champid = cd.key; this->icon = icon; setIcon(QIcon(icon)); + + #define QS(A) arg(QString::fromStdString(A)) + setToolTip(QWidget::tr("Champion: %1\nType: %2\nTitle: %3\nID: %4").QS(cd.name).QS(cd.partype).QS(cd.title).arg(cd.key)); + #undef QS } QString ChampRow::getChamp() const { diff --git a/src/stagesettings.cpp b/src/stagesettings.cpp index 4593ae5..698914a 100644 --- a/src/stagesettings.cpp +++ b/src/stagesettings.cpp @@ -60,11 +60,11 @@ void StageSettings::setDataDragon(DataDragon* dd_) { dd = dd_; } -void StageSettings::addChamp(const std::string& champname, uint32_t id, QPixmap icon) { +void StageSettings::addChamp(const DataDragon::ChampData& cd, QPixmap icon) { auto champr = new ChampRow(); ui->championList->addItem(champr); - champr->setChamp(champname, id, icon); + champr->setChamp(cd, icon); } void StageSettings::loadConfig(Config::StageConfig& c) { @@ -112,7 +112,7 @@ void StageSettings::resolveAndAddChamp(const std::string& name, bool emitchange) auto cd = dd->getBestMatchingChamp(name, &count); dd->getImageAsnyc(cd.id, [this, name, cd, emitchange](QPixmap img) { - addChamp(name, cd.key, img); + addChamp(cd, img); if(emitchange) { emit championsChanged(); } diff --git a/ts/de_DE.ts b/ts/de_DE.ts index 7a10499..5a0f2cc 100644 --- a/ts/de_DE.ts +++ b/ts/de_DE.ts @@ -109,6 +109,20 @@ Auto-Acceptor fehlgeschlagen! + + QWidget + + + Champion: %1 +Type: %2 +Title: %3 +ID: %4 + Champion: %1 +Typ: %2 +Titel: %3 +ID: %4 + + RuneDisplay diff --git a/ts/en.ts b/ts/en.ts index e766304..5a53ad6 100644 --- a/ts/en.ts +++ b/ts/en.ts @@ -109,6 +109,20 @@ Auto-Acceptor failed! + + QWidget + + + Champion: %1 +Type: %2 +Title: %3 +ID: %4 + Champion: %1 +Type: %2 +Title: %3 +ID: %4 + + RuneDisplay