| 97 | } |
| 98 | |
| 99 | void ImportPage::updateState() |
| 100 | { |
| 101 | if(!isOpened) |
| 102 | { |
| 103 | return; |
| 104 | } |
| 105 | if(ui->modpackEdit->hasAcceptableInput()) |
| 106 | { |
| 107 | QString input = ui->modpackEdit->text(); |
| 108 | auto url = QUrl::fromUserInput(input); |
| 109 | if(url.isLocalFile()) |
| 110 | { |
| 111 | // FIXME: actually do some validation of what's inside here... this is fake AF |
| 112 | QFileInfo fi(input); |
| 113 | |
| 114 | // Allow non-latin people to use ZIP files! |
| 115 | bool isZip = QMimeDatabase().mimeTypeForUrl(url).suffixes().contains("zip"); |
| 116 | // mrpack is a modrinth pack |
| 117 | bool isMRPack = fi.suffix() == "mrpack"; |
| 118 | |
| 119 | if(fi.exists() && (isZip || isMRPack)) |
| 120 | { |
| 121 | QFileInfo fi(url.fileName()); |
| 122 | dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url,this)); |
| 123 | dialog->setSuggestedIcon("default"); |
| 124 | } |
| 125 | } |
| 126 | else |
| 127 | { |
| 128 | if(input.endsWith("?client=y")) { |
| 129 | input.chop(9); |
| 130 | input.append("/file"); |
| 131 | url = QUrl::fromUserInput(input); |
| 132 | } |
| 133 | // hook, line and sinker. |
| 134 | QFileInfo fi(url.fileName()); |
| 135 | dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url,this)); |
| 136 | dialog->setSuggestedIcon("default"); |
| 137 | } |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | dialog->setSuggestedPack(); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | void ImportPage::setUrl(const QString& url) |
| 146 | { |
nothing calls this directly
no test coverage detected