MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / on_buttonBox_accepted

Method on_buttonBox_accepted

launcher/ui/dialogs/SkinUploadDialog.cpp:56–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void SkinUploadDialog::on_buttonBox_accepted()
57{
58 QString fileName;
59 QString input = ui->skinPathTextBox->text();
60 ProgressDialog prog(this);
61 SequentialTask skinUpload;
62
63 if (!input.isEmpty()) {
64 QRegularExpression urlPrefixMatcher(QRegularExpression::anchoredPattern("^([a-z]+)://.+$"));
65 bool isLocalFile = false;
66 // it has an URL prefix -> it is an URL
67 if(urlPrefixMatcher.match(input).hasMatch())
68 {
69 QUrl fileURL = input;
70 if(fileURL.isValid())
71 {
72 // local?
73 if(fileURL.isLocalFile())
74 {
75 isLocalFile = true;
76 fileName = fileURL.toLocalFile();
77 }
78 else
79 {
80 CustomMessageBox::selectable(
81 this,
82 tr("Skin Upload"),
83 tr("Using remote URLs for setting skins is not implemented yet."),
84 QMessageBox::Warning
85 )->exec();
86 close();
87 return;
88 }
89 }
90 else
91 {
92 CustomMessageBox::selectable(
93 this,
94 tr("Skin Upload"),
95 tr("You cannot use an invalid URL for uploading skins."),
96 QMessageBox::Warning
97 )->exec();
98 close();
99 return;
100 }
101 }
102 else
103 {
104 // just assume it's a path then
105 isLocalFile = true;
106 fileName = ui->skinPathTextBox->text();
107 }
108 if (isLocalFile && !QFile::exists(fileName))
109 {
110 CustomMessageBox::selectable(this, tr("Skin Upload"), tr("Skin file does not exist!"), QMessageBox::Warning)->exec();
111 close();
112 return;
113 }

Callers

nothing calls this directly

Calls 11

selectableFunction · 0.85
readFunction · 0.85
isEmptyMethod · 0.80
addTaskMethod · 0.80
accountDataMethod · 0.80
execWithTaskMethod · 0.80
textMethod · 0.45
isValidMethod · 0.45
execMethod · 0.45
accessTokenMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected