diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-08-25 22:48:41 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-08-25 22:48:41 +0200 |
commit | f0990fae4bc6e54837764c0ded1461b9f1770401 (patch) | |
tree | 619dd1c5007d902e2d349bb42e3f66454596713a | |
parent | d884f849d60db44f05a6a6b22f4ffcf520900389 (diff) | |
download | MultiMC-f0990fae4bc6e54837764c0ded1461b9f1770401.tar MultiMC-f0990fae4bc6e54837764c0ded1461b9f1770401.tar.gz MultiMC-f0990fae4bc6e54837764c0ded1461b9f1770401.tar.lz MultiMC-f0990fae4bc6e54837764c0ded1461b9f1770401.tar.xz MultiMC-f0990fae4bc6e54837764c0ded1461b9f1770401.zip |
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.
-rw-r--r-- | AppSettings.cpp | 4 | ||||
-rw-r--r-- | CMakeLists.txt | 49 | ||||
-rw-r--r-- | depends/groupview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | depends/settings/CMakeLists.txt | 2 | ||||
-rw-r--r-- | depends/settings/include/inifile.h | 10 | ||||
-rw-r--r-- | depends/settings/src/inifile.cpp | 30 | ||||
-rw-r--r-- | depends/util/CMakeLists.txt | 2 | ||||
-rw-r--r-- | gui/EditNotesDialog.cpp | 27 | ||||
-rw-r--r-- | gui/EditNotesDialog.h | 20 | ||||
-rw-r--r-- | gui/EditNotesDialog.ui | 77 | ||||
-rw-r--r-- | gui/LabeledToolButton.cpp | 72 | ||||
-rw-r--r-- | gui/LabeledToolButton.h | 22 | ||||
-rw-r--r-- | gui/LegacyModEditDialog.ui | 2 | ||||
-rw-r--r-- | gui/instancesettings.cpp | 3 | ||||
-rw-r--r-- | gui/instancesettings.ui | 23 | ||||
-rw-r--r-- | gui/mainwindow.cpp | 112 | ||||
-rw-r--r-- | gui/mainwindow.h | 9 | ||||
-rw-r--r-- | gui/mainwindow.ui | 15 | ||||
-rw-r--r-- | gui/settingsdialog.cpp | 2 | ||||
-rw-r--r-- | gui/settingsdialog.ui | 23 | ||||
-rw-r--r-- | logic/BaseInstance.cpp | 11 | ||||
-rw-r--r-- | logic/BaseInstance.h | 10 | ||||
-rw-r--r-- | logic/LegacyInstance.cpp | 1 | ||||
-rw-r--r-- | logic/OneSixInstance.cpp | 1 | ||||
-rw-r--r-- | logic/lists/InstanceList.cpp | 72 | ||||
-rw-r--r-- | logic/lists/InstanceList.h | 7 |
26 files changed, 512 insertions, 96 deletions
diff --git a/AppSettings.cpp b/AppSettings.cpp index 9a4cb99f..403af1dc 100644 --- a/AppSettings.cpp +++ b/AppSettings.cpp @@ -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)); } diff --git a/CMakeLists.txt b/CMakeLists.txt index f6520333..2fead64c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ######## diff --git a/depends/groupview/CMakeLists.txt b/depends/groupview/CMakeLists.txt index 3fa2b044..c3a3dafa 100644 --- a/depends/groupview/CMakeLists.txt +++ b/depends/groupview/CMakeLists.txt @@ -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) diff --git a/depends/settings/CMakeLists.txt b/depends/settings/CMakeLists.txt index e5aae0b7..911b604b 100644 --- a/depends/settings/CMakeLists.txt +++ b/depends/settings/CMakeLists.txt @@ -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) diff --git a/depends/settings/include/inifile.h b/depends/settings/include/inifile.h index 94467832..e3ff6b64 100644 --- a/depends/settings/include/inifile.h +++ b/depends/settings/include/inifile.h @@ -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 diff --git a/depends/settings/src/inifile.cpp b/depends/settings/src/inifile.cpp index 43545a4a..b3ee3a90 100644 --- a/depends/settings/src/inifile.cpp +++ b/depends/settings/src/inifile.cpp @@ -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; } diff --git a/depends/util/CMakeLists.txt b/depends/util/CMakeLists.txt index 7affb5ea..86542c43 100644 --- a/depends/util/CMakeLists.txt +++ b/depends/util/CMakeLists.txt @@ -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) diff --git a/gui/EditNotesDialog.cpp b/gui/EditNotesDialog.cpp new file mode 100644 index 00000000..6cc389f6 --- /dev/null +++ b/gui/EditNotesDialog.cpp @@ -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(); +} diff --git a/gui/EditNotesDialog.h b/gui/EditNotesDialog.h new file mode 100644 index 00000000..582e019f --- /dev/null +++ b/gui/EditNotesDialog.h @@ -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; +}; diff --git a/gui/EditNotesDialog.ui b/gui/EditNotesDialog.ui new file mode 100644 index 00000000..487dfb84 --- /dev/null +++ b/gui/EditNotesDialog.ui @@ -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> diff --git a/gui/LabeledToolButton.cpp b/gui/LabeledToolButton.cpp new file mode 100644 index 00000000..f1e54696 --- /dev/null +++ b/gui/LabeledToolButton.cpp @@ -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); +}
\ No newline at end of file diff --git a/gui/LabeledToolButton.h b/gui/LabeledToolButton.h new file mode 100644 index 00000000..24ef798a --- /dev/null +++ b/gui/LabeledToolButton.h @@ -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); +}; diff --git a/gui/LegacyModEditDialog.ui b/gui/LegacyModEditDialog.ui index bff2bfbe..49ddbb19 100644 --- a/gui/LegacyModEditDialog.ui +++ b/gui/LegacyModEditDialog.ui @@ -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"> diff --git a/gui/instancesettings.cpp b/gui/instancesettings.cpp index 36ff2c20..8a973665 100644 --- a/gui/instancesettings.cpp +++ b/gui/instancesettings.cpp @@ -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()); diff --git a/gui/instancesettings.ui b/gui/instancesettings.ui index 16e64100..8edbbfcf 100644 --- a/gui/instancesettings.ui +++ b/gui/instancesettings.ui @@ -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> diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index b562769e..ffb76d5b 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -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 ), @@ -73,26 +75,23 @@ MainWindow::MainWindow ( QWidget *parent ) : instList ( globalSettings->get ( "InstanceDir" ).toString() ) { 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() ); @@ -118,7 +117,12 @@ MainWindow::MainWindow ( QWidget *parent ) : proxymodel->sort ( 0 ); 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()); + } +} diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 597cc750..6456346d 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -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; diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 60e0f70b..7bc2c3eb 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -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> diff --git a/gui/settingsdialog.cpp b/gui/settingsdialog.cpp index d3be9cd3..f3aa7316 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -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()); diff --git a/gui/settingsdialog.ui b/gui/settingsdialog.ui index 6e6d115f..c1cbee26 100644 --- a/gui/settingsdialog.ui +++ b/gui/settingsdialog.ui @@ -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> diff --git a/logic/BaseInstance.cpp b/logic/BaseInstance.cpp index bd2aad8a..6593e715 100644 --- a/logic/BaseInstance.cpp +++ b/logic/BaseInstance.cpp @@ -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); diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h index 13ed169f..a1e6075a 100644 --- a/logic/BaseInstance.h +++ b/logic/BaseInstance.h @@ -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; }; diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp index dce1d2f3..3aa3e683 100644 --- a/logic/LegacyInstance.cpp +++ b/logic/LegacyInstance.cpp @@ -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; diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp index 4cbf17b2..61002320 100644 --- a/logic/OneSixInstance.cpp +++ b/logic/OneSixInstance.cpp @@ -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; diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp index 39f55f7b..b2c9ec6d 100644 --- a/logic/lists/InstanceList.cpp +++ b/logic/lists/InstanceList.cpp @@ -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(); }; diff --git a/logic/lists/InstanceList.h b/logic/lists/InstanceList.h index 82ef0ea4..50ba56f3 100644 --- a/logic/lists/InstanceList.h +++ b/logic/lists/InstanceList.h @@ -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; |