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

Method updateState

launcher/ui/pages/modplatform/ImportPage.cpp:99–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99void 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
145void ImportPage::setUrl(const QString& url)
146{

Callers

nothing calls this directly

Calls 6

existsMethod · 0.80
setSuggestedPackMethod · 0.80
setSuggestedIconMethod · 0.80
appendMethod · 0.80
textMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected