From f0990fae4bc6e54837764c0ded1461b9f1770401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 25 Aug 2013 22:48:41 +0200 Subject: 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. --- gui/EditNotesDialog.cpp | 27 +++++++++++ gui/EditNotesDialog.h | 20 ++++++++ gui/EditNotesDialog.ui | 77 +++++++++++++++++++++++++++++++ gui/LabeledToolButton.cpp | 72 +++++++++++++++++++++++++++++ gui/LabeledToolButton.h | 22 +++++++++ gui/LegacyModEditDialog.ui | 2 +- gui/instancesettings.cpp | 3 ++ gui/instancesettings.ui | 23 ++++++++++ gui/mainwindow.cpp | 112 +++++++++++++++++++++++++++------------------ gui/mainwindow.h | 9 +++- gui/mainwindow.ui | 15 +++++- gui/settingsdialog.cpp | 2 + gui/settingsdialog.ui | 23 ++++++++++ 13 files changed, 357 insertions(+), 50 deletions(-) create mode 100644 gui/EditNotesDialog.cpp create mode 100644 gui/EditNotesDialog.h create mode 100644 gui/EditNotesDialog.ui create mode 100644 gui/LabeledToolButton.cpp create mode 100644 gui/LabeledToolButton.h (limited to 'gui') 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 +#include + +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 + +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 @@ + + + EditNotesDialog + + + + 0 + 0 + 459 + 399 + + + + Edit Notes + + + + + + Qt::ScrollBarAlwaysOn + + + false + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + EditNotesDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + EditNotesDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + 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 +#include +#include +#include +#include "LabeledToolButton.h" +#include + + +/* + * + * 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 +#include + +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 @@ - 1 + 0 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 @@ + + + + 64 + + + 512 + + + 8 + + + 64 + + + + + + + PermGen: + + + 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 @@ + + @@ -99,8 +101,6 @@ false - - @@ -428,6 +428,17 @@ Open the instance's config folder + + + true + + + Meow + + + Catnatok. Or just a cant with a ball of yarn? WHO KNOWS?! + + 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 @@ + + + + PermGen: + + + + + + + 64 + + + 512 + + + 8 + + + 64 + + + -- cgit v1.2.3