Many improvements
PermGen can be tweaked from the settings menu Groups are saved on change/exit Install target is no longer completely broken All the deplibs are now static Added notes dialog Fixed ini file format support (can save strings with newlines, tabs. UTF-8 is explicitly used!) Rename button now uses line breaks so it doesn't grow ever wider (Added a custom tool button subclass) There is now a CAT button. Meow.
This commit is contained in:
		@@ -57,6 +57,7 @@ AppSettings::AppSettings(QObject *parent) :
 | 
			
		||||
	// Memory
 | 
			
		||||
	registerSetting(new Setting("MinMemAlloc", 512));
 | 
			
		||||
	registerSetting(new Setting("MaxMemAlloc", 1024));
 | 
			
		||||
	registerSetting(new Setting("PermGen", 64));
 | 
			
		||||
	
 | 
			
		||||
	// Java Settings
 | 
			
		||||
	registerSetting(new Setting("JavaPath", "java"));
 | 
			
		||||
@@ -65,4 +66,7 @@ AppSettings::AppSettings(QObject *parent) :
 | 
			
		||||
	// Custom Commands
 | 
			
		||||
	registerSetting(new Setting("PreLaunchCommand", ""));
 | 
			
		||||
	registerSetting(new Setting("PostExitCommand", ""));
 | 
			
		||||
	
 | 
			
		||||
	// The cat
 | 
			
		||||
	registerSetting(new Setting("TheCat", false));
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -173,6 +173,8 @@ gui/instancesettings.h
 | 
			
		||||
gui/IconPickerDialog.h
 | 
			
		||||
gui/LegacyModEditDialog.h
 | 
			
		||||
gui/ModListView.h
 | 
			
		||||
gui/LabeledToolButton.h
 | 
			
		||||
gui/EditNotesDialog.h
 | 
			
		||||
 | 
			
		||||
# Base classes and infrastructure
 | 
			
		||||
logic/InstanceVersion.h
 | 
			
		||||
@@ -242,6 +244,8 @@ gui/instancesettings.cpp
 | 
			
		||||
gui/IconPickerDialog.cpp
 | 
			
		||||
gui/LegacyModEditDialog.cpp
 | 
			
		||||
gui/ModListView.cpp
 | 
			
		||||
gui/LabeledToolButton.cpp
 | 
			
		||||
gui/EditNotesDialog.cpp
 | 
			
		||||
 | 
			
		||||
# Base classes and infrastructure
 | 
			
		||||
logic/InstanceFactory.cpp
 | 
			
		||||
@@ -298,6 +302,7 @@ gui/lwjglselectdialog.ui
 | 
			
		||||
gui/instancesettings.ui
 | 
			
		||||
gui/IconPickerDialog.ui
 | 
			
		||||
gui/LegacyModEditDialog.ui
 | 
			
		||||
gui/EditNotesDialog.ui
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -405,7 +410,7 @@ INSTALL(TARGETS MultiMC
 | 
			
		||||
ELSE()
 | 
			
		||||
INSTALL(TARGETS MultiMC 
 | 
			
		||||
	BUNDLE DESTINATION . COMPONENT Runtime
 | 
			
		||||
	RUNTIME DESTINATION bin COMPONENT Runtime
 | 
			
		||||
	RUNTIME DESTINATION . COMPONENT Runtime
 | 
			
		||||
)
 | 
			
		||||
ENDIF()
 | 
			
		||||
ENDIF()
 | 
			
		||||
@@ -413,27 +418,27 @@ ENDIF()
 | 
			
		||||
 | 
			
		||||
#### Plugins ####
 | 
			
		||||
 | 
			
		||||
# Image formats
 | 
			
		||||
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime)
 | 
			
		||||
 | 
			
		||||
# Platform plugins
 | 
			
		||||
INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/platforms" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime)
 | 
			
		||||
 | 
			
		||||
# qtconf
 | 
			
		||||
