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 #endif
ui->jarModsTreeView->installEventFilter(this); ui->jarModsTreeView->installEventFilter(this);
m_jarmods->startWatching(); m_jarmods->startWatching();
auto smodel = ui->jarModsTreeView->selectionModel();
connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
SLOT(jarCurrent(QModelIndex, QModelIndex)));
} }
// Core mods // Core mods
{ {
@ -55,6 +58,9 @@ LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent)
ui->coreModsTreeView->setModel(m_coremods.get()); ui->coreModsTreeView->setModel(m_coremods.get());
ui->coreModsTreeView->installEventFilter(this); ui->coreModsTreeView->installEventFilter(this);
m_coremods->startWatching(); m_coremods->startWatching();
auto smodel = ui->coreModsTreeView->selectionModel();
connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
SLOT(coreCurrent(QModelIndex, QModelIndex)));
} }
// Loader mods // Loader mods
{ {
@ -63,6 +69,9 @@ LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent)
ui->loaderModTreeView->setModel(m_mods.get()); ui->loaderModTreeView->setModel(m_mods.get());
ui->loaderModTreeView->installEventFilter(this); ui->loaderModTreeView->installEventFilter(this);
m_mods->startWatching(); m_mods->startWatching();
auto smodel = ui->loaderModTreeView->selectionModel();
connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
SLOT(loaderCurrent(QModelIndex, QModelIndex)));
} }
// texture packs // texture packs
{ {
@ -201,7 +210,7 @@ void LegacyModEditDialog::on_addForgeBtn_clicked()
if (vselect.exec() && vselect.selectedVersion()) if (vselect.exec() && vselect.selectedVersion())
{ {
ForgeVersionPtr forge = ForgeVersionPtr forge =
std::dynamic_pointer_cast<ForgeVersion> (vselect.selectedVersion()); std::dynamic_pointer_cast<ForgeVersion>(vselect.selectedVersion());
if (!forge) if (!forge)
return; return;
auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename); auto entry = MMC->metacache()->resolveEntry("minecraftforge", forge->filename);
@ -345,41 +354,38 @@ void LegacyModEditDialog::on_buttonBox_rejected()
close(); close();
} }
void LegacyModEditDialog::on_jarModsTreeView_pressed(const QModelIndex &index) void LegacyModEditDialog::jarCurrent(QModelIndex current, QModelIndex previous)
{ {
int first, last; if(!current.isValid())
auto list = ui->jarModsTreeView->selectionModel()->selectedRows(); {
ui->jarMIFrame->clear();
if (!lastfirst(list, first, last))
return; return;
}
Mod &m = m_jarmods->operator[](first); int row = current.row();
Mod &m = m_jarmods->operator[](row);
handleModInfoUpdate(m, ui->jarMIFrame); ui->jarMIFrame->updateWithMod(m);
} }
void LegacyModEditDialog::on_coreModsTreeView_pressed(const QModelIndex &index) void LegacyModEditDialog::coreCurrent(QModelIndex current, QModelIndex previous)
{ {
int first, last; if(!current.isValid())
auto list = ui->coreModsTreeView->selectionModel()->selectedRows(); {
ui->coreMIFrame->clear();
if (!lastfirst(list, first, last))
return; return;
}
Mod &m = m_coremods->operator[](first); int row = current.row();
Mod &m = m_coremods->operator[](row);
handleModInfoUpdate(m, ui->coreMIFrame); ui->coreMIFrame->updateWithMod(m);
} }
void LegacyModEditDialog::on_loaderModTreeView_pressed(const QModelIndex &index) void LegacyModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous)
{ {
int first, last; if(!current.isValid())
auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); {
ui->loaderMIFrame->clear();
if (!lastfirst(list, first, last))
return; return;
}
Mod &m = m_mods->operator[](first); int row = current.row();
Mod &m = m_mods->operator[](row);
handleModInfoUpdate(m, ui->loaderMIFrame); ui->loaderMIFrame->updateWithMod(m);
} }

View File

@ -56,9 +56,9 @@ slots:
// Questionable: SettingsDialog doesn't need this for some reason? // Questionable: SettingsDialog doesn't need this for some reason?
void on_buttonBox_rejected(); void on_buttonBox_rejected();
void on_jarModsTreeView_pressed(const QModelIndex &index); void jarCurrent(QModelIndex current, QModelIndex previous);
void on_coreModsTreeView_pressed(const QModelIndex &index); void coreCurrent(QModelIndex current, QModelIndex previous);
void on_loaderModTreeView_pressed(const QModelIndex &index); void loaderCurrent(QModelIndex current, QModelIndex previous);
protected: protected:
bool eventFilter(QObject *obj, QEvent *ev); bool eventFilter(QObject *obj, QEvent *ev);

View File

@ -15,21 +15,15 @@
#include "MCModInfoFrame.h" #include "MCModInfoFrame.h"
#include "ui_MCModInfoFrame.h" #include "ui_MCModInfoFrame.h"
void MCModInfoFrame::updateWithMod(Mod &m)
void handleModInfoUpdate(Mod &m, MCModInfoFrame *frame)
{ {
if(m.type() == m.MOD_FOLDER) 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>"); clear();
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>");
return; 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(); QString name = m.name();
if(name.isEmpty()) name = missing; if(name.isEmpty()) name = missing;
@ -43,11 +37,20 @@ void handleModInfoUpdate(Mod &m, MCModInfoFrame *frame)
if(website.isEmpty()) website = missing; if(website.isEmpty()) website = missing;
else website = "<a href=\"" + website + "\">" + website + "</a>"; else website = "<a href=\"" + website + "\">" + website + "</a>";
frame->setName("<p><span style=\" font-size:9pt; font-weight:600;\">" + name + "</span></p>"); setName(name);
frame->setDescription(description); setDescription(description);
frame->setAuthors(authors); setAuthors(authors);
frame->setCredits(credits); setCredits(credits);
frame->setWebsite(website); 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) : MCModInfoFrame::MCModInfoFrame(QWidget *parent) :
@ -65,25 +68,25 @@ MCModInfoFrame::~MCModInfoFrame()
void MCModInfoFrame::setName(QString name) void MCModInfoFrame::setName(QString name)
{ {
ui->label_Name->setText(name); ui->label_Name->setText(name);
ui->label_Name->setToolTip(name); //ui->label_Name->setToolTip(name);
} }
void MCModInfoFrame::setDescription(QString description) void MCModInfoFrame::setDescription(QString description)
{ {
ui->label_Description->setText(description); ui->label_Description->setText(description);
ui->label_Description->setToolTip(description); //ui->label_Description->setToolTip(description);
} }
void MCModInfoFrame::setAuthors(QString authors) void MCModInfoFrame::setAuthors(QString authors)
{ {
ui->label_Authors->setText(authors); ui->label_Authors->setText(authors);
ui->label_Authors->setToolTip(authors); //ui->label_Authors->setToolTip(authors);
} }
void MCModInfoFrame::setCredits(QString credits) void MCModInfoFrame::setCredits(QString credits)
{ {
ui->label_Credits->setText(credits); ui->label_Credits->setText(credits);
ui->label_Credits->setToolTip(credits); //ui->label_Credits->setToolTip(credits);
} }
void MCModInfoFrame::setWebsite(QString website) void MCModInfoFrame::setWebsite(QString website)

View File

@ -18,14 +18,15 @@
#include <QFrame> #include <QFrame>
#include "logic/Mod.h" #include "logic/Mod.h"
namespace Ui { namespace Ui
{
class MCModInfoFrame; class MCModInfoFrame;
} }
class MCModInfoFrame : public QFrame class MCModInfoFrame : public QFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MCModInfoFrame(QWidget *parent = 0); explicit MCModInfoFrame(QWidget *parent = 0);
~MCModInfoFrame(); ~MCModInfoFrame();
@ -36,9 +37,9 @@ public:
void setCredits(QString credits); void setCredits(QString credits);
void setWebsite(QString website); void setWebsite(QString website);
void updateWithMod(Mod &m);
void clear();
private: private:
Ui::MCModInfoFrame *ui; Ui::MCModInfoFrame *ui;
}; };
void handleModInfoUpdate(Mod &m, MCModInfoFrame *frame);

View File

