| 110 | } |
| 111 | |
| 112 | SkinUploadDialog::SkinUploadDialog(MinecraftAccountPtr acct, QWidget *parent) |
| 113 | :QDialog(parent), m_acct(acct), ui(new Ui::SkinUploadDialog) |
| 114 | { |
| 115 | ui->setupUi(this); |
| 116 | |
| 117 | // FIXME: add a model for this, download/refresh the capes on demand |
| 118 | auto &data = *acct->accountData(); |
| 119 | int index = 0; |
| 120 | ui->capeCombo->addItem(tr("No Cape"), QVariant()); |
| 121 | auto currentCape = data.minecraftProfile.currentCape; |
| 122 | if(currentCape.isEmpty()) { |
| 123 | ui->capeCombo->setCurrentIndex(index); |
| 124 | } |
| 125 | |
| 126 | for(auto & cape: data.minecraftProfile.capes) { |
| 127 | index++; |
| 128 | if(cape.data.size()) { |
| 129 | QPixmap capeImage; |
| 130 | if(capeImage.loadFromData(cape.data, "PNG")) { |
| 131 | QPixmap preview = QPixmap(10, 16); |
| 132 | QPainter painter(&preview); |
| 133 | painter.drawPixmap(0, 0, capeImage.copy(1, 1, 10, 16)); |
| 134 | ui->capeCombo->addItem(capeImage, cape.alias, cape.id); |
| 135 | if(currentCape == cape.id) { |
| 136 | ui->capeCombo->setCurrentIndex(index); |
| 137 | } |
| 138 | continue; |
| 139 | } |
| 140 | } |
| 141 | ui->capeCombo->addItem(cape.alias, cape.id); |
| 142 | if(currentCape == cape.id) { |
| 143 | ui->capeCombo->setCurrentIndex(index); |
| 144 | } |
| 145 | } |
| 146 | } |
nothing calls this directly
no test coverage detected