mirror of
https://github.com/UltimMC/Launcher.git
synced 2025-12-23 20:12:34 +00:00
Fix conflict
This commit is contained in:
8
BUILD.md
8
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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
21
launcher/MMCTime.cpp
Normal file
21
launcher/MMCTime.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <MMCTime.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
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);
|
||||
}
|
||||
9
launcher/MMCTime.h
Normal file
9
launcher/MMCTime.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace Time {
|
||||
|
||||
QString prettifyDuration(int64_t duration);
|
||||
|
||||
}
|
||||
@@ -88,6 +88,7 @@
|
||||
#include "UpdateController.h"
|
||||
#include "KonamiCode.h"
|
||||
#include <InstanceCopyTask.h>
|
||||
#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)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <pathmatcher/MultiMatcher.h>
|
||||
#include <FileSystem.h>
|
||||
#include <java/JavaVersion.h>
|
||||
#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())
|
||||
|
||||
@@ -119,9 +119,6 @@ protected:
|
||||
QStringList validLaunchMethods();
|
||||
QString launchMethod();
|
||||
|
||||
private:
|
||||
QString prettifyTimeDuration(int64_t duration);
|
||||
|
||||
protected: // data
|
||||
std::shared_ptr<PackProfile> m_components;
|
||||
mutable std::shared_ptr<ModFolderModel> m_loader_mod_list;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <fedora@kb1000.de> - 1.4-2
|
||||
- Add xrandr to the dependencies
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Package: multimc
|
||||
Version: 1.6-1
|
||||
Version: 1.6-2
|
||||
Architecture: all
|
||||
Maintainer: Petr Mrázek <peterix@gmail.com>
|
||||
Section: games
|
||||
|
||||
90
launcher/package/ubuntu/multimc/usr/share/man/man1/multimc.1
Normal file
90
launcher/package/ubuntu/multimc/usr/share/man/man1/multimc.1
Normal file
@@ -0,0 +1,90 @@
|
||||
'\" t
|
||||
.\" Title: multimc
|
||||
.\" Author: [see the "AUTHORS" section]
|
||||
.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
|
||||
.\" 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 <peterix@gmail\&.com>
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -147,6 +147,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="showGlobalGameTime">
|
||||
<property name="text">
|
||||
<string>Show time spent playing across all instances</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="recordGameTime">
|
||||
<property name="text">
|
||||
|
||||
@@ -416,9 +416,9 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="miscellanousPage">
|
||||
<widget class="QWidget" name="miscellaneousPage">
|
||||
<attribute name="title">
|
||||
<string>Miscellanous</string>
|
||||
<string>Miscellaneous</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
@@ -489,7 +489,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacerMiscellanous">
|
||||
<spacer name="verticalSpacerMiscellaneous">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -67,7 +67,6 @@ private:
|
||||
|
||||
private slots:
|
||||
void triggerSearch();
|
||||
void resetSearch();
|
||||
|
||||
void onSortingSelectionChanged(QString data);
|
||||
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="0">
|
||||
<widget class="QTreeView" name="packView">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>96</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
@@ -68,25 +68,20 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="resetButton">
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="searchEdit">
|
||||
<property name="placeholderText">
|
||||
<string>Search and filter ...</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>searchEdit</tabstop>
|
||||
<tabstop>resetButton</tabstop>
|
||||
<tabstop>packView</tabstop>
|
||||
<tabstop>packDescription</tabstop>
|
||||
<tabstop>sortByBox</tabstop>
|
||||
|
||||
@@ -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<ModpacksCH::Modpack>();
|
||||
return pack.name.contains(searchTerm, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
bool FilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
|
||||
@@ -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<QString, Sorting> sortings;
|
||||
Sorting currentSorting;
|
||||
QString searchTerm { "" };
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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<ModpacksCH::Modpack> modpacks;
|
||||
LogoMap m_logoMap;
|
||||
|
||||
QString currentSearchTerm;
|
||||
enum SearchState {
|
||||
None,
|
||||
CanPossiblyFetchMore,
|
||||
ResetRequested,
|
||||
Finished,
|
||||
Failed,
|
||||
} searchState = None;
|
||||
NetJobPtr jobPtr;
|
||||
int currentPack;
|
||||
QList<int> remainingPacks;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 };
|
||||
};
|
||||
|
||||
@@ -36,12 +36,8 @@
|
||||
<property name="placeholderText">
|
||||
<string>Search and filter ...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="searchButton">
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -49,15 +45,15 @@
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeView" name="packView">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
@@ -76,7 +72,6 @@
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>searchEdit</tabstop>
|
||||
<tabstop>searchButton</tabstop>
|
||||
<tabstop>versionSelectionBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user