From 60e7e019fe62f48ebdb5cea0ab83ab58f3379fdf Mon Sep 17 00:00:00 2001 From: Sky Date: Tue, 8 Oct 2013 17:07:54 +0100 Subject: Start mcmod.info panel. Needs to be its own widget and included in legacy mod edit window, text labels need eliding --- gui/OneSixModEditDialog.cpp | 31 +++- gui/OneSixModEditDialog.h | 4 +- gui/OneSixModEditDialog.ui | 365 ++++++++++++++++++++++++++++++++++++++------ logic/Mod.cpp | 12 ++ logic/Mod.h | 18 +++ 5 files changed, 377 insertions(+), 53 deletions(-) diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index 788a61d0..d97967e8 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -298,12 +298,39 @@ void OneSixModEditDialog::on_viewResPackBtn_clicked() openDirInDefaultProgram(m_inst->resourcePacksDir(), true); } -void OneSixModEditDialog::on_loaderWebsite_clicked() +void OneSixModEditDialog::on_loaderModTreeView_pressed(const QModelIndex &index) { int first, last; auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); if (!lastfirst(list, first, last)) return; - showWebsiteForMod(this, m_mods->operator[](first)); + + Mod &m = m_mods->operator[](first); + + QString missing = "

Missing from mcmod.info

"; + + QString name = m.name(); + if(name.isEmpty()) name = missing; + QString description = m.description(); + if(description.isEmpty()) description = missing; + QString authors = m.authors(); + if(authors.isEmpty()) authors = missing; + QString credits = m.credits(); + if(credits.isEmpty()) credits = missing; + QString website = m.homeurl(); + if(website.isEmpty()) website = missing; + else website = "" + website + ""; + + ui->label_Name->setText("

" + name + "

"); + ui->label_Description->setText(description); + ui->label_Authors->setText(authors); + ui->label_Credits->setText(credits); + ui->label_Website->setText(website); + + ui->label_Name->setToolTip("

" + name + "

"); + ui->label_Description->setToolTip(description); + ui->label_Authors->setToolTip(authors); + ui->label_Credits->setToolTip(credits); + //ui->label_Website->setToolTip(website); } diff --git a/gui/OneSixModEditDialog.h b/gui/OneSixModEditDialog.h index ce4da4fe..03ebf7a3 100644 --- a/gui/OneSixModEditDialog.h +++ b/gui/OneSixModEditDialog.h @@ -44,9 +44,11 @@ private slots: void on_forgeBtn_clicked(); void on_customizeBtn_clicked(); void on_revertBtn_clicked(); - void on_loaderWebsite_clicked(); void updateVersionControls(); void disableVersionControls(); + + void on_loaderModTreeView_pressed(const QModelIndex &index); + protected: bool eventFilter(QObject *obj, QEvent *ev); bool loaderListFilter( QKeyEvent* ev ); diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index b97d4304..88ba5a76 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -26,7 +26,7 @@ - 0 + 1 @@ -157,62 +157,327 @@ Loader Mods - + - - - true - - - QAbstractItemView::DropOnly - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Website - - - + - - - Qt::Vertical - - - - 20 - 40 - - - + + + + + + 0 + 0 + + + + true + + + QAbstractItemView::DropOnly + + + + - - - &View Folder - - + + + + + &Add + + + + + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + &View Folder + + + + + + + + + 55 + 0 + + + + + 16777215 + 150 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 250 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 9 + + + 0 + + + + + + 0 + 0 + + + + + 250 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-size:9pt; font-weight:600; font-style:italic;">Select a mod to view information...</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + 0 + 0 + + + + + 250 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic;">Mod description</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + + QLayout::SetDefaultConstraint + + + QFormLayout::AllNonFixedFieldsGrow + + + + + + 200 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod authors</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Credits: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 200 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod credits</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Website: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 200 + 0 + + + + + 16777215 + 92 + + + + <html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod website</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + true + + + + + + + Authors: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + diff --git a/logic/Mod.cpp b/logic/Mod.cpp index 825e663f..c45e3ad2 100644 --- a/logic/Mod.cpp +++ b/logic/Mod.cpp @@ -119,6 +119,18 @@ void Mod::ReadMCModInfo(QByteArray contents) m_name = firstObj.value("name").toString(); m_version = firstObj.value("version").toString(); m_homeurl = firstObj.value("url").toString(); + m_description = firstObj.value("description").toString(); + QJsonArray authors = firstObj.value("authors").toArray(); + if(authors.size() == 0) m_authors = ""; + else if(authors.size() >= 1) + { + m_authors = authors.at(0).toString(); + for(int i = 1; i < authors.size(); i++) + { + m_authors += ", " + authors.at(i).toString(); + } + } + m_credits = firstObj.value("credits").toString(); return; } ; diff --git a/logic/Mod.h b/logic/Mod.h index 9831fdc0..f3aaf18b 100644 --- a/logic/Mod.h +++ b/logic/Mod.h @@ -63,6 +63,21 @@ public: return m_homeurl; } + QString description() const + { + return m_description; + } + + QString authors() const + { + return m_authors; + } + + QString credits() const + { + return m_credits; + } + // delete all the files of this mod bool destroy(); // replace this mod with a copy of the other @@ -99,6 +114,9 @@ protected: QString m_version; QString m_mcversion; QString m_homeurl; + QString m_description; + QString m_authors; + QString m_credits; ModType m_type; }; -- cgit v1.2.3