diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/logindialog.cpp | 51 | ||||
-rw-r--r-- | gui/logindialog.h | 40 | ||||
-rw-r--r-- | gui/logindialog.ui | 146 | ||||
-rw-r--r-- | gui/mainwindow.cpp | 87 | ||||
-rw-r--r-- | gui/mainwindow.h | 17 | ||||
-rw-r--r-- | gui/mainwindow.ui | 223 | ||||
-rw-r--r-- | gui/newinstancedialog.cpp | 33 | ||||
-rw-r--r-- | gui/newinstancedialog.h | 37 | ||||
-rw-r--r-- | gui/newinstancedialog.ui | 166 | ||||
-rw-r--r-- | gui/settingsdialog.cpp | 112 | ||||
-rw-r--r-- | gui/settingsdialog.h | 7 | ||||
-rw-r--r-- | gui/settingsdialog.ui | 107 | ||||
-rw-r--r-- | gui/taskdialog.cpp | 109 | ||||
-rw-r--r-- | gui/taskdialog.h | 63 | ||||
-rw-r--r-- | gui/taskdialog.ui | 53 |
15 files changed, 1155 insertions, 96 deletions
diff --git a/gui/logindialog.cpp b/gui/logindialog.cpp new file mode 100644 index 00000000..426757a9 --- /dev/null +++ b/gui/logindialog.cpp @@ -0,0 +1,51 @@ +/* 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 "logindialog.h" +#include "ui_logindialog.h" + +LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) : + QDialog(parent), + ui(new Ui::LoginDialog) +{ + ui->setupUi(this); + + if (loginErrMsg.isEmpty()) + ui->loginErrorLabel->setVisible(false); + else + { + ui->loginErrorLabel->setVisible(true); + ui->loginErrorLabel->setText(QString("<span style=\" color:#ff0000;\">%1</span>"). + arg(loginErrMsg)); + } + + resize(minimumSizeHint()); + layout()->setSizeConstraint(QLayout::SetFixedSize); +} + +LoginDialog::~LoginDialog() +{ + delete ui; +} + +QString LoginDialog::getUsername() const +{ + return ui->usernameTextBox->text(); +} + +QString LoginDialog::getPassword() const +{ + return ui->passwordTextBox->text(); +} diff --git a/gui/logindialog.h b/gui/logindialog.h new file mode 100644 index 00000000..1b70dcd5 --- /dev/null +++ b/gui/logindialog.h @@ -0,0 +1,40 @@ +/* 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. + */ + +#ifndef LOGINDIALOG_H +#define LOGINDIALOG_H + +#include <QDialog> + +namespace Ui { +class LoginDialog; +} + +class LoginDialog : public QDialog +{ + Q_OBJECT + +public: + explicit LoginDialog(QWidget *parent = 0, const QString& loginErrMsg = ""); + ~LoginDialog(); + + QString getUsername() const; + QString getPassword() const; + +private: + Ui::LoginDialog *ui; +}; + +#endif // LOGINDIALOG_H diff --git a/gui/logindialog.ui b/gui/logindialog.ui new file mode 100644 index 00000000..ce41d2f5 --- /dev/null +++ b/gui/logindialog.ui @@ -0,0 +1,146 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>LoginDialog</class> + <widget class="QDialog" name="LoginDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>365</width> + <height>145</height> + </rect> + </property> + <property name="windowTitle"> + <string>Login</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="loginErrorLabel"> + <property name="text"> + <string><span style=" color:#ff0000;">Error</span></string> + </property> + </widget> + </item> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="usernameLabel"> + <property name="text"> + <string>Username:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="usernameTextBox"> + <property name="placeholderText"> + <string>Username</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="passwordLabel"> + <property name="text"> + <string>Password:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="passwordTextBox"> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + <property name="placeholderText"> + <string>Password</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="checkboxLayout"> + <item> + <widget class="QPushButton" name="forceUpdateButton"> + <property name="text"> + <string>&Force Update</string> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="rememberUsernameCheckbox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Remember Username?</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="rememberPasswordCheckbox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>R&emember Password?</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="loginButtonBox"> + <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>loginButtonBox</sender> + <signal>accepted()</signal> + <receiver>LoginDialog</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>loginButtonBox</sender> + <signal>rejected()</signal> + <receiver>LoginDialog</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/mainwindow.cpp b/gui/mainwindow.cpp index 87a1dcc0..bc0840a0 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -16,16 +16,35 @@ #include "mainwindow.h" #include "ui_mainwindow.h" +#include <QMenu> +#include <QMessageBox> + #include <QDesktopServices> #include <QUrl> -#include "../gui/settingsdialog.h" +#include "util/osutils.h" + +#include "gui/settingsdialog.h" +#include "gui/newinstancedialog.h" +#include "gui/logindialog.h" +#include "gui/taskdialog.h" + +#include "data/appsettings.h" +#include "data/version.h" + +#include "tasks/logintask.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); + + setWindowTitle(QString("MultiMC %1").arg(Version::current.toString())); + + restoreGeometry(settings->getConfig().value("MainWindowGeometry", saveGeometry()).toByteArray()); + restoreState(settings->getConfig().value("MainWindowState", saveState()).toByteArray()); + instList.initialLoad("instances"); ui->instanceView->setModel(&instList); } @@ -37,12 +56,13 @@ MainWindow::~MainWindow() void MainWindow::on_actionAddInstance_triggered() { - + NewInstanceDialog *newInstDlg = new NewInstanceDialog(this); + newInstDlg->exec(); } void MainWindow::on_actionViewInstanceFolder_triggered() { - + openInDefaultProgram(settings->getInstanceDir()); } void MainWindow::on_actionRefresh_triggered() @@ -52,7 +72,7 @@ void MainWindow::on_actionRefresh_triggered() void MainWindow::on_actionViewCentralModsFolder_triggered() { - + openInDefaultProgram(settings->getCentralModsDir()); } void MainWindow::on_actionCheckUpdate_triggered() @@ -68,15 +88,70 @@ void MainWindow::on_actionSettings_triggered() void MainWindow::on_actionReportBug_triggered() { - + QDesktopServices::openUrl(QUrl("http://bugs.forkk.net/")); } void MainWindow::on_actionNews_triggered() { - + QDesktopServices::openUrl(QUrl("http://news.forkk.net/")); } void MainWindow::on_actionAbout_triggered() { } + +void MainWindow::on_mainToolBar_visibilityChanged(bool) +{ + // Don't allow hiding the main toolbar. + // This is the only way I could find to prevent it... :/ + ui->mainToolBar->setVisible(true); +} + +void MainWindow::closeEvent(QCloseEvent *event) +{ + // Save the window state and geometry. + settings->getConfig().setValue("MainWindowGeometry", saveGeometry()); + settings->getConfig().setValue("MainWindowState", saveState()); + QMainWindow::closeEvent(event); +} + +void MainWindow::on_instanceView_customContextMenuRequested(const QPoint &pos) +{ + QMenu *instContextMenu = new QMenu("Instance", this); + + // Add the actions from the toolbar to the context menu. + instContextMenu->addActions(ui->instanceToolBar->actions()); + + instContextMenu->exec(ui->instanceView->mapToGlobal(pos)); +} + + +void MainWindow::on_actionLaunchInstance_triggered() +{ + doLogin(); +} + +void MainWindow::doLogin(const QString &errorMsg) +{ + LoginDialog* loginDlg = new LoginDialog(this, errorMsg); + if (loginDlg->exec()) + { + UserInfo uInfo(loginDlg->getUsername(), loginDlg->getPassword()); + + TaskDialog* tDialog = new TaskDialog(this); + LoginTask* loginTask = new LoginTask(uInfo, tDialog); + connect(loginTask, SIGNAL(loginComplete(LoginResponse)), + SLOT(onLoginComplete(LoginResponse)), Qt::QueuedConnection); + connect(loginTask, SIGNAL(loginFailed(QString)), + SLOT(doLogin(QString)), Qt::QueuedConnection); + tDialog->exec(loginTask); + } +} + +void MainWindow::onLoginComplete(LoginResponse response) +{ + QMessageBox::information(this, "Login Successful", + QString("Logged in as %1 with session ID %2."). + arg(response.getUsername(), response.getSessionID())); +} diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 77245531..28ca341a 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -18,7 +18,8 @@ #include <QMainWindow> -#include "../data/instancemodel.h" +#include "data/instancemodel.h" +#include "data/loginresponse.h" namespace Ui { @@ -33,6 +34,8 @@ public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); + void closeEvent(QCloseEvent *event); + private slots: void on_actionAbout_triggered(); @@ -52,6 +55,18 @@ private slots: void on_actionNews_triggered(); + void on_mainToolBar_visibilityChanged(bool); + + void on_instanceView_customContextMenuRequested(const QPoint &pos); + + void on_actionLaunchInstance_triggered(); + + + void doLogin(const QString& errorMsg = ""); + + + void onLoginComplete(LoginResponse response); + private: Ui::MainWindow *ui; diff --git a/gui/mainwindow.ui b/gui/mainwindow.ui index 5abfb37d..137f7e97 100644 --- a/gui/mainwindow.ui +++ b/gui/mainwindow.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>739</width> - <height>657</height> + <width>600</width> + <height>400</height> </rect> </property> <property name="windowTitle"> @@ -44,11 +44,17 @@ <attribute name="headerVisible"> <bool>false</bool> </attribute> + <property name="contextMenuPolicy"> + <enum>Qt::CustomContextMenu</enum> + </property> </widget> </item> </layout> </widget> <widget class="QToolBar" name="mainToolBar"> + <property name="windowTitle"> + <string>Main Toolbar</string> + </property> <property name="movable"> <bool>false</bool> </property> @@ -74,6 +80,38 @@ <addaction name="actionAbout"/> </widget> <widget class="QStatusBar" name="statusBar"/> + <widget class="QToolBar" name="instanceToolBar"> + <property name="windowTitle"> + <string>Instance Toolbar</string> + </property> + <property name="floatable"> + <bool>false</bool> + </property> + <attribute name="toolBarArea"> + <enum>RightToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>false</bool> + </attribute> + <addaction name="actionLaunchInstance"/> + <addaction name="separator"/> + <addaction name="actionRenameInstance"/> + <addaction name="actionChangeInstGroup"/> + <addaction name="actionChangeInstIcon"/> + <addaction name="actionChangeInstMCVersion"/> + <addaction name="actionChangeInstLWJGLVersion"/> + <addaction name="actionEditInstNotes"/> + <addaction name="separator"/> + <addaction name="actionEditInstMods"/> + <addaction name="actionManageInstSaves"/> + <addaction name="actionRebuildInstJar"/> + <addaction name="separator"/> + <addaction name="actionInstanceSettings"/> + <addaction name="actionMakeDesktopShortcut"/> + <addaction name="actionViewSelectedInstFolder"/> + <addaction name="separator"/> + <addaction name="actionDeleteInstance"/> + </widget> <action name="actionAddInstance"> <property name="icon"> <iconset resource="../multimc.qrc"> @@ -85,6 +123,9 @@ <property name="toolTip"> <string>Add a new instance.</string> </property> + <property name="statusTip"> + <string>Add a new instance.</string> + </property> </action> <action name="actionViewInstanceFolder"> <property name="icon"> @@ -97,6 +138,9 @@ <property name="toolTip"> <string>Open the instance folder in a file browser.</string> </property> + <property name="statusTip"> + <string>Open the instance folder in a file browser.</string> + </property> </action> <action name="actionRefresh"> <property name="icon"> @@ -109,6 +153,9 @@ <property name="toolTip"> <string>Reload the instance list.</string> </property> + <property name="statusTip"> + <string>Reload the instance list.</string> + </property> </action> <action name="actionViewCentralModsFolder"> <property name="icon"> @@ -121,6 +168,9 @@ <property name="toolTip"> <string>Open the central mods folder in a file browser.</string> </property> + <property name="statusTip"> + <string>Open the central mods folder in a file browser.</string> + </property> </action> <action name="actionCheckUpdate"> <property name="icon"> @@ -133,6 +183,9 @@ <property name="toolTip"> <string>Check for new updates for MultiMC</string> </property> + <property name="statusTip"> + <string>Check for new updates for MultiMC</string> + </property> </action> <action name="actionSettings"> <property name="icon"> @@ -145,6 +198,9 @@ <property name="toolTip"> <string>Change settings.</string> </property> + <property name="statusTip"> + <string>Change settings.</string> + </property> <property name="menuRole"> <enum>QAction::PreferencesRole</enum> </property> @@ -160,6 +216,9 @@ <property name="toolTip"> <string>Open the bug tracker to report a bug with MultiMC.</string> </property> + <property name="statusTip"> + <string>Open the bug tracker to report a bug with MultiMC.</string> + </property> </action> <action name="actionNews"> <property name="icon"> @@ -172,6 +231,9 @@ <property name="toolTip"> <string>Open the MultiMC dev blog to read news about MultiMC.</string> </property> + <property name="statusTip"> + <string>Open the MultiMC dev blog to read news about MultiMC.</string> + </property> </action> <action name="actionAbout"> <property name="icon"> @@ -184,10 +246,167 @@ <property name="toolTip"> <string>View information about MultiMC.</string> </property> + <property name="statusTip"> + <string>About MultiMC</string> + </property> <property name="menuRole"> <enum>QAction::AboutRole</enum> </property> </action> + <action name="actionLaunchInstance"> + <property name="text"> + <string>Play</string> + </property> + <property name="toolTip"> + <string>Launch the selected instance.</string> + </property> + <property name="statusTip"> + <string>Launch the selected instance.</string> + </property> + </action> + <action name="actionRenameInstance"> + <property name="text"> + <string>Rename</string> + </property> + <property name="toolTip"> + <string>Rename the selected instance.</string> + </property> + <property name="statusTip"> + <string>Rename the selected instance.</string> + </property> + </action> + <action name="actionChangeInstGroup"> + <property name="text"> + <string>Change Group</string> + </property> + <property name="toolTip"> + <string>Change the selected instance's group.</string> + </property> + <property name="statusTip"> + <string>Change the selected instance's group.</string> + </property> + </action> + <action name="actionChangeInstIcon"> + <property name="text"> + <string>Change Icon</string> + </property> + <property name="toolTip"> + <string>Change the selected instance's icon.</string> + </property> + <property name="statusTip"> + <string>Change the selected instance's icon.</string> + </property> + </action> + <action name="actionEditInstNotes"> + <property name="text"> + <string>Edit Notes</string> + </property> + <property name="toolTip"> + <string>Edit the notes for the selected instance.</string> + </property> + <property name="statusTip"> + <string>Edit the notes for the selected instance.</string> + </property> + </action> + <action name="actionInstanceSettings"> + <property name="text"> + <string>Settings</string> + </property> + <property name="toolTip"> + <string>Change settings for the selected instance.</string> + </property> + <property name="statusTip"> + <string>Change settings for the selected instance.</string> + </property> + </action> + <action name="actionMakeDesktopShortcut"> + <property name="text"> + <string>Make Shortcut</string> + </property> + <property name="toolTip"> + <string>Make a shortcut on the desktop for the selected instance.</string> + </property> + <property name="statusTip"> + <string>Make a shortcut on the desktop for the selected instance.</string> + </property> + </action> + <action name="actionManageInstSaves"> + <property name="text"> + <string>Manage Saves</string> + </property> + <property name="toolTip"> + <string>Manage saves for the selected instance.</string> + </property> + <property name="statusTip"> + <string>Manage saves for the selected instance.</string> + </property> + </action> + <action name="actionEditInstMods"> + <property name="text"> + <string>Edit Mods</string> + </property> + <property name="toolTip"> + <string>Edit the mods for the selected instance.</string> + </property> + <property name="statusTip"> + <string>Edit the mods for the selected instance.</string> + </property> + </action> + <action name="actionChangeInstMCVersion"> + <property name="text"> + <string>Change Version</string> + </property> + <property name="toolTip"> + <string>Change the selected instance's Minecraft version.</string> + </property> + <property name="statusTip"> + <string>Change the selected instance's Minecraft version.</string> + </property> + </action> + <action name="actionChangeInstLWJGLVersion"> + <property name="text"> + <string>Change LWJGL</string> + </property> + <property name="toolTip"> + <string>Change the version of LWJGL for the selected instance to use.</string> + </property> + <property name="statusTip"> + <string>Change the version of LWJGL for the selected instance to use.</string> + </property> + </action> + <action name="actionRebuildInstJar"> + <property name="text"> + <string>Rebuild Jar</string> + </property> + <property name="toolTip"> + <string>Reinstall the mods for the selected instance.</string> + </property> + <property name="statusTip"> + <string>Reinstall the mods for the selected instance.</string> + </property> + </action> + <action name="actionViewSelectedInstFolder"> + <property name="text"> + <string>View Folder</string> + </property> + <property name="toolTip"> + <string>Open the selected instance's root folder in a file browser.</string> + </property> + <property name="statusTip"> + <string>Open the selected instance's root folder in a file browser.</string> + </property> + </action> + <action name="actionDeleteInstance"> + <property name="text"> + <string>Delete</string> + </property> + <property name="toolTip"> + <string>Delete the selected instance.</string> + </property> + <property name="statusTip"> + <string>Delete the selected instance.</string> + </property> + </action> </widget> <layoutdefault spacing="6" margin="11"/> <resources> diff --git a/gui/newinstancedialog.cpp b/gui/newinstancedialog.cpp new file mode 100644 index 00000000..400b42d8 --- /dev/null +++ b/gui/newinstancedialog.cpp @@ -0,0 +1,33 @@ +/* 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 "newinstancedialog.h" +#include "ui_newinstancedialog.h" + +#include <QLayout> + +NewInstanceDialog::NewInstanceDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::NewInstanceDialog) +{ + ui->setupUi(this); + resize(minimumSizeHint()); + layout()->setSizeConstraint(QLayout::SetFixedSize); +} + +NewInstanceDialog::~NewInstanceDialog() +{ + delete ui; +} diff --git a/gui/newinstancedialog.h b/gui/newinstancedialog.h new file mode 100644 index 00000000..263136f1 --- /dev/null +++ b/gui/newinstancedialog.h @@ -0,0 +1,37 @@ +/* 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. + */ + +#ifndef NEWINSTANCEDIALOG_H +#define NEWINSTANCEDIALOG_H + +#include <QDialog> + +namespace Ui { +class NewInstanceDialog; +} + +class NewInstanceDialog : public QDialog +{ + Q_OBJECT + +public: + explicit NewInstanceDialog(QWidget *parent = 0); + ~NewInstanceDialog(); + +private: + Ui::NewInstanceDialog *ui; +}; + +#endif // NEWINSTANCEDIALOG_H diff --git a/gui/newinstancedialog.ui b/gui/newinstancedialog.ui new file mode 100644 index 00000000..865f6301 --- /dev/null +++ b/gui/newinstancedialog.ui @@ -0,0 +1,166 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>NewInstanceDialog</class> + <widget class="QDialog" name="NewInstanceDialog"> + <property name="windowModality"> + <enum>Qt::ApplicationModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>220</width> + <height>230</height> + </rect> + </property> + <property name="windowTitle"> + <string>New Instance</string> + </property> + <property name="windowIcon"> + <iconset resource="../multimc.qrc"> + <normaloff>:/icons/toolbar/new</normaloff>:/icons/toolbar/new</iconset> + </property> + <property name="modal"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="iconBtnLayout"> + <item> + <spacer name="iconBtnLeftSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="iconButton"> + <property name="icon"> + <iconset resource="../multimc.qrc"> + <normaloff>:/icons/instances/infinity</normaloff>:/icons/instances/infinity</iconset> + </property> + <property name="iconSize"> + <size> + <width>80</width> + <height>80</height> + </size> + </property> + </widget> + </item> + <item> + <spacer name="iconBtnRightSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <widget class="QLineEdit" name="instNameTextBox"> + <property name="placeholderText"> + <string>Name</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="labelVersion"> + <property name="text"> + <string>Version:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="versionTextBox"> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="btnChangeVersion"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="Line" name="line_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </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> + <include location="../multimc.qrc"/> + </resources> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>NewInstanceDialog</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>NewInstanceDialog</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/settingsdialog.cpp b/gui/settingsdialog.cpp index 46569340..ab4d18ee 100644 --- a/gui/settingsdialog.cpp +++ b/gui/settingsdialog.cpp @@ -16,13 +16,19 @@ #include "settingsdialog.h" #include "ui_settingsdialog.h" +#include "data/appsettings.h" + #include <QFileDialog> +#include <QMessageBox> SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SettingsDialog) { ui->setupUi(this); + + loadSettings(settings); + updateCheckboxStuff(); } SettingsDialog::~SettingsDialog() @@ -32,10 +38,10 @@ SettingsDialog::~SettingsDialog() void SettingsDialog::updateCheckboxStuff() { - ui->minMemSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() || - ui->maximizedCheckBox->isChecked())); - ui->maxMemSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() || - ui->maximizedCheckBox->isChecked())); + ui->windowWidthSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() || + ui->maximizedCheckBox->isChecked())); + ui->windowHeightSpinBox->setEnabled(!(ui->compatModeCheckBox->isChecked() || + ui->maximizedCheckBox->isChecked())); ui->maximizedCheckBox->setEnabled(!ui->compatModeCheckBox->isChecked()); } @@ -75,3 +81,101 @@ void SettingsDialog::on_maximizedCheckBox_clicked(bool checked) Q_UNUSED(checked); updateCheckboxStuff(); } + +void SettingsDialog::on_buttonBox_accepted() +{ + applySettings(settings); +} + +void SettingsDialog::applySettings(SettingsBase *s) +{ + // Special cases + + // Warn about dev builds. + if (!ui->devBuildsCheckBox->isChecked()) + { + s->setUseDevBuilds(false); + } + else if (!s->getUseDevBuilds()) + { + int response = QMessageBox::question(this, "Development builds", + "Development builds contain experimental features " + "and may be unstable. Are you sure you want to enable them?"); + if (response == QMessageBox::Yes) + { + s->setUseDevBuilds(true); + } + } + + + // Updates + s->setAutoUpdate(ui->autoUpdateCheckBox->isChecked()); + + // Folders + // TODO: Offer to move instances to new instance folder. + s->setInstanceDir(ui->instDirTextBox->text()); + s->setCentralModsDir(ui->modsDirTextBox->text()); + s->setLWJGLDir(ui->lwjglDirTextBox->text()); + + // Console + s->setShowConsole(ui->showConsoleCheck->isChecked()); + s->setAutoCloseConsole(ui->autoCloseConsoleCheck->isChecked()); + + // Window Size + s->setLaunchCompatMode(ui->compatModeCheckBox->isChecked()); + s->setLaunchMaximized(ui->maximizedCheckBox->isChecked()); + s->setMinecraftWinWidth(ui->windowWidthSpinBox->value()); + s->setMinecraftWinHeight(ui->windowHeightSpinBox->value()); + + // Auto Login + s->setAutoLogin(ui->autoLoginCheckBox->isChecked()); + + // Memory + s->setMinMemAlloc(ui->minMemSpinBox->value()); + s->setMaxMemAlloc(ui->maxMemSpinBox->value()); + + // Java Settings + s->setJavaPath(ui->javaPathTextBox->text()); + s->setJvmArgs(ui->jvmArgsTextBox->text()); + + // Custom Commands + s->setPreLaunchCommand(ui->preLaunchCmdTextBox->text()); + s->setPostExitCommand(ui->postExitCmdTextBox->text()); +} + +void SettingsDialog::loadSettings(SettingsBase *s) +{ + // Updates + ui->autoUpdateCheckBox->setChecked(s->getAutoUpdate()); + ui->devBuildsCheckBox->setChecked(s->getUseDevBuilds()); + + // Folders + ui->instDirTextBox->setText(s->getInstanceDir()); + ui->modsDirTextBox->setText(s->getCentralModsDir()); + ui->lwjglDirTextBox->setText(s->getLWJGLDir()); + + // Console + ui->showConsoleCheck->setChecked(s->getShowConsole()); + ui->autoCloseConsoleCheck->setChecked(s->getAutoCloseConsole()); + + // Window Size + ui->compatModeCheckBox->setChecked(s->getLaunchCompatMode()); + ui->maximizedCheckBox->setChecked(s->getLaunchMaximized()); + ui->windowWidthSpinBox->setValue(s->getMinecraftWinWidth()); + ui->windowHeightSpinBox->setValue(s->getMinecraftWinHeight()); + + // Auto Login + ui->autoLoginCheckBox->setChecked(s->getAutoLogin()); + + // Memory + ui->minMemSpinBox->setValue(s->getMinMemAlloc()); + ui->maxMemSpinBox->setValue(s->getMaxMemAlloc()); + + // Java Settings + ui->javaPathTextBox->setText(s->getJavaPath()); + ui->jvmArgsTextBox->setText(s->getJvmArgs()); + + // Custom Commands + ui->preLaunchCmdTextBox->setText(s->getPreLaunchCommand()); + ui->postExitCmdTextBox->setText(s->getPostExitCommand()); +} diff --git a/gui/settingsdialog.h b/gui/settingsdialog.h index 3e9d9e0f..e223237f 100644 --- a/gui/settingsdialog.h +++ b/gui/settingsdialog.h @@ -18,6 +18,8 @@ #include <QDialog> +class SettingsBase; + namespace Ui { class SettingsDialog; } @@ -32,6 +34,9 @@ public: void updateCheckboxStuff(); + void applySettings(SettingsBase* s); + void loadSettings(SettingsBase* s); + private slots: void on_instDirBrowseBtn_clicked(); @@ -43,6 +48,8 @@ private slots: void on_maximizedCheckBox_clicked(bool checked); + void on_buttonBox_accepted(); + private: Ui::SettingsDialog *ui; }; diff --git a/gui/settingsdialog.ui b/gui/settingsdialog.ui index 315686ca..d30f56bb 100644 --- a/gui/settingsdialog.ui +++ b/gui/settingsdialog.ui @@ -158,88 +158,6 @@ </item> </layout> </widget> - <widget class="QWidget" name="consoleTab"> - <attribute name="title"> - <string>Console</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="consoleSettingsBox"> - <property name="title"> - <string>Console Settings</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QCheckBox" name="showConsoleCheck"> - <property name="text"> - <string>Show console while the game is running?</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="autoCloseConsoleCheck"> - <property name="text"> - <string>Automatically close console when the game quits?</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="consoleColorsBox"> - <property name="title"> - <string>Instance Console Colors</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="labelSysMessageColor"> - <property name="text"> - <string>System message color:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="sysMsgColorTextBox"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="labelOutputMsgColor"> - <property name="text"> - <string>Output message color:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="outMsgColorTextBox"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="labelErrorMessageColor"> - <property name="text"> - <string>Error message color:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="errMsgColorTextBox"/> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="consoleVerticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> <widget class="QWidget" name="minecraftTab"> <attribute name="title"> <string>Minecraft</string> @@ -316,9 +234,32 @@ </widget> </item> <item> + <widget class="QGroupBox" name="consoleSettingsBox"> + <property name="title"> + <string>Console Settings</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QCheckBox" name="showConsoleCheck"> + <property name="text"> + <string>Show console while the game is running?</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="autoCloseConsoleCheck"> + <property name="text"> + <string>Automatically close console when the game quits?</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> <widget class="QCheckBox" name="autoLoginCheckBox"> <property name="text"> - <string>Login automatically when an instance launches?</string> + <string>Login automatically when an instance icon is double clicked?</string> </property> </widget> </item> diff --git a/gui/taskdialog.cpp b/gui/taskdialog.cpp new file mode 100644 index 00000000..a8738fe3 --- /dev/null +++ b/gui/taskdialog.cpp @@ -0,0 +1,109 @@ +/* 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 "taskdialog.h" +#include "ui_taskdialog.h" + +#include <QKeyEvent> + +#include "tasks/task.h" + +TaskDialog::TaskDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::TaskDialog) +{ + ui->setupUi(this); + updateSize(); + + changeProgress(0); +} + +TaskDialog::~TaskDialog() +{ + delete ui; +} + +void TaskDialog::updateSize() +{ + resize(QSize(480, minimumSizeHint().height())); +} + +void TaskDialog::exec(Task *task) +{ + this->task = task; + + // Connect signals. + connect(task, SIGNAL(taskStarted(Task*)), + this, SLOT(onTaskStarted(Task*))); + connect(task, SIGNAL(taskEnded(Task*)), + this, SLOT(onTaskEnded(Task*))); + connect(task, SIGNAL(statusChanged(const QString&)), + this, SLOT(changeStatus(const QString&))); + connect(task, SIGNAL(progressChanged(int)), + this, SLOT(changeProgress(int))); + + task->startTask(); + QDialog::exec(); +} + +Task* TaskDialog::getTask() +{ + return task; +} + +void TaskDialog::onTaskStarted(Task*) +{ + +} + +void TaskDialog::onTaskEnded(Task*) +{ + close(); +} + +void TaskDialog::changeStatus(const QString &status) +{ + ui->statusLabel->setText(status); + updateSize(); +} + +void TaskDialog::changeProgress(int progress) +{ + if (progress < 0) + progress = 0; + else if (progress > 100) + progress = 100; + + ui->taskProgressBar->setValue(progress); +} + +void TaskDialog::keyPressEvent(QKeyEvent* e) +{ + if (e->key() == Qt::Key_Escape) + return; + QDialog::keyPressEvent(e); +} + +void TaskDialog::closeEvent(QCloseEvent* e) +{ + if (task && task->isRunning()) + { + e->ignore(); + } + else + { + QDialog::closeEvent(e); + } +} diff --git a/gui/taskdialog.h b/gui/taskdialog.h new file mode 100644 index 00000000..faf3ed90 --- /dev/null +++ b/gui/taskdialog.h @@ -0,0 +1,63 @@ +/* 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. + */ + +#ifndef TASKDIALOG_H +#define TASKDIALOG_H + +#include <QDialog> + +class Task; + +namespace Ui { +class TaskDialog; +} + +class TaskDialog : public QDialog +{ + Q_OBJECT + +public: + explicit TaskDialog(QWidget *parent = 0); + ~TaskDialog(); + + void updateSize(); + + void exec(Task* task); + + Task* getTask(); + +public slots: + void onTaskStarted(Task*); + void onTaskEnded(Task*); + + void changeStatus(const QString& status); + void changeProgress(int progress); + + void test() { qDebug("Lol"); } + +signals: + + +protected: + virtual void keyPressEvent(QKeyEvent* e); + virtual void closeEvent(QCloseEvent* e); + +private: + Ui::TaskDialog *ui; + + Task* task; +}; + +#endif // TASKDIALOG_H diff --git a/gui/taskdialog.ui b/gui/taskdialog.ui new file mode 100644 index 00000000..1cdf7978 --- /dev/null +++ b/gui/taskdialog.ui @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>TaskDialog</class> + <widget class="QDialog" name="TaskDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>58</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>400</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>600</width> + <height>16777215</height> + </size> + </property> + <property name="windowTitle"> + <string>Please wait...</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="statusLabel"> + <property name="text"> + <string>Task Status...</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QProgressBar" name="taskProgressBar"> + <property name="value"> + <number>24</number> + </property> + <property name="textVisible"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> |