diff options
Diffstat (limited to 'gui')
-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 |
13 files changed, 357 insertions, 50 deletions
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> |