INSTALL(CODE "
 | 
			
		||||
	FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/${QTCONF_DEST_DIR}/qt.conf\" \"\")
 | 
			
		||||
	" COMPONENT Runtime)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Dirs to look for dependencies.
 | 
			
		||||
SET(DIRS "${QT_LIBRARY_DIRS}")
 | 
			
		||||
 | 
			
		||||
INSTALL(CODE "
 | 
			
		||||
	file(GLOB_RECURSE QTPLUGINS
 | 
			
		||||
		\"\${CMAKE_INSTALL_PREFIX}/${PLUGIN_DEST_DIR}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
 | 
			
		||||
	include(BundleUtilities)
 | 
			
		||||
	fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
 | 
			
		||||
	" COMPONENT Runtime)
 | 
			
		||||
# # Image formats
 | 
			
		||||
# INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/imageformats" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime)
 | 
			
		||||
# 
 | 
			
		||||
# # Platform plugins
 | 
			
		||||
# INSTALL(DIRECTORY "${QT_PLUGINS_DIR}/platforms" DESTINATION ${PLUGIN_DEST_DIR} COMPONENT Runtime)
 | 
			
		||||
# 
 | 
			
		||||
# # qtconf
 | 
			
		||||
# INSTALL(CODE "
 | 
			
		||||
# 	FILE(WRITE \"\${CMAKE_INSTALL_PREFIX}/${QTCONF_DEST_DIR}/qt.conf\" \"\")
 | 
			
		||||
# 	" COMPONENT Runtime)
 | 
			
		||||
# 
 | 
			
		||||
# 
 | 
			
		||||
# # Dirs to look for dependencies.
 | 
			
		||||
# SET(DIRS "${QT_LIBRARY_DIRS}")
 | 
			
		||||
# 
 | 
			
		||||
# INSTALL(CODE "
 | 
			
		||||
# 	file(GLOB_RECURSE QTPLUGINS
 | 
			
		||||
# 		\"\${CMAKE_INSTALL_PREFIX}/${PLUGIN_DEST_DIR}/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
 | 
			
		||||
# 	include(BundleUtilities)
 | 
			
		||||
# 	fixup_bundle(\"${APPS}\" \"\${QTPLUGINS}\" \"${DIRS}\")
 | 
			
		||||
# 	" COMPONENT Runtime)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
######## Package ########
 | 
			
		||||
 
 | 
			
		||||
@@ -37,5 +37,5 @@ include_directories(${CMAKE_BINARY_DIR}/include)
 | 
			
		||||
 | 
			
		||||
add_definitions(-DLIBGROUPVIEW_LIBRARY)
 | 
			
		||||
 | 
			
		||||
add_library(libGroupView SHARED ${LIBGROUPVIEW_SOURCES} ${LIBGROUPVIEW_HEADERS})
 | 
			
		||||
add_library(libGroupView STATIC ${LIBGROUPVIEW_SOURCES} ${LIBGROUPVIEW_HEADERS})
 | 
			
		||||
qt5_use_modules(libGroupView Core Widgets)
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,6 @@ include_directories(${LIBSETTINGS_INCLUDE_DIR})
 | 
			
		||||
 | 
			
		||||
add_definitions(-DLIBSETTINGS_LIBRARY)
 | 
			
		||||
 | 
			
		||||
add_library(libSettings SHARED ${LIBSETTINGS_SOURCES} ${LIBSETTINGS_HEADERS} ${LIBSETTINGS_HEADERS_PRIVATE})
 | 
			
		||||
add_library(libSettings STATIC ${LIBSETTINGS_SOURCES} ${LIBSETTINGS_HEADERS} ${LIBSETTINGS_HEADERS_PRIVATE})
 | 
			
		||||
qt5_use_modules(libSettings Core)
 | 
			
		||||
target_link_libraries(libSettings)
 | 
			
		||||
 
 | 
			
		||||
@@ -13,13 +13,11 @@
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef INIFILE_H
 | 
			
		||||
#define INIFILE_H
 | 
			
		||||
 | 
			
		||||
#include <QMap>
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QVariant>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "libsettings_config.h"
 | 
			
		||||
 | 
			
		||||
// Sectionless INI parser (for instance config files)
 | 
			
		||||
@@ -33,6 +31,6 @@ public:
 | 
			
		||||
	
 | 
			
		||||
	QVariant get(QString key, QVariant def) const;
 | 
			
		||||
	void set(QString key, QVariant val);
 | 
			
		||||
	QString unescape(QString orig);
 | 
			
		||||
	QString escape(QString orig);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // INIFILE_H
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,40 @@
 | 
			
		||||
#include <QTextStream>
 | 
			
		||||
#include <QStringList>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
INIFile::INIFile()
 | 
			
		||||
{
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString INIFile::unescape(QString orig)
 | 
			
		||||
{
 | 
			
		||||
	orig.replace("\\n", "\n");
 | 
			
		||||
	orig.replace("\\t", "\t");
 | 
			
		||||
	orig.replace("\\\\", "\\");
 | 
			
		||||
	return orig;
 | 
			
		||||
}
 | 
			
		||||
QString INIFile::escape(QString orig)
 | 
			
		||||
{
 | 
			
		||||
	orig.replace("\\", "\\\\");
 | 
			
		||||
	orig.replace("\n", "\\n");
 | 
			
		||||
	orig.replace("\t", "\\t");
 | 
			
		||||
	return orig;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool INIFile::saveFile(QString fileName)
 | 
			
		||||
{
 | 
			
		||||
	// TODO Handle errors.
 | 
			
		||||
	QFile file(fileName);
 | 
			
		||||
	file.open(QIODevice::WriteOnly);
 | 
			
		||||
	QTextStream out(&file);
 | 
			
		||||
	out.setCodec("UTF-8");
 | 
			
		||||
	
 | 
			
		||||
	for (Iterator iter = begin(); iter != end(); iter++)
 | 
			
		||||
	{
 | 
			
		||||
		out << iter.key() << "=" << iter.value().toString() << "\n";
 | 
			
		||||
		QString value = iter.value().toString();
 | 
			
		||||
		value = escape(value);
 | 
			
		||||
		out << iter.key() << "=" << value << "\n";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	return true;
 | 
			
		||||
@@ -45,6 +64,7 @@ bool INIFile::loadFile(QString fileName)
 | 
			
		||||
	QFile file(fileName);
 | 
			
		||||
	file.open(QIODevice::ReadOnly);
 | 
			
		||||
	QTextStream	in(&file);
 | 
			
		||||
	in.setCodec("UTF-8");
 | 
			
		||||
	
 | 
			
		||||
	QStringList lines = in.readAll().split('\n');
 | 
			
		||||
	for (int i = 0; i < lines.count(); i++)
 | 
			
		||||
@@ -59,13 +79,9 @@ bool INIFile::loadFile(QString fileName)
 | 
			
		||||
		QString key = line.left(eqPos).trimmed();
 | 
			
		||||
		QString valueStr = line.right(line.length() - eqPos - 1).trimmed();
 | 
			
		||||
		
 | 
			
		||||
		valueStr = unescape(valueStr);
 | 
			
		||||
		
 | 
			
		||||
		QVariant value(valueStr);
 | 
			
		||||
		/*
 | 
			
		||||
		QString dbg = key;
 | 
			
		||||
		dbg += " = ";
 | 
			
		||||
		dbg += valueStr;
 | 
			
		||||
		qDebug(dbg.toLocal8Bit());
 | 
			
		||||
		*/
 | 
			
		||||
		this->operator [](key) = value;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -45,7 +45,7 @@ SET(LIBUTIL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" PARENT_SCOPE)
 | 
			
		||||
 | 
			
		||||
add_definitions(-DLIBUTIL_LIBRARY)
 | 
			
		||||
 | 
			
		||||
add_library(libUtil SHARED ${LIBUTIL_SOURCES} ${LIBUTIL_HEADERS})
 | 
			
		||||
add_library(libUtil STATIC ${LIBUTIL_SOURCES} ${LIBUTIL_HEADERS})
 | 
			
		||||
# qt5_use_modules(libUtil Core Network)
 | 
			
		||||
qt5_use_modules(libUtil Core)
 | 
			
		||||
target_link_libraries(libUtil)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								gui/EditNotesDialog.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								gui/EditNotesDialog.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
#include "EditNotesDialog.h"
 | 
			
		||||
#include "ui_EditNotesDialog.h"
 | 
			
		||||
 | 
			
		||||
#include <QIcon>
 | 
			
		||||
#include <QApplication>
 | 
			
		||||
 | 
			
		||||
EditNotesDialog::EditNotesDialog( QString notes, QString name, QWidget* parent ) :
 | 
			
		||||
    m_instance_notes(notes),
 | 
			
		||||
    m_instance_name(name),
 | 
			
		||||
    QDialog(parent),
 | 
			
		||||
    ui(new Ui::EditNotesDialog)
 | 
			
		||||
{
 | 
			
		||||
	ui->setupUi(this);
 | 
			
		||||
	ui->noteEditor->setText(notes);
 | 
			
		||||
	setWindowTitle("Edit notes of " + m_instance_name);
 | 
			
		||||
	//connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
EditNotesDialog::~EditNotesDialog()
 | 
			
		||||
{
 | 
			
		||||
    delete ui;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString EditNotesDialog::getText()
 | 
			
		||||
{
 | 
			
		||||
	return ui->noteEditor->toPlainText();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										20
									
								
								gui/EditNotesDialog.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								gui/EditNotesDialog.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <QDialog>
 | 
			
		||||
 | 
			
		||||
namespace Ui {
 | 
			
		||||
class EditNotesDialog;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class EditNotesDialog : public QDialog
 | 
			
		||||
{
 | 
			
		||||
	Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	explicit EditNotesDialog(QString notes, QString name, QWidget *parent = 0);
 | 
			
		||||
	~EditNotesDialog();
 | 
			
		||||
	QString getText();
 | 
			
		||||
private:
 | 
			
		||||
	Ui::EditNotesDialog *ui;
 | 
			
		||||
	QString m_instance_name;
 | 
			
		||||
	QString m_instance_notes;
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										77
									
								
								gui/EditNotesDialog.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								gui/EditNotesDialog.ui
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,77 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<ui version="4.0">
 | 
			
		||||
 <class>EditNotesDialog</class>
 | 
			
		||||
 <widget class="QDialog" name="EditNotesDialog">
 | 
			
		||||
  <property name="geometry">
 | 
			
		||||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>459</width>
 | 
			
		||||
    <height>399</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="windowTitle">
 | 
			
		||||
   <string>Edit Notes</string>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QVBoxLayout" name="verticalLayout">
 | 
			
		||||
   <item>
 | 
			
		||||
    <widget class="QTextEdit" name="noteEditor">
 | 
			
		||||
     <property name="verticalScrollBarPolicy">
 | 
			
		||||
      <enum>Qt::ScrollBarAlwaysOn</enum>
 | 
			
		||||
     </property>
 | 
			
		||||
     <property name="acceptRichText">
 | 
			
		||||
      <bool>false</bool>
 | 
			
		||||
     </property>
 | 
			
		||||
     <property name="textInteractionFlags">
 | 
			
		||||
      <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
 | 
			
		||||
     </property>
 | 
			
		||||
    </widget>
 | 
			
		||||
   </item>
 | 
			
		||||
   <item>
 | 
			
		||||
    <widget class="QDialogButtonBox" name="buttonBox">
 | 
			
		||||
     <property name="orientation">
 | 
			
		||||
      <enum>Qt::Horizontal</enum>
 | 
			
		||||
     </property>
 | 
			
		||||
     <property name="standardButtons">
 | 
			
		||||
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
 | 
			
		||||
     </property>
 | 
			
		||||
    </widget>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <resources/>
 | 
			
		||||
 <connections>
 | 
			
		||||
  <connection>
 | 
			
		||||
   <sender>buttonBox</sender>
 | 
			
		||||
   <signal>accepted()</signal>
 | 
			
		||||
   <receiver>EditNotesDialog</receiver>
 | 
			
		||||
   <slot>accept()</slot>
 | 
			
		||||
   <hints>
 | 
			
		||||
    <hint type="sourcelabel">
 | 
			
		||||
     <x>248</x>
 | 
			
		||||
     <y>254</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
    <hint type="destinationlabel">
 | 
			
		||||
     <x>157</x>
 | 
			
		||||
     <y>274</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
   </hints>
 | 
			
		||||
  </connection>
 | 
			
		||||
  <connection>
 | 
			
		||||
   <sender>buttonBox</sender>
 | 
			
		||||
   <signal>rejected()</signal>
 | 
			
		||||
   <receiver>EditNotesDialog</receiver>
 | 
			
		||||
   <slot>reject()</slot>
 | 
			
		||||
   <hints>
 | 
			
		||||
    <hint type="sourcelabel">
 | 
			
		||||
     <x>316</x>
 | 
			
		||||
     <y>260</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
    <hint type="destinationlabel">
 | 
			
		||||
     <x>286</x>
 | 
			
		||||
     <y>274</y>
 | 
			
		||||
    </hint>
 | 
			
		||||
   </hints>
 | 
			
		||||
  </connection>
 | 
			
		||||
 </connections>
 | 
			
		||||
</ui>
 | 
			
		||||
							
								
								
									
										72
									
								
								gui/LabeledToolButton.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								gui/LabeledToolButton.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,72 @@
 | 
			
		||||
#include <QLabel>
 | 
			
		||||
#include <QVBoxLayout>
 | 
			
		||||
#include <QResizeEvent>
 | 
			
		||||
#include <QStyleOption>
 | 
			
		||||
#include "LabeledToolButton.h"
 | 
			
		||||
#include <QApplication>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * 
 | 
			
		||||
 *  Tool Button with a label on it, instead of the normal text rendering
 | 
			
		||||
 * 
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
LabeledToolButton::LabeledToolButton(QWidget * parent)
 | 
			
		||||
	: QToolButton(parent)
 | 
			
		||||
	, m_label(new QLabel(this))
 | 
			
		||||
{
 | 
			
		||||
	//QToolButton::setText(" ");
 | 
			
		||||
	m_label->setWordWrap(true);
 | 
			
		||||
	m_label->setMouseTracking(false);
 | 
			
		||||
	m_label->setAlignment(Qt::AlignCenter);
 | 
			
		||||
	m_label->setTextInteractionFlags(Qt::NoTextInteraction);
 | 
			
		||||
	// somehow, this makes word wrap work in the QLabel. yay.
 | 
			
		||||
	m_label->setMinimumWidth(100);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString LabeledToolButton::text() const
 | 
			
		||||
{
 | 
			
		||||
	return m_label->text();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void LabeledToolButton::setText(const QString & text)
 | 
			
		||||
{
 | 
			
		||||
	m_label->setText(text);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
    \reimp
 | 
			
		||||
*/
 | 
			
		||||
QSize LabeledToolButton::sizeHint() const
 | 
			
		||||
{
 | 
			
		||||
	/*
 | 
			
		||||
	Q_D(const QToolButton);
 | 
			
		||||
	if (d->sizeHint.isValid())
 | 
			
		||||
		return d->sizeHint;
 | 
			
		||||
	*/
 | 
			
		||||
	ensurePolished();
 | 
			
		||||
 | 
			
		||||
	int w = 0, h = 0;
 | 
			
		||||
	QStyleOptionToolButton opt;
 | 
			
		||||
	initStyleOption(&opt);
 | 
			
		||||
	QSize sz =m_label->sizeHint();
 | 
			
		||||
	w = sz.width();
 | 
			
		||||
	h = sz.height();
 | 
			
		||||
 | 
			
		||||
	opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height
 | 
			
		||||
	if (popupMode() == MenuButtonPopup)
 | 
			
		||||
		w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this);
 | 
			
		||||
	
 | 
			
		||||
	QSize rawSize = style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(w, h), this);
 | 
			
		||||
	QSize sizeHint = rawSize.expandedTo(QApplication::globalStrut());
 | 
			
		||||
	return sizeHint;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void LabeledToolButton::resizeEvent(QResizeEvent * event)
 | 
			
		||||
{
 | 
			
		||||
	m_label->setGeometry(QRect(4, 4, width()-8, height()-8));
 | 
			
		||||
	QWidget::resizeEvent(event);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										22
									
								
								gui/LabeledToolButton.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								gui/LabeledToolButton.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <QPushButton>
 | 
			
		||||
#include <QToolButton>
 | 
			
		||||
 | 
			
		||||
class QLabel;
 | 
			
		||||
 | 
			
		||||
class LabeledToolButton : public QToolButton
 | 
			
		||||
{
 | 
			
		||||
	Q_OBJECT
 | 
			
		||||
 | 
			
		||||
	QLabel * m_label;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	LabeledToolButton(QWidget * parent = 0);
 | 
			
		||||
 | 
			
		||||
	QString text() const;
 | 
			
		||||
	void setText(const QString & text);
 | 
			
		||||
	virtual QSize sizeHint() const;
 | 
			
		||||
protected:
 | 
			
		||||
	void resizeEvent(QResizeEvent * event);
 | 
			
		||||
};
 | 
			
		||||
@@ -17,7 +17,7 @@
 | 
			
		||||
   <item>
 | 
			
		||||
    <widget class="QTabWidget" name="tabWidget">
 | 
			
		||||
     <property name="currentIndex">
 | 
			
		||||
      <number>1</number>
 | 
			
		||||
      <number>0</number>
 | 
			
		||||
     </property>
 | 
			
		||||
     <widget class="QWidget" name="jarTab">
 | 
			
		||||
      <attribute name="title">
 | 
			
		||||
 
 | 
			
		||||
@@ -104,11 +104,13 @@ void InstanceSettings::applySettings()
 | 
			
		||||
	{
 | 
			
		||||
		m_obj->set("MinMemAlloc", ui->minMemSpinBox->value());
 | 
			
		||||
		m_obj->set("MaxMemAlloc", ui->maxMemSpinBox->value());
 | 
			
		||||
		m_obj->set("PermGen", ui->permGenSpinBox->value());
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		m_obj->reset("MinMemAlloc");
 | 
			
		||||
		m_obj->reset("MaxMemAlloc");
 | 
			
		||||
		m_obj->reset("PermGen");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
@@ -165,6 +167,7 @@ void InstanceSettings::loadSettings()
 | 
			
		||||
	ui->memoryGroupBox->setChecked(m_obj->get("OverrideMemory").toBool());
 | 
			
		||||
	ui->minMemSpinBox->setValue(m_obj->get("MinMemAlloc").toInt());
 | 
			
		||||
	ui->maxMemSpinBox->setValue(m_obj->get("MaxMemAlloc").toInt());
 | 
			
		||||
	ui->permGenSpinBox->setValue(m_obj->get("PermGen").toInt());
 | 
			
		||||
 | 
			
		||||
	// Java Settings
 | 
			
		||||
	ui->javaSettingsGroupBox->setChecked(m_obj->get("OverrideJava").toBool());
 | 
			
		||||
 
 | 
			
		||||
@@ -256,6 +256,29 @@
 | 
			
		||||
          </property>
 | 
			
		||||
         </widget>
 | 
			
		||||
        </item>
 | 
			
		||||
        <item row="2" column="1">
 | 
			
		||||
         <widget class="QSpinBox" name="permGenSpinBox">
 | 
			
		||||
          <property name="minimum">
 | 
			
		||||
           <number>64</number>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="maximum">
 | 
			
		||||
           <number>512</number>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="singleStep">
 | 
			
		||||
           <number>8</number>
 | 
			
		||||
          </property>
 | 
			
		||||
          <property name="value">
 | 
			
		||||
           <number>64</number>
 | 
			
		||||
          </property>
 | 
			
		||||
         </widget>
 | 
			
		||||
        </item>
 | 
			
		||||
        <item row="2" column="0">
 | 
			
		||||
         <widget class="QLabel" name="labelPermGen">
 | 
			
		||||
          <property name="text">
 | 
			
		||||
           <string>PermGen:</string>
 | 
			
		||||
          </property>
 | 
			
		||||
         </widget>
 | 
			
		||||
        </item>
 | 
			
		||||
       </layout>
 | 
			
		||||
      </widget>
 | 
			
		||||
     </item>
 | 
			
		||||
 
 | 
			
		||||
@@ -66,6 +66,8 @@
 | 
			
		||||
#include "instancemodel.h"
 | 
			
		||||
#include "instancedelegate.h"
 | 
			
		||||
#include "IconPickerDialog.h"
 | 
			
		||||
#include "LabeledToolButton.h"
 | 
			
		||||
#include "EditNotesDialog.h"
 | 
			
		||||
 | 
			
		||||
MainWindow::MainWindow ( QWidget *parent ) :
 | 
			
		||||
	QMainWindow ( parent ),
 | 
			
		||||
@@ -74,25 +76,22 @@ MainWindow::MainWindow ( QWidget *parent ) :
 | 
			
		||||
{
 | 
			
		||||
	ui->setupUi ( this );
 | 
			
		||||
	
 | 
			
		||||
	ui->instanceToolBar->setEnabled(false);
 | 
			
		||||
	// Set the selected instance to null
 | 
			
		||||
	m_selectedInstance = nullptr;
 | 
			
		||||
	// Set active instance to null.
 | 
			
		||||
	m_activeInst = nullptr;
 | 
			
		||||
	
 | 
			
		||||
	// the rename label is inside the rename tool button
 | 
			
		||||
	renameLabel = nullptr;
 | 
			
		||||
	renameButton = new LabeledToolButton();
 | 
			
		||||
	renameButton->setText("Instance Name");
 | 
			
		||||
	connect(renameButton, SIGNAL(clicked(bool)), SLOT(on_actionRenameInstance_triggered()));
 | 
			
		||||
	ui->instanceToolBar->insertWidget(ui->actionLaunchInstance, renameButton);
 | 
			
		||||
	ui->instanceToolBar->insertSeparator(ui->actionLaunchInstance);
 | 
			
		||||
	renameButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
 | 
			
		||||
	// Create the widget
 | 
			
		||||
	view = new KCategorizedView ( ui->centralWidget );
 | 
			
		||||
	drawer = new KCategoryDrawer ( view );
 | 
			
		||||
	view->setStyleSheet(
 | 
			
		||||
		"QListView\
 | 
			
		||||
		{\
 | 
			
		||||
			background-image: url(:/backgrounds/kitteh);\
 | 
			
		||||
			background-attachment: fixed;\
 | 
			
		||||
			background-clip: padding;\
 | 
			
		||||
			background-position: top right;\
 | 
			
		||||
			background-repeat: none;\
 | 
			
		||||
			background-color:palette(base);\
 | 
			
		||||
		}");
 | 
			
		||||
	
 | 
			
		||||
	view->setSelectionMode ( QAbstractItemView::SingleSelection );
 | 
			
		||||
	//view->setSpacing( KDialog::spacingHint() );
 | 
			
		||||
@@ -119,6 +118,11 @@ MainWindow::MainWindow ( QWidget *parent ) :
 | 
			
		||||
 | 
			
		||||
	view->setFrameShape ( QFrame::NoFrame );
 | 
			
		||||
	
 | 
			
		||||
	bool cat_enable = globalSettings->get("TheCat").toBool();
 | 
			
		||||
	ui->actionCAT->setChecked(cat_enable);
 | 
			
		||||
	connect(ui->actionCAT, SIGNAL(toggled(bool)), SLOT(onCatToggled(bool)));
 | 
			
		||||
	setCatBackground(cat_enable);
 | 
			
		||||
	
 | 
			
		||||
	ui->horizontalLayout->addWidget ( view );
 | 
			
		||||
	setWindowTitle ( QString ( "MultiMC %1" ).arg ( AppVersion::current.toString() ) );
 | 
			
		||||
	// TODO: Make this work with the new settings system.
 | 
			
		||||
@@ -191,6 +195,34 @@ bool MainWindow::eventFilter ( QObject* obj, QEvent* ev )
 | 
			
		||||
	return QMainWindow::eventFilter ( obj, ev );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::onCatToggled ( bool state )
 | 
			
		||||
{
 | 
			
		||||
	setCatBackground(state);
 | 
			
		||||
	globalSettings->set("TheCat", state);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::setCatBackground ( bool enabled )
 | 
			
		||||
{
 | 
			
		||||
	if(enabled)
 | 
			
		||||
	{
 | 
			
		||||
		view->setStyleSheet(
 | 
			
		||||
			"QListView"
 | 
			
		||||
			"{"
 | 
			
		||||
				"background-image: url(:/backgrounds/kitteh);"
 | 
			
		||||
				"background-attachment: fixed;"
 | 
			
		||||
				"background-clip: padding;"
 | 
			
		||||
				"background-position: top right;"
 | 
			
		||||
				"background-repeat: none;"
 | 
			
		||||
				"background-color:palette(base);"
 | 
			
		||||
			"}"
 | 
			
		||||
		);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		view->setStyleSheet(QString());
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void MainWindow::instanceActivated ( QModelIndex index )
 | 
			
		||||
{
 | 
			
		||||
@@ -276,7 +308,7 @@ void MainWindow::on_actionChangeInstGroup_triggered()
 | 
			
		||||
	name = QInputDialog::getText ( this, tr ( "Group name" ), tr ( "Enter a new group name." ),
 | 
			
		||||
									QLineEdit::Normal, name, &ok );
 | 
			
		||||
	if(ok)
 | 
			
		||||
		m_selectedInstance->setGroup(name);
 | 
			
		||||
		m_selectedInstance->setGroupPost(name);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -367,8 +399,7 @@ void MainWindow::on_actionRenameInstance_triggered()
 | 
			
		||||
		{
 | 
			
		||||
			if(ok && name.length() && name.length() <= 25)
 | 
			
		||||
				m_selectedInstance->setName(name);
 | 
			
		||||
			//ui->actionRenameInstance->setText(name);
 | 
			
		||||
			setRenameText(name);
 | 
			
		||||
			renameButton->setText(name);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
@@ -563,31 +594,6 @@ void MainWindow::on_actionInstanceSettings_triggered()
 | 
			
		||||
	settings.exec();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::setRenameText ( QString text )
 | 
			
		||||
{
 | 
			
		||||
	ui->actionRenameInstance->setText(text);
 | 
			
		||||
	// FIXME: too much bullshit.
 | 
			
		||||
	/*
 | 
			
		||||
	QToolButton * toolbtn = (QToolButton *) ui->instanceToolBar->widgetForAction(ui->actionRenameInstance);
 | 
			
		||||
	QLayout *layout = toolbtn->layout();
 | 
			
		||||
	if(!layout)
 | 
			
		||||
	{
 | 
			
		||||
		layout = new QHBoxLayout();
 | 
			
		||||
		renameLabel = new QLabel();
 | 
			
		||||
		renameLabel->setWordWrap(true);
 | 
			
		||||
		renameLabel->setAlignment(Qt::AlignCenter);
 | 
			
		||||
		layout->addWidget(renameLabel);
 | 
			
		||||
		toolbtn->setText(" ");
 | 
			
		||||
		toolbtn->setLayout(layout);
 | 
			
		||||
		toolbtn->setMinimumWidth(120);
 | 
			
		||||
		toolbtn->setMinimumHeight(renameLabel->minsize().height());
 | 
			
		||||
	}
 | 
			
		||||
	if(renameLabel)
 | 
			
		||||
		renameLabel->setText(text);
 | 
			
		||||
	*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void MainWindow::instanceChanged( const QModelIndex& current, const QModelIndex& previous )
 | 
			
		||||
{
 | 
			
		||||
	QString iconKey = "infinity";
 | 
			
		||||
@@ -596,8 +602,7 @@ void MainWindow::instanceChanged( const QModelIndex& current, const QModelIndex&
 | 
			
		||||
	{
 | 
			
		||||
		ui->instanceToolBar->setEnabled(true);
 | 
			
		||||
		iconKey = m_selectedInstance->iconKey();
 | 
			
		||||
		//ui->actionRenameInstance->setText(m_selectedInstance->name());
 | 
			
		||||
		setRenameText(m_selectedInstance->name());
 | 
			
		||||
		renameButton->setText(m_selectedInstance->name());
 | 
			
		||||
		ui->actionChangeInstLWJGLVersion->setEnabled(m_selectedInstance->menuActionEnabled("actionChangeInstLWJGLVersion"));
 | 
			
		||||
		ui->actionEditInstMods->setEnabled(m_selectedInstance->menuActionEnabled("actionEditInstMods"));
 | 
			
		||||
		statusBar()->clearMessage();
 | 
			
		||||
@@ -607,11 +612,28 @@ void MainWindow::instanceChanged( const QModelIndex& current, const QModelIndex&
 | 
			
		||||
	{
 | 
			
		||||
		statusBar()->clearMessage();
 | 
			
		||||
		ui->instanceToolBar->setEnabled(false);
 | 
			
		||||
		//ui->actionRenameInstance->setText("Rename Instance");
 | 
			
		||||
		setRenameText("Rename Instance");
 | 
			
		||||
		renameButton->setText("Rename Instance");
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	IconList * iconListModel = IconList::instance();
 | 
			
		||||
	auto ico =iconListModel->getIcon(iconKey);
 | 
			
		||||
	ui->actionChangeInstIcon->setIcon(ico);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void MainWindow::on_actionEditInstNotes_triggered()
 | 
			
		||||
{
 | 
			
		||||
	if (!m_selectedInstance)
 | 
			
		||||
		return;
 | 
			
		||||
	LegacyInstance * linst = (LegacyInstance *) m_selectedInstance;
 | 
			
		||||
	
 | 
			
		||||
	EditNotesDialog noteedit(linst->notes(), linst->name(), this);
 | 
			
		||||
	noteedit.exec();
 | 
			
		||||
	if (noteedit.result() == QDialog::Accepted)
 | 
			
		||||
	{
 | 
			
		||||
		
 | 
			
		||||
		linst->setNotes(noteedit.getText());
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -22,6 +22,7 @@
 | 
			
		||||
#include "logic/tasks/LoginTask.h"
 | 
			
		||||
#include "logic/BaseInstance.h"
 | 
			
		||||
 | 
			
		||||
class LabeledToolButton;
 | 
			
		||||
class QLabel;
 | 
			
		||||
class InstanceModel;
 | 
			
		||||
class InstanceProxyModel;
 | 
			
		||||
@@ -51,6 +52,8 @@ public:
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
private slots:
 | 
			
		||||
	void onCatToggled(bool);
 | 
			
		||||
	
 | 
			
		||||
	void on_actionAbout_triggered();
 | 
			
		||||
	
 | 
			
		||||
	void on_actionAddInstance_triggered();
 | 
			
		||||
@@ -93,6 +96,8 @@ private slots:
 | 
			
		||||
	
 | 
			
		||||
	void on_actionEditInstMods_triggered();
 | 
			
		||||
	
 | 
			
		||||
	void on_actionEditInstNotes_triggered();
 | 
			
		||||
	
 | 
			
		||||
	void doLogin(const QString& errorMsg = "");
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
@@ -120,7 +125,7 @@ public slots:
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
	bool eventFilter(QObject *obj, QEvent *ev);
 | 
			
		||||
	void setRenameText(QString text);
 | 
			
		||||
	void setCatBackground(bool enabled);
 | 
			
		||||
private:
 | 
			
		||||
	Ui::MainWindow *ui;
 | 
			
		||||
	KCategoryDrawer * drawer;
 | 
			
		||||
@@ -131,7 +136,7 @@ private:
 | 
			
		||||
	MinecraftProcess *proc;
 | 
			
		||||
	ConsoleWindow *console;
 | 
			
		||||
	OneSixAssets *assets_downloader;
 | 
			
		||||
	QLabel * renameLabel;
 | 
			
		||||
	LabeledToolButton * renameButton;
 | 
			
		||||
	
 | 
			
		||||
	BaseInstance *m_selectedInstance;
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -68,6 +68,8 @@
 | 
			
		||||
   <addaction name="actionReportBug"/>
 | 
			
		||||
   <addaction name="actionNews"/>
 | 
			
		||||
   <addaction name="actionAbout"/>
 | 
			
		||||
   <addaction name="separator"/>
 | 
			
		||||
   <addaction name="actionCAT"/>
 | 
			
		||||
  </widget>
 | 
			
		||||
  <widget class="QStatusBar" name="statusBar"/>
 | 
			
		||||
  <widget class="QToolBar" name="instanceToolBar">
 | 
			
		||||
@@ -99,8 +101,6 @@
 | 
			
		||||
    <bool>false</bool>
 | 
			
		||||
   </attribute>
 | 
			
		||||
   <addaction name="actionChangeInstIcon"/>
 | 
			
		||||
   <addaction name="actionRenameInstance"/>
 | 
			
		||||
   <addaction name="separator"/>
 | 
			
		||||
   <addaction name="actionLaunchInstance"/>
 | 
			
		||||
   <addaction name="separator"/>
 | 
			
		||||
   <addaction name="actionEditInstNotes"/>
 | 
			
		||||
@@ -428,6 +428,17 @@
 | 
			
		||||
    <string>Open the instance's config folder</string>
 | 
			
		||||
   </property>
 | 
			
		||||
  </action>
 | 
			
		||||
  <action name="actionCAT">
 | 
			
		||||
   <property name="checkable">
 | 
			
		||||
    <bool>true</bool>
 | 
			
		||||
   </property>
 | 
			
		||||
   <property name="text">
 | 
			
		||||
    <string>Meow</string>
 | 
			
		||||
   </property>
 | 
			
		||||
   <property name="toolTip">
 | 
			
		||||
    <string>Catnatok. Or just a cant with a ball of yarn? WHO KNOWS?!</string>
 | 
			
		||||
   </property>
 | 
			
		||||
  </action>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <layoutdefault spacing="6" margin="11"/>
 | 
			
		||||
 <resources>
 | 
			
		||||
 
 | 
			
		||||
@@ -132,6 +132,7 @@ void SettingsDialog::applySettings(SettingsObject *s)
 | 
			
		||||
	// Memory
 | 
			
		||||
	s->set("MinMemAlloc", ui->minMemSpinBox->value());
 | 
			
		||||
	s->set("MaxMemAlloc", ui->maxMemSpinBox->value());
 | 
			
		||||
	s->set("PermGen", ui->permGenSpinBox->value());
 | 
			
		||||
	
 | 
			
		||||
	// Java Settings
 | 
			
		||||
	s->set("JavaPath", ui->javaPathTextBox->text());
 | 
			
		||||
@@ -168,6 +169,7 @@ void SettingsDialog::loadSettings(SettingsObject *s)
 | 
			
		||||
	// Memory
 | 
			
		||||
	ui->minMemSpinBox->setValue(s->get("MinMemAlloc").toInt());
 | 
			
		||||
	ui->maxMemSpinBox->setValue(s->get("MaxMemAlloc").toInt());
 | 
			
		||||
	ui->permGenSpinBox->setValue(s->get("PermGen").toInt());
 | 
			
		||||
	
 | 
			
		||||
	// Java Settings
 | 
			
		||||
	ui->javaPathTextBox->setText(s->get("JavaPath").toString());
 | 
			
		||||
 
 | 
			
		||||
@@ -341,6 +341,29 @@
 | 
			
		||||
            </property>
 | 
			
		||||
           </widget>
 | 
			
		||||
          </item>
 | 
			
		||||
          <item row="2" column="0">
 | 
			
		||||
           <widget class="QLabel" name="labelPermGen">
 | 
			
		||||
            <property name="text">
 | 
			
		||||
             <string>PermGen:</string>
 | 
			
		||||
            </property>
 | 
			
		||||
           </widget>
 | 
			
		||||
          </item>
 | 
			
		||||
          <item row="2" column="1">
 | 
			
		||||
           <widget class="QSpinBox" name="permGenSpinBox">
 | 
			
		||||
            <property name="minimum">
 | 
			
		||||
             <number>64</number>
 | 
			
		||||
            </property>
 | 
			
		||||
            <property name="maximum">
 | 
			
		||||
             <number>512</number>
 | 
			
		||||
            </property>
 | 
			
		||||
            <property name="singleStep">
 | 
			
		||||
             <number>8</number>
 | 
			
		||||
            </property>
 | 
			
		||||
            <property name="value">
 | 
			
		||||
             <number>64</number>
 | 
			
		||||
            </property>
 | 
			
		||||
           </widget>
 | 
			
		||||
          </item>
 | 
			
		||||
         </layout>
 | 
			
		||||
        </widget>
 | 
			
		||||
       </item>
 | 
			
		||||
 
 | 
			
		||||
@@ -71,6 +71,7 @@ BaseInstance::BaseInstance( BaseInstancePrivate* d_in,
 | 
			
		||||
	settings().registerSetting(new Setting("OverrideMemory", false));
 | 
			
		||||
	settings().registerSetting(new OverrideSetting("MinMemAlloc", globalSettings->getSetting("MinMemAlloc")));
 | 
			
		||||
	settings().registerSetting(new OverrideSetting("MaxMemAlloc", globalSettings->getSetting("MaxMemAlloc")));
 | 
			
		||||
	settings().registerSetting(new OverrideSetting("PermGen", globalSettings->getSetting("PermGen")));
 | 
			
		||||
	
 | 
			
		||||
	// Auto login
 | 
			
		||||
	settings().registerSetting(new Setting("OverrideLogin", false));
 | 
			
		||||
@@ -187,12 +188,20 @@ void BaseInstance::setLastLaunch ( qint64 val )
 | 
			
		||||
	emit propertiesChanged ( this );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BaseInstance::setGroup ( QString val )
 | 
			
		||||
void BaseInstance::setGroupInitial ( QString val )
 | 
			
		||||
{
 | 
			
		||||
	I_D(BaseInstance);
 | 
			
		||||
	d->m_group = val;
 | 
			
		||||
	emit propertiesChanged ( this );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void BaseInstance::setGroupPost ( QString val )
 | 
			
		||||
{
 | 
			
		||||
	setGroupInitial(val);
 | 
			
		||||
	emit groupChanged();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
QString BaseInstance::group() const
 | 
			
		||||
{
 | 
			
		||||
	I_D(BaseInstance);
 | 
			
		||||
 
 | 
			
		||||
@@ -70,7 +70,9 @@ public:
 | 
			
		||||
	void setNotes(QString val);
 | 
			
		||||
	
 | 
			
		||||
	QString group() const;
 | 
			
		||||
	void setGroup(QString val);
 | 
			
		||||
	void setGroupInitial(QString val);
 | 
			
		||||
	void setGroupPost(QString val);
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	virtual QString intendedVersionId() const = 0;
 | 
			
		||||
	virtual bool setIntendedVersionId(QString version) = 0;
 | 
			
		||||
@@ -157,12 +159,16 @@ public:
 | 
			
		||||
	
 | 
			
		||||
	/// FIXME: this really should be elsewhere...
 | 
			
		||||
	virtual QString instanceConfigFolder() const = 0;
 | 
			
		||||
	
 | 
			
		||||
signals:
 | 
			
		||||
	/*!
 | 
			
		||||
	 * \brief Signal emitted when properties relevant to the instance view change
 | 
			
		||||
	 */
 | 
			
		||||
	void propertiesChanged(BaseInstance * inst);
 | 
			
		||||
	
 | 
			
		||||
	/*!
 | 
			
		||||
	 * \brief Signal emitted when groups are affected in any way
 | 
			
		||||
	 */
 | 
			
		||||
	void groupChanged();
 | 
			
		||||
protected:
 | 
			
		||||
	QSharedPointer<BaseInstancePrivate> inst_d;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -68,6 +68,7 @@ MinecraftProcess* LegacyInstance::prepareForLaunch(QString user, QString session
 | 
			
		||||
		// launcher arguments
 | 
			
		||||
		args << QString("-Xms%1m").arg(settings().get("MinMemAlloc").toInt());
 | 
			
		||||
		args << QString("-Xmx%1m").arg(settings().get("MaxMemAlloc").toInt());
 | 
			
		||||
		args << QString("-XX:MaxPermSize=%1m").arg(settings().get("PermGen").toInt());
 | 
			
		||||
		args << "-jar" << LAUNCHER_FILE;
 | 
			
		||||
		args << user;
 | 
			
		||||
		args << session;
 | 
			
		||||
 
 | 
			
		||||
@@ -113,6 +113,7 @@ MinecraftProcess* OneSixInstance::prepareForLaunch ( QString user, QString sessi
 | 
			
		||||
	args.append(Util::Commandline::splitArgs(settings().get("JvmArgs").toString()));
 | 
			
		||||
	args << QString("-Xms%1m").arg(settings().get("MinMemAlloc").toInt());
 | 
			
		||||
	args << QString("-Xmx%1m").arg(settings().get("MaxMemAlloc").toInt());
 | 
			
		||||
	args << QString("-XX:MaxPermSize=%1m").arg(settings().get("PermGen").toInt());
 | 
			
		||||
	QDir natives_dir(natives_dir_raw);
 | 
			
		||||
	args << QString("-Djava.library.path=%1").arg( natives_dir.absolutePath() );
 | 
			
		||||
	QString classPath;
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <QDir>
 | 
			
		||||
#include <QSet>
 | 
			
		||||
#include <QFile>
 | 
			
		||||
#include <QDirIterator>
 | 
			
		||||
#include <QThread>
 | 
			
		||||
@@ -36,6 +37,73 @@ InstanceList::InstanceList(const QString &instDir, QObject *parent) :
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
InstanceList::~InstanceList()
 | 
			
		||||
{
 | 
			
		||||
	saveGroupList();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void InstanceList::groupChanged()
 | 
			
		||||
{
 | 
			
		||||
	// save the groups. save all of them.
 | 
			
		||||
	saveGroupList();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void InstanceList::saveGroupList()
 | 
			
		||||
{
 | 
			
		||||
	QString groupFileName = m_instDir + "/instgroups.json";
 | 
			
		||||
	QFile groupFile(groupFileName);
 | 
			
		||||
	
 | 
			
		||||
	// if you can't open the file, fail
 | 
			
		||||
	if (!groupFile.open(QIODevice::WriteOnly| QIODevice::Truncate))
 | 
			
		||||
	{
 | 
			
		||||
		// An error occurred. Ignore it.
 | 
			
		||||
		qDebug("Failed to read instance group file.");
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	QTextStream out(&groupFile);
 | 
			
		||||
	QMap<QString, QSet<QString> > groupMap;
 | 
			
		||||
	for(auto instance: m_instances)
 | 
			
		||||
	{
 | 
			
		||||
		QString id = instance->id();
 | 
			
		||||
		QString group = instance->group();
 | 
			
		||||
		if(group.isEmpty())
 | 
			
		||||
			continue;
 | 
			
		||||
		if(!groupMap.count(group))
 | 
			
		||||
		{
 | 
			
		||||
			QSet<QString> set;
 | 
			
		||||
			set.insert(id);
 | 
			
		||||
			groupMap[group] = set;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			QSet<QString> &set = groupMap[group];
 | 
			
		||||
			set.insert(id);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	QJsonObject toplevel;
 | 
			
		||||
	toplevel.insert("formatVersion",QJsonValue(QString("1")));
 | 
			
		||||
	QJsonObject groupsArr;
 | 
			
		||||
	for(auto iter = groupMap.begin(); iter != groupMap.end(); iter++)
 | 
			
		||||
	{
 | 
			
		||||
		auto list = iter.value();
 | 
			
		||||
		auto name = iter.key();
 | 
			
		||||
		QJsonObject groupObj;
 | 
			
		||||
		QJsonArray instanceArr;
 | 
			
		||||
		groupObj.insert("hidden",QJsonValue(QString("false")));
 | 
			
		||||
		for(auto item: list)
 | 
			
		||||
		{
 | 
			
		||||
			instanceArr.append(QJsonValue(item));
 | 
			
		||||
		}
 | 
			
		||||
		groupObj.insert("instances",instanceArr);
 | 
			
		||||
		groupsArr.insert(name,groupObj);
 | 
			
		||||
	}
 | 
			
		||||
	toplevel.insert("groups",groupsArr);
 | 
			
		||||
	QJsonDocument doc(toplevel);
 | 
			
		||||
	groupFile.write(doc.toJson(QJsonDocument::Indented));
 | 
			
		||||
	groupFile.close();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void InstanceList::loadGroupList(QMap<QString, QString> & groupMap)
 | 
			
		||||
{
 | 
			
		||||
	QString groupFileName = m_instDir + "/instgroups.json";
 | 
			
		||||
@@ -176,12 +244,13 @@ InstanceList::InstListError InstanceList::loadList()
 | 
			
		||||
			auto iter = groupMap.find(inst->id());
 | 
			
		||||
			if(iter != groupMap.end())
 | 
			
		||||
			{
 | 
			
		||||
				inst->setGroup((*iter));
 | 
			
		||||
				inst->setGroupInitial((*iter));
 | 
			
		||||
			}
 | 
			
		||||
			qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8());
 | 
			
		||||
			inst->setParent(this);
 | 
			
		||||
			m_instances.append(inst);
 | 
			
		||||
			connect(instPtr, SIGNAL(propertiesChanged(BaseInstance*)),this, SLOT(propertiesChanged(BaseInstance*)));
 | 
			
		||||
			connect(instPtr, SIGNAL(groupChanged()),this, SLOT(groupChanged()));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	emit invalidated();
 | 
			
		||||
@@ -191,6 +260,7 @@ InstanceList::InstListError InstanceList::loadList()
 | 
			
		||||
/// Clear all instances. Triggers notifications.
 | 
			
		||||
void InstanceList::clear()
 | 
			
		||||
{
 | 
			
		||||
	saveGroupList();
 | 
			
		||||
	m_instances.clear();
 | 
			
		||||
	emit invalidated();
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -26,13 +26,12 @@ class InstanceList : public QObject
 | 
			
		||||
{
 | 
			
		||||
	Q_OBJECT
 | 
			
		||||
private:
 | 
			
		||||
	/*!
 | 
			
		||||
	 * \brief Get the instance groups
 | 
			
		||||
	 */
 | 
			
		||||
	void loadGroupList(QMap<QString, QString> & groupList);
 | 
			
		||||
	void saveGroupList();
 | 
			
		||||
	
 | 
			
		||||
public:
 | 
			
		||||
	explicit InstanceList(const QString &instDir, QObject *parent = 0);
 | 
			
		||||
	virtual ~InstanceList();
 | 
			
		||||
	
 | 
			
		||||
	/*!
 | 
			
		||||
	 * \brief Error codes returned by functions in the InstanceList class.
 | 
			
		||||
@@ -84,7 +83,7 @@ signals:
 | 
			
		||||
	
 | 
			
		||||
private slots:
 | 
			
		||||
	void propertiesChanged(BaseInstance * inst);
 | 
			
		||||
	
 | 
			
		||||
	void groupChanged();
 | 
			
		||||
protected:
 | 
			
		||||
	QString m_instDir;
 | 
			
		||||
	QList< InstancePtr > m_instances;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user