@ -2,136 +2,81 @@
<ui version="4.0"> <ui version="4.0">
<class>MCModInfoFrame</class> <class>MCModInfoFrame</class>
<widget class="QFrame" name="MCModInfoFrame"> <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"> <property name="windowTitle">
<string>Frame</string> <string>Frame</string>
</property> </property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout"> <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> <item>
<widget class="QFrame" name="frame_2"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="sizePolicy"> <item>
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <widget class="QLabel" name="label_Name">
<horstretch>0</horstretch> <property name="sizePolicy">
<verstretch>0</verstretch> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
</sizepolicy> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
<property name="minimumSize"> </sizepolicy>
<size> </property>
<width>250</width> <property name="minimumSize">
<height>0</height> <size>
</size> <width>250</width>
</property> <height>0</height>
<property name="frameShape"> </size>
<enum>QFrame::StyledPanel</enum> </property>
</property> <property name="maximumSize">
<property name="frameShadow"> <size>
<enum>QFrame::Raised</enum> <width>16777215</width>
</property> <height>92</height>
<layout class="QVBoxLayout" name="verticalLayout_5"> </size>
<property name="spacing"> </property>
<number>0</number> <property name="font">
</property> <font>
<property name="leftMargin"> <weight>75</weight>
<number>0</number> <bold>true</bold>
</property> </font>
<property name="topMargin"> </property>
<number>0</number> <property name="text">
</property> <string>Select a mod to view information...</string>
<property name="rightMargin"> </property>
<number>9</number> <property name="alignment">
</property> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<property name="bottomMargin"> </property>
<number>0</number> <property name="wordWrap">
</property> <bool>true</bool>
<item> </property>
<widget class="QLabel" name="label_Name"> </widget>
<property name="sizePolicy"> </item>
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <item>
<horstretch>0</horstretch> <widget class="QLabel" name="label_Description">
<verstretch>0</verstretch> <property name="sizePolicy">
</sizepolicy> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
</property> <horstretch>0</horstretch>
<property name="minimumSize"> <verstretch>0</verstretch>
<size> </sizepolicy>
<width>250</width> </property>
<height>0</height> <property name="minimumSize">
</size> <size>
</property> <width>250</width>
<property name="maximumSize"> <height>0</height>
<size> </size>
<width>16777215</width> </property>
<height>92</height> <property name="maximumSize">
</size> <size>
</property> <width>16777215</width>
<property name="text"> <height>92</height>
<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> </size>
</property> </property>
<property name="alignment"> <property name="text">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> <string>Mod description</string>
</property> </property>
<property name="wordWrap"> <property name="alignment">
<bool>true</bool> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property> </property>
</widget> <property name="wordWrap">
</item> <bool>true</bool>
<item> </property>
<widget class="QLabel" name="label_Description"> </widget>
<property name="sizePolicy"> </item>
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> </layout>
<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>&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>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item> </item>
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
@ -169,7 +114,7 @@
</size> </size>
</property> </property>
<property name="text"> <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>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
@ -204,7 +149,7 @@
</size> </size>
</property> </property>
<property name="text"> <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>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
@ -232,7 +177,7 @@
</size> </size>
</property> </property>
<property name="text"> <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>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> <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->setModel(m_mods.get());
ui->loaderModTreeView->installEventFilter(this); ui->loaderModTreeView->installEventFilter(this);
m_mods->startWatching(); m_mods->startWatching();
auto smodel = ui->loaderModTreeView->selectionModel();
connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
SLOT(loaderCurrent(QModelIndex,QModelIndex)));
} }
// resource packs // resource packs
{ {
@ -298,15 +301,14 @@ void OneSixModEditDialog::on_viewResPackBtn_clicked()
openDirInDefaultProgram(m_inst->resourcePacksDir(), true); openDirInDefaultProgram(m_inst->resourcePacksDir(), true);
} }
void OneSixModEditDialog::on_loaderModTreeView_pressed(const QModelIndex &index) void OneSixModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous)
{ {
int first, last; if(!current.isValid())
auto list = ui->loaderModTreeView->selectionModel()->selectedRows(); {
ui->frame->clear();
if (!lastfirst(list, first, last))
return; return;
}
Mod &m = m_mods->operator[](first); int row = current.row();
Mod &m = m_mods->operator[](row);
handleModInfoUpdate(m, ui->frame); ui->frame->updateWithMod(m);
} }

View File

@ -1,9 +1,9 @@
/* Copyright 2013 MultiMC Contributors /* Copyright 2013 MultiMC Contributors
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
@ -19,23 +19,25 @@
#include <logic/OneSixInstance.h> #include <logic/OneSixInstance.h>
class EnabledItemFilter; class EnabledItemFilter;
namespace Ui { namespace Ui
class OneSixModEditDialog; {
class OneSixModEditDialog;
} }
class OneSixModEditDialog : public QDialog class OneSixModEditDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit OneSixModEditDialog(OneSixInstance* inst, QWidget *parent = 0); explicit OneSixModEditDialog(OneSixInstance *inst, QWidget *parent = 0);
virtual ~OneSixModEditDialog(); virtual ~OneSixModEditDialog();
private slots: private
slots:
void on_addModBtn_clicked(); void on_addModBtn_clicked();
void on_rmModBtn_clicked(); void on_rmModBtn_clicked();
void on_viewModBtn_clicked(); void on_viewModBtn_clicked();
void on_addResPackBtn_clicked(); void on_addResPackBtn_clicked();
void on_rmResPackBtn_clicked(); void on_rmResPackBtn_clicked();
void on_viewResPackBtn_clicked(); void on_viewResPackBtn_clicked();
@ -44,20 +46,22 @@ private slots:
void on_forgeBtn_clicked(); void on_forgeBtn_clicked();
void on_customizeBtn_clicked(); void on_customizeBtn_clicked();
void on_revertBtn_clicked(); void on_revertBtn_clicked();
void updateVersionControls(); void updateVersionControls();
void disableVersionControls(); void disableVersionControls();
void on_loaderModTreeView_pressed(const QModelIndex &index);
protected: protected:
bool eventFilter(QObject *obj, QEvent *ev); bool eventFilter(QObject *obj, QEvent *ev);
bool loaderListFilter( QKeyEvent* ev ); bool loaderListFilter(QKeyEvent *ev);
bool resourcePackListFilter( QKeyEvent* ev ); bool resourcePackListFilter(QKeyEvent *ev);
private: private:
Ui::OneSixModEditDialog *ui; Ui::OneSixModEditDialog *ui;
std::shared_ptr<OneSixVersion> m_version; std::shared_ptr<OneSixVersion> m_version;
std::shared_ptr<ModList> m_mods; std::shared_ptr<ModList> m_mods;
std::shared_ptr<ModList> m_resourcepacks; std::shared_ptr<ModList> m_resourcepacks;
EnabledItemFilter * main_model; EnabledItemFilter *main_model;
OneSixInstance * m_inst; OneSixInstance *m_inst;
public
slots:
void loaderCurrent(QModelIndex current, QModelIndex previous);
}; };