Mod info, with less HTML!

And responding to keyboard events too.
This commit is contained in:
Petr Mrázek 2013-10-09 02:03:02 +02:00
parent 36edf6cbc6
commit 6bc9df84d9
7 changed files with 168 additions and 207 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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)

View File

@ -18,7 +18,8 @@
#include <QFrame>
#include "logic/Mod.h"
namespace Ui {
namespace Ui
{
class 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);

View File

@ -2,72 +2,12 @@
<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>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_Name">
<property name="sizePolicy">
@ -88,8 +28,14 @@
<height>92</height>
</size>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt; font-weight:600; font-style:italic;&quot;&gt;Select a mod to view information...&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Select a mod to view information...</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
@ -120,7 +66,7 @@
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Mod description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Mod description</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
@ -131,7 +77,6 @@
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
@ -169,7 +114,7 @@
</size>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic; color:#4a4a4a;&quot;&gt;Mod authors&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic; color:#4a4a4a;&quot;&gt;Mod website&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic; color:#4a4a4a;&quot;&gt;Mod credits&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Mod credits</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>

View File

@ -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);
}

View File

@ -19,8 +19,9 @@
#include <logic/OneSixInstance.h>
class EnabledItemFilter;
namespace Ui {
class OneSixModEditDialog;
namespace Ui
{
class OneSixModEditDialog;
}
class OneSixModEditDialog : public QDialog
@ -28,10 +29,11 @@ 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();
@ -47,17 +49,19 @@ private slots:
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);
};