aboutsummaryrefslogtreecommitdiff
path: root/launcher/dialogs
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2021-08-20 01:34:32 +0200
committerPetr Mrázek <peterix@gmail.com>2021-08-20 01:34:32 +0200
commit1b68d51da634ddab39fe872fcc28a4f491c0c8a4 (patch)
tree9a22465d682018830635a8929eab3cc8482b1faa /launcher/dialogs
parent94fd9a3535ae9a55c228720858292ed2bb69ff98 (diff)
downloadPrismLauncher-1b68d51da634ddab39fe872fcc28a4f491c0c8a4.tar.gz
PrismLauncher-1b68d51da634ddab39fe872fcc28a4f491c0c8a4.tar.bz2
PrismLauncher-1b68d51da634ddab39fe872fcc28a4f491c0c8a4.zip
NOISSUE add setting capes, tweak missing profile message, fix cape IDs
Diffstat (limited to 'launcher/dialogs')
-rw-r--r--launcher/dialogs/LoginDialog.cpp12
-rw-r--r--launcher/dialogs/MSALoginDialog.cpp12
-rw-r--r--launcher/dialogs/MSALoginDialog.ui10
-rw-r--r--launcher/dialogs/SkinUploadDialog.cpp44
-rw-r--r--launcher/dialogs/SkinUploadDialog.ui170
5 files changed, 161 insertions, 87 deletions
diff --git a/launcher/dialogs/LoginDialog.cpp b/launcher/dialogs/LoginDialog.cpp
index 1dee9920..b1ca2c88 100644
--- a/launcher/dialogs/LoginDialog.cpp
+++ b/launcher/dialogs/LoginDialog.cpp
@@ -73,7 +73,17 @@ void LoginDialog::on_passTextBox_textEdited(const QString &newText)
void LoginDialog::onTaskFailed(const QString &reason)
{
// Set message
- ui->label->setText("<span style='color:red'>" + reason + "</span>");
+ auto lines = reason.split('\n');
+ QString processed;
+ for(auto line: lines) {
+ if(line.size()) {
+ processed += "<font color='red'>" + line + "</font>\n";
+ }
+ else {
+ processed += '\n';
+ }
+ }
+ ui->label->setText(processed);
// Re-enable user-interaction
setUserInputsEnabled(true);
diff --git a/launcher/dialogs/MSALoginDialog.cpp b/launcher/dialogs/MSALoginDialog.cpp
index 778b379d..86ebdf91 100644
--- a/launcher/dialogs/MSALoginDialog.cpp
+++ b/launcher/dialogs/MSALoginDialog.cpp
@@ -60,7 +60,17 @@ void MSALoginDialog::setUserInputsEnabled(bool enable)
void MSALoginDialog::onTaskFailed(const QString &reason)
{
// Set message
- ui->label->setText("<span style='color:red'>" + reason + "</span>");
+ auto lines = reason.split('\n');
+ QString processed;
+ for(auto line: lines) {
+ if(line.size()) {
+ processed += "<font color='red'>" + line + "</font>\n";
+ }
+ else {
+ processed += '\n';
+ }
+ }
+ ui->label->setText(processed);
// Re-enable user-interaction
setUserInputsEnabled(true);
diff --git a/launcher/dialogs/MSALoginDialog.ui b/launcher/dialogs/MSALoginDialog.ui
index 4ae8085a..5479a726 100644
--- a/launcher/dialogs/MSALoginDialog.ui
+++ b/launcher/dialogs/MSALoginDialog.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>421</width>
- <height>114</height>
+ <width>491</width>
+ <height>143</height>
</rect>
</property>
<property name="sizePolicy">
@@ -23,10 +23,12 @@
<item>
<widget class="QLabel" name="label">
<property name="text">
- <string notr="true">Message label placeholder.</string>
+ <string notr="true">Message label placeholder.
+
+aaaaa</string>
</property>
<property name="textFormat">
- <enum>Qt::RichText</enum>
+ <enum>Qt::MarkdownText</enum>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
diff --git a/launcher/dialogs/SkinUploadDialog.cpp b/launcher/dialogs/SkinUploadDialog.cpp
index 19bfac4d..97478f4b 100644
--- a/launcher/dialogs/SkinUploadDialog.cpp
+++ b/launcher/dialogs/SkinUploadDialog.cpp
@@ -1,11 +1,16 @@
#include <QFileInfo>
#include <QFileDialog>
+#include <QPainter>
+
#include <FileSystem.h>
#include <minecraft/services/SkinUpload.h>
+#include <tasks/SequentialTask.h>
+
#include "SkinUploadDialog.h"
#include "ui_SkinUploadDialog.h"
#include "ProgressDialog.h"
#include "CustomMessageBox.h"
+#include <minecraft/services/CapeChange.h>
void SkinUploadDialog::on_buttonBox_rejected()
{
@@ -85,8 +90,13 @@ void SkinUploadDialog::on_buttonBox_accepted()
{
model = SkinUpload::ALEX;
}
- SkinUploadPtr upload = std::make_shared<SkinUpload>(this, session, FS::read(fileName), model);
- if (prog.execWithTask((Task*)upload.get()) != QDialog::Accepted)
+ SequentialTask skinUpload;
+ skinUpload.addTask(std::make_shared<SkinUpload>(this, session, FS::read(fileName), model));
+ auto selectedCape = ui->capeCombo->currentData().toString();
+ if(selectedCape != session->m_accountPtr->accountData()->minecraftProfile.currentCape) {
+ skinUpload.addTask(std::make_shared<CapeChange>(this, session, selectedCape));
+ }
+ if (prog.execWithTask(&skinUpload) != QDialog::Accepted)
{
CustomMessageBox::selectable(this, tr("Skin Upload"), tr("Failed to upload skin!"), QMessageBox::Warning)->exec();
close();
@@ -111,4 +121,34 @@ SkinUploadDialog::SkinUploadDialog(MinecraftAccountPtr acct, QWidget *parent)
:QDialog(parent), m_acct(acct), ui(new Ui::SkinUploadDialog)
{
ui->setupUi(this);
+
+ // FIXME: add a model for this, download/refresh the capes on demand
+ auto &data = *acct->accountData();
+ int index = 0;
+ ui->capeCombo->addItem(tr("No Cape"), QVariant());
+ auto currentCape = data.minecraftProfile.currentCape;
+ if(currentCape.isEmpty()) {
+ ui->capeCombo->setCurrentIndex(index);
+ }
+
+ for(auto & cape: data.minecraftProfile.capes) {
+ index++;
+ if(cape.data.size()) {
+ QPixmap capeImage;
+ if(capeImage.loadFromData(cape.data, "PNG")) {
+ QPixmap preview = QPixmap(10, 16);
+ QPainter painter(&preview);
+ painter.drawPixmap(0, 0, capeImage.copy(1, 1, 10, 16));
+ ui->capeCombo->addItem(capeImage, cape.alias, cape.id);
+ if(currentCape == cape.id) {
+ ui->capeCombo->setCurrentIndex(index);
+ }
+ continue;
+ }
+ }
+ ui->capeCombo->addItem(cape.alias, cape.id);
+ if(currentCape == cape.id) {
+ ui->capeCombo->setCurrentIndex(index);
+ }
+ }
}
diff --git a/launcher/dialogs/SkinUploadDialog.ui b/launcher/dialogs/SkinUploadDialog.ui
index 6f5307e3..f4b0ed0a 100644
--- a/launcher/dialogs/SkinUploadDialog.ui
+++ b/launcher/dialogs/SkinUploadDialog.ui
@@ -1,85 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>SkinUploadDialog</class>
- <widget class="QDialog" name="SkinUploadDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>413</width>
- <height>300</height>
- </rect>
+ <class>SkinUploadDialog</class>
+ <widget class="QDialog" name="SkinUploadDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>394</width>
+ <height>360</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Skin Upload</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="fileBox">
+ <property name="title">
+ <string>Skin File</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="skinPathTextBox"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="skinBrowseBtn">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="windowTitle">
- <string>Skin Upload</string>
+ <property name="maximumSize">
+ <size>
+ <width>28</width>
+ <height>16777215</height>
+ </size>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QGroupBox" name="fileBox">
- <property name="title">
- <string>Skin File</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLineEdit" name="skinPathTextBox"/>
- </item>
- <item>
- <widget class="QPushButton" name="skinBrowseBtn">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="maximumSize">
- <size>
- <width>28</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string notr="true">...</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="modelBox">
- <property name="title">
- <string>Player Model</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_1">
- <item>
- <widget class="QRadioButton" name="steveBtn">
- <property name="text">
- <string>Steve Model</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="alexBtn">
- <property name="text">
- <string>Alex Model</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
+ <property name="text">
+ <string notr="true">...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="modelBox">
+ <property name="title">
+ <string>Player Model</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_1">
+ <item>
+ <widget class="QRadioButton" name="steveBtn">
+ <property name="text">
+ <string>Steve Model</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="alexBtn">
+ <property name="text">
+ <string>Alex Model</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="capeBox">
+ <property name="title">
+ <string>Cape</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QComboBox" name="capeCombo"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
</widget>
- <resources/>
- <connections/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
</ui>