Tooltip for champrows

This commit is contained in:
mrbesen 2022-08-28 01:43:14 +02:00
parent 71853c65d6
commit 226c031ecf
Signed by untrusted user: MrBesen
GPG Key ID: 596B2350DCD67504
7 changed files with 44 additions and 12 deletions

View File

@ -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();

View File

@ -36,7 +36,7 @@ public:
void setChampions(const std::vector<std::string>& 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);

View File

@ -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<const DataDragon::ChampData*> 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);
});
}

View File

@ -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 {

View File

@ -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();
}

View File

@ -109,6 +109,20 @@
<translation>Auto-Acceptor fehlgeschlagen!</translation>
</message>
</context>
<context>
<name>QWidget</name>
<message>
<location filename="../src/champrow.cpp" line="16"/>
<source>Champion: %1
Type: %2
Title: %3
ID: %4</source>
<translation>Champion: %1
Typ: %2
Titel: %3
ID: %4</translation>
</message>
</context>
<context>
<name>RuneDisplay</name>
<message>

View File

@ -109,6 +109,20 @@
<translation>Auto-Acceptor failed!</translation>
</message>
</context>
<context>
<name>QWidget</name>
<message>
<location filename="../src/champrow.cpp" line="16"/>
<source>Champion: %1
Type: %2
Title: %3
ID: %4</source>
<translation>Champion: %1
Type: %2
Title: %3
ID: %4</translation>
</message>
</context>
<context>
<name>RuneDisplay</name>
<message>