diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-04-10 04:29:29 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-04-30 23:59:23 +0200 |
commit | 47e37635f50c09b4f9a9ee7699e3120bab3e4088 (patch) | |
tree | 061c2f675fb7e244ebe4b54ef206bfbd615c91f8 /application | |
parent | fcd4a482f759cd58ee319a51082d0146b7e426e2 (diff) | |
download | MultiMC-47e37635f50c09b4f9a9ee7699e3120bab3e4088.tar MultiMC-47e37635f50c09b4f9a9ee7699e3120bab3e4088.tar.gz MultiMC-47e37635f50c09b4f9a9ee7699e3120bab3e4088.tar.lz MultiMC-47e37635f50c09b4f9a9ee7699e3120bab3e4088.tar.xz MultiMC-47e37635f50c09b4f9a9ee7699e3120bab3e4088.zip |
NOISSUE split GUI stuff from logic library
Diffstat (limited to 'application')
-rw-r--r-- | application/CMakeLists.txt | 2 | ||||
-rw-r--r-- | application/ConsoleWindow.cpp | 2 | ||||
-rw-r--r-- | application/InstanceProxyModel.cpp | 11 | ||||
-rw-r--r-- | application/InstanceProxyModel.h | 3 | ||||
-rw-r--r-- | application/MainWindow.cpp | 12 | ||||
-rw-r--r-- | application/MultiMC.cpp | 4 | ||||
-rw-r--r-- | application/MultiMC.h | 6 | ||||
-rw-r--r-- | application/dialogs/CopyInstanceDialog.cpp | 4 | ||||
-rw-r--r-- | application/dialogs/ExportInstanceDialog.cpp | 4 | ||||
-rw-r--r-- | application/dialogs/IconPickerDialog.cpp | 8 | ||||
-rw-r--r-- | application/dialogs/NewInstanceDialog.cpp | 4 | ||||
-rw-r--r-- | application/pages/VersionPage.cpp | 2 |
12 files changed, 40 insertions, 22 deletions
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index 5983fb42..f1a95a8a 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -318,7 +318,7 @@ qt5_add_resources(MULTIMC_RESOURCES ${MULTIMC_QRCS}) # Add executable add_executable(MultiMC MACOSX_BUNDLE WIN32 ${MULTIMC_SOURCES} ${MULTIMC_UI} ${MULTIMC_RESOURCES} ${MULTIMC_RCS}) -target_link_libraries(MultiMC MultiMC_logic xz-embedded unpack200 iconfix ${QUAZIP_LIBRARIES} hoedown rainbow) +target_link_libraries(MultiMC MultiMC_gui ${QUAZIP_LIBRARIES} hoedown rainbow) if(APPLE) find_library(OSX_CORE_FOUNDATION CoreFoundation) diff --git a/application/ConsoleWindow.cpp b/application/ConsoleWindow.cpp index a843536b..e620d700 100644 --- a/application/ConsoleWindow.cpp +++ b/application/ConsoleWindow.cpp @@ -58,7 +58,7 @@ ConsoleWindow::ConsoleWindow(std::shared_ptr<LaunchTask> proc, QWidget *parent) setAttribute(Qt::WA_DeleteOnClose); auto instance = m_proc->instance(); - auto icon = ENV.icons()->getIcon(instance->iconKey()); + auto icon = MMC->icons()->getIcon(instance->iconKey()); QString windowTitle = tr("Console window for ") + instance->name(); // Set window properties diff --git a/application/InstanceProxyModel.cpp b/application/InstanceProxyModel.cpp index 2048252c..d0e9e10d 100644 --- a/application/InstanceProxyModel.cpp +++ b/application/InstanceProxyModel.cpp @@ -1,11 +1,22 @@ #include "InstanceProxyModel.h" #include "MultiMC.h" #include <BaseInstance.h> +#include <icons/IconList.h> InstanceProxyModel::InstanceProxyModel(QObject *parent) : GroupedProxyModel(parent) { } +QVariant InstanceProxyModel::data(const QModelIndex & index, int role) const +{ + QVariant data = QSortFilterProxyModel::data(index, role); + if(role == Qt::DecorationRole) + { + return QVariant(MMC->icons()->getIcon(data.toString())); + } + return data; +} + bool InstanceProxyModel::subSortLessThan(const QModelIndex &left, const QModelIndex &right) const { diff --git a/application/InstanceProxyModel.h b/application/InstanceProxyModel.h index cc6c1b86..c063f526 100644 --- a/application/InstanceProxyModel.h +++ b/application/InstanceProxyModel.h @@ -9,7 +9,8 @@ class InstanceProxyModel : public GroupedProxyModel { public: explicit InstanceProxyModel(QObject *parent = 0); + QVariant data(const QModelIndex & index, int role) const override; protected: - virtual bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const; + virtual bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const override; }; diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index e1d306b0..97c0b02a 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -56,7 +56,7 @@ #include <launch/LaunchTask.h> #include <minecraft/MinecraftVersionList.h> #include <minecraft/legacy/LwjglVersionList.h> -#include <minecraft/SkinUtils.h> +#include <SkinUtils.h> #include <net/URLConstants.h> #include <net/NetJob.h> #include <net/CacheDownload.h> @@ -468,7 +468,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow connect(view->selectionModel(), &QItemSelectionModel::currentChanged, this, &MainWindow::instanceChanged); // track icon changes and update the toolbar! - connect(ENV.icons().get(), &IconList::iconUpdated, this, &MainWindow::iconUpdated); + connect(MMC->icons().get(), &IconList::iconUpdated, this, &MainWindow::iconUpdated); // model reset -> selection is invalid. All the instance pointers are wrong. connect(MMC->instances().get(), &InstanceList::dataIsInvalid, this, &MainWindow::selectionBad); @@ -1108,7 +1108,7 @@ InstancePtr MainWindow::instanceFromZipPack(QString instName, QString instGroup, if (QFile::exists(importIconPath)) { // import icon - auto iconList = ENV.icons(); + auto iconList = MMC->icons(); // FIXME: check if the file is OK before removing the existing one... if (iconList->iconFileExists(instIcon)) { @@ -1311,7 +1311,7 @@ void MainWindow::on_actionChangeInstIcon_triggered() if (dlg.result() == QDialog::Accepted) { m_selectedInstance->setIconKey(dlg.selectedIconKey); - auto ico = ENV.icons()->getBigIcon(dlg.selectedIconKey); + auto ico = MMC->icons()->getBigIcon(dlg.selectedIconKey); ui->actionChangeInstIcon->setIcon(ico); } } @@ -1320,14 +1320,14 @@ void MainWindow::iconUpdated(QString icon) { if (icon == m_currentInstIcon) { - ui->actionChangeInstIcon->setIcon(ENV.icons()->getBigIcon(m_currentInstIcon)); + ui->actionChangeInstIcon->setIcon(MMC->icons()->getBigIcon(m_currentInstIcon)); } } void MainWindow::updateInstanceToolIcon(QString new_icon) { m_currentInstIcon = new_icon; - ui->actionChangeInstIcon->setIcon(ENV.icons()->getBigIcon(m_currentInstIcon)); + ui->actionChangeInstIcon->setIcon(MMC->icons()->getBigIcon(m_currentInstIcon)); } void MainWindow::setSelectedInstanceById(const QString &id) diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 4a84c6bd..24e71fa0 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -342,10 +342,10 @@ void MultiMC::initTranslations() void MultiMC::initIcons() { auto setting = MMC->settings()->getSetting("IconsDir"); - ENV.m_icons.reset(new IconList(QString(":/icons/instances/"), setting->get().toString())); + m_icons.reset(new IconList(QString(":/icons/instances/"), setting->get().toString())); connect(setting.get(), &Setting::SettingChanged,[&](const Setting &, QVariant value) { - ENV.m_icons->directoryChanged(value.toString()); + m_icons->directoryChanged(value.toString()); }); //FIXME: none of this should be here. diff --git a/application/MultiMC.h b/application/MultiMC.h index 5b19db19..8219d66c 100644 --- a/application/MultiMC.h +++ b/application/MultiMC.h @@ -87,6 +87,11 @@ public: return m_instances; } + std::shared_ptr<IconList> icons() + { + return m_icons; + } + // APPLICATION ONLY std::shared_ptr<MojangAccountList> accounts() { @@ -154,6 +159,7 @@ private: std::shared_ptr<QTranslator> m_mmc_translator; std::shared_ptr<SettingsObject> m_settings; std::shared_ptr<InstanceList> m_instances; + std::shared_ptr<IconList> m_icons; std::shared_ptr<UpdateChecker> m_updateChecker; std::shared_ptr<MojangAccountList> m_accounts; std::shared_ptr<LWJGLVersionList> m_lwjgllist; diff --git a/application/dialogs/CopyInstanceDialog.cpp b/application/dialogs/CopyInstanceDialog.cpp index 67e2e8e1..85c70d91 100644 --- a/application/dialogs/CopyInstanceDialog.cpp +++ b/application/dialogs/CopyInstanceDialog.cpp @@ -36,7 +36,7 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent) layout()->setSizeConstraint(QLayout::SetFixedSize); InstIconKey = original->iconKey(); - ui->iconButton->setIcon(ENV.icons()->getIcon(InstIconKey)); + ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey)); ui->instNameTextBox->setText(original->name()); ui->instNameTextBox->setFocus(); auto groups = MMC->instances()->getGroups().toSet(); @@ -88,7 +88,7 @@ void CopyInstanceDialog::on_iconButton_clicked() if (dlg.result() == QDialog::Accepted) { InstIconKey = dlg.selectedIconKey; - ui->iconButton->setIcon(ENV.icons()->getIcon(InstIconKey)); + ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey)); } } diff --git a/application/dialogs/ExportInstanceDialog.cpp b/application/dialogs/ExportInstanceDialog.cpp index a38fd238..2712f24c 100644 --- a/application/dialogs/ExportInstanceDialog.cpp +++ b/application/dialogs/ExportInstanceDialog.cpp @@ -27,7 +27,7 @@ #include <QSaveFile> #include "MMCStrings.h" #include "SeparatorPrefixTree.h" -#include "Env.h" +#include "MultiMC.h" #include <icons/IconList.h> #include <FileSystem.h> @@ -339,7 +339,7 @@ ExportInstanceDialog::~ExportInstanceDialog() void SaveIcon(InstancePtr m_instance) { auto iconKey = m_instance->iconKey(); - auto iconList = ENV.icons(); + auto iconList = MMC->icons(); auto mmcIcon = iconList->icon(iconKey); if(mmcIcon) { diff --git a/application/dialogs/IconPickerDialog.cpp b/application/dialogs/IconPickerDialog.cpp index f750cd27..7ee7d045 100644 --- a/application/dialogs/IconPickerDialog.cpp +++ b/application/dialogs/IconPickerDialog.cpp @@ -57,7 +57,7 @@ IconPickerDialog::IconPickerDialog(QWidget *parent) contentsWidget->installEventFilter(this); - contentsWidget->setModel(ENV.icons().get()); + contentsWidget->setModel(MMC->icons().get()); auto buttonAdd = ui->buttonBox->addButton(tr("Add Icon"), QDialogButtonBox::ResetRole); auto buttonRemove = @@ -102,12 +102,12 @@ void IconPickerDialog::addNewIcon() //: The type of icon files QStringList fileNames = QFileDialog::getOpenFileNames(this, selectIcons, QString(), tr("Icons") + "(*.png *.jpg *.jpeg *.ico)"); - ENV.icons()->installIcons(fileNames); + MMC->icons()->installIcons(fileNames); } void IconPickerDialog::removeSelectedIcon() { - ENV.icons()->deleteIcon(selectedIconKey); + MMC->icons()->deleteIcon(selectedIconKey); } void IconPickerDialog::activated(QModelIndex index) @@ -128,7 +128,7 @@ void IconPickerDialog::selectionChanged(QItemSelection selected, QItemSelection int IconPickerDialog::execWithSelection(QString selection) { - auto list = ENV.icons(); + auto list = MMC->icons(); auto contentsWidget = ui->iconView; selectedIconKey = selection; diff --git a/application/dialogs/NewInstanceDialog.cpp b/application/dialogs/NewInstanceDialog.cpp index a883d1dc..1e12c9ba 100644 --- a/application/dialogs/NewInstanceDialog.cpp +++ b/application/dialogs/NewInstanceDialog.cpp @@ -64,7 +64,7 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, QWidget *pare setSelectedVersion(MMC->minecraftlist()->getRecommended()); InstIconKey = "default"; - ui->iconButton->setIcon(ENV.icons()->getIcon(InstIconKey)); + ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey)); ui->modpackEdit->setValidator(new UrlValidator(ui->modpackEdit)); @@ -211,7 +211,7 @@ void NewInstanceDialog::on_iconButton_clicked() if (dlg.result() == QDialog::Accepted) { InstIconKey = dlg.selectedIconKey; - ui->iconButton->setIcon(ENV.icons()->getIcon(InstIconKey)); + ui->iconButton->setIcon(MMC->icons()->getIcon(InstIconKey)); } } diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp index 6cbc9e92..14e48cff 100644 --- a/application/pages/VersionPage.cpp +++ b/application/pages/VersionPage.cpp @@ -94,7 +94,7 @@ private: QIcon VersionPage::icon() const { - return ENV.icons()->getIcon(m_inst->iconKey()); + return MMC->icons()->getIcon(m_inst->iconKey()); } bool VersionPage::shouldDisplay() const { |