summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt6
-rw-r--r--gui/MainWindow.cpp50
-rw-r--r--gui/dialogs/EditNotesDialog.cpp43
-rw-r--r--gui/dialogs/EditNotesDialog.ui77
-rw-r--r--gui/pages/NotesPage.cpp35
-rw-r--r--gui/pages/NotesPage.h (renamed from gui/dialogs/EditNotesDialog.h)27
-rw-r--r--gui/pages/NotesPage.ui46
-rw-r--r--logic/LegacyInstance.cpp2
-rw-r--r--logic/OneSixInstance.cpp2
9 files changed, 124 insertions, 164 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 656e350b..af8dca4b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -301,6 +301,8 @@ SET(MULTIMC_SOURCES
gui/pages/ResourcePackPage.h
gui/pages/ModFolderPage.cpp
gui/pages/ModFolderPage.h
+ gui/pages/NotesPage.cpp
+ gui/pages/NotesPage.h
gui/pages/LegacyUpgradePage.cpp
gui/pages/LegacyUpgradePage.h
gui/pages/LegacyJarModPage.cpp
@@ -321,8 +323,6 @@ SET(MULTIMC_SOURCES
gui/dialogs/CustomMessageBox.h
gui/dialogs/EditAccountDialog.cpp
gui/dialogs/EditAccountDialog.h
- gui/dialogs/EditNotesDialog.cpp
- gui/dialogs/EditNotesDialog.h
gui/dialogs/IconPickerDialog.cpp
gui/dialogs/IconPickerDialog.h
gui/dialogs/LoginDialog.cpp
@@ -615,6 +615,7 @@ SET(MULTIMC_UIS
gui/pages/LegacyUpgradePage.ui
gui/pages/LegacyJarModPage.ui
gui/pages/InstanceSettingsPage.ui
+ gui/pages/NotesPage.ui
# Dialogs
gui/dialogs/SettingsDialog.ui
@@ -625,7 +626,6 @@ SET(MULTIMC_UIS
gui/dialogs/LwjglSelectDialog.ui
gui/dialogs/ProgressDialog.ui
gui/dialogs/IconPickerDialog.ui
- gui/dialogs/EditNotesDialog.ui
gui/dialogs/AccountListDialog.ui
gui/dialogs/AccountSelectDialog.ui
gui/dialogs/EditAccountDialog.ui
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index e9cfd361..35ac541d 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -57,7 +57,6 @@
#include "gui/dialogs/CustomMessageBox.h"
#include "gui/dialogs/LwjglSelectDialog.h"
#include "gui/dialogs/IconPickerDialog.h"
-#include "gui/dialogs/EditNotesDialog.h"
#include "gui/dialogs/CopyInstanceDialog.h"
#include "gui/dialogs/AccountListDialog.h"
#include "gui/dialogs/AccountSelectDialog.h"
@@ -941,17 +940,31 @@ void MainWindow::on_actionSettings_triggered()
updateToolsMenu();
}
-void MainWindow::on_actionInstanceSettings_triggered()
+template <typename T>
+void ShowPageDialog(T raw_provider, QWidget * parent, QString open_page = QString())
{
- if (!m_selectedInstance)
- return;
- auto provider = std::dynamic_pointer_cast<BasePageProvider>(m_selectedInstance);
+ auto provider = std::dynamic_pointer_cast<BasePageProvider>(raw_provider);
if(!provider)
return;
- PageDialog dlg(provider, "settings" , this);
+ PageDialog dlg(provider, open_page, parent);
dlg.exec();
}
+void MainWindow::on_actionInstanceSettings_triggered()
+{
+ ShowPageDialog(m_selectedInstance, this, "settings");
+}
+
+void MainWindow::on_actionEditInstNotes_triggered()
+{
+ ShowPageDialog(m_selectedInstance, this, "notes");
+}
+
+void MainWindow::on_actionEditInstance_triggered()
+{
+ ShowPageDialog(m_selectedInstance, this);
+}
+
void MainWindow::on_actionManageAccounts_triggered()
{
AccountListDialog dialog(this);
@@ -1040,17 +1053,6 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered()
}
}
-void MainWindow::on_actionEditInstance_triggered()
-{
- if (!m_selectedInstance)
- return;
- auto provider = std::dynamic_pointer_cast<BasePageProvider>(m_selectedInstance);
- if(!provider)
- return;
- PageDialog dlg(provider, "" , this);
- dlg.exec();
-}
-
void MainWindow::closeEvent(QCloseEvent *event)
{
// Save the window state and geometry.
@@ -1398,20 +1400,6 @@ void MainWindow::selectionBad()
setSelectedInstanceById(MMC->settings()->get("SelectedInstance").toString());
}
-void MainWindow::on_actionEditInstNotes_triggered()
-{
- if (!m_selectedInstance)
- return;
-
- EditNotesDialog noteedit(m_selectedInstance->notes(), m_selectedInstance->name(), this);
- noteedit.exec();
- if (noteedit.result() == QDialog::Accepted)
- {
-
- m_selectedInstance->setNotes(noteedit.getText());
- }
-}
-
void MainWindow::instanceEnded()
{
this->show();
diff --git a/gui/dialogs/EditNotesDialog.cpp b/gui/dialogs/EditNotesDialog.cpp
deleted file mode 100644
index f2aa029f..00000000
--- a/gui/dialogs/EditNotesDialog.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "EditNotesDialog.h"
-#include "ui_EditNotesDialog.h"
-#include "gui/Platform.h"
-
-#include <QIcon>
-#include <QApplication>
-
-EditNotesDialog::EditNotesDialog(QString notes, QString name, QWidget *parent)
- : QDialog(parent), ui(new Ui::EditNotesDialog), m_instance_name(name),
- m_instance_notes(notes)
-{
- MultiMCPlatform::fixWM_CLASS(this);
- ui->setupUi(this);
- ui->noteEditor->setText(notes);
- setWindowTitle(tr("Edit notes of %1").arg(m_instance_name));
- // connect(ui->closeButton, SIGNAL(clicked()), SLOT(close()));
-}
-
-EditNotesDialog::~EditNotesDialog()
-{
- delete ui;
-}
-
-QString EditNotesDialog::getText()
-{
- QString test = ui->noteEditor->toPlainText();
- return test;
-}
diff --git a/gui/dialogs/EditNotesDialog.ui b/gui/dialogs/EditNotesDialog.ui
deleted file mode 100644
index 487dfb84..00000000
--- a/gui/dialogs/EditNotesDialog.ui
+++ /dev/null
@@ -1,77 +0,0 @@
-<?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/pages/NotesPage.cpp b/gui/pages/NotesPage.cpp
new file mode 100644
index 00000000..b4746a77
--- /dev/null
+++ b/gui/pages/NotesPage.cpp
@@ -0,0 +1,35 @@
+#include "NotesPage.h"
+#include "ui_NotesPage.h"
+
+QString NotesPage::displayName()
+{
+ return tr("Notes");
+}
+
+QIcon NotesPage::icon()
+{
+ return QIcon::fromTheme("news");
+}
+
+QString NotesPage::id()
+{
+ return "notes";
+}
+
+NotesPage::NotesPage(BaseInstance *inst, QWidget *parent)
+ : QWidget(parent), ui(new Ui::NotesPage), m_inst(inst)
+{
+ ui->setupUi(this);
+ ui->noteEditor->setText(m_inst->notes());
+}
+
+NotesPage::~NotesPage()
+{
+ delete ui;
+}
+
+bool NotesPage::apply()
+{
+ m_inst->setNotes(ui->noteEditor->toPlainText());
+ return true;
+}
diff --git a/gui/dialogs/EditNotesDialog.h b/gui/pages/NotesPage.h
index b74558c4..fe916f21 100644
--- a/gui/dialogs/EditNotesDialog.h
+++ b/gui/pages/NotesPage.h
@@ -1,4 +1,4 @@
-/* Copyright 2013 MultiMC Contributors
+/* Copyright 2014 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,25 +14,32 @@
*/
#pragma once
+#include <QWidget>
-#include <QDialog>
+#include <logic/BaseInstance.h>
+#include <logic/net/NetJob.h>
+#include "BasePage.h"
+class EnabledItemFilter;
namespace Ui
{
-class EditNotesDialog;
+class NotesPage;
}
-class EditNotesDialog : public QDialog
+class NotesPage : public QWidget, public BasePage
{
Q_OBJECT
public:
- explicit EditNotesDialog(QString notes, QString name, QWidget *parent = 0);
- ~EditNotesDialog();
- QString getText();
+ explicit NotesPage(BaseInstance *inst, QWidget *parent = 0);
+ virtual ~NotesPage();
+ virtual QString displayName() override;
+ virtual QIcon icon() override;
+ virtual QString id() override;
+ virtual bool apply();
+ virtual QString helpPage() override { return "Notes"; };
private:
- Ui::EditNotesDialog *ui;
- QString m_instance_name;
- QString m_instance_notes;
+ Ui::NotesPage *ui;
+ BaseInstance *m_inst;
};
diff --git a/gui/pages/NotesPage.ui b/gui/pages/NotesPage.ui
new file mode 100644
index 00000000..ab33ffd3
--- /dev/null
+++ b/gui/pages/NotesPage.ui
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>NotesPage</class>
+ <widget class="QWidget" name="NotesPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <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>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index 58a3c321..b646bd7b 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -33,6 +33,7 @@
#include "gui/pages/LegacyJarModPage.h"
#include <gui/pages/TexturePackPage.h>
#include <gui/pages/InstanceSettingsPage.h>
+#include <gui/pages/NotesPage.h>
LegacyInstance::LegacyInstance(const QString &rootDir, SettingsObject *settings,
QObject *parent)
@@ -55,6 +56,7 @@ QList<BasePage *> LegacyInstance::getPages()
values.append(new ModFolderPage(coreModList(), "coremods", "plugin-green", tr("Core mods"),
"Core-mods"));
values.append(new TexturePackPage(this));
+ values.append(new NotesPage(this));
values.append(new InstanceSettingsPage(&settings()));
return values;
}
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index d3b35512..30e62d73 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -35,6 +35,7 @@
#include <gui/pages/ResourcePackPage.h>
#include <gui/pages/TexturePackPage.h>
#include <gui/pages/InstanceSettingsPage.h>
+#include <gui/pages/NotesPage.h>
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings,
QObject *parent)
@@ -67,6 +68,7 @@ QList<BasePage *> OneSixInstance::getPages()
"Core-mods"));
values.append(new ResourcePackPage(this));
values.append(new TexturePackPage(this));
+ values.append(new NotesPage(this));
values.append(new InstanceSettingsPage(&settings()));
return values;
}