From f2291ef161c6ae2d47ede15633626ab1e8caab86 Mon Sep 17 00:00:00 2001 From: Sky <git@bunnies.cc> Date: Tue, 8 Oct 2013 21:45:48 +0100 Subject: Move mod info frame and handler to MCModInfoFrame, use on all instances --- gui/MCModInfoFrame.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 gui/MCModInfoFrame.h (limited to 'gui/MCModInfoFrame.h') diff --git a/gui/MCModInfoFrame.h b/gui/MCModInfoFrame.h new file mode 100644 index 00000000..7910bd0c --- /dev/null +++ b/gui/MCModInfoFrame.h @@ -0,0 +1,32 @@ +#ifndef MCMODINFOFRAME_H +#define MCMODINFOFRAME_H + +#include <QFrame> +#include "logic/Mod.h" + +namespace Ui { +class MCModInfoFrame; +} + +class MCModInfoFrame : public QFrame +{ + Q_OBJECT + +public: + explicit MCModInfoFrame(QWidget *parent = 0); + ~MCModInfoFrame(); + + void setName(QString name); + void setDescription(QString description); + void setAuthors(QString authors); + void setCredits(QString credits); + void setWebsite(QString website); + + +private: + Ui::MCModInfoFrame *ui; +}; + +void handleModInfoUpdate(Mod &m, MCModInfoFrame *frame); + +#endif // MCMODINFOFRAME_H -- cgit From bf951c3eb82f90a83e5496b6a897f95f585aff89 Mon Sep 17 00:00:00 2001 From: Sky <git@bunnies.cc> Date: Tue, 8 Oct 2013 22:11:24 +0100 Subject: Licenses, cleanup --- gui/LegacyModEditDialog.cpp | 32 ------------------------------ gui/LegacyModEditDialog.h | 6 ------ gui/MCModInfoFrame.cpp | 15 ++++++++++++++ gui/MCModInfoFrame.h | 20 +++++++++++++++---- gui/MCModInfoFrame.ui | 48 ++++++++++++++++++++++----------------------- 5 files changed, 55 insertions(+), 66 deletions(-) (limited to 'gui/MCModInfoFrame.h') diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index 72792581..585bfdfb 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -345,38 +345,6 @@ void LegacyModEditDialog::on_buttonBox_rejected() close(); } -//FIXME: too much copypasta makes peterix a sad hacker. BUT IT'S SO DELICIOUS! - -void LegacyModEditDialog::on_coreWebsite_clicked() -{ - int first, last; - auto list = ui->coreModsTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) - return; - showWebsiteForMod(this, m_coremods->operator[](first)); -} - -void LegacyModEditDialog::on_jarWebsite_clicked() -{ - int first, last; - auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) - return; - showWebsiteForMod(this, m_jarmods->operator[](first)); -} - -void LegacyModEditDialog::on_loaderWebsite_clicked() -{ - int first, last; - auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) - return; - showWebsiteForMod(this, m_mods->operator[](first)); -} - void LegacyModEditDialog::on_jarModsTreeView_pressed(const QModelIndex &index) { int first, last; diff --git a/gui/LegacyModEditDialog.h b/gui/LegacyModEditDialog.h index fcf07f1c..b5d51fd5 100644 --- a/gui/LegacyModEditDialog.h +++ b/gui/LegacyModEditDialog.h @@ -53,17 +53,11 @@ slots: void on_rmTexPackBtn_clicked(); void on_viewTexPackBtn_clicked(); - void on_jarWebsite_clicked(); - void on_loaderWebsite_clicked(); - void on_coreWebsite_clicked(); - // Questionable: SettingsDialog doesn't need this for some reason? void on_buttonBox_rejected(); void on_jarModsTreeView_pressed(const QModelIndex &index); - void on_coreModsTreeView_pressed(const QModelIndex &index); - void on_loaderModTreeView_pressed(const QModelIndex &index); protected: diff --git a/gui/MCModInfoFrame.cpp b/gui/MCModInfoFrame.cpp index 805af56b..e7e669ec 100644 --- a/gui/MCModInfoFrame.cpp +++ b/gui/MCModInfoFrame.cpp @@ -1,3 +1,18 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + #include "MCModInfoFrame.h" #include "ui_MCModInfoFrame.h" diff --git a/gui/MCModInfoFrame.h b/gui/MCModInfoFrame.h index 7910bd0c..516fc5ed 100644 --- a/gui/MCModInfoFrame.h +++ b/gui/MCModInfoFrame.h @@ -1,5 +1,19 @@ -#ifndef MCMODINFOFRAME_H -#define MCMODINFOFRAME_H +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once #include <QFrame> #include "logic/Mod.h" @@ -28,5 +42,3 @@ private: }; void handleModInfoUpdate(Mod &m, MCModInfoFrame *frame); - -#endif // MCMODINFOFRAME_H diff --git a/gui/MCModInfoFrame.ui b/gui/MCModInfoFrame.ui index 022588d5..73b93a2e 100644 --- a/gui/MCModInfoFrame.ui +++ b/gui/MCModInfoFrame.ui @@ -144,6 +144,16 @@ <property name="labelAlignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> </property> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Authors:</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> <item row="0" column="1"> <widget class="QLabel" name="label_Authors"> <property name="minimumSize"> @@ -169,18 +179,18 @@ </property> </widget> </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> + <item row="2" column="0"> + <widget class="QLabel" name="label_4"> <property name="text"> - <string>Credits:</string> + <string>Website:</string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> </property> </widget> </item> - <item row="1" column="1"> - <widget class="QLabel" name="label_Credits"> + <item row="2" column="1"> + <widget class="QLabel" name="label_Website"> <property name="minimumSize"> <size> <width>200</width> @@ -194,7 +204,7 @@ </size> </property> <property name="text"> - <string><html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod credits</span></p></body></html></string> + <string><html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod website</span></p></body></html></string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> @@ -202,20 +212,13 @@ <property name="wordWrap"> <bool>true</bool> </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Website:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + <property name="openExternalLinks"> + <bool>true</bool> </property> </widget> </item> - <item row="2" column="1"> - <widget class="QLabel" name="label_Website"> + <item row="1" column="1"> + <widget class="QLabel" name="label_Credits"> <property name="minimumSize"> <size> <width>200</width> @@ -229,7 +232,7 @@ </size> </property> <property name="text"> - <string><html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod website</span></p></body></html></string> + <string><html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod credits</span></p></body></html></string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> @@ -237,15 +240,12 @@ <property name="wordWrap"> <bool>true</bool> </property> - <property name="openExternalLinks"> - <bool>true</bool> - </property> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> + <item row="1" column="0"> + <widget class="QLabel" name="label_3"> <property name="text"> - <string>Authors:</string> + <string>Credits:</string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> -- cgit From 6bc9df84d9e72d8ee06c23c505b6c5ad54820115 Mon Sep 17 00:00:00 2001 From: Petr Mrázek <peterix@gmail.com> Date: Wed, 9 Oct 2013 02:03:02 +0200 Subject: Mod info, with less HTML! And responding to keyboard events too. --- gui/LegacyModEditDialog.cpp | 62 ++++++++------ gui/LegacyModEditDialog.h | 6 +- gui/MCModInfoFrame.cpp | 39 +++++---- gui/MCModInfoFrame.h | 11 +-- gui/MCModInfoFrame.ui | 201 ++++++++++++++++---------------------------- gui/OneSixModEditDialog.cpp | 20 +++-- gui/OneSixModEditDialog.h | 36 ++++---- 7 files changed, 168 insertions(+), 207 deletions(-) (limited to 'gui/MCModInfoFrame.h') diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index 585bfdfb..82532cfd 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -47,6 +47,9 @@ LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent) #endif ui->jarModsTreeView->installEventFilter(this); m_jarmods->startWatching(); + auto smodel = ui->jarModsTreeView->selectionModel(); + connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + SLOT(jarCurrent(QModelIndex, QModelIndex))); } // Core mods { @@ -55,6 +58,9 @@ LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent) ui->coreModsTreeView->setModel(m_coremods.get()); ui->coreModsTreeView->installEventFilter(this); m_coremods->startWatching(); + auto smodel = ui->coreModsTreeView->selectionModel(); + connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + SLOT(coreCurrent(QModelIndex, QModelIndex))); } // Loader mods { @@ -63,6 +69,9 @@ LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent) ui->loaderModTreeView->setModel(m_mods.get()); ui->loaderModTreeView->installEventFilter(this); m_mods->startWatching(); + auto smodel = ui->loaderModTreeView->selectionModel(); + connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + SLOT(loaderCurrent(QModelIndex, QModelIndex))); } // texture packs { @@ -201,7 +210,7 @@ void LegacyModEditDialog::on_addForgeBtn_clicked() if (vselect.exec() && vselect.selectedVersion()) { ForgeVersionPtr forge = - std::dynamic_pointer_cast<ForgeVersion> (vselect.selectedVersion()); + std::dynamic_pointer_cast<ForgeVersion>(vselect.selectedVersion()); if (!forge) return; auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename); @@ -345,41 +354,38 @@ void LegacyModEditDialog::on_buttonBox_rejected() close(); } -void LegacyModEditDialog::on_jarModsTreeView_pressed(const QModelIndex &index) +void LegacyModEditDialog::jarCurrent(QModelIndex current, QModelIndex previous) { - int first, last; - auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) + if(!current.isValid()) + { + ui->jarMIFrame->clear(); return; - - Mod &m = m_jarmods->operator[](first); - - handleModInfoUpdate(m, ui->jarMIFrame); + } + int row = current.row(); + Mod &m = m_jarmods->operator[](row); + ui->jarMIFrame->updateWithMod(m); } -void LegacyModEditDialog::on_coreModsTreeView_pressed(const QModelIndex &index) +void LegacyModEditDialog::coreCurrent(QModelIndex current, QModelIndex previous) { - int first, last; - auto list = ui->coreModsTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) + if(!current.isValid()) + { + ui->coreMIFrame->clear(); return; - - Mod &m = m_coremods->operator[](first); - - handleModInfoUpdate(m, ui->coreMIFrame); + } + int row = current.row(); + Mod &m = m_coremods->operator[](row); + ui->coreMIFrame->updateWithMod(m); } -void LegacyModEditDialog::on_loaderModTreeView_pressed(const QModelIndex &index) +void LegacyModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous) { - int first, last; - auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) + if(!current.isValid()) + { + ui->loaderMIFrame->clear(); return; - - Mod &m = m_mods->operator[](first); - - handleModInfoUpdate(m, ui->loaderMIFrame); + } + int row = current.row(); + Mod &m = m_mods->operator[](row); + ui->loaderMIFrame->updateWithMod(m); } diff --git a/gui/LegacyModEditDialog.h b/gui/LegacyModEditDialog.h index b5d51fd5..fc3ea1e6 100644 --- a/gui/LegacyModEditDialog.h +++ b/gui/LegacyModEditDialog.h @@ -56,9 +56,9 @@ slots: // Questionable: SettingsDialog doesn't need this for some reason? void on_buttonBox_rejected(); - void on_jarModsTreeView_pressed(const QModelIndex &index); - void on_coreModsTreeView_pressed(const QModelIndex &index); - void on_loaderModTreeView_pressed(const QModelIndex &index); + void jarCurrent(QModelIndex current, QModelIndex previous); + void coreCurrent(QModelIndex current, QModelIndex previous); + void loaderCurrent(QModelIndex current, QModelIndex previous); protected: bool eventFilter(QObject *obj, QEvent *ev); diff --git a/gui/MCModInfoFrame.cpp b/gui/MCModInfoFrame.cpp index 70cfd46a..15ead7ab 100644 --- a/gui/MCModInfoFrame.cpp +++ b/gui/MCModInfoFrame.cpp @@ -15,21 +15,15 @@ #include "MCModInfoFrame.h" #include "ui_MCModInfoFrame.h" - -void handleModInfoUpdate(Mod &m, MCModInfoFrame *frame) +void MCModInfoFrame::updateWithMod(Mod &m) { if(m.type() == m.MOD_FOLDER) { - frame->setName("<p><span style=\" font-size:9pt; font-weight:600; font-style:italic;\">Select a mod to view information...</span></p>"); - frame->setDescription("<p><span style=\" font-style:italic;\">Mod description</span></p>"); - frame->setAuthors("<p><span style=\" font-style:italic; color:#4a4a4a;\">Mod authors</span></p>"); - frame->setCredits("<p><span style=\" font-style:italic; color:#4a4a4a;\">Mod credits</span></p>"); - frame->setWebsite("<p><span style=\" font-style:italic; color:#4a4a4a;\">Mod website</span></p>"); - + clear(); return; } - QString missing = "<p><span style=\" font-style:italic; color:#4a4a4a;\">Missing from mcmod.info</span></p>"; + QString missing = tr("Missing from mcmod.info"); QString name = m.name(); if(name.isEmpty()) name = missing; @@ -43,11 +37,20 @@ void handleModInfoUpdate(Mod &m, MCModInfoFrame *frame) if(website.isEmpty()) website = missing; else website = "<a href=\"" + website + "\">" + website + "</a>"; - frame->setName("<p><span style=\" font-size:9pt; font-weight:600;\">" + name + "</span></p>"); - frame->setDescription(description); - frame->setAuthors(authors); - frame->setCredits(credits); - frame->setWebsite(website); + setName(name); + setDescription(description); + setAuthors(authors); + setCredits(credits); + setWebsite(website); +} + +void MCModInfoFrame::clear() +{ + setName(tr("Select a mod to view information...")); + setDescription(tr("Mod description")); + setAuthors(tr("Mod authors")); + setCredits(tr("Mod credits")); + setWebsite(tr("Mod website")); } MCModInfoFrame::MCModInfoFrame(QWidget *parent) : @@ -65,25 +68,25 @@ MCModInfoFrame::~MCModInfoFrame() void MCModInfoFrame::setName(QString name) { ui->label_Name->setText(name); - ui->label_Name->setToolTip(name); + //ui->label_Name->setToolTip(name); } void MCModInfoFrame::setDescription(QString description) { ui->label_Description->setText(description); - ui->label_Description->setToolTip(description); + //ui->label_Description->setToolTip(description); } void MCModInfoFrame::setAuthors(QString authors) { ui->label_Authors->setText(authors); - ui->label_Authors->setToolTip(authors); + //ui->label_Authors->setToolTip(authors); } void MCModInfoFrame::setCredits(QString credits) { ui->label_Credits->setText(credits); - ui->label_Credits->setToolTip(credits); + //ui->label_Credits->setToolTip(credits); } void MCModInfoFrame::setWebsite(QString website) diff --git a/gui/MCModInfoFrame.h b/gui/MCModInfoFrame.h index 516fc5ed..01812df7 100644 --- a/gui/MCModInfoFrame.h +++ b/gui/MCModInfoFrame.h @@ -18,14 +18,15 @@ #include <QFrame> #include "logic/Mod.h" -namespace Ui { +namespace Ui +{ class MCModInfoFrame; } class MCModInfoFrame : public QFrame { Q_OBJECT - + public: explicit MCModInfoFrame(QWidget *parent = 0); ~MCModInfoFrame(); @@ -36,9 +37,9 @@ public: void setCredits(QString credits); void setWebsite(QString website); - + void updateWithMod(Mod &m); + void clear(); + private: Ui::MCModInfoFrame *ui; }; - -void handleModInfoUpdate(Mod &m, MCModInfoFrame *frame); diff --git a/gui/MCModInfoFrame.ui b/gui/MCModInfoFrame.ui index 73b93a2e..41902c1a 100644 --- a/gui/MCModInfoFrame.ui +++ b/gui/MCModInfoFrame.ui @@ -2,136 +2,81 @@ <ui version="4.0"> <class>MCModInfoFrame</class> <widget class="QFrame" name="MCModInfoFrame"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>571</width> - <height>55</height> - </rect> - </property> <property name="windowTitle"> <string>Frame</string> </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> <item> - <widget class="QFrame" name="frame_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>250</width> - <height>0</height> - </size> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <property name="spacing"> - <number>0</number> - </property> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>9</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="label_Name"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>250</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>92</height> - </size> - </property> - <property name="text"> - <string><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></string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_Description"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>250</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>92</height> - </size> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-style:italic;">Mod description</span></p></body></html></string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </widget> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label_Name"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>250</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>92</height> + </size> + </property> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>Select a mod to view information...</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_Description"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>250</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>92</height> + </size> + </property> + <property name="text"> + <string>Mod description</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> </item> <item> <layout class="QFormLayout" name="formLayout"> @@ -169,7 +114,7 @@ </size> </property> <property name="text"> - <string><html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod authors</span></p></body></html></string> + <string>Mod authors</string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> @@ -204,7 +149,7 @@ </size> </property> <property name="text"> - <string><html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod website</span></p></body></html></string> + <string>Mod website</string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> @@ -232,7 +177,7 @@ </size> </property> <property name="text"> - <string><html><head/><body><p><span style=" font-style:italic; color:#4a4a4a;">Mod credits</span></p></body></html></string> + <string>Mod credits</string> </property> <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> diff --git a/gui/OneSixModEditDialog.cpp b/gui/OneSixModEditDialog.cpp index 9724cec5..e072a238 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/OneSixModEditDialog.cpp @@ -60,6 +60,9 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent) ui->loaderModTreeView->setModel(m_mods.get()); ui->loaderModTreeView->installEventFilter(this); m_mods->startWatching(); + auto smodel = ui->loaderModTreeView->selectionModel(); + connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), + SLOT(loaderCurrent(QModelIndex,QModelIndex))); } // resource packs { @@ -298,15 +301,14 @@ void OneSixModEditDialog::on_viewResPackBtn_clicked() openDirInDefaultProgram(m_inst->resourcePacksDir(), true); } -void OneSixModEditDialog::on_loaderModTreeView_pressed(const QModelIndex &index) +void OneSixModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous) { - int first, last; - auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); - - if (!lastfirst(list, first, last)) + if(!current.isValid()) + { + ui->frame->clear(); return; - - Mod &m = m_mods->operator[](first); - - handleModInfoUpdate(m, ui->frame); + } + int row = current.row(); + Mod &m = m_mods->operator[](row); + ui->frame->updateWithMod(m); } diff --git a/gui/OneSixModEditDialog.h b/gui/OneSixModEditDialog.h index 03ebf7a3..5376e526 100644 --- a/gui/OneSixModEditDialog.h +++ b/gui/OneSixModEditDialog.h @@ -1,9 +1,9 @@ /* Copyright 2013 MultiMC Contributors - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -19,23 +19,25 @@ #include <logic/OneSixInstance.h> class EnabledItemFilter; -namespace Ui { - class OneSixModEditDialog; +namespace Ui +{ +class OneSixModEditDialog; } class OneSixModEditDialog : public QDialog { Q_OBJECT - + public: - explicit OneSixModEditDialog(OneSixInstance* inst, QWidget *parent = 0); + explicit OneSixModEditDialog(OneSixInstance *inst, QWidget *parent = 0); virtual ~OneSixModEditDialog(); - -private slots: + +private +slots: void on_addModBtn_clicked(); void on_rmModBtn_clicked(); void on_viewModBtn_clicked(); - + void on_addResPackBtn_clicked(); void on_rmResPackBtn_clicked(); void on_viewResPackBtn_clicked(); @@ -44,20 +46,22 @@ private slots: void on_forgeBtn_clicked(); void on_customizeBtn_clicked(); void on_revertBtn_clicked(); - void updateVersionControls(); + void updateVersionControls(); void disableVersionControls(); - void on_loaderModTreeView_pressed(const QModelIndex &index); - protected: bool eventFilter(QObject *obj, QEvent *ev); - bool loaderListFilter( QKeyEvent* ev ); - bool resourcePackListFilter( QKeyEvent* ev ); + bool loaderListFilter(QKeyEvent *ev); + bool resourcePackListFilter(QKeyEvent *ev); + private: Ui::OneSixModEditDialog *ui; std::shared_ptr<OneSixVersion> m_version; std::shared_ptr<ModList> m_mods; std::shared_ptr<ModList> m_resourcepacks; - EnabledItemFilter * main_model; - OneSixInstance * m_inst; + EnabledItemFilter *main_model; + OneSixInstance *m_inst; +public +slots: + void loaderCurrent(QModelIndex current, QModelIndex previous); }; -- cgit From 14b47057fdbcec7d259ae0a73b201f3f0757b8e2 Mon Sep 17 00:00:00 2001 From: Sky <git@bunnies.cc> Date: Wed, 9 Oct 2013 02:26:03 +0100 Subject: Clean up mcmod panel massively. Keep it simple - name (optionally linked), optional authors and description. Needs cut-off handling, frame looking at on Windows --- gui/LegacyModEditDialog.ui | 5 +- gui/MCModInfoFrame.cpp | 64 ++++-------- gui/MCModInfoFrame.h | 7 +- gui/MCModInfoFrame.ui | 246 +++++++++++---------------------------------- gui/OneSixModEditDialog.ui | 10 +- 5 files changed, 87 insertions(+), 245 deletions(-) (limited to 'gui/MCModInfoFrame.h') diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui index 3ab946d9..bb0d9ef2 100644 --- a/gui/LegacyModEditDialog.ui +++ b/gui/LegacyModEditDialog.ui @@ -92,11 +92,8 @@ </item> <item> <widget class="MCModInfoFrame" name="jarMIFrame"> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> <property name="frameShadow"> - <enum>QFrame::Raised</enum> + <enum>QFrame::Plain</enum> </property> </widget> </item> diff --git a/gui/MCModInfoFrame.cpp b/gui/MCModInfoFrame.cpp index 15ead7ab..a0458cbc 100644 --- a/gui/MCModInfoFrame.cpp +++ b/gui/MCModInfoFrame.cpp @@ -23,34 +23,27 @@ void MCModInfoFrame::updateWithMod(Mod &m) return; } - QString missing = tr("Missing from mcmod.info"); + QString text = ""; + if(m.homeurl().isEmpty()) text = m.name(); + else text = "<a href=\"" + m.homeurl() + "\">" + m.name() + "</a>"; + if(!m.authors().isEmpty()) text += " by " + m.authors(); - 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 = "<a href=\"" + website + "\">" + website + "</a>"; + setModText(text); - setName(name); - setDescription(description); - setAuthors(authors); - setCredits(credits); - setWebsite(website); + if(m.description().isEmpty()) + { + setModDescription(tr("No description provided in mcmod.info")); + } + else + { + setModDescription(m.description()); + } } void MCModInfoFrame::clear() { - setName(tr("Select a mod to view information...")); - setDescription(tr("Mod description")); - setAuthors(tr("Mod authors")); - setCredits(tr("Mod credits")); - setWebsite(tr("Mod website")); + setModText(tr("Select a mod to view title and authors...")); + setModDescription(tr("Select a mod to view description...")); } MCModInfoFrame::MCModInfoFrame(QWidget *parent) : @@ -65,31 +58,12 @@ MCModInfoFrame::~MCModInfoFrame() delete ui; } -void MCModInfoFrame::setName(QString name) -{ - ui->label_Name->setText(name); - //ui->label_Name->setToolTip(name); -} - -void MCModInfoFrame::setDescription(QString description) -{ - ui->label_Description->setText(description); - //ui->label_Description->setToolTip(description); -} - -void MCModInfoFrame::setAuthors(QString authors) -{ - ui->label_Authors->setText(authors); - //ui->label_Authors->setToolTip(authors); -} - -void MCModInfoFrame::setCredits(QString credits) +void MCModInfoFrame::setModText(QString text) { - ui->label_Credits->setText(credits); - //ui->label_Credits->setToolTip(credits); + ui->label_ModText->setText(text); } -void MCModInfoFrame::setWebsite(QString website) +void MCModInfoFrame::setModDescription(QString text) { - ui->label_Website->setText(website); + ui->label_ModDescription->setText(text); } diff --git a/gui/MCModInfoFrame.h b/gui/MCModInfoFrame.h index 01812df7..cdf399cb 100644 --- a/gui/MCModInfoFrame.h +++ b/gui/MCModInfoFrame.h @@ -31,11 +31,8 @@ public: explicit MCModInfoFrame(QWidget *parent = 0); ~MCModInfoFrame(); - void setName(QString name); - void setDescription(QString description); - void setAuthors(QString authors); - void setCredits(QString credits); - void setWebsite(QString website); + void setModText(QString text); + void setModDescription(QString text); void updateWithMod(Mod &m); void clear(); diff --git a/gui/MCModInfoFrame.ui b/gui/MCModInfoFrame.ui index 41902c1a..b24251ae 100644 --- a/gui/MCModInfoFrame.ui +++ b/gui/MCModInfoFrame.ui @@ -2,202 +2,76 @@ <ui version="4.0"> <class>MCModInfoFrame</class> <widget class="QFrame" name="MCModInfoFrame"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>527</width> + <height>68</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>120</height> + </size> + </property> <property name="windowTitle"> <string>Frame</string> </property> - <layout class="QHBoxLayout" name="horizontalLayout"> + <layout class="QVBoxLayout" name="verticalLayout_2"> <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label_Name"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>250</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>92</height> - </size> - </property> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Select a mod to view information...</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_Description"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>250</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>92</height> - </size> - </property> - <property name="text"> - <string>Mod description</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> + <widget class="QLabel" name="label_ModText"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Select a mod to view title and authors...</string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + <property name="openExternalLinks"> + <bool>true</bool> + </property> + </widget> </item> <item> - <layout class="QFormLayout" name="formLayout"> - <property name="sizeConstraint"> - <enum>QLayout::SetDefaultConstraint</enum> + <widget class="QLabel" name="label_ModDescription"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Select a mod to view description...</string> </property> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + <property name="textFormat"> + <enum>Qt::PlainText</enum> </property> - <property name="labelAlignment"> + <property name="alignment"> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> </property> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Authors:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="label_Authors"> - <property name="minimumSize"> - <size> - <width>200</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>92</height> - </size> - </property> - <property name="text"> - <string>Mod authors</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Website:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="label_Website"> - <property name="minimumSize"> - <size> - <width>200</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>92</height> - </size> - </property> - <property name="text"> - <string>Mod website</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - <property name="openExternalLinks"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="label_Credits"> - <property name="minimumSize"> - <size> - <width>200</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>16777215</width> - <height>92</height> - </size> - </property> - <property name="text"> - <string>Mod credits</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Credits:</string> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> - </property> - </widget> - </item> - </layout> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> </item> </layout> </widget> diff --git a/gui/OneSixModEditDialog.ui b/gui/OneSixModEditDialog.ui index 675a6faa..6d70200a 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/OneSixModEditDialog.ui @@ -222,11 +222,11 @@ </item> <item> <widget class="MCModInfoFrame" name="frame"> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> </widget> </item> -- cgit From 4d320e8fc9997ec54ba53c44bd8607399a2c4476 Mon Sep 17 00:00:00 2001 From: robotbrainify <robotbrainify@gmail.com> Date: Fri, 11 Oct 2013 17:54:58 -0400 Subject: remove dupe newlines from trimmed mod description. whoo --- gui/MCModInfoFrame.cpp | 15 ++++++++++++++- gui/MCModInfoFrame.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'gui/MCModInfoFrame.h') diff --git a/gui/MCModInfoFrame.cpp b/gui/MCModInfoFrame.cpp index 51651e33..22a53819 100644 --- a/gui/MCModInfoFrame.cpp +++ b/gui/MCModInfoFrame.cpp @@ -69,5 +69,18 @@ void MCModInfoFrame::setModText(QString text) void MCModInfoFrame::setModDescription(QString text) { - ui->label_ModDescription->setText(text); + QString intermediatetext = text.trimmed(); + bool prev(false); + QChar rem('\n'); + QString finaltext; + finaltext.reserve(intermediatetext.size()); + foreach(const QChar& c, intermediatetext) + { + if(c == rem && prev){ + continue; + } + prev = c == rem; + finaltext += c; + } + ui->label_ModDescription->setText(finaltext); } diff --git a/gui/MCModInfoFrame.h b/gui/MCModInfoFrame.h index cdf399cb..bc10ae6a 100644 --- a/gui/MCModInfoFrame.h +++ b/gui/MCModInfoFrame.h @@ -17,6 +17,7 @@ #include <QFrame> #include "logic/Mod.h" +#include <stdio.h> namespace Ui { -- cgit From 281826f713d9a373c71cf01fb365c045c1555fe6 Mon Sep 17 00:00:00 2001 From: robotbrainify <robotbrainify@gmail.com> Date: Sat, 12 Oct 2013 09:19:49 -0400 Subject: switch from tooltip to messagebox --- gui/MCModInfoFrame.cpp | 15 ++++++++++++--- gui/MCModInfoFrame.h | 5 ++++- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'gui/MCModInfoFrame.h') diff --git a/gui/MCModInfoFrame.cpp b/gui/MCModInfoFrame.cpp index a45e30ea..4a78d329 100644 --- a/gui/MCModInfoFrame.cpp +++ b/gui/MCModInfoFrame.cpp @@ -15,6 +15,8 @@ #include "MCModInfoFrame.h" #include "ui_MCModInfoFrame.h" +#include <QMessageBox> +#include <QtGui> void MCModInfoFrame::updateWithMod(Mod &m) { if(m.type() == m.MOD_FOLDER) @@ -85,10 +87,11 @@ void MCModInfoFrame::setModDescription(QString text) } QString labeltext; labeltext.reserve(300); - if(finaltext.length() > 297) + if(finaltext.length() > 290) { - labeltext.append(finaltext.left(287) + "..."); - ui->label_ModDescription->setToolTip(text.replace('\n', "<br/>")); + ui->label_ModDescription->setOpenExternalLinks(false); + labeltext.append(finaltext.left(287) + "<a href=\"\">...</a>"); + QObject::connect(ui->label_ModDescription, &QLabel::linkActivated, this, &MCModInfoFrame::modDescEllipsisHandler); } else { @@ -96,3 +99,9 @@ void MCModInfoFrame::setModDescription(QString text) } ui->label_ModDescription->setText(labeltext); } +void MCModInfoFrame::modDescEllipsisHandler(const QString &link) +{ + QMessageBox msgbox; + msgbox.setDetailedText(desc); + msgbox.exec(); +} diff --git a/gui/MCModInfoFrame.h b/gui/MCModInfoFrame.h index bc10ae6a..9064fea7 100644 --- a/gui/MCModInfoFrame.h +++ b/gui/MCModInfoFrame.h @@ -17,7 +17,6 @@ #include <QFrame> #include "logic/Mod.h" -#include <stdio.h> namespace Ui { @@ -38,6 +37,10 @@ public: void updateWithMod(Mod &m); void clear(); +public slots: + void modDescEllipsisHandler(const QString& link ); + private: Ui::MCModInfoFrame *ui; + QString desc; }; -- cgit From 52031a681429d475ed323c1756cc2ec546ced5f1 Mon Sep 17 00:00:00 2001 From: robotbrain <robotbrainify@gmail.com> Date: Sat, 12 Oct 2013 15:44:34 -0400 Subject: Update MCModInfoFrame.h fix moar indents :) --- gui/MCModInfoFrame.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gui/MCModInfoFrame.h') diff --git a/gui/MCModInfoFrame.h b/gui/MCModInfoFrame.h index 9064fea7..54c5d674 100644 --- a/gui/MCModInfoFrame.h +++ b/gui/MCModInfoFrame.h @@ -38,9 +38,9 @@ public: void clear(); public slots: - void modDescEllipsisHandler(const QString& link ); + void modDescEllipsisHandler(const QString& link ); private: Ui::MCModInfoFrame *ui; - QString desc; + QString desc; }; -- cgit