diff --git a/BUILD.md b/BUILD.md index a2a8502b..f70e9dc0 100644 --- a/BUILD.md +++ b/BUILD.md @@ -75,7 +75,7 @@ You can use IDEs like KDevelop or QtCreator to open the CMake project if you wan ### Loading the project in Qt Creator (optional) 1. Open Qt Creator. 2. Choose `File->Open File or Project`. -3. Navigate to the MultiMC5 source folder you cloned and choose CMakeLists.txt. +3. Navigate to the Launcher source folder you cloned and choose CMakeLists.txt. 4. Read the instructions that just popped up about a build location and choose one. 5. You should see "Run CMake" in the window. - Make sure that Generator is set to "Unix Generator (Desktop Qt 5.6.x GCC 64bit)". @@ -83,7 +83,7 @@ You can use IDEs like KDevelop or QtCreator to open the CMake project if you wan - You'll see warnings and it might not be clear that it succeeded until you scroll to the bottom of the window. - Hit "Finish" if CMake ran successfully. 6. Cross your fingers and press the Run button (bottom left of Qt Creator). - - If the project builds successfully it will run and the MultiMC5 window will pop up. + - If the project builds successfully it will run and the Launcher window will pop up. # Windows @@ -130,7 +130,7 @@ Ensure that OpenSSL, zlib, Java and CMake are on `PATH`. ### Loading the project 1. Open Qt Creator, 2. Choose File->Open File or Project, -3. Navigate to the MultiMC5 source folder you cloned and choose CMakeLists.txt, +3. Navigate to the Launcher source folder you cloned and choose CMakeLists.txt, 4. Read the instructions that just popped up about a build location and choose one, 5. If you chose not to add CMake to the system PATH, tell Qt Creator where you installed it, - Otherwise you can skip this step. @@ -140,7 +140,7 @@ Ensure that OpenSSL, zlib, Java and CMake are on `PATH`. - You'll see warnings and it might not be clear that it succeeded until you scroll to the bottom of the window. - Hit "Finish" if CMake ran successfully. 7. Cross your fingers and press the Run button (bottom left of Qt Creator)! - - If the project builds successfully it will run and the MultiMC5 window will pop up, + - If the project builds successfully it will run and the Launcher window will pop up, - Test OpenSSL by making an instance and trying to log in. If Qt Creator couldn't find OpenSSL during the CMake stage, login will fail and you'll get an error. The following .dlls are needed for the app to run (copy them to build directory if you want to be able to move the build to another pc): diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 5c45273b..d67dcdbf 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -84,6 +84,10 @@ set(CORE_SOURCES # A Recursive file system watcher RecursiveFileSystemWatcher.h RecursiveFileSystemWatcher.cpp + + # Time + MMCTime.h + MMCTime.cpp ) add_unit_test(FileSystem diff --git a/launcher/Launcher.cpp b/launcher/Launcher.cpp index ea3fd800..262bbe3d 100644 --- a/launcher/Launcher.cpp +++ b/launcher/Launcher.cpp @@ -646,6 +646,7 @@ Launcher::Launcher(int &argc, char **argv) : QApplication(argc, argv) // Game time m_settings->registerSetting("ShowGameTime", true); + m_settings->registerSetting("ShowGlobalGameTime", true); m_settings->registerSetting("RecordGameTime", true); // Minecraft launch method diff --git a/launcher/MMCTime.cpp b/launcher/MMCTime.cpp new file mode 100644 index 00000000..fa26e0b9 --- /dev/null +++ b/launcher/MMCTime.cpp @@ -0,0 +1,21 @@ +#include + +#include + +QString Time::prettifyDuration(int64_t duration) { + int seconds = (int) (duration % 60); + duration /= 60; + int minutes = (int) (duration % 60); + duration /= 60; + int hours = (int) (duration % 24); + int days = (int) (duration / 24); + if((hours == 0)&&(days == 0)) + { + return QObject::tr("%1m %2s").arg(minutes).arg(seconds); + } + if (days == 0) + { + return QObject::tr("%1h %2m").arg(hours).arg(minutes); + } + return QObject::tr("%1d %2h %3m").arg(days).arg(hours).arg(minutes); +} diff --git a/launcher/MMCTime.h b/launcher/MMCTime.h new file mode 100644 index 00000000..728a5abb --- /dev/null +++ b/launcher/MMCTime.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +namespace Time { + +QString prettifyDuration(int64_t duration); + +} diff --git a/launcher/MainWindow.cpp b/launcher/MainWindow.cpp index c3cc6b8d..0c414285 100644 --- a/launcher/MainWindow.cpp +++ b/launcher/MainWindow.cpp @@ -88,6 +88,7 @@ #include "UpdateController.h" #include "KonamiCode.h" #include +#include "MMCTime.h" namespace { QString profileInUseFilter(const QString & profile, bool used) @@ -747,7 +748,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow connect(LAUNCHER, &Launcher::globalSettingsClosed, this, &MainWindow::globalSettingsClosed); m_statusLeft = new QLabel(tr("No instance selected"), this); - m_statusCenter = new QLabel(tr("Total playtime: 0s."), this); + m_statusCenter = new QLabel(tr("Total playtime: 0s"), this); statusBar()->addPermanentWidget(m_statusLeft, 1); statusBar()->addPermanentWidget(m_statusCenter, 0); @@ -1609,6 +1610,7 @@ void MainWindow::globalSettingsClosed() proxymodel->invalidate(); proxymodel->sort(0); updateToolsMenu(); + updateStatusCenter(); update(); } @@ -1926,15 +1928,10 @@ void MainWindow::checkInstancePathForProblems() void MainWindow::updateStatusCenter() { - int timeplayed = LAUNCHER->instances()->getTotalPlayTime(); - int minutesTotal = timeplayed / 60; - int seconds = timeplayed % 60; - int minutes = minutesTotal % 60; - int hours = minutesTotal / 60; - if(hours != 0) - m_statusCenter->setText(tr("Total playtime: %1h %2m %3s").arg(hours).arg(minutes).arg(seconds)); - else if(minutes != 0) - m_statusCenter->setText(tr("Total playtime: %1m %2s").arg(minutes).arg(seconds)); - else if(seconds != 0) - m_statusCenter->setText(tr("Total playtime: %1s").arg(seconds)); + m_statusCenter->setVisible(LAUNCHER->settings()->get("ShowGlobalGameTime").toBool()); + + int timePlayed = LAUNCHER->instances()->getTotalPlayTime(); + if (timePlayed > 0) { + m_statusCenter->setText(tr("Total playtime: %1").arg(Time::prettifyDuration(timePlayed))); + } } diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index ffa6b821..734d64bc 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "MMCTime.h" #include "launch/LaunchTask.h" #include "launch/steps/LookupServerAddress.h" @@ -769,25 +770,6 @@ QString MinecraftInstance::getLogFileRoot() return gameRoot(); } -QString MinecraftInstance::prettifyTimeDuration(int64_t duration) -{ - int seconds = (int) (duration % 60); - duration /= 60; - int minutes = (int) (duration % 60); - duration /= 60; - int hours = (int) (duration % 24); - int days = (int) (duration / 24); - if((hours == 0)&&(days == 0)) - { - return tr("%1m %2s").arg(minutes).arg(seconds); - } - if (days == 0) - { - return tr("%1h %2m").arg(hours).arg(minutes); - } - return tr("%1d %2h %3m").arg(days).arg(hours).arg(minutes); -} - QString MinecraftInstance::getStatusbarDescription() { QStringList traits; @@ -801,11 +783,11 @@ QString MinecraftInstance::getStatusbarDescription() if(m_settings->get("ShowGameTime").toBool()) { if (lastTimePlayed() > 0) { - description.append(tr(", last played for %1").arg(prettifyTimeDuration(lastTimePlayed()))); + description.append(tr(", last played for %1").arg(Time::prettifyDuration(lastTimePlayed()))); } if (totalTimePlayed() > 0) { - description.append(tr(", total played for %1").arg(prettifyTimeDuration(totalTimePlayed()))); + description.append(tr(", total played for %1").arg(Time::prettifyDuration(totalTimePlayed()))); } } if(hasCrashed()) diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h index 4f6c0489..96e99c34 100644 --- a/launcher/minecraft/MinecraftInstance.h +++ b/launcher/minecraft/MinecraftInstance.h @@ -119,9 +119,6 @@ protected: QStringList validLaunchMethods(); QString launchMethod(); -private: - QString prettifyTimeDuration(int64_t duration); - protected: // data std::shared_ptr m_components; mutable std::shared_ptr m_loader_mod_list; diff --git a/launcher/minecraft/OneSixVersionFormat.cpp b/launcher/minecraft/OneSixVersionFormat.cpp index 2572c39e..0329d70e 100644 --- a/launcher/minecraft/OneSixVersionFormat.cpp +++ b/launcher/minecraft/OneSixVersionFormat.cpp @@ -16,11 +16,11 @@ static void readString(const QJsonObject &root, const QString &key, QString &var LibraryPtr OneSixVersionFormat::libraryFromJson(ProblemContainer & problems, const QJsonObject &libObj, const QString &filename) { LibraryPtr out = MojangVersionFormat::libraryFromJson(problems, libObj, filename); - readString(libObj, "LAUNCHER-hint", out->m_hint); - readString(libObj, "LAUNCHER-absulute_url", out->m_absoluteURL); - readString(libObj, "LAUNCHER-absoluteUrl", out->m_absoluteURL); - readString(libObj, "LAUNCHER-filename", out->m_filename); - readString(libObj, "LAUNCHER-displayname", out->m_displayname); + readString(libObj, "MMC-hint", out->m_hint); + readString(libObj, "MMC-absulute_url", out->m_absoluteURL); + readString(libObj, "MMC-absoluteUrl", out->m_absoluteURL); + readString(libObj, "MMC-filename", out->m_filename); + readString(libObj, "MMC-displayname", out->m_displayname); return out; } @@ -28,13 +28,13 @@ QJsonObject OneSixVersionFormat::libraryToJson(Library *library) { QJsonObject libRoot = MojangVersionFormat::libraryToJson(library); if (library->m_absoluteURL.size()) - libRoot.insert("LAUNCHER-absoluteUrl", library->m_absoluteURL); + libRoot.insert("MMC-absoluteUrl", library->m_absoluteURL); if (library->m_hint.size()) - libRoot.insert("LAUNCHER-hint", library->m_hint); + libRoot.insert("MMC-hint", library->m_hint); if (library->m_filename.size()) - libRoot.insert("LAUNCHER-filename", library->m_filename); + libRoot.insert("MMC-filename", library->m_filename); if (library->m_displayname.size()) - libRoot.insert("LAUNCHER-displayname", library->m_displayname); + libRoot.insert("MMC-displayname", library->m_displayname); return libRoot; } diff --git a/launcher/package/rpm/MultiMC5.spec b/launcher/package/rpm/MultiMC5.spec index 78b9000e..20839f11 100644 --- a/launcher/package/rpm/MultiMC5.spec +++ b/launcher/package/rpm/MultiMC5.spec @@ -1,6 +1,6 @@ Name: MultiMC5 Version: 1.4 -Release: 2%{?dist} +Release: 3%{?dist} Summary: A local install wrapper for MultiMC License: ASL 2.0 @@ -18,25 +18,30 @@ A local install wrapper for MultiMC %build - %install mkdir -p %{buildroot}/opt/multimc install -m 0644 ../ubuntu/multimc/opt/multimc/icon.svg %{buildroot}/opt/multimc/icon.svg install -m 0755 ../ubuntu/multimc/opt/multimc/run.sh %{buildroot}/opt/multimc/run.sh mkdir -p %{buildroot}/%{_datadir}/applications install -m 0644 ../ubuntu/multimc/usr/share/applications/multimc.desktop %{buildroot}/%{_datadir}/applications/multimc.desktop -mkdir -p %{buildroot}/%{_metainfodir} -install -m 0644 ../ubuntu/multimc/usr/share/metainfo/multimc.metainfo.xml %{buildroot}/%{_metainfodir}/multimc.metainfo.xml +mkdir -p %{buildroot}/%{_datadir}/metainfo +install -m 0644 ../ubuntu/multimc/usr/share/metainfo/multimc.metainfo.xml %{buildroot}/%{_datadir}/metainfo/multimc.metainfo.xml +mkdir -p %{buildroot}/%{_mandir}/man1 +install -m 0644 ../ubuntu/multimc/usr/share/man/man1/multimc.1 %{buildroot}/%{_mandir}/man1/multimc.1 %files %dir /opt/multimc /opt/multimc/icon.svg /opt/multimc/run.sh %{_datadir}/applications/multimc.desktop -%{_metainfodir}/multimc.metainfo.xml - +%{_datadir}/metainfo/multimc.metainfo.xml +%dir /usr/share/man/man1 +%{_mandir}/man1/multimc.1.gz %changelog +* Sun Oct 03 2021 imperatorstorm <30777770+ImperatorStorm@users.noreply.github.com> +- added manpage + * Tue Jun 01 2021 kb1000 - 1.4-2 - Add xrandr to the dependencies diff --git a/launcher/package/ubuntu/multimc/DEBIAN/control b/launcher/package/ubuntu/multimc/DEBIAN/control index be64f517..bfa3f1f2 100644 --- a/launcher/package/ubuntu/multimc/DEBIAN/control +++ b/launcher/package/ubuntu/multimc/DEBIAN/control @@ -1,5 +1,5 @@ Package: multimc -Version: 1.6-1 +Version: 1.6-2 Architecture: all Maintainer: Petr Mrázek Section: games diff --git a/launcher/package/ubuntu/multimc/usr/share/man/man1/multimc.1 b/launcher/package/ubuntu/multimc/usr/share/man/man1/multimc.1 new file mode 100644 index 00000000..b2031aa9 --- /dev/null +++ b/launcher/package/ubuntu/multimc/usr/share/man/man1/multimc.1 @@ -0,0 +1,90 @@ +'\" t +.\" Title: multimc +.\" Author: [see the "AUTHORS" section] +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 10/21/2021 +.\" Manual: \ \& +.\" Source: \ \& +.\" Language: English +.\" +.TH "MULTIMC" "1" "10/21/2021" "\ \&" "\ \&" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +multimc \- a launcher and instance manager for Minecraft\&. +.SH "SYNOPSIS" +.sp +\fBmultimc\fR [\fIOPTIONS\fR] +.SH "DESCRIPTION" +.sp +MultiMC is a custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once\&. It also allows you to easily install and remove mods by simply dragging and dropping\&. Here are the current features of MultiMC\&. +.SH "OPTIONS" +.PP +\fB\-d, \-\-dir\fR=\fIDIRECTORY\fR +.RS 4 +Use +\fIDIRECTORY\fR +as the MultiMC root\&. +.RE +.PP +\fB\-l, \-\-launch\fR=\fIINSTANCE_ID\fR +.RS 4 +Launch the instance specified by +\fIINSTANCE_ID\fR\&. +.RE +.PP +\fB\-\-alive\fR +.RS 4 +Write a small +\fIlive\&.check\fR +file after MultiMC starts\&. +.RE +.PP +\fB\-h, \-\-help\fR +.RS 4 +Display help text and exit\&. +.RE +.PP +\fB\-v, \-\-version\fR +.RS 4 +Display program version and exit\&. +.RE +.SH "EXIT STATUS" +.PP +\fB0\fR +.RS 4 +Success +.RE +.PP +\fB1\fR +.RS 4 +Failure (syntax or usage error; configuration error; unexpected error)\&. +.RE +.SH "BUGS" +.sp +https://github\&.com/MultiMC/Launcher/issues +.SH "RESOURCES" +.sp +GitHub: https://github\&.com/MultiMC/Launcher +.sp +Main website: https://multimc\&.org +.SH "AUTHORS" +.sp +peterix diff --git a/launcher/pages/global/MinecraftPage.cpp b/launcher/pages/global/MinecraftPage.cpp index 2830dc7c..342941f4 100644 --- a/launcher/pages/global/MinecraftPage.cpp +++ b/launcher/pages/global/MinecraftPage.cpp @@ -54,7 +54,6 @@ void MinecraftPage::on_maximizedCheckBox_clicked(bool checked) updateCheckboxStuff(); } - void MinecraftPage::applySettings() { auto s = LAUNCHER->settings(); @@ -70,6 +69,7 @@ void MinecraftPage::applySettings() // Game time s->set("ShowGameTime", ui->showGameTime->isChecked()); + s->set("ShowGlobalGameTime", ui->showGlobalGameTime->isChecked()); s->set("RecordGameTime", ui->recordGameTime->isChecked()); } @@ -86,5 +86,6 @@ void MinecraftPage::loadSettings() ui->useNativeGLFWCheck->setChecked(s->get("UseNativeGLFW").toBool()); ui->showGameTime->setChecked(s->get("ShowGameTime").toBool()); + ui->showGlobalGameTime->setChecked(s->get("ShowGlobalGameTime").toBool()); ui->recordGameTime->setChecked(s->get("RecordGameTime").toBool()); } diff --git a/launcher/pages/global/MinecraftPage.ui b/launcher/pages/global/MinecraftPage.ui index 2abd4bd4..857b8cfb 100644 --- a/launcher/pages/global/MinecraftPage.ui +++ b/launcher/pages/global/MinecraftPage.ui @@ -147,6 +147,13 @@ + + + + Show time spent playing across all instances + + + diff --git a/launcher/pages/instance/InstanceSettingsPage.ui b/launcher/pages/instance/InstanceSettingsPage.ui index e569ce56..35cd7335 100644 --- a/launcher/pages/instance/InstanceSettingsPage.ui +++ b/launcher/pages/instance/InstanceSettingsPage.ui @@ -416,9 +416,9 @@ - + - Miscellanous + Miscellaneous @@ -489,7 +489,7 @@ - + Qt::Vertical diff --git a/launcher/pages/modplatform/atlauncher/AtlPage.cpp b/launcher/pages/modplatform/atlauncher/AtlPage.cpp index e59e5fe1..cdf5cc86 100644 --- a/launcher/pages/modplatform/atlauncher/AtlPage.cpp +++ b/launcher/pages/modplatform/atlauncher/AtlPage.cpp @@ -31,7 +31,6 @@ AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget *parent) ui->sortByBox->setCurrentText(filterModel->translateCurrentSorting()); connect(ui->searchEdit, &QLineEdit::textChanged, this, &AtlPage::triggerSearch); - connect(ui->resetButton, &QPushButton::clicked, this, &AtlPage::resetSearch); connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &AtlPage::onSortingSelectionChanged); connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &AtlPage::onSelectionChanged); connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &AtlPage::onVersionSelectionChanged); @@ -71,7 +70,7 @@ void AtlPage::suggestCurrent() return; } - dialog->setSuggestedPack(selected.name, new ATLauncher::PackInstallTask(this, selected.safeName, selectedVersion)); + dialog->setSuggestedPack(selected.name + " " + selectedVersion, new ATLauncher::PackInstallTask(this, selected.safeName, selectedVersion)); auto editedLogoName = selected.safeName; auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/images/%1.png").arg(selected.safeName.toLower()); listModel->getLogo(selected.safeName, url, [this, editedLogoName](QString logo) @@ -85,11 +84,6 @@ void AtlPage::triggerSearch() filterModel->setSearchTerm(ui->searchEdit->text()); } -void AtlPage::resetSearch() -{ - ui->searchEdit->setText(""); -} - void AtlPage::onSortingSelectionChanged(QString data) { auto toSet = filterModel->getAvailableSortings().value(data); diff --git a/launcher/pages/modplatform/atlauncher/AtlPage.h b/launcher/pages/modplatform/atlauncher/AtlPage.h index ed872053..84c40656 100644 --- a/launcher/pages/modplatform/atlauncher/AtlPage.h +++ b/launcher/pages/modplatform/atlauncher/AtlPage.h @@ -67,7 +67,6 @@ private: private slots: void triggerSearch(); - void resetSearch(); void onSortingSelectionChanged(QString data); diff --git a/launcher/pages/modplatform/atlauncher/AtlPage.ui b/launcher/pages/modplatform/atlauncher/AtlPage.ui index f16c24b8..9085766a 100644 --- a/launcher/pages/modplatform/atlauncher/AtlPage.ui +++ b/launcher/pages/modplatform/atlauncher/AtlPage.ui @@ -15,15 +15,15 @@ + + true + 96 48 - - true - @@ -68,25 +68,20 @@ - - - - Reset - - - Search and filter ... + + true + searchEdit - resetButton packView packDescription sortByBox diff --git a/launcher/pages/modplatform/ftb/FtbFilterModel.cpp b/launcher/pages/modplatform/ftb/FtbFilterModel.cpp index dec3a017..793b8769 100644 --- a/launcher/pages/modplatform/ftb/FtbFilterModel.cpp +++ b/launcher/pages/modplatform/ftb/FtbFilterModel.cpp @@ -36,9 +36,21 @@ FilterModel::Sorting FilterModel::getCurrentSorting() return currentSorting; } +void FilterModel::setSearchTerm(const QString& term) +{ + searchTerm = term.trimmed(); + invalidate(); +} + bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { - return true; + if (searchTerm.isEmpty()) { + return true; + } + + auto index = sourceModel()->index(sourceRow, 0, sourceParent); + auto pack = sourceModel()->data(index, Qt::UserRole).value(); + return pack.name.contains(searchTerm, Qt::CaseInsensitive); } bool FilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const diff --git a/launcher/pages/modplatform/ftb/FtbFilterModel.h b/launcher/pages/modplatform/ftb/FtbFilterModel.h index 4fe2a274..2e712c7d 100644 --- a/launcher/pages/modplatform/ftb/FtbFilterModel.h +++ b/launcher/pages/modplatform/ftb/FtbFilterModel.h @@ -19,6 +19,7 @@ public: QString translateCurrentSorting(); void setSorting(Sorting sorting); Sorting getCurrentSorting(); + void setSearchTerm(const QString& term); protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; @@ -27,6 +28,7 @@ protected: private: QMap sortings; Sorting currentSorting; + QString searchTerm { "" }; }; diff --git a/launcher/pages/modplatform/ftb/FtbListModel.cpp b/launcher/pages/modplatform/ftb/FtbListModel.cpp index 7da4c066..c4c2c83e 100644 --- a/launcher/pages/modplatform/ftb/FtbListModel.cpp +++ b/launcher/pages/modplatform/ftb/FtbListModel.cpp @@ -74,24 +74,6 @@ QVariant ListModel::data(const QModelIndex &index, int role) const return QVariant(); } -void ListModel::performSearch() -{ - auto *netJob = new NetJob("Ftb::Search"); - QString searchUrl; - if(currentSearchTerm.isEmpty()) { - searchUrl = BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/all"; - } - else { - searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/search/25?term=%1") - .arg(currentSearchTerm); - } - netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); - jobPtr = netJob; - jobPtr->start(); - QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished); - QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed); -} - void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback) { if(m_logoMap.contains(logo)) @@ -104,28 +86,23 @@ void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallbac } } -void ListModel::searchWithTerm(const QString &term) +void ListModel::request() { - if(searchState != Failed && currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull()) { - // unless the search has failed, then there is no need to perform an identical search. - return; - } - currentSearchTerm = term; - - if(jobPtr) { - jobPtr->abort(); - jobPtr.reset(); - } - beginResetModel(); modpacks.clear(); endResetModel(); - searchState = None; - performSearch(); + auto *netJob = new NetJob("Ftb::Request"); + auto url = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/all"); + netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response)); + jobPtr = netJob; + jobPtr->start(); + + QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::requestFinished); + QObject::connect(netJob, &NetJob::failed, this, &ListModel::requestFailed); } -void ListModel::searchRequestFinished() +void ListModel::requestFinished() { jobPtr.reset(); remainingPacks.clear(); @@ -150,12 +127,10 @@ void ListModel::searchRequestFinished() } } -void ListModel::searchRequestFailed(QString reason) +void ListModel::requestFailed(QString reason) { jobPtr.reset(); remainingPacks.clear(); - - searchState = Failed; } void ListModel::requestPack() diff --git a/launcher/pages/modplatform/ftb/FtbListModel.h b/launcher/pages/modplatform/ftb/FtbListModel.h index de94e6ba..2d6e91da 100644 --- a/launcher/pages/modplatform/ftb/FtbListModel.h +++ b/launcher/pages/modplatform/ftb/FtbListModel.h @@ -30,13 +30,13 @@ public: int columnCount(const QModelIndex &parent) const override; QVariant data(const QModelIndex &index, int role) const override; + void request(); + void getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback); - void searchWithTerm(const QString & term); private slots: - void performSearch(); - void searchRequestFinished(); - void searchRequestFailed(QString reason); + void requestFinished(); + void requestFailed(QString reason); void requestPack(); void packRequestFinished(); @@ -52,14 +52,6 @@ private: QList modpacks; LogoMap m_logoMap; - QString currentSearchTerm; - enum SearchState { - None, - CanPossiblyFetchMore, - ResetRequested, - Finished, - Failed, - } searchState = None; NetJobPtr jobPtr; int currentPack; QList remainingPacks; diff --git a/launcher/pages/modplatform/ftb/FtbPage.cpp b/launcher/pages/modplatform/ftb/FtbPage.cpp index b7f35c5d..620a56d8 100644 --- a/launcher/pages/modplatform/ftb/FtbPage.cpp +++ b/launcher/pages/modplatform/ftb/FtbPage.cpp @@ -32,7 +32,7 @@ FtbPage::FtbPage(NewInstanceDialog* dialog, QWidget *parent) } ui->sortByBox->setCurrentText(filterModel->translateCurrentSorting()); - connect(ui->searchButton, &QPushButton::clicked, this, &FtbPage::triggerSearch); + connect(ui->searchEdit, &QLineEdit::textChanged, this, &FtbPage::triggerSearch); connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &FtbPage::onSortingSelectionChanged); connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FtbPage::onSelectionChanged); connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &FtbPage::onVersionSelectionChanged); @@ -63,7 +63,12 @@ bool FtbPage::shouldDisplay() const void FtbPage::openedImpl() { - triggerSearch(); + if(!initialised) + { + listModel->request(); + initialised = true; + } + suggestCurrent(); } @@ -80,7 +85,7 @@ void FtbPage::suggestCurrent() return; } - dialog->setSuggestedPack(selected.name, new ModpacksCH::PackInstallTask(selected, selectedVersion)); + dialog->setSuggestedPack(selected.name + " " + selectedVersion, new ModpacksCH::PackInstallTask(selected, selectedVersion)); for(auto art : selected.art) { if(art.type == "square") { QString editedLogoName; @@ -96,7 +101,7 @@ void FtbPage::suggestCurrent() void FtbPage::triggerSearch() { - listModel->searchWithTerm(ui->searchEdit->text()); + filterModel->setSearchTerm(ui->searchEdit->text()); } void FtbPage::onSortingSelectionChanged(QString data) diff --git a/launcher/pages/modplatform/ftb/FtbPage.h b/launcher/pages/modplatform/ftb/FtbPage.h index da121913..0a4a6cea 100644 --- a/launcher/pages/modplatform/ftb/FtbPage.h +++ b/launcher/pages/modplatform/ftb/FtbPage.h @@ -65,6 +65,7 @@ private: private slots: void triggerSearch(); + void onSortingSelectionChanged(QString data); void onSelectionChanged(QModelIndex first, QModelIndex second); void onVersionSelectionChanged(QString data); @@ -77,4 +78,6 @@ private: ModpacksCH::Modpack selected; QString selectedVersion; + + bool initialised { false }; }; diff --git a/launcher/pages/modplatform/ftb/FtbPage.ui b/launcher/pages/modplatform/ftb/FtbPage.ui index 135afc6d..e9c783e3 100644 --- a/launcher/pages/modplatform/ftb/FtbPage.ui +++ b/launcher/pages/modplatform/ftb/FtbPage.ui @@ -36,12 +36,8 @@ Search and filter ... - - - - - - Search + + true @@ -49,15 +45,15 @@ + + true + 48 48 - - true - @@ -76,7 +72,6 @@ searchEdit - searchButton versionSelectionBox diff --git a/launcher/widgets/JavaSettingsWidget.cpp b/launcher/widgets/JavaSettingsWidget.cpp index 0e292bb8..11f0653a 100644 --- a/launcher/widgets/JavaSettingsWidget.cpp +++ b/launcher/widgets/JavaSettingsWidget.cpp @@ -74,7 +74,7 @@ void JavaSettingsWidget::setupUi() m_minMemSpinBox = new QSpinBox(m_memoryGroupBox); m_minMemSpinBox->setObjectName(QStringLiteral("minMemSpinBox")); - m_minMemSpinBox->setSuffix(QStringLiteral(" MB")); + m_minMemSpinBox->setSuffix(QStringLiteral(" MiB")); m_minMemSpinBox->setMinimum(128); m_minMemSpinBox->setMaximum(m_availableMemory); m_minMemSpinBox->setSingleStep(128); @@ -87,7 +87,7 @@ void JavaSettingsWidget::setupUi() m_maxMemSpinBox = new QSpinBox(m_memoryGroupBox); m_maxMemSpinBox->setObjectName(QStringLiteral("maxMemSpinBox")); - m_maxMemSpinBox->setSuffix(QStringLiteral(" MB")); + m_maxMemSpinBox->setSuffix(QStringLiteral(" MiB")); m_maxMemSpinBox->setMinimum(128); m_maxMemSpinBox->setMaximum(m_availableMemory); m_maxMemSpinBox->setSingleStep(128); @@ -102,7 +102,7 @@ void JavaSettingsWidget::setupUi() m_permGenSpinBox = new QSpinBox(m_memoryGroupBox); m_permGenSpinBox->setObjectName(QStringLiteral("permGenSpinBox")); - m_permGenSpinBox->setSuffix(QStringLiteral(" MB")); + m_permGenSpinBox->setSuffix(QStringLiteral(" MiB")); m_permGenSpinBox->setMinimum(64); m_permGenSpinBox->setMaximum(m_availableMemory); m_permGenSpinBox->setSingleStep(8); diff --git a/notsecrets/CMakeLists.txt b/notsecrets/CMakeLists.txt index 2369d046..b5dd3cf8 100644 --- a/notsecrets/CMakeLists.txt +++ b/notsecrets/CMakeLists.txt @@ -11,7 +11,7 @@ set(Launcher_Name "${Launcher_CommonName}" PARENT_SCOPE) set(Launcher_DisplayName "${Launcher_CommonName} 5" PARENT_SCOPE) set(Launcher_UserAgent "${Launcher_CommonName}/5.0" PARENT_SCOPE) set(Launcher_ConfigFile "devlauncher.cfg" PARENT_SCOPE) -set(Launcher_Git "https://github.com/MultiMC/MultiMC5" PARENT_SCOPE) +set(Launcher_Git "https://github.com/MultiMC/Launcher" PARENT_SCOPE) set(Launcher_Branding_ICNS "notsecrets/Launcher.icns" PARENT_SCOPE) set(Launcher_Branding_WindowsRC "notsecrets/launcher.rc" PARENT_SCOPE)