| 54 | } |
| 55 | |
| 56 | void 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 | } |
nothing calls this directly
no test coverage detected