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

Method setDescription

launcher/ui/widgets/InfoFrame.cpp:208–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208void InfoFrame::setDescription(QString text)
209{
210 if(text.isEmpty())
211 {
212 ui->descriptionLabel->setHidden(true);
213 updateHiddenState();
214 return;
215 }
216 else
217 {
218 ui->descriptionLabel->setHidden(false);
219 updateHiddenState();
220 }
221 ui->descriptionLabel->setToolTip("");
222 QString intermediatetext = text.trimmed();
223 bool prev(false);
224 QChar rem('\n');
225 QString finaltext;
226 finaltext.reserve(intermediatetext.size());
227 foreach(const QChar& c, intermediatetext)
228 {
229 if(c == rem && prev){
230 continue;
231 }
232 prev = c == rem;
233 finaltext += c;
234 }
235 QString labeltext;
236 labeltext.reserve(300);
237 if(finaltext.length() > 290)
238 {
239 ui->descriptionLabel->setOpenExternalLinks(false);
240 ui->descriptionLabel->setTextFormat(Qt::TextFormat::RichText);
241 m_description = text;
242 // This allows injecting HTML here.
243 labeltext.append("<html><body>" + finaltext.left(287) + "<a href=\"#mod_desc\">...</a></body></html>");
244 QObject::connect(ui->descriptionLabel, &QLabel::linkActivated, this, &InfoFrame::descriptionEllipsisHandler);
245 }
246 else
247 {
248 ui->descriptionLabel->setTextFormat(Qt::TextFormat::AutoText);
249 labeltext.append(finaltext);
250 }
251 ui->descriptionLabel->setText(labeltext);
252}
253
254void InfoFrame::setImage(QPixmap img)
255{

Callers 1

packageCurrentMethod · 0.45

Calls 5

isEmptyMethod · 0.80
lengthMethod · 0.80
appendMethod · 0.80
sizeMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected