diff options
author | kb1000 <kaeptmblaubaer1000@gmail.com> | 2020-11-02 22:28:07 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2020-11-30 00:31:27 +0100 |
commit | f4d58e17eeb5bd608766acfebe425925d40d5825 (patch) | |
tree | 8a8de18bf5814d670d23117443d2067398e360ca | |
parent | 6aa126be3014b231651cb6ca55e9efee2168c29d (diff) | |
download | MultiMC-f4d58e17eeb5bd608766acfebe425925d40d5825.tar MultiMC-f4d58e17eeb5bd608766acfebe425925d40d5825.tar.gz MultiMC-f4d58e17eeb5bd608766acfebe425925d40d5825.tar.lz MultiMC-f4d58e17eeb5bd608766acfebe425925d40d5825.tar.xz MultiMC-f4d58e17eeb5bd608766acfebe425925d40d5825.zip |
NOISSUE Add pack author and description to technic modpack import page
-rw-r--r-- | application/pages/modplatform/technic/TechnicData.h | 3 | ||||
-rw-r--r-- | application/pages/modplatform/technic/TechnicPage.cpp | 24 | ||||
-rw-r--r-- | application/pages/modplatform/technic/TechnicPage.ui | 29 | ||||
-rw-r--r-- | application/widgets/MCModInfoFrame.cpp | 1 |
4 files changed, 43 insertions, 14 deletions
diff --git a/application/pages/modplatform/technic/TechnicData.h b/application/pages/modplatform/technic/TechnicData.h index e23cb7f6..c7ddd9ce 100644 --- a/application/pages/modplatform/technic/TechnicData.h +++ b/application/pages/modplatform/technic/TechnicData.h @@ -33,6 +33,9 @@ struct Modpack { QString minecraftVersion; bool metadataLoaded = false; + QString websiteUrl; + QString author; + QString description; }; } diff --git a/application/pages/modplatform/technic/TechnicPage.cpp b/application/pages/modplatform/technic/TechnicPage.cpp index 584e9c27..f6facd57 100644 --- a/application/pages/modplatform/technic/TechnicPage.cpp +++ b/application/pages/modplatform/technic/TechnicPage.cpp @@ -158,6 +158,9 @@ void TechnicPage::suggestCurrent() } current.minecraftVersion = Json::ensureString(obj, "minecraft", QString(), "__placeholder__"); + current.websiteUrl = Json::ensureString(obj, "platformUrl", QString(), "__placeholder__"); + current.author = Json::ensureString(obj, "user", QString(), "__placeholder__"); + current.description = Json::ensureString(obj, "description", QString(), "__placeholder__"); current.metadataLoaded = true; metadataLoaded(); }); @@ -168,29 +171,22 @@ void TechnicPage::suggestCurrent() // expects current.metadataLoaded to be true void TechnicPage::metadataLoaded() { - /*QString text = ""; + QString text = ""; QString name = current.name; if (current.websiteUrl.isEmpty()) + // This allows injecting HTML here. text = name; else + // URL not properly escaped for inclusion in HTML. The name allows for injecting HTML. text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>"; - if (!current.authors.empty()) { - auto authorToStr = [](Technic::ModpackAuthor & author) { - if(author.url.isEmpty()) { - return author.name; - } - return QString("<a href=\"%1\">%2</a>").arg(author.url, author.name); - }; - QStringList authorStrs; - for(auto & author: current.authors) { - authorStrs.push_back(authorToStr(author)); - } - text += tr(" by ") + authorStrs.join(", "); + if (!current.author.isEmpty()) { + // This allows injecting HTML here + text += tr(" by ") + current.author; } ui->frame->setModText(text); - ui->frame->setModDescription(current.description);*/ + ui->frame->setModDescription(current.description); if (!current.isSolder) { dialog->setSuggestedPack(current.name, new Technic::SingleZipPackInstallTask(current.url, current.minecraftVersion)); diff --git a/application/pages/modplatform/technic/TechnicPage.ui b/application/pages/modplatform/technic/TechnicPage.ui index be56fa82..36ce2ecf 100644 --- a/application/pages/modplatform/technic/TechnicPage.ui +++ b/application/pages/modplatform/technic/TechnicPage.ui @@ -55,8 +55,37 @@ </property> </widget> </item> + <item> + <widget class="MCModInfoFrame" name="frame"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + </widget> + </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>MCModInfoFrame</class> + <extends>QFrame</extends> + <header>widgets/MCModInfoFrame.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <tabstops> + <tabstop>searchEdit</tabstop> + <tabstop>searchButton</tabstop> + <tabstop>packView</tabstop> + </tabstops> <resources/> <connections/> </ui> diff --git a/application/widgets/MCModInfoFrame.cpp b/application/widgets/MCModInfoFrame.cpp index 577b32a7..89bb90fd 100644 --- a/application/widgets/MCModInfoFrame.cpp +++ b/application/widgets/MCModInfoFrame.cpp @@ -135,6 +135,7 @@ void MCModInfoFrame::setModDescription(QString text) ui->label_ModDescription->setOpenExternalLinks(false); ui->label_ModDescription->setTextFormat(Qt::TextFormat::RichText); desc = text; + // This allows injecting HTML here. labeltext.append("<html><body>" + finaltext.left(287) + "<a href=\"#mod_desc\">...</a></body></html>"); QObject::connect(ui->label_ModDescription, &QLabel::linkActivated, this, &MCModInfoFrame::modDescEllipsisHandler); } |