aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2022-07-17 09:57:03 +0200
committerGitHub <noreply@github.com>2022-07-17 09:57:03 +0200
commit56085310cb066c7b3899684c3e3f39fe9fd311c4 (patch)
treeb05df5e0da273080ad5d69c6d9a024de78a10e6f
parentdce435c882b3370d04ff9c0af9e690a703007628 (diff)
parent4dfc01899a94ce365284ee1ba57c11afa823c55a (diff)
downloadPrismLauncher-56085310cb066c7b3899684c3e3f39fe9fd311c4.tar.gz
PrismLauncher-56085310cb066c7b3899684c3e3f39fe9fd311c4.tar.bz2
PrismLauncher-56085310cb066c7b3899684c3e3f39fe9fd311c4.zip
Merge pull request #913 from Gingeh/cape-without-skin
-rw-r--r--launcher/ui/dialogs/SkinUploadDialog.cpp90
-rw-r--r--launcher/ui/dialogs/SkinUploadDialog.ui6
2 files changed, 52 insertions, 44 deletions
diff --git a/launcher/ui/dialogs/SkinUploadDialog.cpp b/launcher/ui/dialogs/SkinUploadDialog.cpp
index b5b78690..8180ac1f 100644
--- a/launcher/ui/dialogs/SkinUploadDialog.cpp
+++ b/launcher/ui/dialogs/SkinUploadDialog.cpp
@@ -57,68 +57,72 @@ void SkinUploadDialog::on_buttonBox_accepted()
{
QString fileName;
QString input = ui->skinPathTextBox->text();
- QRegularExpression urlPrefixMatcher(QRegularExpression::anchoredPattern("^([a-z]+)://.+$"));
- bool isLocalFile = false;
- // it has an URL prefix -> it is an URL
- if(urlPrefixMatcher.match(input).hasMatch())
- {
- QUrl fileURL = input;
- if(fileURL.isValid())
+ ProgressDialog prog(this);
+ SequentialTask skinUpload;
+
+ if (!input.isEmpty()) {
+ QRegularExpression urlPrefixMatcher(QRegularExpression::anchoredPattern("^([a-z]+)://.+$"));
+ bool isLocalFile = false;
+ // it has an URL prefix -> it is an URL
+ if(urlPrefixMatcher.match(input).hasMatch())
{
- // local?
- if(fileURL.isLocalFile())
+ QUrl fileURL = input;
+ if(fileURL.isValid())
{
- isLocalFile = true;
- fileName = fileURL.toLocalFile();
+ // local?
+ 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
{
CustomMessageBox::selectable(
this,
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
- )->exec();
+ )->exec();
close();
return;
}
}
else
{
- CustomMessageBox::selectable(
- this,
- tr("Skin Upload"),
- tr("You cannot use an invalid URL for uploading skins."),
- QMessageBox::Warning
- )->exec();
+ // 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;
+ }
+ 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();
if(selectedCape != m_acct->accountData()->minecraftProfile.currentCape) {
skinUpload.addTask(shared_qobject_ptr<CapeChange>(new CapeChange(this, m_acct->accessToken(), selectedCape)));
diff --git a/launcher/ui/dialogs/SkinUploadDialog.ui b/launcher/ui/dialogs/SkinUploadDialog.ui
index f4b0ed0a..c7b16645 100644
--- a/launcher/ui/dialogs/SkinUploadDialog.ui
+++ b/launcher/ui/dialogs/SkinUploadDialog.ui
@@ -21,7 +21,11 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<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>
<widget class="QPushButton" name="skinBrowseBtn">