This avoids creating a bunch of threads that fills up the maximum amount
allowed by QThreadPool, and causes a deadlock between the helper threads
and the main thread (main thread tries to create threads in painting
code, but isn't able to, so it keeps waiting for a thread to free up,
but all the threads are waiting on the main thread to process some
events).
Signed-off-by: flow <flowlnlnln@gmail.com>
This fixes an issue in which, when adding a new resource pack externally
to PolyMC, when the resource pack view was open, would crash poly.
Signed-off-by: flow <flowlnlnln@gmail.com>
This parses the pack format ID and the description from the local file,
from both a ZIP and a folder, and hooks it into the model.
Signed-off-by: flow <flowlnlnln@gmail.com>
TIL that zip resource packs, when disabled, actually have the effect of
not showing up in the game at all. Since this can be useful to someone,
I moved the logic for it to the resources.
Signed-off-by: flow <flowlnlnln@gmail.com>
In order to access the ModFolderModel from the ModFolderPage, i created
a new m_model for the correct type, shadowing the m_model of type
ResourceFolderModel. This creates two shared_ptr references to the same object,
but since they will have the same lifetime, it doesn't generate a memory
leak.
Signed-off-by: flow <flowlnlnln@gmail.com>
This moves the QSortFilterProxyModel to the resource model files,
acessible via a factory method, and moves the sorting and filtering to
the objects themselves, decoupling the code a bit.
This also adds a basic implementation of methods in the
ResourceFolderModel, simplifying the process of constructing a new model
from it.
Signed-off-by: flow <flowlnlnln@gmail.com>
This aims to continue decoupling other types of resources (e.g. resource
packs, shader packs, etc) from mods, so that we don't have to
continuously watch our backs for changes to one of them affecting the
others.
To do so, this creates a more general list model for resources, based on
the mods one, that allows you to extend it with functionality for other
resources.
I had to do some template and preprocessor stuff to get around the
QObject limitation of not allowing templated classes, so that's sadge :c
On the other hand, I tried cleaning up most general-purpose code in the
mod model, and added some documentation, because it looks nice :D
Signed-off-by: flow <flowlnlnln@gmail.com>