Merge pull request #913 from Gingeh/cape-without-skin
This commit is contained in:
commit
56085310cb
@ -57,68 +57,72 @@ void SkinUploadDialog::on_buttonBox_accepted()
|
|||||||
{
|
{
|
||||||
QString fileName;
|
QString fileName;
|
||||||
QString input = ui->skinPathTextBox->text();
|
QString input = ui->skinPathTextBox->text();
|
||||||
QRegularExpression urlPrefixMatcher(QRegularExpression::anchoredPattern("^([a-z]+)://.+$"));
|
ProgressDialog prog(this);
|
||||||
bool isLocalFile = false;
|
SequentialTask skinUpload;
|
||||||
// it has an URL prefix -> it is an URL
|
|
||||||
if(urlPrefixMatcher.match(input).hasMatch())
|
if (!input.isEmpty()) {
|
||||||
{
|
QRegularExpression urlPrefixMatcher(QRegularExpression::anchoredPattern("^([a-z]+)://.+$"));
|
||||||
QUrl fileURL = input;
|
bool isLocalFile = false;
|
||||||
if(fileURL.isValid())
|
// it has an URL prefix -> it is an URL
|
||||||
|
if(urlPrefixMatcher.match(input).hasMatch())
|
||||||
{
|
{
|
||||||
// local?
|
QUrl fileURL = input;
|
||||||
if(fileURL.isLocalFile())
|
if(fileURL.isValid())
|
||||||
{
|
{
|
||||||
isLocalFile = true;
|
// local?
|
||||||
fileName = fileURL.toLocalFile();
|
if(fileURL.isLocalFile())
|
||||||
|
{
|
||||||
|
isLocalFile = true;
|
||||||
|
fileName = fileURL.toLocalFile();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CustomMessageBox::selectable(
|
||||||
|
this,
|
||||||
|
tr("Skin Upload"),
|
||||||
|
tr("Using remote URLs for setting skins is not implemented yet."),
|
||||||
|
QMessageBox::Warning
|
||||||
|
)->exec();
|
||||||
|
close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CustomMessageBox::selectable(
|
CustomMessageBox::selectable(
|
||||||
this,
|
this,
|
||||||
tr("Skin Upload"),
|
tr("Skin Upload"),
|
||||||
tr("Using remote URLs for setting skins is not implemented yet."),
|
tr("You cannot use an invalid URL for uploading skins."),
|
||||||
QMessageBox::Warning
|
QMessageBox::Warning
|
||||||
)->exec();
|
)->exec();
|
||||||
close();
|
close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CustomMessageBox::selectable(
|
// just assume it's a path then
|
||||||
this,
|
isLocalFile = true;
|
||||||
tr("Skin Upload"),
|
fileName = ui->skinPathTextBox->text();
|
||||||
tr("You cannot use an invalid URL for uploading skins."),
|
}
|
||||||
QMessageBox::Warning
|
if (isLocalFile && !QFile::exists(fileName))
|
||||||
)->exec();
|
{
|
||||||
|
CustomMessageBox::selectable(this, tr("Skin Upload"), tr("Skin file does not exist!"), QMessageBox::Warning)->exec();
|
||||||
close();
|
close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
SkinUpload::Model model = SkinUpload::STEVE;
|
||||||
|
if (ui->steveBtn->isChecked())
|
||||||
|
{
|
||||||
|
model = SkinUpload::STEVE;
|
||||||
|
}
|
||||||
|
else if (ui->alexBtn->isChecked())
|
||||||
|
{
|
||||||
|
model = SkinUpload::ALEX;
|
||||||
|
}
|
||||||
|
skinUpload.addTask(shared_qobject_ptr<SkinUpload>(new SkinUpload(this, m_acct->accessToken(), FS::read(fileName), model)));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// just assume it's a path then
|
|
||||||
isLocalFile = true;
|
|
||||||
fileName = ui->skinPathTextBox->text();
|
|
||||||
}
|
|
||||||
if (isLocalFile && !QFile::exists(fileName))
|
|
||||||
{
|
|
||||||
CustomMessageBox::selectable(this, tr("Skin Upload"), tr("Skin file does not exist!"), QMessageBox::Warning)->exec();
|
|
||||||
close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SkinUpload::Model model = SkinUpload::STEVE;
|
|
||||||
if (ui->steveBtn->isChecked())
|
|
||||||
{
|
|
||||||
model = SkinUpload::STEVE;
|
|
||||||
}
|
|
||||||
else if (ui->alexBtn->isChecked())
|
|
||||||
{
|
|
||||||
model = SkinUpload::ALEX;
|
|
||||||
}
|
|
||||||
ProgressDialog prog(this);
|
|
||||||
SequentialTask skinUpload;
|
|
||||||
skinUpload.addTask(shared_qobject_ptr<SkinUpload>(new SkinUpload(this, m_acct->accessToken(), FS::read(fileName), model)));
|
|
||||||
auto selectedCape = ui->capeCombo->currentData().toString();
|
auto selectedCape = ui->capeCombo->currentData().toString();
|
||||||
if(selectedCape != m_acct->accountData()->minecraftProfile.currentCape) {
|
if(selectedCape != m_acct->accountData()->minecraftProfile.currentCape) {
|
||||||
skinUpload.addTask(shared_qobject_ptr<CapeChange>(new CapeChange(this, m_acct->accessToken(), selectedCape)));
|
skinUpload.addTask(shared_qobject_ptr<CapeChange>(new CapeChange(this, m_acct->accessToken(), selectedCape)));
|
||||||
|
@ -21,7 +21,11 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="skinPathTextBox"/>
|
<widget class="QLineEdit" name="skinPathTextBox">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Leave empty to keep current skin</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="skinBrowseBtn">
|
<widget class="QPushButton" name="skinBrowseBtn">
|
||||||
|
Loading…
Reference in New Issue
Block a user