NOISSUE split GUI stuff from logic library
This commit is contained in:
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
Reference in New Issue
Block a user