From f93f867c3da084c6d6c5e3ed23896609cff0e692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 5 Oct 2015 01:47:27 +0200 Subject: NOISSUE dissolve util library --- application/CMakeLists.txt | 2 +- application/InstancePageProvider.h | 6 ++-- application/MainWindow.cpp | 39 +++++++++++----------- application/MultiMC.cpp | 45 +++++++++++++------------- application/VersionProxyModel.cpp | 4 +-- application/dialogs/CopyInstanceDialog.cpp | 18 +++++++++++ application/dialogs/CopyInstanceDialog.h | 3 ++ application/dialogs/CopyInstanceDialog.ui | 11 +++++-- application/dialogs/ExportInstanceDialog.cpp | 11 +++---- application/dialogs/VersionSelectDialog.cpp | 1 - application/pages/InstanceSettingsPage.cpp | 4 +-- application/pages/LegacyJarModPage.cpp | 5 ++- application/pages/ModFolderPage.cpp | 5 ++- application/pages/OtherLogsPage.cpp | 10 +++--- application/pages/ScreenshotsPage.cpp | 8 ++--- application/pages/VersionPage.cpp | 1 - application/pages/WorldListPage.cpp | 3 +- application/pages/WorldListPage.h | 1 - application/pages/global/ExternalToolsPage.cpp | 11 +++---- application/pages/global/JavaPage.cpp | 5 ++- application/pages/global/MinecraftPage.cpp | 2 -- application/pages/global/MultiMCPage.cpp | 20 ++++++------ application/pages/global/PasteEEPage.cpp | 2 -- 23 files changed, 116 insertions(+), 101 deletions(-) (limited to 'application') diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index fdb27607..d9c37a45 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -348,7 +348,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 MultiMC_util ${QUAZIP_LIBRARIES} hoedown rainbow) +target_link_libraries(MultiMC MultiMC_logic xz-embedded unpack200 iconfix ${QUAZIP_LIBRARIES} hoedown rainbow) if(APPLE) find_library(OSX_CORE_FOUNDATION CoreFoundation) diff --git a/application/InstancePageProvider.h b/application/InstancePageProvider.h index c3ae17c1..1b283896 100644 --- a/application/InstancePageProvider.h +++ b/application/InstancePageProvider.h @@ -1,6 +1,7 @@ #pragma once #include "minecraft/OneSixInstance.h" #include "minecraft/LegacyInstance.h" +#include #include "pages/BasePage.h" #include "pages/VersionPage.h" #include "pages/ModFolderPage.h" @@ -13,7 +14,6 @@ #include "pages/BasePageProvider.h" #include "pages/LegacyJarModPage.h" #include "pages/WorldListPage.h" -#include class InstancePageProvider : public QObject, public BasePageProvider @@ -41,7 +41,7 @@ public: values.append(new TexturePackPage(onesix.get())); values.append(new NotesPage(onesix.get())); values.append(new WorldListPage(onesix.get(), onesix->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); - values.append(new ScreenshotsPage(PathCombine(onesix->minecraftRoot(), "screenshots"))); + values.append(new ScreenshotsPage(FS::PathCombine(onesix->minecraftRoot(), "screenshots"))); values.append(new InstanceSettingsPage(onesix.get())); } std::shared_ptr legacy = std::dynamic_pointer_cast(inst); @@ -57,7 +57,7 @@ public: values.append(new TexturePackPage(legacy.get())); values.append(new NotesPage(legacy.get())); values.append(new WorldListPage(legacy.get(), legacy->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); - values.append(new ScreenshotsPage(PathCombine(legacy->minecraftRoot(), "screenshots"))); + values.append(new ScreenshotsPage(FS::PathCombine(legacy->minecraftRoot(), "screenshots"))); values.append(new InstanceSettingsPage(legacy.get())); } auto logMatcher = inst->getLogFileMatcher(); diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 1562efc5..71888870 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -331,10 +331,6 @@ namespace Ui { #include -#include "osutils.h" -#include "userutils.h" -#include "pathutils.h" - #include "groupview/GroupView.h" #include "groupview/InstanceDelegate.h" #include "InstanceProxyModel.h" @@ -972,8 +968,8 @@ void MainWindow::downloadUpdates(GoUpdate::Status status) ProgressDialog updateDlg(this); status.rootPath = MMC->rootPath; - auto dlPath = PathCombine(MMC->root(), "update", "XXXXXX"); - if(!ensureFilePathExists(dlPath)) + auto dlPath = FS::PathCombine(MMC->root(), "update", "XXXXXX"); + if(!FS::ensureFilePathExists(dlPath)) { CustomMessageBox::selectable(this, tr("Error"), tr("Couldn't create folder for update downloads:\n%1").arg(dlPath), QMessageBox::Warning)->show(); } @@ -1053,8 +1049,8 @@ InstancePtr MainWindow::instanceFromZipPack(QString instName, QString instGroup, InstancePtr newInstance; QString instancesDir = MMC->settings()->get("InstanceDir").toString(); - QString instDirName = DirNameFromString(instName, instancesDir); - QString instDir = PathCombine(instancesDir, instDirName); + QString instDirName = FS::DirNameFromString(instName, instancesDir); + QString instDir = FS::PathCombine(instancesDir, instDirName); QString archivePath; if (url.isLocalFile()) @@ -1094,7 +1090,7 @@ InstancePtr MainWindow::instanceFromZipPack(QString instName, QString instGroup, CustomMessageBox::selectable(this, tr("Error"), tr("Archive does not contain instance.cfg"))->show(); return nullptr; } - if (!copyPath(instanceCfgFile.absoluteDir().absolutePath(), instDir)) + if (!FS::copyPath(instanceCfgFile.absoluteDir().absolutePath(), instDir)) { CustomMessageBox::selectable(this, tr("Error"), tr("Unable to copy instance"))->show(); return nullptr; @@ -1124,7 +1120,7 @@ InstancePtr MainWindow::instanceFromZipPack(QString instName, QString instGroup, else { instIcon = newInstance->iconKey(); - auto importIconPath = PathCombine(newInstance->instanceRoot(), instIcon + ".png"); + auto importIconPath = FS::PathCombine(newInstance->instanceRoot(), instIcon + ".png"); if (QFile::exists(importIconPath)) { // import icon @@ -1153,8 +1149,8 @@ InstancePtr MainWindow::instanceFromVersion(QString instName, QString instGroup, InstancePtr newInstance; QString instancesDir = MMC->settings()->get("InstanceDir").toString(); - QString instDirName = DirNameFromString(instName, instancesDir); - QString instDir = PathCombine(instancesDir, instDirName); + QString instDirName = FS::DirNameFromString(instName, instancesDir); + QString instDir = FS::PathCombine(instancesDir, instDirName); auto error = MMC->instances()->createInstance(newInstance, version, instDir); QString errorMsg = tr("Failed to create instance %1: ").arg(instDirName); switch (error) @@ -1257,11 +1253,12 @@ void MainWindow::on_actionCopyInstance_triggered() return; QString instancesDir = MMC->settings()->get("InstanceDir").toString(); - QString instDirName = DirNameFromString(copyInstDlg.instName(), instancesDir); - QString instDir = PathCombine(instancesDir, instDirName); + QString instDirName = FS::DirNameFromString(copyInstDlg.instName(), instancesDir); + QString instDir = FS::PathCombine(instancesDir, instDirName); + bool copySaves = copyInstDlg.shouldCopySaves(); InstancePtr newInstance; - auto error = MMC->instances()->copyInstance(newInstance, m_selectedInstance, instDir); + auto error = MMC->instances()->copyInstance(newInstance, m_selectedInstance, instDir, copySaves); QString errorMsg = tr("Failed to create instance %1: ").arg(instDirName); switch (error) @@ -1359,7 +1356,7 @@ void MainWindow::on_actionChangeInstGroup_triggered() void MainWindow::on_actionViewInstanceFolder_triggered() { QString str = MMC->settings()->get("InstanceDir").toString(); - openDirInDefaultProgram(str); + FS::openDirInDefaultProgram(str); } void MainWindow::on_actionRefresh_triggered() @@ -1369,7 +1366,7 @@ void MainWindow::on_actionRefresh_triggered() void MainWindow::on_actionViewCentralModsFolder_triggered() { - openDirInDefaultProgram(MMC->settings()->get("CentralModsDir").toString(), true); + FS::openDirInDefaultProgram(MMC->settings()->get("CentralModsDir").toString(), true); } void MainWindow::on_actionConfig_Folder_triggered() @@ -1377,7 +1374,7 @@ void MainWindow::on_actionConfig_Folder_triggered() if (m_selectedInstance) { QString str = m_selectedInstance->instanceConfigFolder(); - openDirInDefaultProgram(QDir(str).absolutePath()); + FS::openDirInDefaultProgram(QDir(str).absolutePath()); } } @@ -1509,7 +1506,7 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered() if (m_selectedInstance) { QString str = m_selectedInstance->instanceRoot(); - openDirInDefaultProgram(QDir(str).absolutePath()); + FS::openDirInDefaultProgram(QDir(str).absolutePath()); } } @@ -1677,7 +1674,7 @@ void MainWindow::checkSetDefaultJava() break; } QString currentJavaPath = MMC->settings()->get("JavaPath").toString(); - QString actualPath = ResolveExecutable(currentJavaPath); + QString actualPath = FS::ResolveExecutable(currentJavaPath); if (currentJavaPath.isNull()) { askForJava = true; @@ -1738,7 +1735,7 @@ void MainWindow::checkSetDefaultJava() void MainWindow::checkInstancePathForProblems() { QString instanceFolder = MMC->settings()->get("InstanceDir").toString(); - if (checkProblemticPathJava(QDir(instanceFolder))) + if (FS::checkProblemticPathJava(QDir(instanceFolder))) { QMessageBox warning(this); warning.setText(tr( diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 612ba342..5584de1f 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -41,8 +41,6 @@ #include "tools/JVisualVM.h" #include "tools/MCEditTool.h" -#include "pathutils.h" -#include "cmdutils.h" #include #include "settings/INISettingsObject.h" #include "settings/Setting.h" @@ -54,7 +52,10 @@ #include "ftb/FTBPlugin.h" -using namespace Util::Commandline; +#include +#include + +using namespace Commandline; MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, argv) { @@ -142,7 +143,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar launchId = args["launch"].toString(); - if (!ensureFolderPathExists(dataPath) || !QDir::setCurrent(dataPath)) + if (!FS::ensureFolderPathExists(dataPath) || !QDir::setCurrent(dataPath)) { // BAD STUFF. WHAT DO? initLogger(); @@ -159,7 +160,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar else { #ifdef Q_OS_LINUX - QDir foo(PathCombine(binPath, "..")); + QDir foo(FS::PathCombine(binPath, "..")); rootPath = foo.absolutePath(); #elif defined(Q_OS_WIN32) rootPath = binPath; @@ -171,12 +172,12 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar // static data paths... mostly just for translations #ifdef Q_OS_LINUX - QDir foo(PathCombine(binPath, "..")); + QDir foo(FS::PathCombine(binPath, "..")); staticDataPath = foo.absolutePath(); #elif defined(Q_OS_WIN32) staticDataPath = binPath; #elif defined(Q_OS_MAC) - QDir foo(PathCombine(rootPath, "Contents/Resources")); + QDir foo(FS::PathCombine(rootPath, "Contents/Resources")); staticDataPath = foo.absolutePath(); #endif @@ -220,7 +221,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool test_mode) : QApplication(argc, ar // and rememer that we have to show him a dialog when the gui starts (if it does so) QString instDir = m_settings->get("InstanceDir").toString(); qDebug() << "Instance path : " << instDir; - if (checkProblemticPathJava(QDir(instDir))) + if (FS::checkProblemticPathJava(QDir(instDir))) { qWarning() << "Your instance path contains \'!\' and this is known to cause java problems"; @@ -671,26 +672,26 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi bool started = false; qDebug() << "Installing updates."; -#ifdef WINDOWS +#ifdef Q_OS_WIN QString finishCmd = applicationFilePath(); -#elif LINUX - QString finishCmd = PathCombine(root(), "MultiMC"); -#elif OSX +#elif defined Q_OS_LINUX + QString finishCmd = FS::PathCombine(root(), "MultiMC"); +#elif defined Q_OS_MAC QString finishCmd = applicationFilePath(); #else #error Unsupported operating system. #endif - QString backupPath = PathCombine(root(), "update", "backup"); + QString backupPath = FS::PathCombine(root(), "update", "backup"); QDir origin(root()); // clean up the backup folder. it should be empty before we start - if(!deletePath(backupPath)) + if(!FS::deletePath(backupPath)) { qWarning() << "couldn't remove previous backup folder" << backupPath; } // and it should exist. - if(!ensureFolderPathExists(backupPath)) + if(!FS::ensureFolderPathExists(backupPath)) { qWarning() << "couldn't create folder" << backupPath; return; @@ -726,7 +727,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi // replace = move original out to backup, if it exists, move the new file in its place case GoUpdate::Operation::OP_REPLACE: { - QFileInfo replaced (PathCombine(root(), op.dest)); + QFileInfo replaced (FS::PathCombine(root(), op.dest)); #ifdef Q_OS_WIN32 if(QSysInfo::windowsVersion() < QSysInfo::WV_VISTA) { @@ -735,7 +736,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi QDir rootDir(root()); exeOrigin = rootDir.relativeFilePath(op.file); exePath = rootDir.relativeFilePath(op.dest); - exeBackup = rootDir.relativeFilePath(PathCombine(backupPath, replaced.fileName())); + exeBackup = rootDir.relativeFilePath(FS::PathCombine(backupPath, replaced.fileName())); useXPHack = true; continue; } @@ -745,7 +746,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi { QString backupName = op.dest; backupName.replace('/', '_'); - QString backupFilePath = PathCombine(backupPath, backupName); + QString backupFilePath = FS::PathCombine(backupPath, backupName); if(!QFile::rename(replaced.absoluteFilePath(), backupFilePath)) { qWarning() << "Couldn't move:" << replaced.absoluteFilePath() << "to" << backupFilePath; @@ -759,7 +760,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi backups.append(be); } // make sure the folder we are putting this into exists - if(!ensureFilePathExists(replaced.absoluteFilePath())) + if(!FS::ensureFilePathExists(replaced.absoluteFilePath())) { qWarning() << "REPLACE: Couldn't create folder:" << replaced.absoluteFilePath(); failedOperationType = Replace; @@ -780,12 +781,12 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi // delete = move original to backup case GoUpdate::Operation::OP_DELETE: { - QString origFilePath = PathCombine(root(), op.file); + QString origFilePath = FS::PathCombine(root(), op.file); if(QFile::exists(origFilePath)) { QString backupName = op.file; backupName.replace('/', '_'); - QString trashFilePath = PathCombine(backupPath, backupName); + QString trashFilePath = FS::PathCombine(backupPath, backupName); if(!QFile::rename(origFilePath, trashFilePath)) { @@ -825,7 +826,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, GoUpdate::OperationLi out << "fso.MoveFile \"" << nativeOriginPath << "\", \"" << nativePath << "\"\n"; out << "shell.Run \"" << nativePath << "\"\n"; - QString scriptPath = PathCombine(root(), "update", "update.vbs"); + QString scriptPath = FS::PathCombine(root(), "update", "update.vbs"); // we save it QFile scriptFile(scriptPath); diff --git a/application/VersionProxyModel.cpp b/application/VersionProxyModel.cpp index 4db5cbd0..70894592 100644 --- a/application/VersionProxyModel.cpp +++ b/application/VersionProxyModel.cpp @@ -2,7 +2,7 @@ #include "MultiMC.h" #include #include -#include +#include class VersionFilterModel : public QSortFilterProxyModel { @@ -35,7 +35,7 @@ public: return false; } } - else if (!Util::versionIsInInterval(versionString, it.value().string)) + else if (!versionIsInInterval(versionString, it.value().string)) { return false; } diff --git a/application/dialogs/CopyInstanceDialog.cpp b/application/dialogs/CopyInstanceDialog.cpp index 54c42f29..67e2e8e1 100644 --- a/application/dialogs/CopyInstanceDialog.cpp +++ b/application/dialogs/CopyInstanceDialog.cpp @@ -52,6 +52,7 @@ CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent) } ui->groupBox->setCurrentIndex(index); ui->groupBox->lineEdit()->setPlaceholderText(tr("No group")); + ui->copySavesCheckbox->setChecked(m_copySaves); } CopyInstanceDialog::~CopyInstanceDialog() @@ -95,3 +96,20 @@ void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1) { updateDialogState(); } + +bool CopyInstanceDialog::shouldCopySaves() const +{ + return m_copySaves; +} + +void CopyInstanceDialog::on_copySavesCheckbox_stateChanged(int state) +{ + if(state == Qt::Unchecked) + { + m_copySaves = false; + } + else if(state == Qt::Checked) + { + m_copySaves = true; + } +} diff --git a/application/dialogs/CopyInstanceDialog.h b/application/dialogs/CopyInstanceDialog.h index faa20615..a519443f 100644 --- a/application/dialogs/CopyInstanceDialog.h +++ b/application/dialogs/CopyInstanceDialog.h @@ -39,14 +39,17 @@ public: QString instName() const; QString instGroup() const; QString iconKey() const; + bool shouldCopySaves() const; private slots: void on_iconButton_clicked(); void on_instNameTextBox_textChanged(const QString &arg1); + void on_copySavesCheckbox_stateChanged(int state); private: Ui::CopyInstanceDialog *ui; QString InstIconKey; InstancePtr m_original; + bool m_copySaves = true; }; diff --git a/application/dialogs/CopyInstanceDialog.ui b/application/dialogs/CopyInstanceDialog.ui index 2615168c..bbb1bbb3 100644 --- a/application/dialogs/CopyInstanceDialog.ui +++ b/application/dialogs/CopyInstanceDialog.ui @@ -10,7 +10,7 @@ 0 0 345 - 205 + 240 @@ -87,7 +87,7 @@ - Group + &Group groupBox @@ -109,6 +109,13 @@ + + + + Copy saves + + + diff --git a/application/dialogs/ExportInstanceDialog.cpp b/application/dialogs/ExportInstanceDialog.cpp index ec46b6ba..8d320a3c 100644 --- a/application/dialogs/ExportInstanceDialog.cpp +++ b/application/dialogs/ExportInstanceDialog.cpp @@ -17,7 +17,6 @@ #include "ui_ExportInstanceDialog.h" #include #include -#include #include #include #include @@ -185,7 +184,7 @@ public: blocked.remove(cover); // block all contents, except for any cover QModelIndex rootIndex = - fsm->index(PathCombine(m_instance->instanceRoot(), cover)); + fsm->index(FS::PathCombine(m_instance->instanceRoot(), cover)); QModelIndex doing = rootIndex; int row = 0; QStack todo; @@ -376,18 +375,18 @@ void SaveIcon(InstancePtr m_instance) } } auto pixmap = icon.pixmap(largest); - pixmap.save(PathCombine(m_instance->instanceRoot(), iconKey + ".png")); + pixmap.save(FS::PathCombine(m_instance->instanceRoot(), iconKey + ".png")); } } } bool ExportInstanceDialog::doExport() { - auto name = RemoveInvalidFilenameChars(m_instance->name()); + auto name = FS::RemoveInvalidFilenameChars(m_instance->name()); const QString output = QFileDialog::getSaveFileName( this, tr("Export %1").arg(m_instance->name()), - PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)"); + FS::PathCombine(QDir::homePath(), name + ".zip"), "Zip (*.zip)"); if (output.isNull()) { return false; @@ -452,7 +451,7 @@ void ExportInstanceDialog::rowsInserted(QModelIndex parent, int top, int bottom) QString ExportInstanceDialog::ignoreFileName() { - return PathCombine(m_instance->instanceRoot(), ".packignore"); + return FS::PathCombine(m_instance->instanceRoot(), ".packignore"); } void ExportInstanceDialog::loadPackIgnore() diff --git a/application/dialogs/VersionSelectDialog.cpp b/application/dialogs/VersionSelectDialog.cpp index df72189b..50b543db 100644 --- a/application/dialogs/VersionSelectDialog.cpp +++ b/application/dialogs/VersionSelectDialog.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include "MultiMC.h" #include diff --git a/application/pages/InstanceSettingsPage.cpp b/application/pages/InstanceSettingsPage.cpp index 35cbefe5..a23d7c22 100644 --- a/application/pages/InstanceSettingsPage.cpp +++ b/application/pages/InstanceSettingsPage.cpp @@ -10,7 +10,7 @@ #include "MultiMC.h" #include -#include +#include InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent) : QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst) @@ -186,7 +186,7 @@ void InstanceSettingsPage::on_javaDetectBtn_clicked() void InstanceSettingsPage::on_javaBrowseBtn_clicked() { QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable")); - QString cooked_path = NormalizePath(raw_path); + QString cooked_path = FS::NormalizePath(raw_path); // do not allow current dir - it's dirty. Do not allow dirs that don't exist if(cooked_path.isEmpty()) diff --git a/application/pages/LegacyJarModPage.cpp b/application/pages/LegacyJarModPage.cpp index 87a9f3b5..5d397978 100644 --- a/application/pages/LegacyJarModPage.cpp +++ b/application/pages/LegacyJarModPage.cpp @@ -19,14 +19,13 @@ #include #include -#include - #include "dialogs/VersionSelectDialog.h" #include "dialogs/ProgressDialog.h" #include "dialogs/ModEditDialogCommon.h" #include "minecraft/ModList.h" #include "minecraft/LegacyInstance.h" #include "Env.h" +#include #include "MultiMC.h" #include @@ -147,7 +146,7 @@ void LegacyJarModPage::on_rmJarBtn_clicked() void LegacyJarModPage::on_viewJarBtn_clicked() { - openDirInDefaultProgram(m_inst->jarModsDir(), true); + FS::openDirInDefaultProgram(m_inst->jarModsDir(), true); } void LegacyJarModPage::jarCurrent(QModelIndex current, QModelIndex previous) diff --git a/application/pages/ModFolderPage.cpp b/application/pages/ModFolderPage.cpp index 9a2a43a4..e3ece5a6 100644 --- a/application/pages/ModFolderPage.cpp +++ b/application/pages/ModFolderPage.cpp @@ -22,8 +22,6 @@ #include #include -#include - #include "MultiMC.h" #include "dialogs/CustomMessageBox.h" #include "dialogs/ModEditDialogCommon.h" @@ -31,6 +29,7 @@ #include "minecraft/ModList.h" #include "minecraft/Mod.h" #include "minecraft/VersionFilterData.h" +#include ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr mods, QString id, QString iconName, QString displayName, QString helpPage, @@ -163,7 +162,7 @@ void ModFolderPage::on_rmModBtn_clicked() void ModFolderPage::on_viewModBtn_clicked() { - openDirInDefaultProgram(m_mods->dir().absolutePath(), true); + FS::openDirInDefaultProgram(m_mods->dir().absolutePath(), true); } void ModFolderPage::modCurrent(const QModelIndex ¤t, const QModelIndex &previous) diff --git a/application/pages/OtherLogsPage.cpp b/application/pages/OtherLogsPage.cpp index f1b59f1e..799f4f39 100644 --- a/application/pages/OtherLogsPage.cpp +++ b/application/pages/OtherLogsPage.cpp @@ -21,7 +21,7 @@ #include "GuiUtil.h" #include "RecursiveFileSystemWatcher.h" #include -#include +#include OtherLogsPage::OtherLogsPage(QString path, IPathMatcher::Ptr fileFilter, QWidget *parent) : QWidget(parent), ui(new Ui::OtherLogsPage), m_path(path), m_fileFilter(fileFilter), @@ -83,7 +83,7 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index) file = ui->selectLogBox->itemText(index); } - if (file.isEmpty() || !QFile::exists(PathCombine(m_path, file))) + if (file.isEmpty() || !QFile::exists(FS::PathCombine(m_path, file))) { m_currentFile = QString(); ui->text->clear(); @@ -104,7 +104,7 @@ void OtherLogsPage::on_btnReload_clicked() setControlsEnabled(false); return; } - QFile file(PathCombine(m_path, m_currentFile)); + QFile file(FS::PathCombine(m_path, m_currentFile)); if (!file.open(QFile::ReadOnly)) { setControlsEnabled(false); @@ -174,7 +174,7 @@ void OtherLogsPage::on_btnDelete_clicked() { return; } - QFile file(PathCombine(m_path, m_currentFile)); + QFile file(FS::PathCombine(m_path, m_currentFile)); if (!file.remove()) { QMessageBox::critical(this, tr("Error"), tr("Unable to delete %1: %2") @@ -215,7 +215,7 @@ void OtherLogsPage::on_btnClean_clicked() QStringList failed; for(auto item: toDelete) { - QFile file(PathCombine(m_path, item)); + QFile file(FS::PathCombine(m_path, item)); if (!file.remove()) { failed.push_back(item); diff --git a/application/pages/ScreenshotsPage.cpp b/application/pages/ScreenshotsPage.cpp index 2a8d7a43..5f5d11f7 100644 --- a/application/pages/ScreenshotsPage.cpp +++ b/application/pages/ScreenshotsPage.cpp @@ -15,7 +15,6 @@ #include #include -#include #include #include "dialogs/ProgressDialog.h" @@ -26,6 +25,7 @@ #include "tasks/SequentialTask.h" #include "RWStorage.h" +#include typedef RWStorage SharedIconCache; typedef std::shared_ptr SharedIconCachePtr; @@ -219,7 +219,7 @@ ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent) m_model->setNameFilters({"*.png"}); m_model->setNameFilterDisables(false); m_folder = path; - m_valid = ensureFolderPathExists(m_folder); + m_valid = FS::ensureFolderPathExists(m_folder); ui->setupUi(this); ui->tabWidget->tabBar()->hide(); @@ -271,12 +271,12 @@ void ScreenshotsPage::onItemActivated(QModelIndex index) return; auto info = m_model->fileInfo(index); QString fileName = info.absoluteFilePath(); - openFileInDefaultProgram(info.absoluteFilePath()); + FS::openFileInDefaultProgram(info.absoluteFilePath()); } void ScreenshotsPage::on_viewFolderBtn_clicked() { - openDirInDefaultProgram(m_folder, true); + FS::openDirInDefaultProgram(m_folder, true); } void ScreenshotsPage::on_uploadBtn_clicked() diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp index e6933da7..e1abcf0c 100644 --- a/application/pages/VersionPage.cpp +++ b/application/pages/VersionPage.cpp @@ -15,7 +15,6 @@ #include "MultiMC.h" -#include #include #include #include diff --git a/application/pages/WorldListPage.cpp b/application/pages/WorldListPage.cpp index 6bea9dbd..4e7eeedc 100644 --- a/application/pages/WorldListPage.cpp +++ b/application/pages/WorldListPage.cpp @@ -16,6 +16,7 @@ #include "WorldListPage.h" #include "ui_WorldListPage.h" #include "minecraft/WorldList.h" +#include #include "dialogs/ModEditDialogCommon.h" #include #include @@ -122,7 +123,7 @@ void WorldListPage::on_rmWorldBtn_clicked() void WorldListPage::on_viewFolderBtn_clicked() { - openDirInDefaultProgram(m_worlds->dir().absolutePath(), true); + FS::openDirInDefaultProgram(m_worlds->dir().absolutePath(), true); } QModelIndex WorldListPage::getSelectedWorld() diff --git a/application/pages/WorldListPage.h b/application/pages/WorldListPage.h index 1ef441a6..7a7cf591 100644 --- a/application/pages/WorldListPage.h +++ b/application/pages/WorldListPage.h @@ -20,7 +20,6 @@ #include "minecraft/OneSixInstance.h" #include "BasePage.h" #include -#include class WorldList; namespace Ui diff --git a/application/pages/global/ExternalToolsPage.cpp b/application/pages/global/ExternalToolsPage.cpp index 26b2f31e..e8091dee 100644 --- a/application/pages/global/ExternalToolsPage.cpp +++ b/application/pages/global/ExternalToolsPage.cpp @@ -20,10 +20,9 @@ #include #include -#include - #include "settings/SettingsObject.h" #include "tools/BaseProfiler.h" +#include #include "MultiMC.h" ExternalToolsPage::ExternalToolsPage(QWidget *parent) : @@ -91,7 +90,7 @@ void ExternalToolsPage::on_jprofilerPathBtn_clicked() { break; } - QString cooked_dir = NormalizePath(raw_dir); + QString cooked_dir = FS::NormalizePath(raw_dir); if (!MMC->profilers()["jprofiler"]->check(cooked_dir, &error)) { QMessageBox::critical(this, tr("Error"), @@ -130,7 +129,7 @@ void ExternalToolsPage::on_jvisualvmPathBtn_clicked() { break; } - QString cooked_dir = NormalizePath(raw_dir); + QString cooked_dir = FS::NormalizePath(raw_dir); if (!MMC->profilers()["jvisualvm"]->check(cooked_dir, &error)) { QMessageBox::critical(this, tr("Error"), @@ -174,7 +173,7 @@ void ExternalToolsPage::on_mceditPathBtn_clicked() { break; } - QString cooked_dir = NormalizePath(raw_dir); + QString cooked_dir = FS::NormalizePath(raw_dir); if (!MMC->tools()["mcedit"]->check(cooked_dir, &error)) { QMessageBox::critical(this, tr("Error"), @@ -213,7 +212,7 @@ void ExternalToolsPage::on_jsonEditorBrowseBtn_clicked() ? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first() #endif : ui->jsonEditorTextBox->text()); - QString cooked_file = NormalizePath(raw_file); + QString cooked_file = FS::NormalizePath(raw_file); if (cooked_file.isEmpty()) { diff --git a/application/pages/global/JavaPage.cpp b/application/pages/global/JavaPage.cpp index 18882ad9..1c33a9ff 100644 --- a/application/pages/global/JavaPage.cpp +++ b/application/pages/global/JavaPage.cpp @@ -21,8 +21,6 @@ #include #include -#include - #include "dialogs/VersionSelectDialog.h" #include @@ -30,6 +28,7 @@ #include "java/JavaVersionList.h" #include "settings/SettingsObject.h" +#include #include "MultiMC.h" JavaPage::JavaPage(QWidget *parent) : QWidget(parent), ui(new Ui::JavaPage) @@ -109,7 +108,7 @@ void JavaPage::on_javaDetectBtn_clicked() void JavaPage::on_javaBrowseBtn_clicked() { QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable")); - QString cooked_path = NormalizePath(raw_path); + QString cooked_path = FS::NormalizePath(raw_path); // do not allow current dir - it's dirty. Do not allow dirs that don't exist if(cooked_path.isEmpty()) diff --git a/application/pages/global/MinecraftPage.cpp b/application/pages/global/MinecraftPage.cpp index 3e05924e..3f1e4388 100644 --- a/application/pages/global/MinecraftPage.cpp +++ b/application/pages/global/MinecraftPage.cpp @@ -19,8 +19,6 @@ #include #include -#include - #include "settings/SettingsObject.h" #include "MultiMC.h" diff --git a/application/pages/global/MultiMCPage.cpp b/application/pages/global/MultiMCPage.cpp index 6a8730c7..5b7a1204 100644 --- a/application/pages/global/MultiMCPage.cpp +++ b/application/pages/global/MultiMCPage.cpp @@ -21,11 +21,11 @@ #include #include -#include #include #include "updater/UpdateChecker.h" #include "settings/SettingsObject.h" +#include #include "MultiMC.h" // FIXME: possibly move elsewhere @@ -85,7 +85,7 @@ void MultiMCPage::on_ftbLauncherBrowseBtn_clicked() { QString raw_dir = QFileDialog::getExistingDirectory(this, tr("FTB Launcher Directory"), ui->ftbLauncherBox->text()); - QString cooked_dir = NormalizePath(raw_dir); + QString cooked_dir = FS::NormalizePath(raw_dir); // do not allow current dir - it's dirty. Do not allow dirs that don't exist if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) @@ -97,7 +97,7 @@ void MultiMCPage::on_ftbBrowseBtn_clicked() { QString raw_dir = QFileDialog::getExistingDirectory(this, tr("FTB Directory"), ui->ftbBox->text()); - QString cooked_dir = NormalizePath(raw_dir); + QString cooked_dir = FS::NormalizePath(raw_dir); // do not allow current dir - it's dirty. Do not allow dirs that don't exist if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) @@ -110,12 +110,12 @@ void MultiMCPage::on_instDirBrowseBtn_clicked() { QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Directory"), ui->instDirTextBox->text()); - QString cooked_dir = NormalizePath(raw_dir); + QString cooked_dir = FS::NormalizePath(raw_dir); // do not allow current dir - it's dirty. Do not allow dirs that don't exist if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) { - if (checkProblemticPathJava(QDir(cooked_dir))) + if (FS::checkProblemticPathJava(QDir(cooked_dir))) { QMessageBox warning; warning.setText(tr("You're trying to specify an instance folder which\'s path " @@ -143,7 +143,7 @@ void MultiMCPage::on_iconsDirBrowseBtn_clicked() { QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Directory"), ui->iconsDirTextBox->text()); - QString cooked_dir = NormalizePath(raw_dir); + QString cooked_dir = FS::NormalizePath(raw_dir); // do not allow current dir - it's dirty. Do not allow dirs that don't exist if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) @@ -155,7 +155,7 @@ void MultiMCPage::on_modsDirBrowseBtn_clicked() { QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Directory"), ui->modsDirTextBox->text()); - QString cooked_dir = NormalizePath(raw_dir); + QString cooked_dir = FS::NormalizePath(raw_dir); // do not allow current dir - it's dirty. Do not allow dirs that don't exist if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) @@ -167,7 +167,7 @@ void MultiMCPage::on_lwjglDirBrowseBtn_clicked() { QString raw_dir = QFileDialog::getExistingDirectory(this, tr("LWJGL Directory"), ui->lwjglDirTextBox->text()); - QString cooked_dir = NormalizePath(raw_dir); + QString cooked_dir = FS::NormalizePath(raw_dir); // do not allow current dir - it's dirty. Do not allow dirs that don't exist if (!cooked_dir.isEmpty() && QDir(cooked_dir).exists()) @@ -308,8 +308,8 @@ void MultiMCPage::applySettings() // FTB s->set("TrackFTBInstances", ui->trackFtbBox->isChecked()); - s->set("FTBLauncherLocal", NormalizePath(ui->ftbLauncherBox->text())); - s->set("FTBRoot", NormalizePath(ui->ftbBox->text())); + s->set("FTBLauncherLocal", FS::NormalizePath(ui->ftbLauncherBox->text())); + s->set("FTBRoot", FS::NormalizePath(ui->ftbBox->text())); // Folders // TODO: Offer to move instances to new instance folder. diff --git a/application/pages/global/PasteEEPage.cpp b/application/pages/global/PasteEEPage.cpp index e6827601..15ceafe0 100644 --- a/application/pages/global/PasteEEPage.cpp +++ b/application/pages/global/PasteEEPage.cpp @@ -20,8 +20,6 @@ #include #include -#include - #include "settings/SettingsObject.h" #include "tools/BaseProfiler.h" #include "MultiMC.h" -- cgit v1.2.3