diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/ConsoleWindow.cpp (renamed from gui/consolewindow.cpp) | 23 | ||||
-rw-r--r-- | gui/ConsoleWindow.h (renamed from gui/consolewindow.h) | 32 | ||||
-rw-r--r-- | gui/ConsoleWindow.ui (renamed from gui/consolewindow.ui) | 0 | ||||
-rw-r--r-- | gui/CustomMessageBox.cpp | 19 | ||||
-rw-r--r-- | gui/CustomMessageBox.h | 11 | ||||
-rw-r--r-- | gui/EditNotesDialog.cpp | 29 | ||||
-rw-r--r-- | gui/EditNotesDialog.h | 20 | ||||
-rw-r--r-- | gui/IconPickerDialog.cpp | 147 | ||||
-rw-r--r-- | gui/IconPickerDialog.h | 29 | ||||
-rw-r--r-- | gui/LabeledToolButton.h | 22 | ||||
-rw-r--r-- | gui/MainWindow.cpp (renamed from gui/mainwindow.cpp) | 42 | ||||
-rw-r--r-- | gui/MainWindow.h (renamed from gui/mainwindow.h) | 5 | ||||
-rw-r--r-- | gui/MainWindow.ui (renamed from gui/mainwindow.ui) | 0 | ||||
-rw-r--r-- | gui/ModEditDialogCommon.cpp | 41 | ||||
-rw-r--r-- | gui/ModEditDialogCommon.h | 7 | ||||
-rw-r--r-- | gui/ModListView.h | 13 | ||||
-rw-r--r-- | gui/Platform.h (renamed from gui/platform.h) | 7 | ||||
-rw-r--r-- | gui/Platform_Other.cpp (renamed from gui/platform_other.cpp) | 2 | ||||
-rw-r--r-- | gui/Platform_X11.cpp (renamed from gui/platform_x11.cpp) | 2 | ||||
-rw-r--r-- | gui/aboutdialog.cpp | 24 | ||||
-rw-r--r-- | gui/aboutdialog.h | 22 | ||||
-rw-r--r-- | gui/dialogs/AboutDialog.cpp | 37 | ||||
-rw-r--r-- | gui/dialogs/AboutDialog.h | 35 | ||||
-rw-r--r-- | gui/dialogs/AboutDialog.ui (renamed from gui/aboutdialog.ui) | 31 | ||||
-rw-r--r-- | gui/dialogs/CopyInstanceDialog.cpp (renamed from gui/CopyInstanceDialog.cpp) | 20 | ||||
-rw-r--r-- | gui/dialogs/CopyInstanceDialog.h (renamed from gui/CopyInstanceDialog.h) | 0 | ||||
-rw-r--r-- | gui/dialogs/CopyInstanceDialog.ui (renamed from gui/CopyInstanceDialog.ui) | 6 | ||||
-rw-r--r-- | gui/dialogs/CustomMessageBox.cpp | 34 | ||||
-rw-r--r-- | gui/dialogs/CustomMessageBox.h | 26 | ||||
-rw-r--r-- | gui/dialogs/EditNotesDialog.cpp | 42 | ||||
-rw-r--r-- | gui/dialogs/EditNotesDialog.h | 38 | ||||
-rw-r--r-- | gui/dialogs/EditNotesDialog.ui (renamed from gui/EditNotesDialog.ui) | 0 | ||||
-rw-r--r-- | gui/dialogs/IconPickerDialog.cpp | 156 | ||||
-rw-r--r-- | gui/dialogs/IconPickerDialog.h | 48 | ||||
-rw-r--r-- | gui/dialogs/IconPickerDialog.ui (renamed from gui/IconPickerDialog.ui) | 0 | ||||
-rw-r--r-- | gui/dialogs/InstanceSettings.cpp (renamed from gui/instancesettings.cpp) | 39 | ||||
-rw-r--r-- | gui/dialogs/InstanceSettings.h | 50 | ||||
-rw-r--r-- | gui/dialogs/InstanceSettings.ui (renamed from gui/instancesettings.ui) | 0 | ||||
-rw-r--r-- | gui/dialogs/LegacyModEditDialog.cpp (renamed from gui/LegacyModEditDialog.cpp) | 12 | ||||
-rw-r--r-- | gui/dialogs/LegacyModEditDialog.h (renamed from gui/LegacyModEditDialog.h) | 0 | ||||
-rw-r--r-- | gui/dialogs/LegacyModEditDialog.ui (renamed from gui/LegacyModEditDialog.ui) | 4 | ||||
-rw-r--r-- | gui/dialogs/LoginDialog.cpp (renamed from gui/logindialog.cpp) | 120 | ||||
-rw-r--r-- | gui/dialogs/LoginDialog.h (renamed from gui/logindialog.h) | 38 | ||||
-rw-r--r-- | gui/dialogs/LoginDialog.ui (renamed from gui/logindialog.ui) | 5 | ||||
-rw-r--r-- | gui/dialogs/LwjglSelectDialog.cpp (renamed from gui/lwjglselectdialog.cpp) | 26 | ||||
-rw-r--r-- | gui/dialogs/LwjglSelectDialog.h (renamed from gui/lwjglselectdialog.h) | 20 | ||||
-rw-r--r-- | gui/dialogs/LwjglSelectDialog.ui (renamed from gui/lwjglselectdialog.ui) | 0 | ||||
-rw-r--r-- | gui/dialogs/ModEditDialogCommon.cpp | 57 | ||||
-rw-r--r-- | gui/dialogs/ModEditDialogCommon.h | 22 | ||||
-rw-r--r-- | gui/dialogs/NewInstanceDialog.cpp (renamed from gui/newinstancedialog.cpp) | 12 | ||||
-rw-r--r-- | gui/dialogs/NewInstanceDialog.h (renamed from gui/newinstancedialog.h) | 0 | ||||
-rw-r--r-- | gui/dialogs/NewInstanceDialog.ui (renamed from gui/newinstancedialog.ui) | 6 | ||||
-rw-r--r-- | gui/dialogs/OneSixModEditDialog.cpp (renamed from gui/OneSixModEditDialog.cpp) | 43 | ||||
-rw-r--r-- | gui/dialogs/OneSixModEditDialog.h (renamed from gui/OneSixModEditDialog.h) | 0 | ||||
-rw-r--r-- | gui/dialogs/OneSixModEditDialog.ui (renamed from gui/OneSixModEditDialog.ui) | 4 | ||||
-rw-r--r-- | gui/dialogs/ProgressDialog.cpp (renamed from gui/ProgressDialog.cpp) | 29 | ||||
-rw-r--r-- | gui/dialogs/ProgressDialog.h (renamed from gui/ProgressDialog.h) | 46 | ||||
-rw-r--r-- | gui/dialogs/ProgressDialog.ui (renamed from gui/ProgressDialog.ui) | 0 | ||||
-rw-r--r-- | gui/dialogs/SettingsDialog.cpp (renamed from gui/settingsdialog.cpp) | 44 | ||||
-rw-r--r-- | gui/dialogs/SettingsDialog.h (renamed from gui/settingsdialog.h) | 37 | ||||
-rw-r--r-- | gui/dialogs/SettingsDialog.ui (renamed from gui/settingsdialog.ui) | 4 | ||||
-rw-r--r-- | gui/dialogs/VersionSelectDialog.cpp (renamed from gui/versionselectdialog.cpp) | 15 | ||||
-rw-r--r-- | gui/dialogs/VersionSelectDialog.h (renamed from gui/versionselectdialog.h) | 32 | ||||
-rw-r--r-- | gui/dialogs/VersionSelectDialog.ui (renamed from gui/versionselectdialog.ui) | 0 | ||||
-rw-r--r-- | gui/instancedelegate.h | 12 | ||||
-rw-r--r-- | gui/instancesettings.h | 35 | ||||
-rw-r--r-- | gui/newmodeditwindow.ui | 159 | ||||
-rw-r--r-- | gui/widgets/InstanceDelegate.cpp (renamed from gui/instancedelegate.cpp) | 17 | ||||
-rw-r--r-- | gui/widgets/InstanceDelegate.h | 27 | ||||
-rw-r--r-- | gui/widgets/LabeledToolButton.cpp (renamed from gui/LabeledToolButton.cpp) | 16 | ||||
-rw-r--r-- | gui/widgets/LabeledToolButton.h | 37 | ||||
-rw-r--r-- | gui/widgets/MCModInfoFrame.cpp (renamed from gui/MCModInfoFrame.cpp) | 8 | ||||
-rw-r--r-- | gui/widgets/MCModInfoFrame.h (renamed from gui/MCModInfoFrame.h) | 0 | ||||
-rw-r--r-- | gui/widgets/MCModInfoFrame.ui (renamed from gui/MCModInfoFrame.ui) | 0 | ||||
-rw-r--r-- | gui/widgets/ModListView.cpp (renamed from gui/ModListView.cpp) | 15 | ||||
-rw-r--r-- | gui/widgets/ModListView.h | 27 |
76 files changed, 1055 insertions, 933 deletions
diff --git a/gui/consolewindow.cpp b/gui/ConsoleWindow.cpp index 49e12339..ec25b9cf 100644 --- a/gui/consolewindow.cpp +++ b/gui/ConsoleWindow.cpp @@ -1,11 +1,26 @@ -#include "consolewindow.h" -#include "ui_consolewindow.h" +/* 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 "ConsoleWindow.h" +#include "ui_ConsoleWindow.h" #include <QScrollBar> #include <QMessageBox> -#include <gui/platform.h> -#include <gui/CustomMessageBox.h> +#include <gui/Platform.h> +#include <gui/dialogs/CustomMessageBox.h> ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) : QDialog(parent), diff --git a/gui/consolewindow.h b/gui/ConsoleWindow.h index e8790c92..0ed35554 100644 --- a/gui/consolewindow.h +++ b/gui/ConsoleWindow.h @@ -1,10 +1,25 @@ -#ifndef CONSOLEWINDOW_H -#define CONSOLEWINDOW_H +/* 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. + */ + +#pragma once #include <QDialog> #include "logic/MinecraftProcess.h" -namespace Ui { +namespace Ui +{ class ConsoleWindow; } @@ -23,14 +38,15 @@ public: */ void setMayClose(bool mayclose); -public slots: +public +slots: /** * @brief write a string * @param data the string * @param mode the WriteMode * lines have to be put through this as a whole! */ - void write(QString data, MessageLevel::Enum level=MessageLevel::MultiMC); + void write(QString data, MessageLevel::Enum level = MessageLevel::MultiMC); /** * @brief write a colored paragraph @@ -39,14 +55,15 @@ public slots: * this will only insert a single paragraph. * \n are ignored. a real \n is always appended. */ - void writeColor(QString data, const char *color=nullptr); + void writeColor(QString data, const char *color = nullptr); /** * @brief clear the text widget */ void clear(); -private slots: +private +slots: void on_closeButton_clicked(); void on_btnKillMinecraft_clicked(); void onEnded(BaseInstance *instance); @@ -60,4 +77,3 @@ private: bool m_mayclose; }; -#endif // CONSOLEWINDOW_H diff --git a/gui/consolewindow.ui b/gui/ConsoleWindow.ui index 8dc80015..8dc80015 100644 --- a/gui/consolewindow.ui +++ b/gui/ConsoleWindow.ui diff --git a/gui/CustomMessageBox.cpp b/gui/CustomMessageBox.cpp deleted file mode 100644 index e55ebbbb..00000000 --- a/gui/CustomMessageBox.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "CustomMessageBox.h" - -namespace CustomMessageBox -{ - QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text, - QMessageBox::Icon icon, QMessageBox::StandardButtons buttons, - QMessageBox::StandardButton defaultButton) - { - QMessageBox *messageBox = new QMessageBox(parent); - messageBox->setWindowTitle(title); - messageBox->setText(text); - messageBox->setStandardButtons(buttons); - messageBox->setDefaultButton(defaultButton); - messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse); - messageBox->setIcon(icon); - - return messageBox; - } -} diff --git a/gui/CustomMessageBox.h b/gui/CustomMessageBox.h deleted file mode 100644 index 145651ec..00000000 --- a/gui/CustomMessageBox.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include <QMessageBox> - -namespace CustomMessageBox -{ - QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text, - QMessageBox::Icon icon = QMessageBox::NoIcon, - QMessageBox::StandardButtons buttons = QMessageBox::Ok, - QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); -} diff --git a/gui/EditNotesDialog.cpp b/gui/EditNotesDialog.cpp deleted file mode 100644 index 535ca804..00000000 --- a/gui/EditNotesDialog.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "EditNotesDialog.h" -#include "ui_EditNotesDialog.h" -#include "gui/platform.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) -{ - 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() -{ - return ui->noteEditor->toPlainText(); -} diff --git a/gui/EditNotesDialog.h b/gui/EditNotesDialog.h deleted file mode 100644 index 582e019f..00000000 --- a/gui/EditNotesDialog.h +++ /dev/null @@ -1,20 +0,0 @@ -#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/IconPickerDialog.cpp b/gui/IconPickerDialog.cpp deleted file mode 100644 index ebacf87c..00000000 --- a/gui/IconPickerDialog.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include <MultiMC.h> -#include "IconPickerDialog.h" -#include "instancedelegate.h" -#include "ui_IconPickerDialog.h" -#include "logic/lists/IconList.h" -#include "gui/platform.h" -#include <QKeyEvent> -#include <QPushButton> -#include <QFileDialog> - -IconPickerDialog::IconPickerDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::IconPickerDialog) -{ - MultiMCPlatform::fixWM_CLASS(this); - ui->setupUi(this); - setWindowModality(Qt::WindowModal); - - auto contentsWidget = ui->iconView; - contentsWidget->setViewMode(QListView::IconMode); - contentsWidget->setFlow(QListView::LeftToRight); - contentsWidget->setIconSize(QSize(48, 48)); - contentsWidget->setMovement(QListView::Static); - contentsWidget->setResizeMode(QListView::Adjust); - contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection); - contentsWidget->setSpacing(5); - contentsWidget->setWordWrap(false); - contentsWidget->setWrapping(true); - contentsWidget->setUniformItemSizes(true); - contentsWidget->setTextElideMode(Qt::ElideRight); - contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); - contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - contentsWidget->setItemDelegate(new ListViewDelegate()); - - //contentsWidget->setAcceptDrops(true); - contentsWidget->setDropIndicatorShown(true); - contentsWidget->viewport()->setAcceptDrops(true); - contentsWidget->setDragDropMode(QAbstractItemView::DropOnly); - contentsWidget->setDefaultDropAction(Qt::CopyAction); - - contentsWidget->installEventFilter(this); - - contentsWidget->setModel(MMC->icons().get()); - - auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"),QDialogButtonBox::ResetRole); - auto buttonRemove = ui->buttonBox->addButton(tr("Remove Icon"),QDialogButtonBox::ResetRole); - - - connect(buttonAdd,SIGNAL(clicked(bool)),SLOT(addNewIcon())); - connect(buttonRemove,SIGNAL(clicked(bool)),SLOT(removeSelectedIcon())); - - connect - ( - contentsWidget, - SIGNAL(doubleClicked(QModelIndex)), - SLOT(activated(QModelIndex)) - ); - - connect - ( - contentsWidget->selectionModel(), - SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - SLOT(selectionChanged(QItemSelection,QItemSelection)) - ); -} -bool IconPickerDialog::eventFilter ( QObject* obj, QEvent* evt) -{ - if(obj != ui->iconView) - return QDialog::eventFilter(obj ,evt); - if (evt->type() != QEvent::KeyPress) - { - return QDialog::eventFilter(obj ,evt); - } - QKeyEvent *keyEvent = static_cast<QKeyEvent*>(evt); - switch(keyEvent->key()) - { - case Qt::Key_Delete: - removeSelectedIcon(); - return true; - case Qt::Key_Plus: - addNewIcon(); - return true; - default: - break; - } - return QDialog::eventFilter(obj ,evt); -} - -void IconPickerDialog::addNewIcon() -{ - //: The title of the select icons open file dialog - QString selectIcons = tr("Select Icons"); - //: The type of icon files - QStringList fileNames = QFileDialog::getOpenFileNames(this, selectIcons, QString(), tr("Icons") + "(*.png *.jpg *.jpeg)"); - MMC->icons()->installIcons(fileNames); -} - -void IconPickerDialog::removeSelectedIcon() -{ - MMC->icons()->deleteIcon(selectedIconKey); -} - - -void IconPickerDialog::activated ( QModelIndex index ) -{ - selectedIconKey = index.data(Qt::UserRole).toString(); - accept(); -} - - -void IconPickerDialog::selectionChanged ( QItemSelection selected, QItemSelection deselected ) -{ - if(selected.empty()) - return; - - QString key = selected.first().indexes().first().data(Qt::UserRole).toString(); - if(!key.isEmpty()) - selectedIconKey = key; -} - -int IconPickerDialog::exec ( QString selection ) -{ - auto list = MMC->icons(); - auto contentsWidget = ui->iconView; - selectedIconKey = selection; - - - int index_nr = list->getIconIndex(selection); - auto model_index = list->index(index_nr); - contentsWidget->selectionModel()->select(model_index, QItemSelectionModel::Current | QItemSelectionModel::Select); - - QMetaObject::invokeMethod(this, "delayed_scroll", Qt::QueuedConnection, Q_ARG(QModelIndex,model_index)); - return QDialog::exec(); -} - -void IconPickerDialog::delayed_scroll ( QModelIndex model_index ) -{ - auto contentsWidget = ui->iconView; - contentsWidget->scrollTo(model_index); -} - - -IconPickerDialog::~IconPickerDialog() -{ - delete ui; -} diff --git a/gui/IconPickerDialog.h b/gui/IconPickerDialog.h deleted file mode 100644 index 96fc61ff..00000000 --- a/gui/IconPickerDialog.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include <QDialog> -#include <QItemSelection> - -namespace Ui { -class IconPickerDialog; -} - -class IconPickerDialog : public QDialog -{ - Q_OBJECT - -public: - explicit IconPickerDialog(QWidget *parent = 0); - ~IconPickerDialog(); - int exec(QString selection); - QString selectedIconKey; -protected: - virtual bool eventFilter ( QObject* , QEvent* ); -private: - Ui::IconPickerDialog *ui; - -private slots: - void selectionChanged ( QItemSelection,QItemSelection ); - void activated ( QModelIndex ); - void delayed_scroll ( QModelIndex ); - void addNewIcon(); - void removeSelectedIcon(); -}; diff --git a/gui/LabeledToolButton.h b/gui/LabeledToolButton.h deleted file mode 100644 index 24ef798a..00000000 --- a/gui/LabeledToolButton.h +++ /dev/null @@ -1,22 +0,0 @@ -#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/mainwindow.cpp b/gui/MainWindow.cpp index 20a2b84b..39e6dff2 100644 --- a/gui/mainwindow.cpp +++ b/gui/MainWindow.cpp @@ -16,10 +16,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include <MultiMC.h> +#include "MultiMC.h" -#include "mainwindow.h" -#include "ui_mainwindow.h" +#include "MainWindow.h" +#include "ui_MainWindow.h" #include "keyring.h" #include <QMenu> @@ -40,17 +40,25 @@ #include "categorizedview.h" #include "categorydrawer.h" -#include "gui/settingsdialog.h" -#include "gui/newinstancedialog.h" -#include "gui/logindialog.h" -#include "gui/ProgressDialog.h" -#include "gui/aboutdialog.h" -#include "gui/versionselectdialog.h" -#include "gui/lwjglselectdialog.h" -#include "gui/consolewindow.h" -#include "gui/instancesettings.h" -#include "gui/platform.h" -#include "gui/CustomMessageBox.h" +#include "gui/Platform.h" + +#include "gui/widgets/InstanceDelegate.h" +#include "gui/widgets/LabeledToolButton.h" + +#include "gui/dialogs/SettingsDialog.h" +#include "gui/dialogs/NewInstanceDialog.h" +#include "gui/dialogs/LoginDialog.h" +#include "gui/dialogs/ProgressDialog.h" +#include "gui/dialogs/AboutDialog.h" +#include "gui/dialogs/VersionSelectDialog.h" +#include "gui/dialogs/CustomMessageBox.h" +#include "gui/dialogs/LwjglSelectDialog.h" +#include "gui/dialogs/InstanceSettings.h" +#include "gui/dialogs/IconPickerDialog.h" +#include "gui/dialogs/EditNotesDialog.h" +#include "gui/dialogs/CopyInstanceDialog.h" + +#include "gui/ConsoleWindow.h" #include "logic/lists/InstanceList.h" #include "logic/lists/MinecraftVersionList.h" @@ -70,12 +78,6 @@ #include "logic/LegacyInstance.h" -#include "instancedelegate.h" -#include "IconPickerDialog.h" -#include "LabeledToolButton.h" -#include "EditNotesDialog.h" -#include "CopyInstanceDialog.h" - MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { MultiMCPlatform::fixWM_CLASS(this); diff --git a/gui/mainwindow.h b/gui/MainWindow.h index 36562563..97aa0d9f 100644 --- a/gui/mainwindow.h +++ b/gui/MainWindow.h @@ -13,8 +13,7 @@ * limitations under the License. */ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H +#pragma once #include <QMainWindow> @@ -166,5 +165,3 @@ private: QLabel *m_statusLeft; QLabel *m_statusRight; }; - -#endif // MAINWINDOW_H diff --git a/gui/mainwindow.ui b/gui/MainWindow.ui index 6f70fc98..6f70fc98 100644 --- a/gui/mainwindow.ui +++ b/gui/MainWindow.ui diff --git a/gui/ModEditDialogCommon.cpp b/gui/ModEditDialogCommon.cpp deleted file mode 100644 index 873cd8ea..00000000 --- a/gui/ModEditDialogCommon.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "ModEditDialogCommon.h" -#include "CustomMessageBox.h" -#include <QDesktopServices> -#include <QMessageBox> -#include <QString> -#include <QUrl> -bool lastfirst(QModelIndexList &list, int &first, int &last) -{ - if (!list.size()) - return false; - first = last = list[0].row(); - for (auto item : list) - { - int row = item.row(); - if (row < first) - first = row; - if (row > last) - last = row; - } - return true; -} - -void showWebsiteForMod(QWidget *parentDlg, Mod &m) -{ - QString url = m.homeurl(); - if (url.size()) - { - // catch the cases where the protocol is missing - if(!url.startsWith("http")) - { - url = "http://" + url; - } - QDesktopServices::openUrl(url); - } - else - { - CustomMessageBox::selectable(parentDlg, parentDlg->tr("How sad!"), - parentDlg->tr("The mod author didn't provide a website link for this mod."), - QMessageBox::Warning); - } -} diff --git a/gui/ModEditDialogCommon.h b/gui/ModEditDialogCommon.h deleted file mode 100644 index bc8e223f..00000000 --- a/gui/ModEditDialogCommon.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -#include <QAbstractItemModel> -#include <logic/Mod.h> - -bool lastfirst (QModelIndexList & list, int & first, int & last); - -void showWebsiteForMod(QWidget * parentDlg, Mod& m);
\ No newline at end of file diff --git a/gui/ModListView.h b/gui/ModListView.h deleted file mode 100644 index 69a26755..00000000 --- a/gui/ModListView.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include <QTreeView> - -class Mod; - -class ModListView: public QTreeView -{ - Q_OBJECT -public: - explicit ModListView ( QWidget* parent = 0 ); - virtual void setModel ( QAbstractItemModel* model ); - -}; diff --git a/gui/platform.h b/gui/Platform.h index 5cf9ed80..5cde9505 100644 --- a/gui/platform.h +++ b/gui/Platform.h @@ -15,11 +15,10 @@ * limitations under the License. */ -#ifndef PLATFORM_H -#define PLATFORM_H +#pragma once /** - * @file platform.h + * @file Platform.h * This file contains platform-specific functions, tweaks and fixes. */ @@ -31,5 +30,3 @@ public: // X11 WM_CLASS static void fixWM_CLASS(QWidget *widget); }; - -#endif // PLATFORM_H diff --git a/gui/platform_other.cpp b/gui/Platform_Other.cpp index a41abe36..e02bd921 100644 --- a/gui/platform_other.cpp +++ b/gui/Platform_Other.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include <gui/platform.h> +#include <gui/Platform.h> /** * Stub for non-X11 platforms * @brief MultiMCPlatform::fixWM_CLASS diff --git a/gui/platform_x11.cpp b/gui/Platform_X11.cpp index 0401e8bf..bcd26f53 100644 --- a/gui/platform_x11.cpp +++ b/gui/Platform_X11.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include <gui/platform.h> +#include <gui/Platform.h> #include <QtX11Extras/QX11Info> #include <xcb/xcb.h> diff --git a/gui/aboutdialog.cpp b/gui/aboutdialog.cpp deleted file mode 100644 index 7105446c..00000000 --- a/gui/aboutdialog.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "aboutdialog.h" -#include "ui_aboutdialog.h" -#include <QIcon> -#include <MultiMC.h> -#include "gui/platform.h" - -AboutDialog::AboutDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::AboutDialog) -{ - MultiMCPlatform::fixWM_CLASS(this); - ui->setupUi(this); - - ui->icon->setPixmap(QIcon(":/icons/multimc/scalable/apps/multimc.svg").pixmap(64)); - ui->title->setText("MultiMC " + MMC->version().toString()); - connect(ui->closeButton, SIGNAL(clicked()), SLOT(close())); - - MMC->connect(ui->aboutQt, SIGNAL(clicked()), SLOT(aboutQt())); -} - -AboutDialog::~AboutDialog() -{ - delete ui; -} diff --git a/gui/aboutdialog.h b/gui/aboutdialog.h deleted file mode 100644 index d462de28..00000000 --- a/gui/aboutdialog.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef ABOUTDIALOG_H -#define ABOUTDIALOG_H - -#include <QDialog> - -namespace Ui { -class AboutDialog; -} - -class AboutDialog : public QDialog -{ - Q_OBJECT - -public: - explicit AboutDialog(QWidget *parent = 0); - ~AboutDialog(); - -private: - Ui::AboutDialog *ui; -}; - -#endif // ABOUTDIALOG_H diff --git a/gui/dialogs/AboutDialog.cpp b/gui/dialogs/AboutDialog.cpp new file mode 100644 index 00000000..58d61dd0 --- /dev/null +++ b/gui/dialogs/AboutDialog.cpp @@ -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. + */ + +#include "AboutDialog.h" +#include "ui_AboutDialog.h" +#include <QIcon> +#include "MultiMC.h" +#include "gui/Platform.h" + +AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AboutDialog) +{ + MultiMCPlatform::fixWM_CLASS(this); + ui->setupUi(this); + + ui->icon->setPixmap(QIcon(":/icons/multimc/scalable/apps/multimc.svg").pixmap(64)); + ui->title->setText("MultiMC " + MMC->version().toString()); + connect(ui->closeButton, SIGNAL(clicked()), SLOT(close())); + + MMC->connect(ui->aboutQt, SIGNAL(clicked()), SLOT(aboutQt())); +} + +AboutDialog::~AboutDialog() +{ + delete ui; +} diff --git a/gui/dialogs/AboutDialog.h b/gui/dialogs/AboutDialog.h new file mode 100644 index 00000000..9d747bac --- /dev/null +++ b/gui/dialogs/AboutDialog.h @@ -0,0 +1,35 @@ +/* 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. + */ + +#pragma once + +#include <QDialog> + +namespace Ui +{ +class AboutDialog; +} + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AboutDialog(QWidget *parent = 0); + ~AboutDialog(); + +private: + Ui::AboutDialog *ui; +}; diff --git a/gui/aboutdialog.ui b/gui/dialogs/AboutDialog.ui index c075f895..0a189d9c 100644 --- a/gui/aboutdialog.ui +++ b/gui/dialogs/AboutDialog.ui @@ -59,7 +59,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../multimc.qrc">:/icons/multimc/scalable/apps/multimc.svg</pixmap> + <pixmap resource="../../multimc.qrc">:/icons/multimc/scalable/apps/multimc.svg</pixmap> </property> </widget> </item> @@ -101,7 +101,7 @@ <x>0</x> <y>0</y> <width>432</width> - <height>197</height> + <height>179</height> </rect> </property> <attribute name="label"> @@ -159,8 +159,8 @@ <rect> <x>0</x> <y>0</y> - <width>432</width> - <height>197</height> + <width>98</width> + <height>120</height> </rect> </property> <attribute name="label"> @@ -176,13 +176,13 @@ <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Andrew Okin &lt;</span><a href="mailto:forkk@forkk.net"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">forkk@forkk.net</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Petr Mrázek &lt;</span><a href="mailto:peterix@gmail.com"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">peterix@gmail.com</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Orochimarufan &lt;</span><a href="mailto:orochimarufan.x3@gmail.com"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">orochimarufan.x3@gmail.com</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">TakSuyu &lt;</span><a href="mailto:taksuyu@gmail.com"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">taksuyu@gmail.com</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Sky (Drayshak) &lt;</span><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">multimc@bunnies.cc</span><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;">Kilobyte &lt;</span><a href="mailto:stiepen22@gmx.de"><span style=" font-family:'Ubuntu'; font-size:11pt; text-decoration: underline; color:#0000ff;">stiepen22@gmx.de</span></a><span style=" font-family:'Ubuntu'; font-size:11pt;">&gt;</span></p></body></html></string> +</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Andrew Okin &lt;</span><a href="mailto:forkk@forkk.net"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">forkk@forkk.net</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Petr Mrázek &lt;</span><a href="mailto:peterix@gmail.com"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">peterix@gmail.com</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Orochimarufan &lt;</span><a href="mailto:orochimarufan.x3@gmail.com"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">orochimarufan.x3@gmail.com</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">TakSuyu &lt;</span><a href="mailto:taksuyu@gmail.com"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">taksuyu@gmail.com</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Sky (Drayshak) &lt;</span><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">multimc@bunnies.cc</span><span style=" font-family:'Ubuntu';">&gt;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu';">Kilobyte &lt;</span><a href="mailto:stiepen22@gmx.de"><span style=" font-family:'Ubuntu'; text-decoration: underline; color:#0000ff;">stiepen22@gmx.de</span></a><span style=" font-family:'Ubuntu';">&gt;</span></p></body></html></string> </property> </widget> </item> @@ -203,8 +203,8 @@ p, li { white-space: pre-wrap; } <rect> <x>0</x> <y>0</y> - <width>432</width> - <height>197</height> + <width>98</width> + <height>88</height> </rect> </property> <attribute name="label"> @@ -226,7 +226,7 @@ p, li { white-space: pre-wrap; } <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Copyright 2012 MultiMC Contributors</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:10pt;">you may not use this file except in compliance with the License.</span></p> @@ -309,7 +309,8 @@ p, li { white-space: pre-wrap; } </layout> </widget> <resources> - <include location="../multimc.qrc"/> + <include location="../../multimc.qrc"/> + <include location="../../multimc.qrc"/> </resources> <connections/> </ui> diff --git a/gui/CopyInstanceDialog.cpp b/gui/dialogs/CopyInstanceDialog.cpp index 1e0b9e6c..4d588a1e 100644 --- a/gui/CopyInstanceDialog.cpp +++ b/gui/dialogs/CopyInstanceDialog.cpp @@ -13,24 +13,24 @@ * limitations under the License. */ -#include <MultiMC.h> +#include <QLayout> +#include <QPushButton> + +#include "MultiMC.h" #include "CopyInstanceDialog.h" #include "ui_CopyInstanceDialog.h" +#include "gui/Platform.h" +#include "gui/dialogs/VersionSelectDialog.h" +#include "gui/dialogs/ProgressDialog.h" +#include "gui/dialogs/IconPickerDialog.h" + #include "logic/InstanceFactory.h" #include "logic/BaseVersion.h" #include "logic/lists/IconList.h" #include "logic/lists/MinecraftVersionList.h" #include "logic/tasks/Task.h" -#include <logic/BaseInstance.h> - -#include "gui/platform.h" -#include "versionselectdialog.h" -#include "ProgressDialog.h" -#include "IconPickerDialog.h" - -#include <QLayout> -#include <QPushButton> +#include "logic/BaseInstance.h" CopyInstanceDialog::CopyInstanceDialog(BaseInstance *original, QWidget *parent) : m_original(original), QDialog(parent), ui(new Ui::CopyInstanceDialog) diff --git a/gui/CopyInstanceDialog.h b/gui/dialogs/CopyInstanceDialog.h index 7ab366e2..7ab366e2 100644 --- a/gui/CopyInstanceDialog.h +++ b/gui/dialogs/CopyInstanceDialog.h diff --git a/gui/CopyInstanceDialog.ui b/gui/dialogs/CopyInstanceDialog.ui index 1327ce0b..dd7ce641 100644 --- a/gui/CopyInstanceDialog.ui +++ b/gui/dialogs/CopyInstanceDialog.ui @@ -17,7 +17,7 @@ <string>Copy Instance</string> </property> <property name="windowIcon"> - <iconset resource="../multimc.qrc"> + <iconset resource="../../multimc.qrc"> <normaloff>:/icons/toolbar/copy</normaloff>:/icons/toolbar/copy</iconset> </property> <property name="modal"> @@ -42,7 +42,7 @@ <item> <widget class="QToolButton" name="iconButton"> <property name="icon"> - <iconset resource="../multimc.qrc"> + <iconset resource="../../multimc.qrc"> <normaloff>:/icons/instances/infinity</normaloff>:/icons/instances/infinity</iconset> </property> <property name="iconSize"> @@ -95,7 +95,7 @@ </layout> </widget> <resources> - <include location="../multimc.qrc"/> + <include location="../../multimc.qrc"/> </resources> <connections> <connection> diff --git a/gui/dialogs/CustomMessageBox.cpp b/gui/dialogs/CustomMessageBox.cpp new file mode 100644 index 00000000..1d2ab58a --- /dev/null +++ b/gui/dialogs/CustomMessageBox.cpp @@ -0,0 +1,34 @@ +/* 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 "CustomMessageBox.h" + +namespace CustomMessageBox +{ +QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text, + QMessageBox::Icon icon, QMessageBox::StandardButtons buttons, + QMessageBox::StandardButton defaultButton) +{ + QMessageBox *messageBox = new QMessageBox(parent); + messageBox->setWindowTitle(title); + messageBox->setText(text); + messageBox->setStandardButtons(buttons); + messageBox->setDefaultButton(defaultButton); + messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse); + messageBox->setIcon(icon); + + return messageBox; +} +} diff --git a/gui/dialogs/CustomMessageBox.h b/gui/dialogs/CustomMessageBox.h new file mode 100644 index 00000000..b08b9f57 --- /dev/null +++ b/gui/dialogs/CustomMessageBox.h @@ -0,0 +1,26 @@ +/* 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. + */ + +#pragma once + +#include <QMessageBox> + +namespace CustomMessageBox +{ +QMessageBox *selectable(QWidget *parent, const QString &title, const QString &text, + QMessageBox::Icon icon = QMessageBox::NoIcon, + QMessageBox::StandardButtons buttons = QMessageBox::Ok, + QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); +} diff --git a/gui/dialogs/EditNotesDialog.cpp b/gui/dialogs/EditNotesDialog.cpp new file mode 100644 index 00000000..cd52e694 --- /dev/null +++ b/gui/dialogs/EditNotesDialog.cpp @@ -0,0 +1,42 @@ +/* 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) + : m_instance_notes(notes), m_instance_name(name), QDialog(parent), + ui(new Ui::EditNotesDialog) +{ + 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() +{ + return ui->noteEditor->toPlainText(); +} diff --git a/gui/dialogs/EditNotesDialog.h b/gui/dialogs/EditNotesDialog.h new file mode 100644 index 00000000..b74558c4 --- /dev/null +++ b/gui/dialogs/EditNotesDialog.h @@ -0,0 +1,38 @@ +/* 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. + */ + +#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/dialogs/EditNotesDialog.ui index 487dfb84..487dfb84 100644 --- a/gui/EditNotesDialog.ui +++ b/gui/dialogs/EditNotesDialog.ui diff --git a/gui/dialogs/IconPickerDialog.cpp b/gui/dialogs/IconPickerDialog.cpp new file mode 100644 index 00000000..99d6dc9a --- /dev/null +++ b/gui/dialogs/IconPickerDialog.cpp @@ -0,0 +1,156 @@ +/* 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 <QKeyEvent> +#include <QPushButton> +#include <QFileDialog> + +#include "MultiMC.h" + +#include "IconPickerDialog.h" +#include "ui_IconPickerDialog.h" + +#include "gui/Platform.h" +#include "gui/widgets/InstanceDelegate.h" + +#include "logic/lists/IconList.h" + +IconPickerDialog::IconPickerDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::IconPickerDialog) +{ + MultiMCPlatform::fixWM_CLASS(this); + ui->setupUi(this); + setWindowModality(Qt::WindowModal); + + auto contentsWidget = ui->iconView; + contentsWidget->setViewMode(QListView::IconMode); + contentsWidget->setFlow(QListView::LeftToRight); + contentsWidget->setIconSize(QSize(48, 48)); + contentsWidget->setMovement(QListView::Static); + contentsWidget->setResizeMode(QListView::Adjust); + contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection); + contentsWidget->setSpacing(5); + contentsWidget->setWordWrap(false); + contentsWidget->setWrapping(true); + contentsWidget->setUniformItemSizes(true); + contentsWidget->setTextElideMode(Qt::ElideRight); + contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + contentsWidget->setItemDelegate(new ListViewDelegate()); + + // contentsWidget->setAcceptDrops(true); + contentsWidget->setDropIndicatorShown(true); + contentsWidget->viewport()->setAcceptDrops(true); + contentsWidget->setDragDropMode(QAbstractItemView::DropOnly); + contentsWidget->setDefaultDropAction(Qt::CopyAction); + + contentsWidget->installEventFilter(this); + + contentsWidget->setModel(MMC->icons().get()); + + auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"), QDialogButtonBox::ResetRole); + auto buttonRemove = + ui->buttonBox->addButton(tr("Remove Icon"), QDialogButtonBox::ResetRole); + + connect(buttonAdd, SIGNAL(clicked(bool)), SLOT(addNewIcon())); + connect(buttonRemove, SIGNAL(clicked(bool)), SLOT(removeSelectedIcon())); + + connect(contentsWidget, SIGNAL(doubleClicked(QModelIndex)), SLOT(activated(QModelIndex))); + + connect(contentsWidget->selectionModel(), + SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + SLOT(selectionChanged(QItemSelection, QItemSelection))); +} +bool IconPickerDialog::eventFilter(QObject *obj, QEvent *evt) +{ + if (obj != ui->iconView) + return QDialog::eventFilter(obj, evt); + if (evt->type() != QEvent::KeyPress) + { + return QDialog::eventFilter(obj, evt); + } + QKeyEvent *keyEvent = static_cast<QKeyEvent *>(evt); + switch (keyEvent->key()) + { + case Qt::Key_Delete: + removeSelectedIcon(); + return true; + case Qt::Key_Plus: + addNewIcon(); + return true; + default: + break; + } + return QDialog::eventFilter(obj, evt); +} + +void IconPickerDialog::addNewIcon() +{ + //: The title of the select icons open file dialog + QString selectIcons = tr("Select Icons"); + //: The type of icon files + QStringList fileNames = QFileDialog::getOpenFileNames(this, selectIcons, QString(), + tr("Icons") + "(*.png *.jpg *.jpeg)"); + MMC->icons()->installIcons(fileNames); +} + +void IconPickerDialog::removeSelectedIcon() +{ + MMC->icons()->deleteIcon(selectedIconKey); +} + +void IconPickerDialog::activated(QModelIndex index) +{ + selectedIconKey = index.data(Qt::UserRole).toString(); + accept(); +} + +void IconPickerDialog::selectionChanged(QItemSelection selected, QItemSelection deselected) +{ + if (selected.empty()) + return; + + QString key = selected.first().indexes().first().data(Qt::UserRole).toString(); + if (!key.isEmpty()) + selectedIconKey = key; +} + +int IconPickerDialog::exec(QString selection) +{ + auto list = MMC->icons(); + auto contentsWidget = ui->iconView; + selectedIconKey = selection; + + int index_nr = list->getIconIndex(selection); + auto model_index = list->index(index_nr); + contentsWidget->selectionModel()->select( + model_index, QItemSelectionModel::Current | QItemSelectionModel::Select); + + QMetaObject::invokeMethod(this, "delayed_scroll", Qt::QueuedConnection, + Q_ARG(QModelIndex, model_index)); + return QDialog::exec(); +} + +void IconPickerDialog::delayed_scroll(QModelIndex model_index) +{ + auto contentsWidget = ui->iconView; + contentsWidget->scrollTo(model_index); +} + +IconPickerDialog::~IconPickerDialog() +{ + delete ui; +} diff --git a/gui/dialogs/IconPickerDialog.h b/gui/dialogs/IconPickerDialog.h new file mode 100644 index 00000000..f00c2388 --- /dev/null +++ b/gui/dialogs/IconPickerDialog.h @@ -0,0 +1,48 @@ +/* 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. + */ + +#pragma once +#include <QDialog> +#include <QItemSelection> + +namespace Ui +{ +class IconPickerDialog; +} + +class IconPickerDialog : public QDialog +{ + Q_OBJECT + +public: + explicit IconPickerDialog(QWidget *parent = 0); + ~IconPickerDialog(); + int exec(QString selection); + QString selectedIconKey; + +protected: + virtual bool eventFilter(QObject *, QEvent *); + +private: + Ui::IconPickerDialog *ui; + +private +slots: + void selectionChanged(QItemSelection, QItemSelection); + void activated(QModelIndex); + void delayed_scroll(QModelIndex); + void addNewIcon(); + void removeSelectedIcon(); +}; diff --git a/gui/IconPickerDialog.ui b/gui/dialogs/IconPickerDialog.ui index c548edfb..c548edfb 100644 --- a/gui/IconPickerDialog.ui +++ b/gui/dialogs/IconPickerDialog.ui diff --git a/gui/instancesettings.cpp b/gui/dialogs/InstanceSettings.cpp index 73eb6627..57dd6a81 100644 --- a/gui/instancesettings.cpp +++ b/gui/dialogs/InstanceSettings.cpp @@ -17,16 +17,14 @@ * limitations under the License. */ -#include "instancesettings.h" -#include "ui_instancesettings.h" -#include "gui/platform.h" - -InstanceSettings::InstanceSettings( SettingsObject * obj, QWidget *parent) : - m_obj(obj), - QDialog(parent), - ui(new Ui::InstanceSettings) +#include "InstanceSettings.h" +#include "ui_InstanceSettings.h" +#include "gui/Platform.h" + +InstanceSettings::InstanceSettings(SettingsObject *obj, QWidget *parent) + : m_obj(obj), QDialog(parent), ui(new Ui::InstanceSettings) { - MultiMCPlatform::fixWM_CLASS(this); + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); loadSettings(); } @@ -36,7 +34,7 @@ InstanceSettings::~InstanceSettings() delete ui; } -void InstanceSettings::showEvent ( QShowEvent* ev ) +void InstanceSettings::showEvent(QShowEvent *ev) { QDialog::showEvent(ev); adjustSize(); @@ -58,13 +56,12 @@ void InstanceSettings::on_buttonBox_rejected() reject(); } - void InstanceSettings::applySettings() { // Console bool console = ui->consoleSettingsBox->isChecked(); m_obj->set("OverrideConsole", console); - if(console) + if (console) { m_obj->set("ShowConsole", ui->showConsoleCheck->isChecked()); m_obj->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); @@ -78,7 +75,7 @@ void InstanceSettings::applySettings() // Window Size bool window = ui->windowSizeGroupBox->isChecked(); m_obj->set("OverrideWindow", window); - if(window) + if (window) { m_obj->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); m_obj->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); @@ -90,12 +87,11 @@ void InstanceSettings::applySettings() m_obj->reset("MinecraftWinWidth"); m_obj->reset("MinecraftWinHeight"); } - // Auto Login bool login = ui->accountSettingsGroupBox->isChecked(); m_obj->set("OverrideLogin", login); - if(login) + if (login) { m_obj->set("AutoLogin", ui->autoLoginChecBox->isChecked()); } @@ -103,12 +99,11 @@ void InstanceSettings::applySettings() { m_obj->reset("AutoLogin"); } - // Memory bool memory = ui->memoryGroupBox->isChecked(); m_obj->set("OverrideMemory", memory); - if(memory) + if (memory) { m_obj->set("MinMemAlloc", ui->minMemSpinBox->value()); m_obj->set("MaxMemAlloc", ui->maxMemSpinBox->value()); @@ -120,12 +115,11 @@ void InstanceSettings::applySettings() m_obj->reset("MaxMemAlloc"); m_obj->reset("PermGen"); } - // Java Settings - bool java = ui->javaSettingsGroupBox->isChecked(); + bool java = ui->javaSettingsGroupBox->isChecked(); m_obj->set("OverrideJava", java); - if(java) + if (java) { m_obj->set("JavaPath", ui->javaPathTextBox->text()); m_obj->set("JvmArgs", ui->jvmArgsTextBox->text()); @@ -135,12 +129,11 @@ void InstanceSettings::applySettings() m_obj->reset("JavaPath"); m_obj->reset("JvmArgs"); } - // Custom Commands bool custcmd = ui->customCommandsGroupBox->isChecked(); m_obj->set("OverrideCommands", custcmd); - if(custcmd) + if (custcmd) { m_obj->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); m_obj->set("PostExitCommand", ui->postExitCmdTextBox->text()); @@ -150,7 +143,6 @@ void InstanceSettings::applySettings() m_obj->reset("PreLaunchCommand"); m_obj->reset("PostExitCommand"); } - } void InstanceSettings::loadSettings() @@ -165,7 +157,6 @@ void InstanceSettings::loadSettings() ui->maximizedCheckBox->setChecked(m_obj->get("LaunchMaximized").toBool()); ui->windowWidthSpinBox->setValue(m_obj->get("MinecraftWinWidth").toInt()); ui->windowHeightSpinBox->setValue(m_obj->get("MinecraftWinHeight").toInt()); - // Auto Login ui->accountSettingsGroupBox->setChecked(m_obj->get("OverrideLogin").toBool()); diff --git a/gui/dialogs/InstanceSettings.h b/gui/dialogs/InstanceSettings.h new file mode 100644 index 00000000..452e7a58 --- /dev/null +++ b/gui/dialogs/InstanceSettings.h @@ -0,0 +1,50 @@ +/* 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. + */ + +#pragma once + +#include <QDialog> +#include "settingsobject.h" + +namespace Ui +{ +class InstanceSettings; +} + +class InstanceSettings : public QDialog +{ + Q_OBJECT + +public: + explicit InstanceSettings(SettingsObject *s, QWidget *parent = 0); + ~InstanceSettings(); + + void updateCheckboxStuff(); + + void applySettings(); + void loadSettings(); + +protected: + virtual void showEvent(QShowEvent *); +private +slots: + void on_customCommandsGroupBox_toggled(bool arg1); + void on_buttonBox_accepted(); + void on_buttonBox_rejected(); + +private: + Ui::InstanceSettings *ui; + SettingsObject *m_obj; +}; diff --git a/gui/instancesettings.ui b/gui/dialogs/InstanceSettings.ui index b536e9ff..b536e9ff 100644 --- a/gui/instancesettings.ui +++ b/gui/dialogs/InstanceSettings.ui diff --git a/gui/LegacyModEditDialog.cpp b/gui/dialogs/LegacyModEditDialog.cpp index a7021bf9..25a1c616 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/dialogs/LegacyModEditDialog.cpp @@ -16,12 +16,12 @@ #include "MultiMC.h" #include "LegacyModEditDialog.h" #include "ModEditDialogCommon.h" -#include "versionselectdialog.h" +#include "VersionSelectDialog.h" #include "ProgressDialog.h" #include "ui_LegacyModEditDialog.h" #include "logic/ModList.h" #include "logic/lists/ForgeVersionList.h" -#include "gui/platform.h" +#include "gui/Platform.h" #include <pathutils.h> #include <QFileDialog> @@ -33,7 +33,7 @@ LegacyModEditDialog::LegacyModEditDialog(LegacyInstance *inst, QWidget *parent) : m_inst(inst), QDialog(parent), ui(new Ui::LegacyModEditDialog) { - MultiMCPlatform::fixWM_CLASS(this); + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); // Jar mods @@ -358,7 +358,7 @@ void LegacyModEditDialog::on_buttonBox_rejected() void LegacyModEditDialog::jarCurrent(QModelIndex current, QModelIndex previous) { - if(!current.isValid()) + if (!current.isValid()) { ui->jarMIFrame->clear(); return; @@ -370,7 +370,7 @@ void LegacyModEditDialog::jarCurrent(QModelIndex current, QModelIndex previous) void LegacyModEditDialog::coreCurrent(QModelIndex current, QModelIndex previous) { - if(!current.isValid()) + if (!current.isValid()) { ui->coreMIFrame->clear(); return; @@ -382,7 +382,7 @@ void LegacyModEditDialog::coreCurrent(QModelIndex current, QModelIndex previous) void LegacyModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous) { - if(!current.isValid()) + if (!current.isValid()) { ui->loaderMIFrame->clear(); return; diff --git a/gui/LegacyModEditDialog.h b/gui/dialogs/LegacyModEditDialog.h index d5582aef..d5582aef 100644 --- a/gui/LegacyModEditDialog.h +++ b/gui/dialogs/LegacyModEditDialog.h diff --git a/gui/LegacyModEditDialog.ui b/gui/dialogs/LegacyModEditDialog.ui index bb0d9ef2..47db0079 100644 --- a/gui/LegacyModEditDialog.ui +++ b/gui/dialogs/LegacyModEditDialog.ui @@ -307,12 +307,12 @@ <customwidget> <class>ModListView</class> <extends>QTreeView</extends> - <header>gui/ModListView.h</header> + <header>gui/widgets/ModListView.h</header> </customwidget> <customwidget> <class>MCModInfoFrame</class> <extends>QFrame</extends> - <header>gui/MCModInfoFrame.h</header> + <header>gui/widgets/MCModInfoFrame.h</header> <container>1</container> </customwidget> </customwidgets> diff --git a/gui/logindialog.cpp b/gui/dialogs/LoginDialog.cpp index aeaaaa9e..19c6437d 100644 --- a/gui/logindialog.cpp +++ b/gui/dialogs/LoginDialog.cpp @@ -3,7 +3,7 @@ * 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 @@ -13,10 +13,10 @@ * limitations under the License. */ -#include "logindialog.h" -#include "ui_logindialog.h" +#include "LoginDialog.h" +#include "ui_LoginDialog.h" #include "keyring.h" -#include "gui/platform.h" +#include "gui/Platform.h" #include "MultiMC.h" #include <QFile> @@ -24,58 +24,58 @@ #include <QJsonArray> #include <QJsonParseError> #include "logic/net/HttpMetaCache.h" -#include <logger/QsLog.h> +#include "logger/QsLog.h" -LoginDialog::LoginDialog(QWidget *parent, const QString& loginErrMsg) : - QDialog(parent), - ui(new Ui::LoginDialog) +LoginDialog::LoginDialog(QWidget *parent, const QString &loginErrMsg) + : QDialog(parent), ui(new Ui::LoginDialog) { - MultiMCPlatform::fixWM_CLASS(this); + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); - + //: Use offline mode one time offlineButton = new QPushButton(tr("Offline Once")); - + ui->loginButtonBox->addButton(offlineButton, QDialogButtonBox::ActionRole); - + blockToggles = false; isOnline_ = true; onlineForced = false; - + //: The username during login (placeholder) ui->usernameTextBox->lineEdit()->setPlaceholderText(tr("Name")); - - connect(ui->usernameTextBox, SIGNAL(currentTextChanged(QString)), this, SLOT(userTextChanged(QString))); + + connect(ui->usernameTextBox, SIGNAL(currentTextChanged(QString)), this, + SLOT(userTextChanged(QString))); connect(ui->forgetButton, SIGNAL(clicked(bool)), this, SLOT(forgetCurrentUser())); connect(offlineButton, SIGNAL(clicked(bool)), this, SLOT(launchOffline())); - + if (loginErrMsg.isEmpty()) ui->loginErrorLabel->setVisible(false); else { ui->loginErrorLabel->setVisible(true); - ui->loginErrorLabel->setText(QString("<span style=\" color:#ff0000;\">%1</span>"). - arg(loginErrMsg)); + ui->loginErrorLabel->setText( + QString("<span style=\" color:#ff0000;\">%1</span>").arg(loginErrMsg)); } - + ui->lblFace->setVisible(false); resize(minimumSizeHint()); layout()->setSizeConstraint(QLayout::SetFixedSize); - Keyring * k = Keyring::instance(); + Keyring *k = Keyring::instance(); QStringList accounts = k->getStoredAccounts("minecraft"); ui->usernameTextBox->addItems(accounts); - + // TODO: restore last selected account here, if applicable - + int index = ui->usernameTextBox->currentIndex(); - if(index != -1) + if (index != -1) { ui->passwordTextBox->setFocus(Qt::OtherFocusReason); } - - connect(ui->rememberUsernameCheckbox,SIGNAL(toggled(bool)), SLOT(usernameToggled(bool))); - connect(ui->rememberPasswordCheckbox,SIGNAL(toggled(bool)), SLOT(passwordToggled(bool))); + + connect(ui->rememberUsernameCheckbox, SIGNAL(toggled(bool)), SLOT(usernameToggled(bool))); + connect(ui->rememberPasswordCheckbox, SIGNAL(toggled(bool)), SLOT(passwordToggled(bool))); } LoginDialog::~LoginDialog() @@ -96,14 +96,14 @@ QString LoginDialog::getPassword() const void LoginDialog::forgetCurrentUser() { - Keyring * k = Keyring::instance(); + Keyring *k = Keyring::instance(); QString acct = ui->usernameTextBox->currentText(); k->removeStoredAccount("minecraft", acct); ui->passwordTextBox->clear(); int index = ui->usernameTextBox->findText(acct); - if(index != -1) + if (index != -1) ui->usernameTextBox->removeItem(index); - if(!ui->usernameTextBox->count()) + if (!ui->usernameTextBox->count()) { blockToggles = true; ui->rememberUsernameCheckbox->setChecked(false); @@ -112,19 +112,19 @@ void LoginDialog::forgetCurrentUser() } } -void LoginDialog::passwordToggled ( bool state ) +void LoginDialog::passwordToggled(bool state) { // if toggled off - if(blockToggles) + if (blockToggles) return; blockToggles = true; - if(!state) + if (!state) { QLOG_DEBUG() << "password disabled"; } else { - if(!ui->rememberUsernameCheckbox->isChecked()) + if (!ui->rememberUsernameCheckbox->isChecked()) { ui->rememberUsernameCheckbox->setChecked(true); } @@ -133,15 +133,15 @@ void LoginDialog::passwordToggled ( bool state ) blockToggles = false; } -void LoginDialog::usernameToggled ( bool state ) +void LoginDialog::usernameToggled(bool state) { // if toggled off - if(blockToggles) + if (blockToggles) return; blockToggles = true; - if(!state) + if (!state) { - if(ui->rememberPasswordCheckbox->isChecked()) + if (ui->rememberPasswordCheckbox->isChecked()) { ui->rememberPasswordCheckbox->setChecked(false); } @@ -154,26 +154,26 @@ void LoginDialog::usernameToggled ( bool state ) blockToggles = false; } - -void LoginDialog::userTextChanged ( const QString& user ) +void LoginDialog::userTextChanged(const QString &user) { blockToggles = true; - Keyring * k = Keyring::instance(); + Keyring *k = Keyring::instance(); QStringList sl = k->getStoredAccounts("minecraft"); bool gotFace = false; - if(sl.contains(user)) + if (sl.contains(user)) { ui->rememberUsernameCheckbox->setChecked(true); - QString passwd = k->getPassword("minecraft",user); + QString passwd = k->getPassword("minecraft", user); ui->rememberPasswordCheckbox->setChecked(!passwd.isEmpty()); ui->passwordTextBox->setText(passwd); QByteArray data; { - auto filename = MMC->metacache()->resolveEntry("skins", "skins.json")->getFullPath(); + auto filename = + MMC->metacache()->resolveEntry("skins", "skins.json")->getFullPath(); QFile listFile(filename); - if(!listFile.open(QIODevice::ReadOnly)) + if (!listFile.open(QIODevice::ReadOnly)) return; data = listFile.readAll(); } @@ -183,20 +183,25 @@ void LoginDialog::userTextChanged ( const QString& user ) QJsonObject root = jsonDoc.object(); QJsonObject mappings = root.value("mappings").toObject(); - if(!mappings[user].isUndefined()) + if (!mappings[user].isUndefined()) { QJsonArray usernames = mappings.value(user).toArray(); - if(!usernames.isEmpty()) + if (!usernames.isEmpty()) { QString mapped_username = usernames[0].toString(); - if(!mapped_username.isEmpty()) + if (!mapped_username.isEmpty()) { - QFile fskin(MMC->metacache()->resolveEntry("skins", mapped_username + ".png")->getFullPath()); - if(fskin.exists()) + QFile fskin(MMC->metacache() + ->resolveEntry("skins", mapped_username + ".png") + ->getFullPath()); + if (fskin.exists()) { - QPixmap skin(MMC->metacache()->resolveEntry("skins", mapped_username + ".png")->getFullPath()); - QPixmap face = skin.copy(8, 8, 8, 8).scaled(48, 48, Qt::KeepAspectRatio); + QPixmap skin(MMC->metacache() + ->resolveEntry("skins", mapped_username + ".png") + ->getFullPath()); + QPixmap face = + skin.copy(8, 8, 8, 8).scaled(48, 48, Qt::KeepAspectRatio); ui->lblFace->setPixmap(face); gotFace = true; @@ -210,21 +215,20 @@ void LoginDialog::userTextChanged ( const QString& user ) blockToggles = false; } - void LoginDialog::accept() { bool saveName = ui->rememberUsernameCheckbox->isChecked(); bool savePass = ui->rememberPasswordCheckbox->isChecked(); - Keyring * k = Keyring::instance(); - if(saveName) + Keyring *k = Keyring::instance(); + if (saveName) { - if(savePass) + if (savePass) { - k->storePassword("minecraft",getUsername(),getPassword()); + k->storePassword("minecraft", getUsername(), getPassword()); } else { - k->storePassword("minecraft",getUsername(),QString()); + k->storePassword("minecraft", getUsername(), QString()); } } else @@ -235,7 +239,7 @@ void LoginDialog::accept() QDialog::accept(); } -void LoginDialog::launchOffline() +void LoginDialog::launchOffline() { isOnline_ = false; QDialog::accept(); diff --git a/gui/logindialog.h b/gui/dialogs/LoginDialog.h index f7c0e930..73a92aab 100644 --- a/gui/logindialog.h +++ b/gui/dialogs/LoginDialog.h @@ -3,7 +3,7 @@ * 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 @@ -13,39 +13,45 @@ * limitations under the License. */ -#ifndef LOGINDIALOG_H -#define LOGINDIALOG_H +#pragma once #include <QDialog> #include <QPushButton> -namespace Ui { +namespace Ui +{ class LoginDialog; } class LoginDialog : public QDialog { Q_OBJECT - + public: - explicit LoginDialog(QWidget *parent = 0, const QString& loginErrMsg = ""); + explicit LoginDialog(QWidget *parent = 0, const QString &loginErrMsg = ""); ~LoginDialog(); - + QString getUsername() const; QString getPassword() const; - - inline bool isOnline() { return isOnline_; } - + + inline bool isOnline() + { + return isOnline_; + } + void forceOnline(); -public slots: +public +slots: virtual void accept(); - virtual void userTextChanged(const QString& user); + virtual void userTextChanged(const QString &user); virtual void forgetCurrentUser(); -private slots: - void usernameToggled ( bool ); - void passwordToggled ( bool ); +private +slots: + void usernameToggled(bool); + void passwordToggled(bool); void launchOffline(); + private: Ui::LoginDialog *ui; bool blockToggles; @@ -53,5 +59,3 @@ private: bool isOnline_; bool onlineForced; }; - -#endif // LOGINDIALOG_H diff --git a/gui/logindialog.ui b/gui/dialogs/LoginDialog.ui index 94900d72..d15679dd 100644 --- a/gui/logindialog.ui +++ b/gui/dialogs/LoginDialog.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>476</width> + <width>496</width> <height>168</height> </rect> </property> @@ -50,7 +50,7 @@ <string/> </property> <property name="pixmap"> - <pixmap resource="../multimc.qrc">:/icons/instances/steve</pixmap> + <pixmap resource="../../multimc.qrc">:/icons/instances/steve</pixmap> </property> <property name="scaledContents"> <bool>true</bool> @@ -146,6 +146,7 @@ </layout> </widget> <resources> + <include location="../../multimc.qrc"/> <include location="../multimc.qrc"/> </resources> <connections> diff --git a/gui/lwjglselectdialog.cpp b/gui/dialogs/LwjglSelectDialog.cpp index 09963ce0..046a4e2e 100644 --- a/gui/lwjglselectdialog.cpp +++ b/gui/dialogs/LwjglSelectDialog.cpp @@ -3,7 +3,7 @@ * 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 @@ -14,23 +14,23 @@ */ #include "MultiMC.h" -#include "lwjglselectdialog.h" -#include "ui_lwjglselectdialog.h" -#include "gui/platform.h" +#include "LwjglSelectDialog.h" +#include "ui_LwjglSelectDialog.h" +#include "gui/Platform.h" #include "logic/lists/LwjglVersionList.h" -LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::LWJGLSelectDialog) +LWJGLSelectDialog::LWJGLSelectDialog(QWidget *parent) + : QDialog(parent), ui(new Ui::LWJGLSelectDialog) { - MultiMCPlatform::fixWM_CLASS(this); + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); ui->labelStatus->setVisible(false); auto lwjgllist = MMC->lwjgllist(); ui->lwjglListView->setModel(lwjgllist.get()); - - connect(lwjgllist.get(), SIGNAL(loadingStateUpdated(bool)), SLOT(loadingStateUpdated(bool))); + + connect(lwjgllist.get(), SIGNAL(loadingStateUpdated(bool)), + SLOT(loadingStateUpdated(bool))); connect(lwjgllist.get(), SIGNAL(loadListFailed(QString)), SLOT(loadingFailed(QString))); loadingStateUpdated(lwjgllist->isLoading()); } @@ -42,9 +42,9 @@ LWJGLSelectDialog::~LWJGLSelectDialog() QString LWJGLSelectDialog::selectedVersion() const { - return MMC->lwjgllist()->data( - ui->lwjglListView->selectionModel()->currentIndex(), - Qt::DisplayRole).toString(); + return MMC->lwjgllist() + ->data(ui->lwjglListView->selectionModel()->currentIndex(), Qt::DisplayRole) + .toString(); } void LWJGLSelectDialog::on_refreshButton_clicked() diff --git a/gui/lwjglselectdialog.h b/gui/dialogs/LwjglSelectDialog.h index 1772904a..2724cbe8 100644 --- a/gui/lwjglselectdialog.h +++ b/gui/dialogs/LwjglSelectDialog.h @@ -3,7 +3,7 @@ * 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 @@ -13,8 +13,7 @@ * limitations under the License. */ -#ifndef LWJGLSELECTDIALOG_H -#define LWJGLSELECTDIALOG_H +#pragma once #include <QDialog> @@ -26,21 +25,20 @@ class LWJGLSelectDialog; class LWJGLSelectDialog : public QDialog { Q_OBJECT - + public: explicit LWJGLSelectDialog(QWidget *parent = 0); ~LWJGLSelectDialog(); - + QString selectedVersion() const; - -private slots: + +private +slots: void on_refreshButton_clicked(); - + void loadingStateUpdated(bool loading); void loadingFailed(QString error); - + private: Ui::LWJGLSelectDialog *ui; }; - -#endif // LWJGLSELECTDIALOG_H diff --git a/gui/lwjglselectdialog.ui b/gui/dialogs/LwjglSelectDialog.ui index c715cc07..c715cc07 100644 --- a/gui/lwjglselectdialog.ui +++ b/gui/dialogs/LwjglSelectDialog.ui diff --git a/gui/dialogs/ModEditDialogCommon.cpp b/gui/dialogs/ModEditDialogCommon.cpp new file mode 100644 index 00000000..9a15d92d --- /dev/null +++ b/gui/dialogs/ModEditDialogCommon.cpp @@ -0,0 +1,57 @@ +/* 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 "ModEditDialogCommon.h" +#include "CustomMessageBox.h" +#include <QDesktopServices> +#include <QMessageBox> +#include <QString> +#include <QUrl> +bool lastfirst(QModelIndexList &list, int &first, int &last) +{ + if (!list.size()) + return false; + first = last = list[0].row(); + for (auto item : list) + { + int row = item.row(); + if (row < first) + first = row; + if (row > last) + last = row; + } + return true; +} + +void showWebsiteForMod(QWidget *parentDlg, Mod &m) +{ + QString url = m.homeurl(); + if (url.size()) + { + // catch the cases where the protocol is missing + if (!url.startsWith("http")) + { + url = "http://" + url; + } + QDesktopServices::openUrl(url); + } + else + { + CustomMessageBox::selectable( + parentDlg, parentDlg->tr("How sad!"), + parentDlg->tr("The mod author didn't provide a website link for this mod."), + QMessageBox::Warning); + } +} diff --git a/gui/dialogs/ModEditDialogCommon.h b/gui/dialogs/ModEditDialogCommon.h new file mode 100644 index 00000000..a226d5a9 --- /dev/null +++ b/gui/dialogs/ModEditDialogCommon.h @@ -0,0 +1,22 @@ +/* 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. + */ + +#pragma once +#include <QAbstractItemModel> +#include <logic/Mod.h> + +bool lastfirst(QModelIndexList &list, int &first, int &last); + +void showWebsiteForMod(QWidget *parentDlg, Mod &m);
\ No newline at end of file diff --git a/gui/newinstancedialog.cpp b/gui/dialogs/NewInstanceDialog.cpp index c37db2ac..5b2cd086 100644 --- a/gui/newinstancedialog.cpp +++ b/gui/dialogs/NewInstanceDialog.cpp @@ -13,9 +13,9 @@ * limitations under the License. */ -#include <MultiMC.h> -#include "newinstancedialog.h" -#include "ui_newinstancedialog.h" +#include "MultiMC.h" +#include "NewInstanceDialog.h" +#include "ui_NewInstanceDialog.h" #include "logic/InstanceFactory.h" #include "logic/BaseVersion.h" @@ -23,8 +23,8 @@ #include "logic/lists/MinecraftVersionList.h" #include "logic/tasks/Task.h" -#include "gui/platform.h" -#include "versionselectdialog.h" +#include "gui/Platform.h" +#include "VersionSelectDialog.h" #include "ProgressDialog.h" #include "IconPickerDialog.h" @@ -34,7 +34,7 @@ NewInstanceDialog::NewInstanceDialog(QWidget *parent) : QDialog(parent), ui(new Ui::NewInstanceDialog) { - MultiMCPlatform::fixWM_CLASS(this); + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); resize(minimumSizeHint()); layout()->setSizeConstraint(QLayout::SetFixedSize); diff --git a/gui/newinstancedialog.h b/gui/dialogs/NewInstanceDialog.h index 4357c28d..4357c28d 100644 --- a/gui/newinstancedialog.h +++ b/gui/dialogs/NewInstanceDialog.h diff --git a/gui/newinstancedialog.ui b/gui/dialogs/NewInstanceDialog.ui index 540176d5..b4b8723e 100644 --- a/gui/newinstancedialog.ui +++ b/gui/dialogs/NewInstanceDialog.ui @@ -17,7 +17,7 @@ <string>New Instance</string> </property> <property name="windowIcon"> - <iconset resource="../multimc.qrc"> + <iconset resource="../../multimc.qrc"> <normaloff>:/icons/toolbar/new</normaloff>:/icons/toolbar/new</iconset> </property> <property name="modal"> @@ -42,7 +42,7 @@ <item> <widget class="QToolButton" name="iconButton"> <property name="icon"> - <iconset resource="../multimc.qrc"> + <iconset resource="../../multimc.qrc"> <normaloff>:/icons/instances/infinity</normaloff>:/icons/instances/infinity</iconset> </property> <property name="iconSize"> @@ -140,7 +140,7 @@ </layout> </widget> <resources> - <include location="../multimc.qrc"/> + <include location="../../multimc.qrc"/> </resources> <connections> <connection> diff --git a/gui/OneSixModEditDialog.cpp b/gui/dialogs/OneSixModEditDialog.cpp index 42bcfeb0..dea1b86b 100644 --- a/gui/OneSixModEditDialog.cpp +++ b/gui/dialogs/OneSixModEditDialog.cpp @@ -12,19 +12,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "MultiMC.h" -#include "OneSixModEditDialog.h" -#include "ModEditDialogCommon.h" -#include "ui_OneSixModEditDialog.h" -#include "logic/ModList.h" -#include "logic/OneSixVersion.h" -#include "logic/EnabledItemFilter.h" -#include "logic/lists/ForgeVersionList.h" -#include "logic/ForgeInstaller.h" -#include "gui/versionselectdialog.h" -#include "gui/platform.h" -#include "gui/CustomMessageBox.h" -#include "ProgressDialog.h" #include <pathutils.h> #include <QFileDialog> @@ -34,10 +23,26 @@ #include <QKeyEvent> #include <QDesktopServices> +#include "OneSixModEditDialog.h" +#include "ModEditDialogCommon.h" +#include "ui_OneSixModEditDialog.h" + +#include "gui/Platform.h" +#include "gui/dialogs/CustomMessageBox.h" +#include "gui/dialogs/VersionSelectDialog.h" + +#include "gui/dialogs/ProgressDialog.h" + +#include "logic/ModList.h" +#include "logic/OneSixVersion.h" +#include "logic/EnabledItemFilter.h" +#include "logic/lists/ForgeVersionList.h" +#include "logic/ForgeInstaller.h" + OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent) : m_inst(inst), QDialog(parent), ui(new Ui::OneSixModEditDialog) { - MultiMCPlatform::fixWM_CLASS(this); + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); // libraries! @@ -65,7 +70,7 @@ OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent) m_mods->startWatching(); auto smodel = ui->loaderModTreeView->selectionModel(); connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - SLOT(loaderCurrent(QModelIndex,QModelIndex))); + SLOT(loaderCurrent(QModelIndex, QModelIndex))); } // resource packs { @@ -111,10 +116,10 @@ void OneSixModEditDialog::on_customizeBtn_clicked() void OneSixModEditDialog::on_revertBtn_clicked() { - auto response = CustomMessageBox::selectable(this, tr("Revert?"), - tr("Do you want to revert the " - "version of this instance to its original configuration?"), - QMessageBox::Question, QMessageBox::Yes | QMessageBox::No)->exec(); + auto response = CustomMessageBox::selectable( + this, tr("Revert?"), tr("Do you want to revert the " + "version of this instance to its original configuration?"), + QMessageBox::Question, QMessageBox::Yes | QMessageBox::No)->exec(); if (response == QMessageBox::Yes) { if (m_inst->revertCustomVersion()) @@ -306,7 +311,7 @@ void OneSixModEditDialog::on_viewResPackBtn_clicked() void OneSixModEditDialog::loaderCurrent(QModelIndex current, QModelIndex previous) { - if(!current.isValid()) + if (!current.isValid()) { ui->frame->clear(); return; diff --git a/gui/OneSixModEditDialog.h b/gui/dialogs/OneSixModEditDialog.h index 5376e526..5376e526 100644 --- a/gui/OneSixModEditDialog.h +++ b/gui/dialogs/OneSixModEditDialog.h diff --git a/gui/OneSixModEditDialog.ui b/gui/dialogs/OneSixModEditDialog.ui index 6d70200a..8f301438 100644 --- a/gui/OneSixModEditDialog.ui +++ b/gui/dialogs/OneSixModEditDialog.ui @@ -305,12 +305,12 @@ <customwidget> <class>ModListView</class> <extends>QTreeView</extends> - <header>gui/ModListView.h</header> + <header>gui/widgets/ModListView.h</header> </customwidget> <customwidget> <class>MCModInfoFrame</class> <extends>QFrame</extends> - <header>gui/MCModInfoFrame.h</header> + <header>gui/widgets/MCModInfoFrame.h</header> <container>1</container> </customwidget> </customwidgets> diff --git a/gui/ProgressDialog.cpp b/gui/dialogs/ProgressDialog.cpp index 2e5251a0..ca433dab 100644 --- a/gui/ProgressDialog.cpp +++ b/gui/dialogs/ProgressDialog.cpp @@ -3,7 +3,7 @@ * 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 @@ -19,17 +19,15 @@ #include <QKeyEvent> #include "logic/tasks/Task.h" -#include "gui/platform.h" +#include "gui/Platform.h" -ProgressDialog::ProgressDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::ProgressDialog) +ProgressDialog::ProgressDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ProgressDialog) { - MultiMCPlatform::fixWM_CLASS(this); + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); updateSize(); - - changeProgress(0,100); + + changeProgress(0, 100); } ProgressDialog::~ProgressDialog() @@ -45,27 +43,26 @@ void ProgressDialog::updateSize() int ProgressDialog::exec(ProgressProvider *task) { this->task = task; - + // Connect signals. connect(task, SIGNAL(started()), SLOT(onTaskStarted())); connect(task, SIGNAL(failed(QString)), SLOT(onTaskFailed(QString))); connect(task, SIGNAL(succeeded()), SLOT(onTaskSucceeded())); - connect(task, SIGNAL(status(QString)), SLOT(changeStatus(const QString&))); - connect(task, SIGNAL(progress(qint64,qint64)), SLOT(changeProgress(qint64,qint64))); - + connect(task, SIGNAL(status(QString)), SLOT(changeStatus(const QString &))); + connect(task, SIGNAL(progress(qint64, qint64)), SLOT(changeProgress(qint64, qint64))); + // this makes sure that the task is started after the dialog is created QMetaObject::invokeMethod(task, "start", Qt::QueuedConnection); return QDialog::exec(); } -ProgressProvider* ProgressDialog::getTask() +ProgressProvider *ProgressDialog::getTask() { return task; } void ProgressDialog::onTaskStarted() { - } void ProgressDialog::onTaskFailed(QString failure) @@ -90,14 +87,14 @@ void ProgressDialog::changeProgress(qint64 current, qint64 total) ui->taskProgressBar->setValue(current); } -void ProgressDialog::keyPressEvent(QKeyEvent* e) +void ProgressDialog::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Escape) return; QDialog::keyPressEvent(e); } -void ProgressDialog::closeEvent(QCloseEvent* e) +void ProgressDialog::closeEvent(QCloseEvent *e) { if (task && task->isRunning()) { diff --git a/gui/ProgressDialog.h b/gui/dialogs/ProgressDialog.h index ac6bb412..0029d3ec 100644 --- a/gui/ProgressDialog.h +++ b/gui/dialogs/ProgressDialog.h @@ -3,7 +3,7 @@ * 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 @@ -13,50 +13,48 @@ * limitations under the License. */ -#ifndef TASKDIALOG_H -#define TASKDIALOG_H +#pragma once #include <QDialog> class ProgressProvider; -namespace Ui { +namespace Ui +{ class ProgressDialog; } class ProgressDialog : public QDialog { Q_OBJECT - + public: explicit ProgressDialog(QWidget *parent = 0); ~ProgressDialog(); - + void updateSize(); - - int exec(ProgressProvider* task); - - ProgressProvider* getTask(); - -public slots: + + int exec(ProgressProvider *task); + + ProgressProvider *getTask(); + +public +slots: void onTaskStarted(); void onTaskFailed(QString failure); void onTaskSucceeded(); - - void changeStatus(const QString& status); + + void changeStatus(const QString &status); void changeProgress(qint64 current, qint64 total); - + signals: - - + protected: - virtual void keyPressEvent(QKeyEvent* e); - virtual void closeEvent(QCloseEvent* e); - + virtual void keyPressEvent(QKeyEvent *e); + virtual void closeEvent(QCloseEvent *e); + private: Ui::ProgressDialog *ui; - - ProgressProvider* task; -}; -#endif // TASKDIALOG_H + ProgressProvider *task; +}; diff --git a/gui/ProgressDialog.ui b/gui/dialogs/ProgressDialog.ui index a56d2a92..a56d2a92 100644 --- a/gui/ProgressDialog.ui +++ b/gui/dialogs/ProgressDialog.ui diff --git a/gui/settingsdialog.cpp b/gui/dialogs/SettingsDialog.cpp index bf331fc0..e4f22d83 100644 --- a/gui/settingsdialog.cpp +++ b/gui/dialogs/SettingsDialog.cpp @@ -13,14 +13,17 @@ * limitations under the License. */ -#include <MultiMC.h> -#include "settingsdialog.h" -#include "ui_settingsdialog.h" +#include "MultiMC.h" + +#include "gui/dialogs/SettingsDialog.h" +#include "ui_SettingsDialog.h" + +#include "gui/Platform.h" +#include "gui/dialogs/VersionSelectDialog.h" +#include "gui/dialogs/CustomMessageBox.h" + #include "logic/JavaUtils.h" #include "logic/NagUtils.h" -#include "gui/versionselectdialog.h" -#include "gui/platform.h" -#include "gui/CustomMessageBox.h" #include "logic/lists/JavaVersionList.h" #include <settingsobject.h> @@ -123,10 +126,11 @@ void SettingsDialog::applySettings(SettingsObject *s) } else if (!s->get("UseDevBuilds").toBool()) { - auto response = CustomMessageBox::selectable(this, tr("Development builds"), - tr("Development builds contain experimental features " - "and may be unstable. Are you sure you want to enable them?"), - QMessageBox::Question, QMessageBox::Yes | QMessageBox::No)->exec(); + auto response = CustomMessageBox::selectable( + this, tr("Development builds"), + tr("Development builds contain experimental features " + "and may be unstable. Are you sure you want to enable them?"), + QMessageBox::Question, QMessageBox::Yes | QMessageBox::No)->exec(); if (response == QMessageBox::Yes) { s->set("UseDevBuilds", true); @@ -168,16 +172,16 @@ void SettingsDialog::applySettings(SettingsObject *s) s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); s->set("PostExitCommand", ui->postExitCmdTextBox->text()); - auto sortMode = (InstSortMode) ui->sortingModeGroup->checkedId(); - switch(sortMode) + auto sortMode = (InstSortMode)ui->sortingModeGroup->checkedId(); + switch (sortMode) { - case Sort_LastLaunch: - s->set("InstSortMode", "LastLaunch"); - break; - case Sort_Name: - default: - s->set("InstSortMode", "Name"); - break; + case Sort_LastLaunch: + s->set("InstSortMode", "LastLaunch"); + break; + case Sort_Name: + default: + s->set("InstSortMode", "Name"); + break; } s->set("PostExitCommand", ui->postExitCmdTextBox->text()); @@ -213,7 +217,7 @@ void SettingsDialog::loadSettings(SettingsObject *s) QString sortMode = s->get("InstSortMode").toString(); - if(sortMode == "LastLaunch") + if (sortMode == "LastLaunch") { ui->sortLastLaunchedBtn->setChecked(true); } diff --git a/gui/settingsdialog.h b/gui/dialogs/SettingsDialog.h index a8dfb1c6..e24047c3 100644 --- a/gui/settingsdialog.h +++ b/gui/dialogs/SettingsDialog.h @@ -3,7 +3,7 @@ * 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 @@ -13,46 +13,47 @@ * limitations under the License. */ -#ifndef SETTINGSDIALOG_H -#define SETTINGSDIALOG_H +#pragma once #include <QDialog> class SettingsObject; -namespace Ui { +namespace Ui +{ class SettingsDialog; } class SettingsDialog : public QDialog { Q_OBJECT - + public: explicit SettingsDialog(QWidget *parent = 0); ~SettingsDialog(); - + void updateCheckboxStuff(); - + void applySettings(SettingsObject *s); - void loadSettings(SettingsObject* s); + void loadSettings(SettingsObject *s); protected: - virtual void showEvent ( QShowEvent* ); - -private slots: + virtual void showEvent(QShowEvent *); + +private +slots: void on_instDirBrowseBtn_clicked(); - + void on_modsDirBrowseBtn_clicked(); - + void on_lwjglDirBrowseBtn_clicked(); - + void on_compatModeCheckBox_clicked(bool checked); - + void on_maximizedCheckBox_clicked(bool checked); - + void on_buttonBox_accepted(); - + void on_pushButton_clicked(); void on_btnBrowse_clicked(); @@ -60,5 +61,3 @@ private slots: private: Ui::SettingsDialog *ui; }; - -#endif // SETTINGSDIALOG_H diff --git a/gui/settingsdialog.ui b/gui/dialogs/SettingsDialog.ui index bf173b1b..6da9420e 100644 --- a/gui/settingsdialog.ui +++ b/gui/dialogs/SettingsDialog.ui @@ -20,7 +20,7 @@ <string>Settings</string> </property> <property name="windowIcon"> - <iconset resource="../multimc.qrc"> + <iconset resource="../../multimc.qrc"> <normaloff>:/icons/toolbar/settings</normaloff>:/icons/toolbar/settings</iconset> </property> <property name="modal"> @@ -527,7 +527,7 @@ <tabstop>postExitCmdTextBox</tabstop> </tabstops> <resources> - <include location="../multimc.qrc"/> + <include location="../../multimc.qrc"/> </resources> <connections> <connection> diff --git a/gui/versionselectdialog.cpp b/gui/dialogs/VersionSelectDialog.cpp index 8fa62f75..d6efe3c0 100644 --- a/gui/versionselectdialog.cpp +++ b/gui/dialogs/VersionSelectDialog.cpp @@ -13,24 +13,25 @@ * limitations under the License. */ -#include "versionselectdialog.h" -#include "ui_versionselectdialog.h" +#include "VersionSelectDialog.h" +#include "ui_VersionSelectDialog.h" #include <QHeaderView> #include <QDebug> -#include <gui/ProgressDialog.h> -#include "gui/platform.h" +#include <gui/dialogs/ProgressDialog.h> +#include "gui/Platform.h" #include <logic/BaseVersion.h> #include <logic/lists/BaseVersionList.h> #include <logic/tasks/Task.h> -VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, QWidget *parent, bool cancelable) +VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, QWidget *parent, + bool cancelable) : QDialog(parent), ui(new Ui::VersionSelectDialog) { - MultiMCPlatform::fixWM_CLASS(this); + MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); setWindowModality(Qt::WindowModal); setWindowTitle(title); @@ -44,7 +45,7 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title, ui->listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); ui->listView->header()->setSectionResizeMode(resizeOnColumn, QHeaderView::Stretch); - if(!cancelable) + if (!cancelable) { ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); } diff --git a/gui/versionselectdialog.h b/gui/dialogs/VersionSelectDialog.h index 319caeca..e36341db 100644 --- a/gui/versionselectdialog.h +++ b/gui/dialogs/VersionSelectDialog.h @@ -3,7 +3,7 @@ * 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 @@ -13,12 +13,11 @@ * limitations under the License. */ -#ifndef VERSIONSELECTDIALOG_H -#define VERSIONSELECTDIALOG_H +#pragma once #include <QDialog> - #include <QSortFilterProxyModel> + #include "logic/BaseVersion.h" class BaseVersionList; @@ -31,31 +30,32 @@ class VersionSelectDialog; class VersionSelectDialog : public QDialog { Q_OBJECT - + public: - explicit VersionSelectDialog(BaseVersionList *vlist, QString title, QWidget *parent = 0, bool cancelable = true); + explicit VersionSelectDialog(BaseVersionList *vlist, QString title, QWidget *parent = 0, + bool cancelable = true); ~VersionSelectDialog(); - + virtual int exec(); - + //! Starts a task that loads the list. void loadList(); - + BaseVersionPtr selectedVersion() const; - + void setFilter(int column, QString filter); void setResizeOn(int column); - -private slots: + +private +slots: void on_refreshButton_clicked(); + private: Ui::VersionSelectDialog *ui; - + BaseVersionList *m_vlist; - + QSortFilterProxyModel *m_proxyModel; int resizeOnColumn = 0; }; - -#endif // VERSIONSELECTDIALOG_H diff --git a/gui/versionselectdialog.ui b/gui/dialogs/VersionSelectDialog.ui index 222f29cf..222f29cf 100644 --- a/gui/versionselectdialog.ui +++ b/gui/dialogs/VersionSelectDialog.ui diff --git a/gui/instancedelegate.h b/gui/instancedelegate.h deleted file mode 100644 index 56bc34ba..00000000 --- a/gui/instancedelegate.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include <QStyledItemDelegate> - -class ListViewDelegate : public QStyledItemDelegate -{ -public: - explicit ListViewDelegate ( QObject* parent = 0 ); -protected: - void paint ( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const; - QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const; -}; diff --git a/gui/instancesettings.h b/gui/instancesettings.h deleted file mode 100644 index b6cdb92c..00000000 --- a/gui/instancesettings.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef INSTANCESETTINGS_H -#define INSTANCESETTINGS_H - -#include <QDialog> -#include "settingsobject.h" - -namespace Ui { -class InstanceSettings; -} - -class InstanceSettings : public QDialog -{ - Q_OBJECT - -public: - explicit InstanceSettings(SettingsObject *s, QWidget *parent = 0); - ~InstanceSettings(); - - void updateCheckboxStuff(); - - void applySettings(); - void loadSettings(); -protected: - virtual void showEvent ( QShowEvent* ); -private slots: - void on_customCommandsGroupBox_toggled(bool arg1); - void on_buttonBox_accepted(); - void on_buttonBox_rejected(); - -private: - Ui::InstanceSettings *ui; - SettingsObject * m_obj; -}; - -#endif // INSTANCESETTINGS_H diff --git a/gui/newmodeditwindow.ui b/gui/newmodeditwindow.ui deleted file mode 100644 index a7587d11..00000000 --- a/gui/newmodeditwindow.ui +++ /dev/null @@ -1,159 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Dialog</class> - <widget class="QDialog" name="Dialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>569</width> - <height>420</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="currentIndex"> - <number>2</number> - </property> - <property name="elideMode"> - <enum>Qt::ElideNone</enum> - </property> - <property name="tabsClosable"> - <bool>false</bool> - </property> - <widget class="QWidget" name="libraryTab"> - <attribute name="title"> - <string>Library</string> - </attribute> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QTreeView" name="treeView"/> - </item> - </layout> - </widget> - <widget class="QWidget" name="modTab"> - <attribute name="title"> - <string>Mods</string> - </attribute> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QListView" name="listView"/> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="addModButton"> - <property name="text"> - <string>&Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeModButton"> - <property name="text"> - <string>&Remove</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="viewModButton"> - <property name="text"> - <string>&View Folder</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QWidget" name="resourcePackTab"> - <attribute name="title"> - <string>Resource Pack</string> - </attribute> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QListView" name="listView_2"/> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QPushButton" name="pushButton"> - <property name="text"> - <string>PushButton</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_2"> - <property name="text"> - <string>PushButton</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pushButton_3"> - <property name="text"> - <string>PushButton</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="autoFillBackground"> - <bool>false</bool> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/gui/instancedelegate.cpp b/gui/widgets/InstanceDelegate.cpp index 4c7a3a3a..487fed61 100644 --- a/gui/instancedelegate.cpp +++ b/gui/widgets/InstanceDelegate.cpp @@ -1,4 +1,19 @@ -#include "instancedelegate.h" +/* 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 "InstanceDelegate.h" #include <QPainter> #include <QTextOption> #include <QTextLayout> diff --git a/gui/widgets/InstanceDelegate.h b/gui/widgets/InstanceDelegate.h new file mode 100644 index 00000000..6f924405 --- /dev/null +++ b/gui/widgets/InstanceDelegate.h @@ -0,0 +1,27 @@ +/* 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. + */ + +#pragma once + +#include <QStyledItemDelegate> + +class ListViewDelegate : public QStyledItemDelegate +{ +public: + explicit ListViewDelegate ( QObject* parent = 0 ); +protected: + void paint ( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const; + QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const; +}; diff --git a/gui/LabeledToolButton.cpp b/gui/widgets/LabeledToolButton.cpp index be84d1b7..fe3cac45 100644 --- a/gui/LabeledToolButton.cpp +++ b/gui/widgets/LabeledToolButton.cpp @@ -1,3 +1,18 @@ +/* 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 <QLabel> #include <QVBoxLayout> #include <QResizeEvent> @@ -5,7 +20,6 @@ #include "LabeledToolButton.h" #include <QApplication> - /* * * Tool Button with a label on it, instead of the normal text rendering diff --git a/gui/widgets/LabeledToolButton.h b/gui/widgets/LabeledToolButton.h new file mode 100644 index 00000000..b417f814 --- /dev/null +++ b/gui/widgets/LabeledToolButton.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. + */ + +#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/MCModInfoFrame.cpp b/gui/widgets/MCModInfoFrame.cpp index 55ef13f1..ad167bc9 100644 --- a/gui/MCModInfoFrame.cpp +++ b/gui/widgets/MCModInfoFrame.cpp @@ -13,11 +13,13 @@ * limitations under the License. */ -#include "MCModInfoFrame.h" -#include "ui_MCModInfoFrame.h" -#include "CustomMessageBox.h" #include <QMessageBox> #include <QtGui> + +#include "MCModInfoFrame.h" +#include "ui_MCModInfoFrame.h" +#include "gui/dialogs/CustomMessageBox.h" + void MCModInfoFrame::updateWithMod(Mod &m) { if(m.type() == m.MOD_FOLDER) diff --git a/gui/MCModInfoFrame.h b/gui/widgets/MCModInfoFrame.h index 54c5d674..54c5d674 100644 --- a/gui/MCModInfoFrame.h +++ b/gui/widgets/MCModInfoFrame.h diff --git a/gui/MCModInfoFrame.ui b/gui/widgets/MCModInfoFrame.ui index 60e0a65c..60e0a65c 100644 --- a/gui/MCModInfoFrame.ui +++ b/gui/widgets/MCModInfoFrame.ui diff --git a/gui/ModListView.cpp b/gui/widgets/ModListView.cpp index 1d0e834c..838af75e 100644 --- a/gui/ModListView.cpp +++ b/gui/widgets/ModListView.cpp @@ -1,3 +1,18 @@ +/* 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 "ModListView.h" #include <QHeaderView> #include <QMouseEvent> diff --git a/gui/widgets/ModListView.h b/gui/widgets/ModListView.h new file mode 100644 index 00000000..b26fa26b --- /dev/null +++ b/gui/widgets/ModListView.h @@ -0,0 +1,27 @@ +/* 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. + */ + +#pragma once +#include <QTreeView> + +class Mod; + +class ModListView: public QTreeView +{ + Q_OBJECT +public: + explicit ModListView ( QWidget* parent = 0 ); + virtual void setModel ( QAbstractItemModel* model ); +}; |