Merge pull request #1107 from Ryex/chore/add-compiler-warnings
Introduce more strict compiler warnings and fix them
This commit is contained in:
commit
a44cb6430e
@ -33,6 +33,13 @@ if(MSVC)
|
||||
# Use /W4 as /Wall includes unnesserey warnings such as added padding to structs
|
||||
set(CMAKE_CXX_FLAGS "/GS /permissive- /W4 ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
# /EHs Enables stack unwind semantics for standard C++ exceptions to ensure stackframes are unwound
|
||||
# and object deconstructors are called when an exception is caught.
|
||||
# without it memory leaks and a warning is printed
|
||||
# /EHc tells the compiler to assume that functions declared as extern "C" never throw a C++ exception
|
||||
# This appears to not always be a defualt compiler option in CMAKE
|
||||
set(CMAKE_CXX_FLAGS "/EHsc ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
# LINK accepts /SUBSYSTEM whics sets if we are a WINDOWS (gui) or a CONSOLE programs
|
||||
# This implicitly selects an entrypoint specific to the subsystem selected
|
||||
# qtmain/QtEntryPointLib provides the correct entrypoint (wWinMain) for gui programs
|
||||
@ -88,35 +95,36 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O2 -D_FORTIFY_SOURCE=2 ${CMAKE_CXX_FLAGS_RELEASE}"
|
||||
option(DEBUG_ADDRESS_SANITIZER "Enable Address Sanitizer in Debug builds" OFF)
|
||||
|
||||
# If this is a Debug build turn on address sanitiser
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND DEBUG_ADDRESS_SANITIZER)
|
||||
if ((CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") AND DEBUG_ADDRESS_SANITIZER)
|
||||
message(STATUS "Address Sanitizer enabled for Debug builds, Turn it off with -DDEBUG_ADDRESS_SANITIZER=off")
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
||||
# using clang with clang-cl front end
|
||||
message(STATUS "Address Sanitizer available on Clang MSVC frontend")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address /O1 /Oy-")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address /O1 /Oy-")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address /Oy-")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address /Oy-")
|
||||
else()
|
||||
# AppleClang and Clang
|
||||
message(STATUS "Address Sanitizer available on Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1 -fno-omit-frame-pointer")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -O1 -fno-omit-frame-pointer")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
||||
endif()
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
# GCC
|
||||
message(STATUS "Address Sanitizer available on GCC")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1 -fno-omit-frame-pointer")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -O1 -fno-omit-frame-pointer")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
||||
link_libraries("asan")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||
message(STATUS "Address Sanitizer available on MSVC")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address /O1 /Oy-")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address /O1 /Oy-")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address /Oy-")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address /Oy-")
|
||||
else()
|
||||
message(STATUS "Address Sanitizer not available on compiler ${CMAKE_CXX_COMPILER_ID}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
option(ENABLE_LTO "Enable Link Time Optimization" off)
|
||||
|
||||
if(ENABLE_LTO)
|
||||
|
152
cmake/CompilerWarnings.cmake
Normal file
152
cmake/CompilerWarnings.cmake
Normal file
@ -0,0 +1,152 @@
|
||||
#
|
||||
# Function to set compiler warnings with reasonable defaults at the project level.
|
||||
# Taken from https://github.com/aminya/project_options/blob/main/src/CompilerWarnings.cmake
|
||||
# under the folowing license:
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2022-2100 Amin Yahyaabadi
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
|
||||
include_guard()
|
||||
|
||||
function(_set_project_warnings_add_target_link_option TARGET OPTIONS)
|
||||
target_link_options(${_project_name} INTERFACE ${OPTIONS})
|
||||
endfunction()
|
||||
|
||||
# Set the compiler warnings
|
||||
#
|
||||
# https://clang.llvm.org/docs/DiagnosticsReference.html
|
||||
# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md
|
||||
function(
|
||||
set_project_warnings
|
||||
_project_name
|
||||
MSVC_WARNINGS
|
||||
CLANG_WARNINGS
|
||||
GCC_WARNINGS
|
||||
)
|
||||
if("${MSVC_WARNINGS}" STREQUAL "")
|
||||
set(MSVC_WARNINGS
|
||||
/W4 # Baseline reasonable warnings
|
||||
/w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss of data
|
||||
/w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
|
||||
/w14263 # 'function': member function does not override any base class virtual member function
|
||||
/w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may not
|
||||
# be destructed correctly
|
||||
/w14287 # 'operator': unsigned/negative constant mismatch
|
||||
/we4289 # nonstandard extension used: 'variable': loop control variable declared in the for-loop is used outside
|
||||
# the for-loop scope
|
||||
/w14296 # 'operator': expression is always 'boolean_value'
|
||||
/w14311 # 'variable': pointer truncation from 'type1' to 'type2'
|
||||
/w14545 # expression before comma evaluates to a function which is missing an argument list
|
||||
/w14546 # function call before comma missing argument list
|
||||
/w14547 # 'operator': operator before comma has no effect; expected operator with side-effect
|
||||
/w14549 # 'operator': operator before comma has no effect; did you intend 'operator'?
|
||||
/w14555 # expression has no effect; expected expression with side- effect
|
||||
/w14619 # pragma warning: there is no warning number 'number'
|
||||
/w14640 # Enable warning on thread un-safe static member initialization
|
||||
/w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may cause unexpected runtime behavior.
|
||||
/w14905 # wide string literal cast to 'LPSTR'
|
||||
/w14906 # string literal cast to 'LPWSTR'
|
||||
/w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied
|
||||
/permissive- # standards conformance mode for MSVC compiler.
|
||||
)
|
||||
endif()
|
||||
|
||||
if("${CLANG_WARNINGS}" STREQUAL "")
|
||||
set(CLANG_WARNINGS
|
||||
-Wall
|
||||
-Wextra # reasonable and standard
|
||||
-Wextra-semi # Warn about semicolon after in-class function definition.
|
||||
-Wshadow # warn the user if a variable declaration shadows one from a parent context
|
||||
-Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps
|
||||
# catch hard to track down memory errors
|
||||
-Wold-style-cast # warn for c-style casts
|
||||
-Wcast-align # warn for potential performance problem casts
|
||||
-Wunused # warn on anything being unused
|
||||
-Woverloaded-virtual # warn if you overload (not override) a virtual function
|
||||
-Wpedantic # warn if non-standard C++ is used
|
||||
-Wconversion # warn on type conversions that may lose data
|
||||
-Wsign-conversion # warn on sign conversions
|
||||
-Wnull-dereference # warn if a null dereference is detected
|
||||
-Wdouble-promotion # warn if float is implicit promoted to double
|
||||
-Wformat=2 # warn on security issues around functions that format output (ie printf)
|
||||
-Wimplicit-fallthrough # warn on statements that fallthrough without an explicit annotation
|
||||
)
|
||||
endif()
|
||||
|
||||
if("${GCC_WARNINGS}" STREQUAL "")
|
||||
set(GCC_WARNINGS
|
||||
${CLANG_WARNINGS}
|
||||
-Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist
|
||||
-Wduplicated-cond # warn if if / else chain has duplicated conditions
|
||||
-Wduplicated-branches # warn if if / else branches have duplicated code
|
||||
-Wlogical-op # warn about logical operations being used where bitwise were probably wanted
|
||||
-Wuseless-cast # warn if you perform a cast to the same type
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(PROJECT_WARNINGS_CXX ${MSVC_WARNINGS})
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
||||
set(PROJECT_WARNINGS_CXX ${CLANG_WARNINGS})
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(PROJECT_WARNINGS_CXX ${GCC_WARNINGS})
|
||||
else()
|
||||
message(AUTHOR_WARNING "No compiler warnings set for CXX compiler: '${CMAKE_CXX_COMPILER_ID}'")
|
||||
# TODO support Intel compiler
|
||||
endif()
|
||||
|
||||
# Add C warnings
|
||||
set(PROJECT_WARNINGS_C "${PROJECT_WARNINGS_CXX}")
|
||||
list(
|
||||
REMOVE_ITEM
|
||||
PROJECT_WARNINGS_C
|
||||
-Wnon-virtual-dtor
|
||||
-Wold-style-cast
|
||||
-Woverloaded-virtual
|
||||
-Wuseless-cast
|
||||
-Wextra-semi
|
||||
)
|
||||
|
||||
target_compile_options(
|
||||
${_project_name}
|
||||
INTERFACE # C++ warnings
|
||||
$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_WARNINGS_CXX}>
|
||||
# C warnings
|
||||
$<$<COMPILE_LANGUAGE:C>:${PROJECT_WARNINGS_C}>
|
||||
)
|
||||
|
||||
# If we are using the compiler as a linker driver pass the warnings to it
|
||||
# (most useful when using LTO or warnings as errors)
|
||||
if(CMAKE_CXX_LINK_EXECUTABLE MATCHES "^<CMAKE_CXX_COMPILER>")
|
||||
_set_project_warnings_add_target_link_option(
|
||||
${_project_name} "$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_WARNINGS_CXX}>"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_LINK_EXECUTABLE MATCHES "^<CMAKE_C_COMPILER>")
|
||||
_set_project_warnings_add_target_link_option(
|
||||
${_project_name} "$<$<COMPILE_LANGUAGE:C>:${PROJECT_WARNINGS_C}>"
|
||||
)
|
||||
endif()
|
||||
|
||||
endfunction()
|
@ -88,7 +88,7 @@ public: /* types */
|
||||
|
||||
public:
|
||||
/// virtual destructor to make sure the destruction is COMPLETE
|
||||
virtual ~BaseInstance() {};
|
||||
virtual ~BaseInstance() {}
|
||||
|
||||
virtual void saveNow() = 0;
|
||||
|
||||
@ -154,7 +154,7 @@ public:
|
||||
virtual MessageLevel::Enum guessLevel([[maybe_unused]] const QString &line, MessageLevel::Enum level)
|
||||
{
|
||||
return level;
|
||||
};
|
||||
}
|
||||
|
||||
virtual QStringList extraArguments();
|
||||
|
||||
@ -291,7 +291,7 @@ public:
|
||||
protected:
|
||||
void changeStatus(Status newStatus);
|
||||
|
||||
SettingsObjectPtr globalSettings() const { return m_global_settings.lock(); };
|
||||
SettingsObjectPtr globalSettings() const { return m_global_settings.lock(); }
|
||||
|
||||
bool isSpecificSettingsLoaded() const { return m_specific_settings_loaded; }
|
||||
void setSpecificSettingsLoaded(bool loaded) { m_specific_settings_loaded = loaded; }
|
||||
|
@ -43,9 +43,8 @@ class BaseVersion {
|
||||
* the kind of version this is (Stable, Beta, Snapshot, whatever)
|
||||
*/
|
||||
virtual QString typeString() const = 0;
|
||||
|
||||
virtual bool operator<(BaseVersion& a) { return name() < a.name(); };
|
||||
virtual bool operator>(BaseVersion& a) { return name() > a.name(); };
|
||||
virtual bool operator<(BaseVersion& a) { return name() < a.name(); }
|
||||
virtual bool operator>(BaseVersion& a) { return name() > a.name(); }
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(BaseVersion::Ptr)
|
||||
|
@ -1131,8 +1131,14 @@ if(WIN32)
|
||||
set(LAUNCHER_RCS ${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_WindowsRC})
|
||||
endif()
|
||||
|
||||
include(CompilerWarnings)
|
||||
|
||||
# Add executable
|
||||
add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHER_UI} ${LAUNCHER_RESOURCES})
|
||||
set_project_warnings(Launcher_logic
|
||||
"${Launcher_MSVC_WARNINGS}"
|
||||
"${Launcher_CLANG_WARNINGS}"
|
||||
"${Launcher_GCC_WARNINGS}")
|
||||
target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_APPLICATION)
|
||||
target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(Launcher_logic
|
||||
@ -1218,6 +1224,11 @@ install(TARGETS ${Launcher_Name}
|
||||
|
||||
if(WIN32)
|
||||
add_library(filelink_logic STATIC ${LINKEXE_SOURCES})
|
||||
set_project_warnings(filelink_logic
|
||||
"${Launcher_MSVC_WARNINGS}"
|
||||
"${Launcher_CLANG_WARNINGS}"
|
||||
"${Launcher_GCC_WARNINGS}")
|
||||
|
||||
target_include_directories(filelink_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(filelink_logic
|
||||
systeminfo
|
||||
|
@ -104,7 +104,7 @@ bool IndirectOpen(T callable, qint64 *pid_forked = nullptr)
|
||||
#endif
|
||||
|
||||
namespace DesktopServices {
|
||||
bool openDirectory(const QString &path, bool ensureExists)
|
||||
bool openDirectory(const QString &path, [[maybe_unused]] bool ensureExists)
|
||||
{
|
||||
qDebug() << "Opening directory" << path;
|
||||
QDir parentPath;
|
||||
|
@ -112,8 +112,8 @@ class copy : public QObject {
|
||||
|
||||
bool operator()(bool dryRun = false) { return operator()(QString(), dryRun); }
|
||||
|
||||
int totalCopied() { return m_copied; }
|
||||
int totalFailed() { return m_failedPaths.length(); }
|
||||
qsizetype totalCopied() { return m_copied; }
|
||||
qsizetype totalFailed() { return m_failedPaths.length(); }
|
||||
QStringList failed() { return m_failedPaths; }
|
||||
|
||||
signals:
|
||||
@ -130,7 +130,7 @@ class copy : public QObject {
|
||||
bool m_whitelist = false;
|
||||
QDir m_src;
|
||||
QDir m_dst;
|
||||
int m_copied;
|
||||
qsizetype m_copied;
|
||||
QStringList m_failedPaths;
|
||||
};
|
||||
|
||||
@ -475,8 +475,8 @@ class clone : public QObject {
|
||||
|
||||
bool operator()(bool dryRun = false) { return operator()(QString(), dryRun); }
|
||||
|
||||
int totalCloned() { return m_cloned; }
|
||||
int totalFailed() { return m_failedClones.length(); }
|
||||
qsizetype totalCloned() { return m_cloned; }
|
||||
qsizetype totalFailed() { return m_failedClones.length(); }
|
||||
|
||||
QList<QPair<QString, QString>> failed() { return m_failedClones; }
|
||||
|
||||
@ -492,7 +492,7 @@ class clone : public QObject {
|
||||
bool m_whitelist = false;
|
||||
QDir m_src;
|
||||
QDir m_dst;
|
||||
int m_cloned;
|
||||
qsizetype m_cloned;
|
||||
QList<QPair<QString, QString>> m_failedClones;
|
||||
};
|
||||
|
||||
|
@ -41,9 +41,9 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QMimeData>
|
||||
#include <QPair>
|
||||
#include <QSet>
|
||||
#include <QStack>
|
||||
#include <QPair>
|
||||
#include <QTextStream>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
@ -96,7 +96,11 @@ Qt::DropActions InstanceList::supportedDropActions() const
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
bool InstanceList::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) const
|
||||
bool InstanceList::canDropMimeData(const QMimeData* data,
|
||||
[[maybe_unused]] Qt::DropAction action,
|
||||
[[maybe_unused]] int row,
|
||||
[[maybe_unused]] int column,
|
||||
[[maybe_unused]] const QModelIndex& parent) const
|
||||
{
|
||||
if (data && data->hasFormat("application/x-instanceid")) {
|
||||
return true;
|
||||
@ -104,7 +108,11 @@ bool InstanceList::canDropMimeData(const QMimeData* data, Qt::DropAction action,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InstanceList::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent)
|
||||
bool InstanceList::dropMimeData(const QMimeData* data,
|
||||
[[maybe_unused]] Qt::DropAction action,
|
||||
[[maybe_unused]] int row,
|
||||
[[maybe_unused]] int column,
|
||||
[[maybe_unused]] const QModelIndex& parent)
|
||||
{
|
||||
if (data && data->hasFormat("application/x-instanceid")) {
|
||||
return true;
|
||||
@ -129,7 +137,7 @@ QMimeData* InstanceList::mimeData(const QModelIndexList& indexes) const
|
||||
return mimeData;
|
||||
}
|
||||
|
||||
QStringList InstanceList::getLinkedInstancesById(const QString &id) const
|
||||
QStringList InstanceList::getLinkedInstancesById(const QString& id) const
|
||||
{
|
||||
QStringList linkedInstances;
|
||||
for (auto inst : m_instances) {
|
||||
@ -158,42 +166,34 @@ QVariant InstanceList::data(const QModelIndex& index, int role) const
|
||||
if (!index.isValid()) {
|
||||
return QVariant();
|
||||
}
|
||||
BaseInstance *pdata = static_cast<BaseInstance *>(index.internalPointer());
|
||||
switch (role)
|
||||
{
|
||||
case InstancePointerRole:
|
||||
{
|
||||
QVariant v = QVariant::fromValue((void *)pdata);
|
||||
return v;
|
||||
}
|
||||
case InstanceIDRole:
|
||||
{
|
||||
return pdata->id();
|
||||
}
|
||||
case Qt::EditRole:
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
return pdata->name();
|
||||
}
|
||||
case Qt::AccessibleTextRole:
|
||||
{
|
||||
return tr("%1 Instance").arg(pdata->name());
|
||||
}
|
||||
case Qt::ToolTipRole:
|
||||
{
|
||||
return pdata->instanceRoot();
|
||||
}
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
return pdata->iconKey();
|
||||
}
|
||||
// HACK: see InstanceView.h in gui!
|
||||
case GroupRole:
|
||||
{
|
||||
return getInstanceGroup(pdata->id());
|
||||
}
|
||||
default:
|
||||
break;
|
||||
BaseInstance* pdata = static_cast<BaseInstance*>(index.internalPointer());
|
||||
switch (role) {
|
||||
case InstancePointerRole: {
|
||||
QVariant v = QVariant::fromValue((void*)pdata);
|
||||
return v;
|
||||
}
|
||||
case InstanceIDRole: {
|
||||
return pdata->id();
|
||||
}
|
||||
case Qt::EditRole:
|
||||
case Qt::DisplayRole: {
|
||||
return pdata->name();
|
||||
}
|
||||
case Qt::AccessibleTextRole: {
|
||||
return tr("%1 Instance").arg(pdata->name());
|
||||
}
|
||||
case Qt::ToolTipRole: {
|
||||
return pdata->instanceRoot();
|
||||
}
|
||||
case Qt::DecorationRole: {
|
||||
return pdata->iconKey();
|
||||
}
|
||||
// HACK: see InstanceView.h in gui!
|
||||
case GroupRole: {
|
||||
return getInstanceGroup(pdata->id());
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
@ -320,16 +320,18 @@ bool InstanceList::trashInstance(const InstanceId& id)
|
||||
}
|
||||
|
||||
qDebug() << "Instance" << id << "has been trashed by the launcher.";
|
||||
m_trashHistory.push({id, inst->instanceRoot(), trashedLoc, cachedGroupId});
|
||||
|
||||
m_trashHistory.push({ id, inst->instanceRoot(), trashedLoc, cachedGroupId });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InstanceList::trashedSomething() {
|
||||
bool InstanceList::trashedSomething()
|
||||
{
|
||||
return !m_trashHistory.empty();
|
||||
}
|
||||
|
||||
void InstanceList::undoTrashInstance() {
|
||||
void InstanceList::undoTrashInstance()
|
||||
{
|
||||
if (m_trashHistory.empty()) {
|
||||
qWarning() << "Nothing to recover from trash.";
|
||||
return;
|
||||
@ -558,7 +560,7 @@ InstancePtr InstanceList::getInstanceByManagedName(const QString& managed_name)
|
||||
return {};
|
||||
}
|
||||
|
||||
QModelIndex InstanceList::getInstanceIndexById(const QString &id) const
|
||||
QModelIndex InstanceList::getInstanceIndexById(const QString& id) const
|
||||
{
|
||||
return index(getInstIndex(getInstanceById(id).get()));
|
||||
}
|
||||
@ -597,13 +599,11 @@ InstancePtr InstanceList::loadInstance(const InstanceId& id)
|
||||
|
||||
QString inst_type = instanceSettings->get("InstanceType").toString();
|
||||
|
||||
// NOTE: Some PolyMC versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a OneSix instance
|
||||
if (inst_type == "OneSix" || inst_type.isEmpty())
|
||||
{
|
||||
// NOTE: Some PolyMC versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a OneSix
|
||||
// instance
|
||||
if (inst_type == "OneSix" || inst_type.isEmpty()) {
|
||||
inst.reset(new MinecraftInstance(m_globalSettings, instanceSettings, instanceRoot));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
inst.reset(new NullInstance(m_globalSettings, instanceSettings, instanceRoot));
|
||||
}
|
||||
qDebug() << "Loaded instance " << inst->name() << " from " << inst->instanceRoot();
|
||||
@ -759,7 +759,7 @@ void InstanceList::instanceDirContentsChanged(const QString& path)
|
||||
emit instancesChanged();
|
||||
}
|
||||
|
||||
void InstanceList::on_InstFolderChanged(const Setting& setting, QVariant value)
|
||||
void InstanceList::on_InstFolderChanged( [[maybe_unused]] const Setting& setting, QVariant value)
|
||||
{
|
||||
QString newInstDir = QDir(value.toString()).canonicalPath();
|
||||
if (newInstDir != m_instDir) {
|
||||
@ -787,12 +787,17 @@ class InstanceStaging : public Task {
|
||||
Q_OBJECT
|
||||
const unsigned minBackoff = 1;
|
||||
const unsigned maxBackoff = 16;
|
||||
|
||||
public:
|
||||
InstanceStaging(InstanceList* parent, InstanceTask* child, QString stagingPath, InstanceName const& instanceName, QString groupName)
|
||||
: m_parent(parent), backoff(minBackoff, maxBackoff), m_stagingPath(std::move(stagingPath)), m_instance_name(std::move(instanceName)), m_groupName(std::move(groupName))
|
||||
: m_parent(parent)
|
||||
, backoff(minBackoff, maxBackoff)
|
||||
, m_stagingPath(std::move(stagingPath))
|
||||
, m_instance_name(std::move(instanceName))
|
||||
, m_groupName(std::move(groupName))
|
||||
{
|
||||
m_child.reset(child);
|
||||
connect(child, &Task::succeeded, this, &InstanceStaging::childSucceded);
|
||||
connect(child, &Task::succeeded, this, &InstanceStaging::childSucceeded);
|
||||
connect(child, &Task::failed, this, &InstanceStaging::childFailed);
|
||||
connect(child, &Task::aborted, this, &InstanceStaging::childAborted);
|
||||
connect(child, &Task::abortStatusChanged, this, &InstanceStaging::setAbortable);
|
||||
@ -800,7 +805,7 @@ class InstanceStaging : public Task {
|
||||
connect(child, &Task::details, this, &InstanceStaging::setDetails);
|
||||
connect(child, &Task::progress, this, &InstanceStaging::setProgress);
|
||||
connect(child, &Task::stepProgress, this, &InstanceStaging::propagateStepProgress);
|
||||
connect(&m_backoffTimer, &QTimer::timeout, this, &InstanceStaging::childSucceded);
|
||||
connect(&m_backoffTimer, &QTimer::timeout, this, &InstanceStaging::childSucceeded);
|
||||
}
|
||||
|
||||
virtual ~InstanceStaging(){};
|
||||
@ -815,21 +820,17 @@ class InstanceStaging : public Task {
|
||||
|
||||
return Task::abort();
|
||||
}
|
||||
bool canAbort() const override
|
||||
{
|
||||
return (m_child && m_child->canAbort());
|
||||
}
|
||||
bool canAbort() const override { return (m_child && m_child->canAbort()); }
|
||||
|
||||
protected:
|
||||
virtual void executeTask() override { m_child->start(); }
|
||||
QStringList warnings() const override { return m_child->warnings(); }
|
||||
|
||||
private slots:
|
||||
void childSucceded()
|
||||
void childSucceeded()
|
||||
{
|
||||
unsigned sleepTime = backoff();
|
||||
if (m_parent->commitStagedInstance(m_stagingPath, m_instance_name, m_groupName, *m_child.get()))
|
||||
{
|
||||
if (m_parent->commitStagedInstance(m_stagingPath, m_instance_name, m_groupName, *m_child.get())) {
|
||||
emitSucceeded();
|
||||
return;
|
||||
}
|
||||
@ -847,13 +848,10 @@ class InstanceStaging : public Task {
|
||||
emitFailed(reason);
|
||||
}
|
||||
|
||||
void childAborted()
|
||||
{
|
||||
emitAborted();
|
||||
}
|
||||
void childAborted() { emitAborted(); }
|
||||
|
||||
private:
|
||||
InstanceList * m_parent;
|
||||
private:
|
||||
InstanceList* m_parent;
|
||||
/*
|
||||
* WHY: the whole reason why this uses an exponential backoff retry scheme is antivirus on Windows.
|
||||
* Basically, it starts messing things up while the launcher is extracting/creating instances
|
||||
@ -892,7 +890,10 @@ QString InstanceList::getStagedInstancePath()
|
||||
return path;
|
||||
}
|
||||
|
||||
bool InstanceList::commitStagedInstance(const QString& path, InstanceName const& instanceName, const QString& groupName, InstanceTask const& commiting)
|
||||
bool InstanceList::commitStagedInstance(const QString& path,
|
||||
InstanceName const& instanceName,
|
||||
const QString& groupName,
|
||||
InstanceTask const& commiting)
|
||||
{
|
||||
QDir dir;
|
||||
QString instID;
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
shared_qobject_ptr< Task > createUpdateTask(Net::Mode mode) override
|
||||
shared_qobject_ptr< Task > createUpdateTask([[maybe_unused]] Net::Mode mode) override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
enum class ProblemSeverity
|
||||
{
|
||||
None,
|
||||
@ -16,7 +19,7 @@ struct PatchProblem
|
||||
class ProblemProvider
|
||||
{
|
||||
public:
|
||||
virtual ~ProblemProvider() {};
|
||||
virtual ~ProblemProvider() {}
|
||||
virtual const QList<PatchProblem> getProblems() const = 0;
|
||||
virtual ProblemSeverity getProblemSeverity() const = 0;
|
||||
};
|
||||
|
@ -105,7 +105,7 @@ void RecursiveFileSystemWatcher::fileChange(const QString &path)
|
||||
{
|
||||
emit fileChanged(path);
|
||||
}
|
||||
void RecursiveFileSystemWatcher::directoryChange(const QString &path)
|
||||
void RecursiveFileSystemWatcher::directoryChange([[maybe_unused]] const QString& path)
|
||||
{
|
||||
setFiles(scanRecursive(m_root));
|
||||
}
|
||||
|
@ -12,28 +12,20 @@ class Usable;
|
||||
*
|
||||
* @see UseLock
|
||||
*/
|
||||
class Usable
|
||||
{
|
||||
class Usable {
|
||||
friend class UseLock;
|
||||
public:
|
||||
std::size_t useCount() const
|
||||
{
|
||||
return m_useCount;
|
||||
}
|
||||
bool isInUse() const
|
||||
{
|
||||
return m_useCount > 0;
|
||||
}
|
||||
protected:
|
||||
virtual void decrementUses()
|
||||
{
|
||||
m_useCount--;
|
||||
}
|
||||
virtual void incrementUses()
|
||||
{
|
||||
m_useCount++;
|
||||
}
|
||||
private:
|
||||
|
||||
public:
|
||||
virtual ~Usable() {}
|
||||
|
||||
std::size_t useCount() const { return m_useCount; }
|
||||
bool isInUse() const { return m_useCount > 0; }
|
||||
|
||||
protected:
|
||||
virtual void decrementUses() { m_useCount--; }
|
||||
virtual void incrementUses() { m_useCount++; }
|
||||
|
||||
private:
|
||||
std::size_t m_useCount = 0;
|
||||
};
|
||||
|
||||
|
@ -63,7 +63,7 @@ class Version {
|
||||
struct Section {
|
||||
explicit Section(QString fullString) : m_fullString(std::move(fullString))
|
||||
{
|
||||
int cutoff = m_fullString.size();
|
||||
qsizetype cutoff = m_fullString.size();
|
||||
for (int i = 0; i < m_fullString.size(); i++) {
|
||||
if (!m_fullString[i].isDigit()) {
|
||||
cutoff = i;
|
||||
|
@ -218,16 +218,12 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if(hasRecommended)
|
||||
{
|
||||
auto value = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
|
||||
if(value.toBool())
|
||||
{
|
||||
auto recommenced = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
|
||||
if (recommenced.toBool()) {
|
||||
return APPLICATION->getThemedIcon("star");
|
||||
}
|
||||
else if(hasLatest)
|
||||
{
|
||||
auto value = sourceModel()->data(parentIndex, BaseVersionList::LatestRole);
|
||||
if(value.toBool())
|
||||
{
|
||||
} else if (hasLatest) {
|
||||
auto latest = sourceModel()->data(parentIndex, BaseVersionList::LatestRole);
|
||||
if (latest.toBool()) {
|
||||
return APPLICATION->getThemedIcon("bug");
|
||||
}
|
||||
}
|
||||
@ -260,7 +256,7 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex VersionProxyModel::parent(const QModelIndex &child) const
|
||||
QModelIndex VersionProxyModel::parent([[maybe_unused]] const QModelIndex& child) const
|
||||
{
|
||||
return QModelIndex();
|
||||
}
|
||||
@ -459,7 +455,9 @@ void VersionProxyModel::sourceRowsAboutToBeInserted(const QModelIndex& parent, i
|
||||
beginInsertRows(parent, first, last);
|
||||
}
|
||||
|
||||
void VersionProxyModel::sourceRowsInserted(const QModelIndex& parent, int first, int last)
|
||||
void VersionProxyModel::sourceRowsInserted([[maybe_unused]] const QModelIndex& parent,
|
||||
[[maybe_unused]] int first,
|
||||
[[maybe_unused]] int last)
|
||||
{
|
||||
endInsertRows();
|
||||
}
|
||||
@ -469,7 +467,7 @@ void VersionProxyModel::sourceRowsAboutToBeRemoved(const QModelIndex& parent, in
|
||||
beginRemoveRows(parent, first, last);
|
||||
}
|
||||
|
||||
void VersionProxyModel::sourceRowsRemoved(const QModelIndex& parent, int first, int last)
|
||||
void VersionProxyModel::sourceRowsRemoved([[maybe_unused]] const QModelIndex& parent, [[maybe_unused]] int first, [[maybe_unused]] int last)
|
||||
{
|
||||
endRemoveRows();
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ void FileLinkApp::readPathPairs()
|
||||
in >> numLinks;
|
||||
qDebug() << "numLinks" << numLinks;
|
||||
|
||||
for (unsigned int i = 0; i < numLinks; i++) {
|
||||
for (quint32 i = 0; i < numLinks; i++) {
|
||||
FS::LinkPair pair;
|
||||
in >> pair.src;
|
||||
in >> pair.dst;
|
||||
|
@ -14,7 +14,7 @@ class JavaVersion
|
||||
{
|
||||
friend class JavaVersionTest;
|
||||
public:
|
||||
JavaVersion() {};
|
||||
JavaVersion() {}
|
||||
JavaVersion(const QString & rhs);
|
||||
|
||||
JavaVersion & operator=(const QString & rhs);
|
||||
|
@ -40,7 +40,7 @@ public: /* methods */
|
||||
}
|
||||
bool write(QByteArray & data) override
|
||||
{
|
||||
this->data.append(data);
|
||||
this->m_data.append(data);
|
||||
return true;
|
||||
}
|
||||
bool abort() override
|
||||
@ -52,7 +52,7 @@ public: /* methods */
|
||||
auto fname = m_entity->localFilename();
|
||||
try
|
||||
{
|
||||
auto doc = Json::requireDocument(data, fname);
|
||||
auto doc = Json::requireDocument(m_data, fname);
|
||||
auto obj = Json::requireObject(doc, fname);
|
||||
m_entity->parse(obj);
|
||||
return true;
|
||||
@ -65,7 +65,7 @@ public: /* methods */
|
||||
}
|
||||
|
||||
private: /* data */
|
||||
QByteArray data;
|
||||
QByteArray m_data;
|
||||
Meta::BaseEntity *m_entity;
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,8 @@ public:
|
||||
Component(PackProfile * parent, std::shared_ptr<Meta::Version> version);
|
||||
Component(PackProfile * parent, const QString & uid, std::shared_ptr<VersionFile> file);
|
||||
|
||||
virtual ~Component(){};
|
||||
virtual ~Component(){}
|
||||
|
||||
void applyTo(LaunchProfile *profile);
|
||||
|
||||
bool isEnabled();
|
||||
|
@ -42,7 +42,7 @@
|
||||
class LaunchProfile: public ProblemProvider
|
||||
{
|
||||
public:
|
||||
virtual ~LaunchProfile() {};
|
||||
virtual ~LaunchProfile() {}
|
||||
|
||||
public: /* application of profile variables from patches */
|
||||
void applyMinecraftVersion(const QString& id);
|
||||
|
@ -23,8 +23,8 @@ struct MojangDownloadInfo
|
||||
|
||||
struct MojangLibraryDownloadInfo
|
||||
{
|
||||
MojangLibraryDownloadInfo(MojangDownloadInfo::Ptr artifact): artifact(artifact) {};
|
||||
MojangLibraryDownloadInfo() {};
|
||||
MojangLibraryDownloadInfo(MojangDownloadInfo::Ptr artifact_): artifact(artifact_) {}
|
||||
MojangLibraryDownloadInfo() {}
|
||||
|
||||
// types
|
||||
typedef std::shared_ptr<MojangLibraryDownloadInfo> Ptr;
|
||||
@ -57,20 +57,20 @@ struct MojangAssetIndexInfo : public MojangDownloadInfo
|
||||
{
|
||||
}
|
||||
|
||||
MojangAssetIndexInfo(QString id)
|
||||
MojangAssetIndexInfo(QString id_)
|
||||
{
|
||||
this->id = id;
|
||||
this->id = id_;
|
||||
// HACK: ignore assets from other version files than Minecraft
|
||||
// workaround for stupid assets issue caused by amazon:
|
||||
// https://www.theregister.co.uk/2017/02/28/aws_is_awol_as_s3_goes_haywire/
|
||||
if(id == "legacy")
|
||||
if(id_ == "legacy")
|
||||
{
|
||||
url = "https://piston-meta.mojang.com/mc/assets/legacy/c0fd82e8ce9fbc93119e40d96d5a4e62cfa3f729/legacy.json";
|
||||
}
|
||||
// HACK
|
||||
else
|
||||
{
|
||||
url = "https://s3.amazonaws.com/Minecraft.Download/indexes/" + id + ".json";
|
||||
url = "https://s3.amazonaws.com/Minecraft.Download/indexes/" + id_ + ".json";
|
||||
}
|
||||
known = false;
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch
|
||||
}
|
||||
|
||||
LibraryPtr OneSixVersionFormat::plusJarModFromJson(
|
||||
ProblemContainer & problems,
|
||||
[[maybe_unused]] ProblemContainer & problems,
|
||||
const QJsonObject &libObj,
|
||||
const QString &filename,
|
||||
const QString &originalName
|
||||
|
@ -226,11 +226,11 @@ static bool loadPackProfile(PackProfile * parent, const QString & filename, cons
|
||||
auto orderArray = Json::requireArray(obj.value("components"));
|
||||
for(auto item: orderArray)
|
||||
{
|
||||
auto obj = Json::requireObject(item, "Component must be an object.");
|
||||
container.append(componentFromJsonV1(parent, componentJsonPattern, obj));
|
||||
auto comp_obj = Json::requireObject(item, "Component must be an object.");
|
||||
container.append(componentFromJsonV1(parent, componentJsonPattern, comp_obj));
|
||||
}
|
||||
}
|
||||
catch (const JSONValidationError &err)
|
||||
catch ([[maybe_unused]] const JSONValidationError &err)
|
||||
{
|
||||
qCritical() << "Couldn't parse" << componentsFile.fileName() << ": bad file format";
|
||||
container.clear();
|
||||
@ -415,7 +415,7 @@ void PackProfile::insertComponent(size_t index, ComponentPtr component)
|
||||
qWarning() << "Attempt to add a component that is already present!";
|
||||
return;
|
||||
}
|
||||
beginInsertRows(QModelIndex(), index, index);
|
||||
beginInsertRows(QModelIndex(), static_cast<int>(index), static_cast<int>(index));
|
||||
d->components.insert(index, component);
|
||||
d->componentIndex[id] = component;
|
||||
endInsertRows();
|
||||
@ -428,7 +428,7 @@ void PackProfile::componentDataChanged()
|
||||
auto objPtr = qobject_cast<Component *>(sender());
|
||||
if(!objPtr)
|
||||
{
|
||||
qWarning() << "PackProfile got dataChenged signal from a non-Component!";
|
||||
qWarning() << "PackProfile got dataChanged signal from a non-Component!";
|
||||
return;
|
||||
}
|
||||
if(objPtr->getID() == "net.minecraft") {
|
||||
@ -446,7 +446,7 @@ void PackProfile::componentDataChanged()
|
||||
}
|
||||
index++;
|
||||
}
|
||||
qWarning() << "PackProfile got dataChenged signal from a Component which does not belong to it!";
|
||||
qWarning() << "PackProfile got dataChanged signal from a Component which does not belong to it!";
|
||||
}
|
||||
|
||||
bool PackProfile::remove(const int index)
|
||||
@ -533,9 +533,9 @@ ComponentPtr PackProfile::getComponent(const QString &id)
|
||||
return (*iter);
|
||||
}
|
||||
|
||||
ComponentPtr PackProfile::getComponent(int index)
|
||||
ComponentPtr PackProfile::getComponent(size_t index)
|
||||
{
|
||||
if(index < 0 || index >= d->components.size())
|
||||
if(index >= static_cast<size_t>(d->components.size()))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
@ -616,7 +616,7 @@ QVariant PackProfile::data(const QModelIndex &index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool PackProfile::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
bool PackProfile::setData(const QModelIndex& index, [[maybe_unused]] const QVariant& value, int role)
|
||||
{
|
||||
if (!index.isValid() || index.row() < 0 || index.row() >= rowCount(index.parent()))
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ public:
|
||||
ComponentPtr getComponent(const QString &id);
|
||||
|
||||
/// get the profile component by index
|
||||
ComponentPtr getComponent(int index);
|
||||
ComponentPtr getComponent(size_t index);
|
||||
|
||||
/// Add the component to the internal list of patches
|
||||
// todo(merged): is this the best approach
|
||||
|
@ -92,7 +92,7 @@ bool readOverrideOrders(QString path, PatchOrder &order)
|
||||
order.append(Json::requireString(item));
|
||||
}
|
||||
}
|
||||
catch (const JSONValidationError &err)
|
||||
catch ([[maybe_unused]] const JSONValidationError &err)
|
||||
{
|
||||
qCritical() << "Couldn't parse" << orderFile.fileName() << ": bad file format";
|
||||
qWarning() << "Ignoring overriden order";
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
Rule(RuleAction result) : m_result(result)
|
||||
{
|
||||
}
|
||||
virtual ~Rule() {};
|
||||
virtual ~Rule() {}
|
||||
virtual QJsonObject toJson() = 0;
|
||||
RuleAction apply(const Library *parent, const RuntimeContext & runtimeContext)
|
||||
{
|
||||
|
@ -408,13 +408,13 @@ optional<QString> read_string (nbt::value& parent, const char * name)
|
||||
auto & tag_str = namedValue.as<nbt::tag_string>();
|
||||
return QString::fromStdString(tag_str.get());
|
||||
}
|
||||
catch (const std::out_of_range &e)
|
||||
catch ([[maybe_unused]] const std::out_of_range &e)
|
||||
{
|
||||
// fallback for old world formats
|
||||
qWarning() << "String NBT tag" << name << "could not be found.";
|
||||
return nullopt;
|
||||
}
|
||||
catch (const std::bad_cast &e)
|
||||
catch ([[maybe_unused]] const std::bad_cast &e)
|
||||
{
|
||||
// type mismatch
|
||||
qWarning() << "NBT tag" << name << "could not be converted to string.";
|
||||
@ -434,13 +434,13 @@ optional<int64_t> read_long (nbt::value& parent, const char * name)
|
||||
auto & tag_str = namedValue.as<nbt::tag_long>();
|
||||
return tag_str.get();
|
||||
}
|
||||
catch (const std::out_of_range &e)
|
||||
catch ([[maybe_unused]] const std::out_of_range &e)
|
||||
{
|
||||
// fallback for old world formats
|
||||
qWarning() << "Long NBT tag" << name << "could not be found.";
|
||||
return nullopt;
|
||||
}
|
||||
catch (const std::bad_cast &e)
|
||||
catch ([[maybe_unused]] const std::bad_cast &e)
|
||||
{
|
||||
// type mismatch
|
||||
qWarning() << "NBT tag" << name << "could not be converted to long.";
|
||||
@ -460,13 +460,13 @@ optional<int> read_int (nbt::value& parent, const char * name)
|
||||
auto & tag_str = namedValue.as<nbt::tag_int>();
|
||||
return tag_str.get();
|
||||
}
|
||||
catch (const std::out_of_range &e)
|
||||
catch ([[maybe_unused]] const std::out_of_range &e)
|
||||
{
|
||||
// fallback for old world formats
|
||||
qWarning() << "Int NBT tag" << name << "could not be found.";
|
||||
return nullopt;
|
||||
}
|
||||
catch (const std::bad_cast &e)
|
||||
catch ([[maybe_unused]] const std::bad_cast &e)
|
||||
{
|
||||
// type mismatch
|
||||
qWarning() << "NBT tag" << name << "could not be converted to int.";
|
||||
|
@ -278,7 +278,7 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
QVariant WorldList::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant WorldList::headerData(int section, [[maybe_unused]] Qt::Orientation orientation, int role) const
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
@ -320,7 +320,6 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QStringList WorldList::mimeTypes() const
|
||||
@ -373,7 +372,7 @@ QMimeData *WorldList::mimeData(const QModelIndexList &indexes) const
|
||||
if (indexes.size() == 0)
|
||||
return new QMimeData();
|
||||
|
||||
QList<World> worlds;
|
||||
QList<World> worlds_;
|
||||
for(auto idx : indexes)
|
||||
{
|
||||
if(idx.column() != 0)
|
||||
@ -381,13 +380,13 @@ QMimeData *WorldList::mimeData(const QModelIndexList &indexes) const
|
||||
int row = idx.row();
|
||||
if (row < 0 || row >= this->worlds.size())
|
||||
continue;
|
||||
worlds.append(this->worlds[row]);
|
||||
worlds_.append(this->worlds[row]);
|
||||
}
|
||||
if(!worlds.size())
|
||||
if(!worlds_.size())
|
||||
{
|
||||
return new QMimeData();
|
||||
}
|
||||
return new WorldMimeData(worlds);
|
||||
return new WorldMimeData(worlds_);
|
||||
}
|
||||
|
||||
Qt::ItemFlags WorldList::flags(const QModelIndex &index) const
|
||||
|
@ -310,7 +310,7 @@ bool AccountData::resumeStateFromV2(QJsonObject data) {
|
||||
QJsonObject profileObject = profileVal.toObject();
|
||||
QString id = profileObject.value("id").toString("");
|
||||
QString name = profileObject.value("name").toString("");
|
||||
bool legacy = profileObject.value("legacy").toBool(false);
|
||||
bool legacy_ = profileObject.value("legacy").toBool(false);
|
||||
if (id.isEmpty() || name.isEmpty())
|
||||
{
|
||||
qWarning() << "Unable to load a profile" << name << "because it was missing an ID or a name.";
|
||||
@ -319,7 +319,7 @@ bool AccountData::resumeStateFromV2(QJsonObject data) {
|
||||
if(id == currentProfile) {
|
||||
currentProfileIndex = index;
|
||||
}
|
||||
profiles.append({id, name, legacy});
|
||||
profiles.append({id, name, legacy_});
|
||||
}
|
||||
auto & profile = profiles[currentProfileIndex];
|
||||
|
||||
|
@ -369,7 +369,7 @@ QVariant AccountList::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
QVariant AccountList::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant AccountList::headerData(int section, [[maybe_unused]] Qt::Orientation orientation, int role) const
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
|
@ -107,16 +107,16 @@ bool parseXTokenResponse(QByteArray & data, Katabasis::Token &output, QString na
|
||||
if(!item.isObject()) {
|
||||
continue;
|
||||
}
|
||||
auto obj = item.toObject();
|
||||
if(obj.contains("uhs")) {
|
||||
auto obj_ = item.toObject();
|
||||
if(obj_.contains("uhs")) {
|
||||
foundUHS = true;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
// consume all 'display claims' ... whatever that means
|
||||
for(auto iter = obj.begin(); iter != obj.end(); iter++) {
|
||||
for(auto iter = obj_.begin(); iter != obj_.end(); iter++) {
|
||||
QString claim;
|
||||
if(!getString(obj.value(iter.key()), claim)) {
|
||||
if(!getString(obj_.value(iter.key()), claim)) {
|
||||
qWarning() << "display claim " << iter.key() << " is not a string...";
|
||||
return false;
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ void EntitlementsStep::rehydrate() {
|
||||
}
|
||||
|
||||
void EntitlementsStep::onRequestDone(
|
||||
QNetworkReply::NetworkError error,
|
||||
[[maybe_unused]] QNetworkReply::NetworkError error,
|
||||
QByteArray data,
|
||||
QList<QNetworkReply::RawHeaderPair> headers
|
||||
[[maybe_unused]] QList<QNetworkReply::RawHeaderPair> headers
|
||||
) {
|
||||
auto requestor = qobject_cast<AuthRequest *>(QObject::sender());
|
||||
requestor->deleteLater();
|
||||
|
@ -112,12 +112,11 @@ QVariant GameOptions::data(const QModelIndex& index, int role) const
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int GameOptions::rowCount(const QModelIndex&) const
|
||||
{
|
||||
return contents.size();
|
||||
return static_cast<int>(contents.size());
|
||||
}
|
||||
|
||||
int GameOptions::columnCount(const QModelIndex&) const
|
||||
|
@ -54,7 +54,7 @@ LauncherPartLaunch::LauncherPartLaunch(LaunchTask *parent) : LaunchStep(parent)
|
||||
if (instance->settings()->get("CloseAfterLaunch").toBool())
|
||||
{
|
||||
std::shared_ptr<QMetaObject::Connection> connection{new QMetaObject::Connection};
|
||||
*connection = connect(&m_process, &LoggedProcess::log, this, [=](QStringList lines, MessageLevel::Enum level) {
|
||||
*connection = connect(&m_process, &LoggedProcess::log, this, [=](QStringList lines, [[maybe_unused]] MessageLevel::Enum level) {
|
||||
qDebug() << lines;
|
||||
if (lines.filter(QRegularExpression(".*Setting user.+", QRegularExpression::CaseInsensitiveOption)).length() != 0)
|
||||
{
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
auto metaurl() const -> QString;
|
||||
|
||||
/** Get the intneral path to the mod's icon file*/
|
||||
QString iconPath() const { return m_local_details.icon_file; };
|
||||
QString iconPath() const { return m_local_details.icon_file; }
|
||||
/** Gets the icon of the mod, converted to a QPixmap for drawing, and scaled to size. */
|
||||
[[nodiscard]] QPixmap icon(QSize size, Qt::AspectRatioMode mode = Qt::AspectRatioMode::IgnoreAspectRatio) const;
|
||||
/** Thread-safe. */
|
||||
|
@ -59,17 +59,17 @@ struct ModLicense {
|
||||
ModLicense() {}
|
||||
|
||||
ModLicense(const QString license) {
|
||||
// FIXME: come up with a better license parseing.
|
||||
// FIXME: come up with a better license parsing.
|
||||
// handle SPDX identifiers? https://spdx.org/licenses/
|
||||
auto parts = license.split(' ');
|
||||
QStringList notNameParts = {};
|
||||
for (auto part : parts) {
|
||||
auto url = QUrl(part);
|
||||
auto _url = QUrl(part);
|
||||
if (part.startsWith("(") && part.endsWith(")"))
|
||||
url = QUrl(part.mid(1, part.size() - 2));
|
||||
_url = QUrl(part.mid(1, part.size() - 2));
|
||||
|
||||
if (url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty()) {
|
||||
this->url = url.toString();
|
||||
if (_url.isValid() && !_url.scheme().isEmpty() && !_url.host().isEmpty()) {
|
||||
this->url = _url.toString();
|
||||
notNameParts.append(part);
|
||||
continue;
|
||||
}
|
||||
@ -89,12 +89,9 @@ struct ModLicense {
|
||||
|
||||
}
|
||||
|
||||
ModLicense(const QString name, const QString id, const QString url, const QString description) {
|
||||
this->name = name;
|
||||
this->id = id;
|
||||
this->url = url;
|
||||
this->description = description;
|
||||
}
|
||||
ModLicense(const QString& name_, const QString& id_, const QString& url_, const QString& description_)
|
||||
: name(name_), id(id_), url(url_), description(description_)
|
||||
{}
|
||||
|
||||
ModLicense(const ModLicense& other)
|
||||
: name(other.name)
|
||||
|
@ -140,7 +140,7 @@ QVariant ModFolderModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
QVariant ModFolderModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant ModFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientation orientation, int role) const
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
|
@ -447,7 +447,7 @@ QVariant ResourceFolderModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
bool ResourceFolderModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
bool ResourceFolderModel::setData(const QModelIndex& index, [[maybe_unused]] const QVariant& value, int role)
|
||||
{
|
||||
int row = index.row();
|
||||
if (row < 0 || row >= rowCount(index.parent()) || !index.isValid())
|
||||
@ -471,7 +471,7 @@ bool ResourceFolderModel::setData(const QModelIndex& index, const QVariant& valu
|
||||
return false;
|
||||
}
|
||||
|
||||
QVariant ResourceFolderModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant ResourceFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientation orientation, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
@ -588,7 +588,7 @@ SortType ResourceFolderModel::columnToSortKey(size_t column) const
|
||||
}
|
||||
|
||||
/* Standard Proxy Model for createFilterProxyModel */
|
||||
[[nodiscard]] bool ResourceFolderModel::ProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
[[nodiscard]] bool ResourceFolderModel::ProxyModel::filterAcceptsRow(int source_row, [[maybe_unused]] const QModelIndex& source_parent) const
|
||||
{
|
||||
auto* model = qobject_cast<ResourceFolderModel*>(sourceModel());
|
||||
if (!model)
|
||||
|
@ -49,8 +49,8 @@ class ResourceFolderModel : public QAbstractListModel {
|
||||
bool stopWatching(const QStringList paths);
|
||||
|
||||
/* Helper methods for subclasses, using a predetermined list of paths. */
|
||||
virtual bool startWatching() { return startWatching({ m_dir.absolutePath() }); };
|
||||
virtual bool stopWatching() { return stopWatching({ m_dir.absolutePath() }); };
|
||||
virtual bool startWatching() { return startWatching({ m_dir.absolutePath() }); }
|
||||
virtual bool stopWatching() { return stopWatching({ m_dir.absolutePath() }); }
|
||||
|
||||
/** Given a path in the system, install that resource, moving it to its place in the
|
||||
* instance file hierarchy.
|
||||
@ -78,7 +78,7 @@ class ResourceFolderModel : public QAbstractListModel {
|
||||
/** Creates a new parse task, if needed, for 'res' and start it.*/
|
||||
virtual void resolveResource(Resource* res);
|
||||
|
||||
[[nodiscard]] size_t size() const { return m_resources.size(); };
|
||||
[[nodiscard]] qsizetype size() const { return m_resources.size(); }
|
||||
[[nodiscard]] bool empty() const { return size() == 0; }
|
||||
[[nodiscard]] Resource& at(int index) { return *m_resources.at(index); }
|
||||
[[nodiscard]] Resource const& at(int index) const { return *m_resources.at(index); }
|
||||
@ -97,10 +97,10 @@ class ResourceFolderModel : public QAbstractListModel {
|
||||
|
||||
/* Basic columns */
|
||||
enum Columns { ACTIVE_COLUMN = 0, NAME_COLUMN, DATE_COLUMN, NUM_COLUMNS };
|
||||
QStringList columnNames(bool translated = true) const { return translated ? m_column_names_translated : m_column_names; };
|
||||
QStringList columnNames(bool translated = true) const { return translated ? m_column_names_translated : m_column_names; }
|
||||
|
||||
[[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : static_cast<int>(size()); }
|
||||
[[nodiscard]] int columnCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : NUM_COLUMNS; };
|
||||
[[nodiscard]] int rowCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : size(); }
|
||||
[[nodiscard]] int columnCount(const QModelIndex& parent = {}) const override { return parent.isValid() ? 0 : NUM_COLUMNS; }
|
||||
|
||||
[[nodiscard]] Qt::DropActions supportedDropActions() const override;
|
||||
|
||||
@ -159,7 +159,7 @@ class ResourceFolderModel : public QAbstractListModel {
|
||||
* This task should load and parse all heavy info needed by a resource, such as parsing a manifest. It gets executed
|
||||
* in the background, so it slowly updates the UI as tasks get done.
|
||||
*/
|
||||
[[nodiscard]] virtual Task* createParseTask(Resource&) { return nullptr; };
|
||||
[[nodiscard]] virtual Task* createParseTask(Resource&) { return nullptr; }
|
||||
|
||||
/** Standard implementation of the model update logic.
|
||||
*
|
||||
@ -224,15 +224,15 @@ class ResourceFolderModel : public QAbstractListModel {
|
||||
|
||||
/* A macro to define useful functions to handle Resource* -> T* more easily on derived classes */
|
||||
#define RESOURCE_HELPERS(T) \
|
||||
[[nodiscard]] T* operator[](size_t index) \
|
||||
[[nodiscard]] T* operator[](int index) \
|
||||
{ \
|
||||
return static_cast<T*>(m_resources[index].get()); \
|
||||
} \
|
||||
[[nodiscard]] T* at(size_t index) \
|
||||
[[nodiscard]] T* at(int index) \
|
||||
{ \
|
||||
return static_cast<T*>(m_resources[index].get()); \
|
||||
} \
|
||||
[[nodiscard]] const T* at(size_t index) const \
|
||||
[[nodiscard]] const T* at(int index) const \
|
||||
{ \
|
||||
return static_cast<const T*>(m_resources.at(index).get()); \
|
||||
} \
|
||||
|
@ -128,7 +128,7 @@ QVariant ResourcePackFolderModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
QVariant ResourcePackFolderModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant ResourcePackFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientation orientation, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
@ -165,7 +165,6 @@ QVariant ResourcePackFolderModel::headerData(int section, Qt::Orientation orient
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
int ResourcePackFolderModel::columnCount(const QModelIndex& parent) const
|
||||
|
@ -115,7 +115,7 @@ QVariant TexturePackFolderModel::data(const QModelIndex& index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
QVariant TexturePackFolderModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
QVariant TexturePackFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientation orientation, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
|
@ -61,7 +61,7 @@ GetModDependenciesTask::GetModDependenciesTask(QObject* parent,
|
||||
if (auto meta = mod->metadata(); meta)
|
||||
m_mods.append(meta);
|
||||
prepare();
|
||||
};
|
||||
}
|
||||
|
||||
void GetModDependenciesTask::prepare()
|
||||
{
|
||||
@ -130,7 +130,7 @@ QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion
|
||||
c_dependencies.append(getOverride(ver_dep, providerName));
|
||||
}
|
||||
return c_dependencies;
|
||||
};
|
||||
}
|
||||
|
||||
Task::Ptr GetModDependenciesTask::getProjectInfoTask(std::shared_ptr<PackDependency> pDep)
|
||||
{
|
||||
@ -181,7 +181,7 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
||||
ResourceAPI::DependencySearchArgs args = { dep, m_version, m_loaderType };
|
||||
ResourceAPI::DependencySearchCallbacks callbacks;
|
||||
|
||||
callbacks.on_succeed = [dep, provider, pDep, level, this](auto& doc, auto& pack) {
|
||||
callbacks.on_succeed = [dep, provider, pDep, level, this](auto& doc, [[maybe_unused]] auto& pack) {
|
||||
try {
|
||||
QJsonArray arr;
|
||||
if (dep.version.length() != 0 && doc.isObject()) {
|
||||
@ -215,27 +215,27 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
|
||||
return;
|
||||
}
|
||||
if (level == 0) {
|
||||
qWarning() << "Dependency cycle exeeded";
|
||||
qWarning() << "Dependency cycle exceeded";
|
||||
return;
|
||||
}
|
||||
if (dep.addonId.toString().isEmpty() && !pDep->version.addonId.toString().isEmpty()) {
|
||||
pDep->pack->addonId = pDep->version.addonId;
|
||||
auto dep = getOverride({ pDep->version.addonId, pDep->dependency.type }, provider.name);
|
||||
if (dep.addonId != pDep->version.addonId) {
|
||||
auto dep_ = getOverride({ pDep->version.addonId, pDep->dependency.type }, provider.name);
|
||||
if (dep_.addonId != pDep->version.addonId) {
|
||||
removePack(pDep->version.addonId);
|
||||
addTask(prepareDependencyTask(dep, provider.name, level));
|
||||
addTask(prepareDependencyTask(dep_, provider.name, level));
|
||||
} else
|
||||
addTask(getProjectInfoTask(pDep));
|
||||
}
|
||||
for (auto dep : getDependenciesForVersion(pDep->version, provider.name)) {
|
||||
addTask(prepareDependencyTask(dep, provider.name, level - 1));
|
||||
for (auto dep_ : getDependenciesForVersion(pDep->version, provider.name)) {
|
||||
addTask(prepareDependencyTask(dep_, provider.name, level - 1));
|
||||
}
|
||||
};
|
||||
|
||||
auto version = provider.api->getDependencyVersion(std::move(args), std::move(callbacks));
|
||||
tasks->addTask(version);
|
||||
return tasks;
|
||||
};
|
||||
}
|
||||
|
||||
void GetModDependenciesTask::removePack(const QVariant addonId)
|
||||
{
|
||||
|
@ -104,14 +104,15 @@ ModDetails ReadMCModTOML(QByteArray contents)
|
||||
#if TOML_EXCEPTIONS
|
||||
try {
|
||||
tomlData = toml::parse(contents.toStdString());
|
||||
} catch (const toml::parse_error& err) {
|
||||
} catch ([[maybe_unused]] const toml::parse_error& err) {
|
||||
return {};
|
||||
}
|
||||
#else
|
||||
tomlData = toml::parse(contents.toStdString());
|
||||
if (!tomlData) {
|
||||
toml::parse_result result = toml::parse(contents.toStdString());
|
||||
if (!result) {
|
||||
return {};
|
||||
}
|
||||
tomlData = result.table();
|
||||
#endif
|
||||
|
||||
// array defined by [[mods]]
|
||||
@ -151,8 +152,8 @@ ModDetails ReadMCModTOML(QByteArray contents)
|
||||
QString authors = "";
|
||||
if (auto authorsDatum = tomlData["authors"].as_string()) {
|
||||
authors = QString::fromStdString(authorsDatum->get());
|
||||
} else if (auto authorsDatum = (*modsTable)["authors"].as_string()) {
|
||||
authors = QString::fromStdString(authorsDatum->get());
|
||||
} else if (auto authorsDatumMods = (*modsTable)["authors"].as_string()) {
|
||||
authors = QString::fromStdString(authorsDatumMods->get());
|
||||
}
|
||||
if (!authors.isEmpty()) {
|
||||
details.authors.append(authors);
|
||||
@ -161,8 +162,8 @@ ModDetails ReadMCModTOML(QByteArray contents)
|
||||
QString homeurl = "";
|
||||
if (auto homeurlDatum = tomlData["displayURL"].as_string()) {
|
||||
homeurl = QString::fromStdString(homeurlDatum->get());
|
||||
} else if (auto homeurlDatum = (*modsTable)["displayURL"].as_string()) {
|
||||
homeurl = QString::fromStdString(homeurlDatum->get());
|
||||
} else if (auto homeurlDatumMods = (*modsTable)["displayURL"].as_string()) {
|
||||
homeurl = QString::fromStdString(homeurlDatumMods->get());
|
||||
}
|
||||
// fix up url.
|
||||
if (!homeurl.isEmpty() && !homeurl.startsWith("http://") && !homeurl.startsWith("https://") && !homeurl.startsWith("ftp://")) {
|
||||
@ -173,16 +174,16 @@ ModDetails ReadMCModTOML(QByteArray contents)
|
||||
QString issueTrackerURL = "";
|
||||
if (auto issueTrackerURLDatum = tomlData["issueTrackerURL"].as_string()) {
|
||||
issueTrackerURL = QString::fromStdString(issueTrackerURLDatum->get());
|
||||
} else if (auto issueTrackerURLDatum = (*modsTable)["issueTrackerURL"].as_string()) {
|
||||
issueTrackerURL = QString::fromStdString(issueTrackerURLDatum->get());
|
||||
} else if (auto issueTrackerURLDatumMods = (*modsTable)["issueTrackerURL"].as_string()) {
|
||||
issueTrackerURL = QString::fromStdString(issueTrackerURLDatumMods->get());
|
||||
}
|
||||
details.issue_tracker = issueTrackerURL;
|
||||
|
||||
QString license = "";
|
||||
if (auto licenseDatum = tomlData["license"].as_string()) {
|
||||
license = QString::fromStdString(licenseDatum->get());
|
||||
} else if (auto licenseDatum =(*modsTable)["license"].as_string()) {
|
||||
license = QString::fromStdString(licenseDatum->get());
|
||||
} else if (auto licenseDatumMods =(*modsTable)["license"].as_string()) {
|
||||
license = QString::fromStdString(licenseDatumMods->get());
|
||||
}
|
||||
if (!license.isEmpty())
|
||||
details.licenses.append(ModLicense(license));
|
||||
@ -190,8 +191,8 @@ ModDetails ReadMCModTOML(QByteArray contents)
|
||||
QString logoFile = "";
|
||||
if (auto logoFileDatum = tomlData["logoFile"].as_string()) {
|
||||
logoFile = QString::fromStdString(logoFileDatum->get());
|
||||
} else if (auto logoFileDatum =(*modsTable)["logoFile"].as_string()) {
|
||||
logoFile = QString::fromStdString(logoFileDatum->get());
|
||||
} else if (auto logoFileDatumMods =(*modsTable)["logoFile"].as_string()) {
|
||||
logoFile = QString::fromStdString(logoFileDatumMods->get());
|
||||
}
|
||||
details.icon_file = logoFile;
|
||||
|
||||
@ -458,7 +459,7 @@ bool process(Mod& mod, ProcessingLevel level)
|
||||
}
|
||||
}
|
||||
|
||||
bool processZIP(Mod& mod, ProcessingLevel level)
|
||||
bool processZIP(Mod& mod, [[maybe_unused]] ProcessingLevel level)
|
||||
{
|
||||
ModDetails details;
|
||||
|
||||
@ -591,7 +592,7 @@ bool processZIP(Mod& mod, ProcessingLevel level)
|
||||
return false; // no valid mod found in archive
|
||||
}
|
||||
|
||||
bool processFolder(Mod& mod, ProcessingLevel level)
|
||||
bool processFolder(Mod& mod, [[maybe_unused]] ProcessingLevel level)
|
||||
{
|
||||
ModDetails details;
|
||||
|
||||
@ -612,7 +613,7 @@ bool processFolder(Mod& mod, ProcessingLevel level)
|
||||
return false; // no valid mcmod.info file found
|
||||
}
|
||||
|
||||
bool processLitemod(Mod& mod, ProcessingLevel level)
|
||||
bool processLitemod(Mod& mod, [[maybe_unused]] ProcessingLevel level)
|
||||
{
|
||||
ModDetails details;
|
||||
|
||||
|
@ -45,7 +45,7 @@ CapeChange::CapeChange(QObject *parent, QString token, QString cape)
|
||||
{
|
||||
}
|
||||
|
||||
void CapeChange::setCape(QString& cape) {
|
||||
void CapeChange::setCape([[maybe_unused]] QString& cape) {
|
||||
QNetworkRequest request(QUrl("https://api.minecraftservices.com/minecraft/profile/capes/active"));
|
||||
auto requestString = QString("{\"capeId\":\"%1\"}").arg(m_capeId);
|
||||
request.setRawHeader("Authorization", QString("Bearer %1").arg(m_token).toLocal8Bit());
|
||||
|
@ -113,7 +113,7 @@ struct IndexedPack {
|
||||
ExtraPackData extraData;
|
||||
|
||||
// For internal use, not provided by APIs
|
||||
[[nodiscard]] bool isVersionSelected(size_t index) const
|
||||
[[nodiscard]] bool isVersionSelected(int index) const
|
||||
{
|
||||
if (!versionsLoaded)
|
||||
return false;
|
||||
@ -144,9 +144,12 @@ inline auto getOverrideDeps() -> QList<OverrideDep>
|
||||
|
||||
{ "qvIfYCYJ", "P7dR8mSH", "API", ModPlatform::ResourceProvider::MODRINTH },
|
||||
{ "lwVhp9o5", "Ha28R6CL", "KotlinLibraries", ModPlatform::ResourceProvider::MODRINTH } };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
QString getMetaURL(ResourceProvider provider, QVariant projectID);
|
||||
|
||||
|
||||
} // namespace ModPlatform
|
||||
|
||||
Q_DECLARE_METATYPE(ModPlatform::IndexedPack)
|
||||
|
@ -128,28 +128,28 @@ class ResourceAPI {
|
||||
public slots:
|
||||
[[nodiscard]] virtual Task::Ptr searchProjects(SearchArgs&&, SearchCallbacks&&) const
|
||||
{
|
||||
qWarning() << "TODO";
|
||||
qWarning() << "TODO: ResourceAPI::searchProjects";
|
||||
return nullptr;
|
||||
}
|
||||
[[nodiscard]] virtual Task::Ptr getProject(QString addonId, std::shared_ptr<QByteArray> response) const
|
||||
[[nodiscard]] virtual Task::Ptr getProject([[maybe_unused]] QString addonId, [[maybe_unused]] std::shared_ptr<QByteArray> response) const
|
||||
{
|
||||
qWarning() << "TODO";
|
||||
qWarning() << "TODO: ResourceAPI::getProject";
|
||||
return nullptr;
|
||||
}
|
||||
[[nodiscard]] virtual Task::Ptr getProjects(QStringList addonIds, std::shared_ptr<QByteArray> response) const
|
||||
[[nodiscard]] virtual Task::Ptr getProjects([[maybe_unused]] QStringList addonIds, [[maybe_unused]] std::shared_ptr<QByteArray> response) const
|
||||
{
|
||||
qWarning() << "TODO";
|
||||
qWarning() << "TODO: ResourceAPI::getProjects";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]] virtual Task::Ptr getProjectInfo(ProjectInfoArgs&&, ProjectInfoCallbacks&&) const
|
||||
{
|
||||
qWarning() << "TODO";
|
||||
qWarning() << "TODO: ResourceAPI::getProjectInfo";
|
||||
return nullptr;
|
||||
}
|
||||
[[nodiscard]] virtual Task::Ptr getProjectVersions(VersionSearchArgs&&, VersionSearchCallbacks&&) const
|
||||
{
|
||||
qWarning() << "TODO";
|
||||
qWarning() << "TODO: ResourceAPI::getProjectVersions";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ void Flame::FileResolvingTask::netJobFinished()
|
||||
auto& out = m_toProcess.files[fileid];
|
||||
try {
|
||||
out.parseFromObject(Json::requireObject(file));
|
||||
} catch (const JSONValidationError& e) {
|
||||
} catch ([[maybe_unused]] const JSONValidationError& e) {
|
||||
qDebug() << "Blocked mod on curseforge" << out.fileName;
|
||||
auto hash = out.hash;
|
||||
if (!hash.isEmpty()) {
|
||||
|
@ -54,7 +54,7 @@ void FlameMod::loadURLs(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
||||
pack.extraDataLoaded = true;
|
||||
}
|
||||
|
||||
void FlameMod::loadBody(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
||||
void FlameMod::loadBody(ModPlatform::IndexedPack& pack, [[maybe_unused]] QJsonObject& obj)
|
||||
{
|
||||
pack.extraData.body = api.getModDescription(pack.addonId.toInt());
|
||||
|
||||
@ -75,7 +75,7 @@ static QString enumToString(int hash_algorithm)
|
||||
|
||||
void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
||||
QJsonArray& arr,
|
||||
const shared_qobject_ptr<QNetworkAccessManager>& network,
|
||||
[[maybe_unused]] const shared_qobject_ptr<QNetworkAccessManager>& network,
|
||||
const BaseInstance* inst)
|
||||
{
|
||||
QVector<ModPlatform::IndexedVersion> unsortedVersions;
|
||||
@ -193,4 +193,5 @@ ModPlatform::IndexedVersion FlameMod::loadDependencyVersions(const ModPlatform::
|
||||
};
|
||||
std::sort(versions.begin(), versions.end(), orderSortPredicate);
|
||||
return versions.front();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -147,4 +147,5 @@ Task::Ptr NetworkResourceAPI::getDependencyVersion(DependencySearchArgs&& args,
|
||||
});
|
||||
|
||||
return netJob;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -174,10 +174,10 @@ void ModrinthPackExportTask::parseApiResponse(const std::shared_ptr<QByteArray>
|
||||
if (obj.isEmpty())
|
||||
continue;
|
||||
|
||||
const QJsonArray files = obj["files"].toArray();
|
||||
if (auto fileIter = std::find_if(files.begin(), files.end(),
|
||||
const QJsonArray files_array = obj["files"].toArray();
|
||||
if (auto fileIter = std::find_if(files_array.begin(), files_array.end(),
|
||||
[&iterator](const QJsonValue& file) { return file["hashes"]["sha512"] == iterator.value(); });
|
||||
fileIter != files.end()) {
|
||||
fileIter != files_array.end()) {
|
||||
// map the file to the url
|
||||
resolvedFiles[iterator.key()] =
|
||||
ResolvedFile{ fileIter->toObject()["hashes"].toObject()["sha1"].toString(), iterator.value(),
|
||||
@ -260,6 +260,7 @@ QByteArray ModrinthPackExportTask::generateIndex()
|
||||
out["dependencies"] = dependencies;
|
||||
}
|
||||
|
||||
|
||||
QJsonArray filesOut;
|
||||
for (auto iterator = resolvedFiles.constBegin(); iterator != resolvedFiles.constEnd(); iterator++) {
|
||||
QJsonObject fileOut;
|
||||
@ -287,6 +288,7 @@ QByteArray ModrinthPackExportTask::generateIndex()
|
||||
hashes["sha512"] = value.sha512;
|
||||
fileOut["hashes"] = hashes;
|
||||
|
||||
|
||||
fileOut["fileSize"] = value.size;
|
||||
filesOut << fileOut;
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ void Modrinth::loadExtraPackData(ModPlatform::IndexedPack& pack, QJsonObject& ob
|
||||
|
||||
void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
|
||||
QJsonArray& arr,
|
||||
const shared_qobject_ptr<QNetworkAccessManager>& network,
|
||||
[[maybe_unused]] const shared_qobject_ptr<QNetworkAccessManager>& network,
|
||||
const BaseInstance* inst)
|
||||
{
|
||||
QVector<ModPlatform::IndexedVersion> unsortedVersions;
|
||||
@ -218,7 +218,7 @@ auto Modrinth::loadIndexedPackVersion(QJsonObject& obj, QString preferred_hash_t
|
||||
return {};
|
||||
}
|
||||
|
||||
auto Modrinth::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion
|
||||
auto Modrinth::loadDependencyVersions([[maybe_unused]] const ModPlatform::Dependency& m, QJsonArray& arr) -> ModPlatform::IndexedVersion
|
||||
{
|
||||
QVector<ModPlatform::IndexedVersion> versions;
|
||||
|
||||
@ -235,4 +235,4 @@ auto Modrinth::loadDependencyVersions(const ModPlatform::Dependency& m, QJsonArr
|
||||
};
|
||||
std::sort(versions.begin(), versions.end(), orderSortPredicate);
|
||||
return versions.length() != 0 ? versions.front() : ModPlatform::IndexedVersion();
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,8 @@ auto intEntry(toml::table table, QString entry_name) -> int
|
||||
return node.value_or(0);
|
||||
}
|
||||
|
||||
auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version) -> Mod
|
||||
auto V1::createModFormat([[maybe_unused]] QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version)
|
||||
-> Mod
|
||||
{
|
||||
Mod mod;
|
||||
|
||||
@ -114,7 +115,7 @@ auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, Mo
|
||||
return mod;
|
||||
}
|
||||
|
||||
auto V1::createModFormat(QDir& index_dir, ::Mod& internal_mod, QString slug) -> Mod
|
||||
auto V1::createModFormat(QDir& index_dir, [[maybe_unused]] ::Mod& internal_mod, QString slug) -> Mod
|
||||
{
|
||||
// Try getting metadata if it exists
|
||||
Mod mod{ getIndexForMod(index_dir, slug) };
|
||||
@ -241,12 +242,13 @@ auto V1::getIndexForMod(QDir& index_dir, QString slug) -> Mod
|
||||
return {};
|
||||
}
|
||||
#else
|
||||
table = toml::parse_file(StringUtils::toStdString(index_dir.absoluteFilePath(real_fname)));
|
||||
if (!table) {
|
||||
toml::parse_result result = toml::parse_file(StringUtils::toStdString(index_dir.absoluteFilePath(real_fname)));
|
||||
if (!result) {
|
||||
qWarning() << QString("Could not open file %1!").arg(normalized_fname);
|
||||
qWarning() << "Reason: " << QString(table.error().what());
|
||||
qWarning() << "Reason: " << result.error().description();
|
||||
return {};
|
||||
}
|
||||
table = result.table();
|
||||
#endif
|
||||
|
||||
// index_file.close();
|
||||
|
@ -26,7 +26,12 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings, const QString &instName, const QString &instIcon, const QString &stagingPath, const QString &minecraftVersion, const bool isSolder)
|
||||
void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings,
|
||||
const QString& instName,
|
||||
const QString& instIcon,
|
||||
const QString& stagingPath,
|
||||
const QString& minecraftVersion,
|
||||
[[maybe_unused]] const bool isSolder)
|
||||
{
|
||||
QString minecraftPath = FS::PathCombine(stagingPath, ".minecraft");
|
||||
QString configPath = FS::PathCombine(stagingPath, "instance.cfg");
|
||||
@ -151,17 +156,16 @@ void Technic::TechnicPackProcessor::run(SettingsObjectPtr globalSettings, const
|
||||
{
|
||||
QJsonDocument doc = Json::requireDocument(data);
|
||||
QJsonObject root = Json::requireObject(doc, "version.json");
|
||||
QString minecraftVersion = Json::ensureString(root, "inheritsFrom", QString(), "");
|
||||
if (minecraftVersion.isEmpty())
|
||||
{
|
||||
QString packMinecraftVersion = Json::ensureString(root, "inheritsFrom", QString(), "");
|
||||
if (packMinecraftVersion.isEmpty()) {
|
||||
if (fmlMinecraftVersion.isEmpty())
|
||||
{
|
||||
emit failed(tr("Could not understand \"version.json\":\ninheritsFrom is missing"));
|
||||
return;
|
||||
}
|
||||
minecraftVersion = fmlMinecraftVersion;
|
||||
packMinecraftVersion = fmlMinecraftVersion;
|
||||
}
|
||||
components->setComponentVersion("net.minecraft", minecraftVersion, true);
|
||||
components->setComponentVersion("net.minecraft", packMinecraftVersion, true);
|
||||
for (auto library: Json::ensureArray(root, "libraries", {}))
|
||||
{
|
||||
if (!library.isObject())
|
||||
|
@ -31,8 +31,8 @@ struct HeaderPair {
|
||||
|
||||
class HeaderProxy {
|
||||
public:
|
||||
HeaderProxy(){};
|
||||
virtual ~HeaderProxy(){};
|
||||
HeaderProxy(){}
|
||||
virtual ~HeaderProxy(){}
|
||||
|
||||
public:
|
||||
virtual QList<HeaderPair> headers(const QNetworkRequest& request) const = 0;
|
||||
|
@ -74,7 +74,7 @@ class MetaEntry {
|
||||
auto getMaximumAge() -> qint64 { return m_max_age; }
|
||||
void setMaximumAge(qint64 age) { m_max_age = age; }
|
||||
|
||||
bool isExpired(qint64 offset) { return !m_is_eternal && (m_current_age >= m_max_age - offset); };
|
||||
bool isExpired(qint64 offset) { return !m_is_eternal && (m_current_age >= m_max_age - offset); }
|
||||
|
||||
protected:
|
||||
QString m_baseId;
|
||||
|
@ -47,7 +47,7 @@
|
||||
class NetAction : public Task {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
explicit NetAction() : Task(){};
|
||||
explicit NetAction() : Task(){}
|
||||
|
||||
public:
|
||||
using Ptr = shared_qobject_ptr<NetAction>;
|
||||
@ -76,7 +76,7 @@ class NetAction : public Task {
|
||||
qCritical() << "Certificate in question:\n" << cert.toText();
|
||||
i++;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public slots:
|
||||
void startAction(shared_qobject_ptr<QNetworkAccessManager> network)
|
||||
@ -86,7 +86,7 @@ class NetAction : public Task {
|
||||
}
|
||||
|
||||
protected:
|
||||
void executeTask() override{};
|
||||
void executeTask() override{}
|
||||
|
||||
public:
|
||||
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||
|
@ -52,7 +52,7 @@ namespace Net {
|
||||
class NetRequest : public NetAction {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
explicit NetRequest() : NetAction(){};
|
||||
explicit NetRequest() : NetAction(){}
|
||||
|
||||
public:
|
||||
using Ptr = shared_qobject_ptr<class NetRequest>;
|
||||
@ -62,7 +62,7 @@ class NetRequest : public NetAction {
|
||||
public:
|
||||
~NetRequest() override = default;
|
||||
|
||||
void init() override{};
|
||||
void init() override{}
|
||||
|
||||
public:
|
||||
void addValidator(Validator* v);
|
||||
|
@ -40,8 +40,9 @@ namespace Net {
|
||||
class Validator
|
||||
{
|
||||
public: /* con/des */
|
||||
Validator() {};
|
||||
virtual ~Validator() {};
|
||||
Validator() {}
|
||||
|
||||
virtual ~Validator() {}
|
||||
|
||||
public: /* methods */
|
||||
virtual bool init(QNetworkRequest & request) = 0;
|
||||
|
@ -42,8 +42,8 @@ inline QString childValue(const QDomElement& element, const QString& childName,
|
||||
QDomNodeList nodes = element.elementsByTagName(childName);
|
||||
if (nodes.count() > 0)
|
||||
{
|
||||
QDomElement element = nodes.at(0).toElement();
|
||||
return element.text();
|
||||
QDomElement elem = nodes.at(0).toElement();
|
||||
return elem.text();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -51,7 +51,7 @@ inline QString childValue(const QDomElement& element, const QString& childName,
|
||||
}
|
||||
}
|
||||
|
||||
bool NewsEntry::fromXmlElement(const QDomElement& element, NewsEntry* entry, QString* errorMsg)
|
||||
bool NewsEntry::fromXmlElement(const QDomElement& element, NewsEntry* entry, [[maybe_unused]] QString* errorMsg)
|
||||
{
|
||||
QString title = childValue(element, "title", tr("Untitled"));
|
||||
QString content = childValue(element, "content", tr("No content."));
|
||||
@ -62,4 +62,3 @@ bool NewsEntry::fromXmlElement(const QDomElement& element, NewsEntry* entry, QSt
|
||||
entry->link = link;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,6 @@ public:
|
||||
typedef std::shared_ptr<IPathMatcher> Ptr;
|
||||
|
||||
public:
|
||||
virtual ~IPathMatcher(){};
|
||||
virtual ~IPathMatcher() {}
|
||||
virtual bool matches(const QString &string) const = 0;
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
class RegexpMatcher : public IPathMatcher
|
||||
{
|
||||
public:
|
||||
virtual ~RegexpMatcher() {};
|
||||
virtual ~RegexpMatcher() {}
|
||||
RegexpMatcher(const QString ®exp)
|
||||
{
|
||||
m_regexp.setPattern(regexp);
|
||||
|
@ -82,7 +82,7 @@ void ImgurAlbumCreation::executeTask()
|
||||
connect(rep, &QNetworkReply::sslErrors, this, &ImgurAlbumCreation::sslErrors);
|
||||
}
|
||||
|
||||
void ImgurAlbumCreation::downloadError(QNetworkReply::NetworkError error)
|
||||
void ImgurAlbumCreation::downloadError([[maybe_unused]] QNetworkReply::NetworkError error)
|
||||
{
|
||||
qDebug() << m_reply->errorString();
|
||||
m_state = State::Failed;
|
||||
|
@ -97,7 +97,7 @@ void ImgurUpload::executeTask()
|
||||
connect(rep, &QNetworkReply::sslErrors, this, &ImgurUpload::sslErrors);
|
||||
}
|
||||
|
||||
void ImgurUpload::downloadError(QNetworkReply::NetworkError error)
|
||||
void ImgurUpload::downloadError([[maybe_unused]] QNetworkReply::NetworkError error)
|
||||
{
|
||||
qCritical() << "ImgurUpload failed with error" << m_reply->errorString() << "Server reply:\n" << m_reply->readAll();
|
||||
if(finished)
|
||||
|
@ -171,7 +171,7 @@ void ConcurrentTask::subTaskSucceeded(Task::Ptr task)
|
||||
startNext();
|
||||
}
|
||||
|
||||
void ConcurrentTask::subTaskFailed(Task::Ptr task, const QString& msg)
|
||||
void ConcurrentTask::subTaskFailed(Task::Ptr task, [[maybe_unused]] const QString& msg)
|
||||
{
|
||||
m_done.insert(task.get(), task);
|
||||
m_failed.insert(task.get(), task);
|
||||
|
@ -53,7 +53,7 @@ class ConcurrentTask : public Task {
|
||||
|
||||
bool canAbort() const override { return true; }
|
||||
|
||||
inline auto isMultiStep() const -> bool override { return totalSize() > 1; };
|
||||
inline auto isMultiStep() const -> bool override { return totalSize() > 1; }
|
||||
auto getStepProgress() const -> TaskStepProgressList override;
|
||||
|
||||
void addTask(Task::Ptr task);
|
||||
@ -80,7 +80,7 @@ class ConcurrentTask : public Task {
|
||||
|
||||
protected:
|
||||
// NOTE: This is not thread-safe.
|
||||
[[nodiscard]] unsigned int totalSize() const { return m_queue.size() + m_doing.size() + m_done.size(); }
|
||||
[[nodiscard]] unsigned int totalSize() const { return static_cast<unsigned int>(m_queue.size() + m_doing.size() + m_done.size()); }
|
||||
|
||||
enum class Operation { ADDED, REMOVED, CHANGED };
|
||||
void updateStepProgress(TaskStepProgress const& changed_progress, Operation);
|
||||
|
@ -64,19 +64,20 @@ struct TaskStepProgress {
|
||||
QString status = "";
|
||||
QString details = "";
|
||||
TaskStepState state = TaskStepState::Waiting;
|
||||
|
||||
TaskStepProgress() {
|
||||
this->uid = QUuid::createUuid();
|
||||
}
|
||||
TaskStepProgress(QUuid uid) {
|
||||
this->uid = uid;
|
||||
}
|
||||
|
||||
TaskStepProgress(QUuid uid_): uid(uid_) {}
|
||||
|
||||
bool isDone() const { return (state == TaskStepState::Failed) || (state == TaskStepState::Succeeded); }
|
||||
void update(qint64 current, qint64 total) {
|
||||
void update(qint64 new_current, qint64 new_total) {
|
||||
this->old_current = this->current;
|
||||
this->old_total = this->total;
|
||||
|
||||
this->current = current;
|
||||
this->total = total;
|
||||
this->current = new_current;
|
||||
this->total = new_total;
|
||||
this->state = TaskStepState::Running;
|
||||
}
|
||||
};
|
||||
@ -155,7 +156,7 @@ class Task : public QObject, public QRunnable {
|
||||
void run() override { start(); }
|
||||
|
||||
virtual void start();
|
||||
virtual bool abort() { if(canAbort()) emitAborted(); return canAbort(); };
|
||||
virtual bool abort() { if(canAbort()) emitAborted(); return canAbort(); }
|
||||
|
||||
void setAbortable(bool can_abort) { m_can_abort = can_abort; emit abortStatusChanged(can_abort); }
|
||||
|
||||
|
@ -34,7 +34,7 @@ void JProfiler::profilerStarted()
|
||||
emit readyToLaunch(tr("Listening on port: %1").arg(listeningPort));
|
||||
}
|
||||
|
||||
void JProfiler::profilerFinished(int exit, QProcess::ExitStatus status)
|
||||
void JProfiler::profilerFinished([[maybe_unused]] int exit, QProcess::ExitStatus status)
|
||||
{
|
||||
if (status == QProcess::CrashExit)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ void JVisualVM::profilerStarted()
|
||||
emit readyToLaunch(tr("JVisualVM started"));
|
||||
}
|
||||
|
||||
void JVisualVM::profilerFinished(int exit, QProcess::ExitStatus status)
|
||||
void JVisualVM::profilerFinished([[maybe_unused]] int exit, QProcess::ExitStatus status)
|
||||
{
|
||||
if (status == QProcess::CrashExit)
|
||||
{
|
||||
|
@ -334,7 +334,7 @@ POTranslator::~POTranslator()
|
||||
delete d;
|
||||
}
|
||||
|
||||
QString POTranslator::translate(const char* context, const char* sourceText, const char* disambiguation, int n) const
|
||||
QString POTranslator::translate(const char* context, const char* sourceText, const char* disambiguation, [[maybe_unused]] int n) const
|
||||
{
|
||||
if(disambiguation)
|
||||
{
|
||||
|
@ -268,14 +268,11 @@ void readIndex(const QString & path, QMap<QString, Language>& languages)
|
||||
try
|
||||
{
|
||||
data = FS::read(path);
|
||||
}
|
||||
catch (const Exception &e)
|
||||
{
|
||||
} catch ([[maybe_unused]] const Exception& e) {
|
||||
qCritical() << "Translations Download Failed: index file not readable";
|
||||
return;
|
||||
}
|
||||
|
||||
int index = 1;
|
||||
try
|
||||
{
|
||||
auto toplevel_doc = Json::requireDocument(data);
|
||||
@ -308,11 +305,8 @@ void readIndex(const QString & path, QMap<QString, Language>& languages)
|
||||
lang.file_size = Json::requireInteger(langObj, "size");
|
||||
|
||||
languages.insert(lang.key, lang);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
catch (Json::JsonException & e)
|
||||
{
|
||||
} catch ([[maybe_unused]] Json::JsonException& e) {
|
||||
qCritical() << "Translations Download Failed: index file could not be parsed as json";
|
||||
}
|
||||
}
|
||||
@ -502,12 +496,12 @@ QVariant TranslationsModel::headerData(int section, Qt::Orientation orientation,
|
||||
return QAbstractListModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
int TranslationsModel::rowCount(const QModelIndex& parent) const
|
||||
int TranslationsModel::rowCount([[maybe_unused]] const QModelIndex& parent) const
|
||||
{
|
||||
return d->m_languages.size();
|
||||
}
|
||||
|
||||
int TranslationsModel::columnCount(const QModelIndex& parent) const
|
||||
int TranslationsModel::columnCount([[maybe_unused]] const QModelIndex& parent) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
@ -514,10 +514,11 @@ void MainWindow::showInstanceContextMenu(const QPoint& pos)
|
||||
|
||||
QAction* actionCreateInstance = new QAction(tr("Create instance"), this);
|
||||
actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());
|
||||
if (!group.isNull()) {
|
||||
QVariantMap data;
|
||||
data["group"] = group;
|
||||
actionCreateInstance->setData(data);
|
||||
if(!group.isNull())
|
||||
{
|
||||
QVariantMap instance_action_data;
|
||||
instance_action_data["group"] = group;
|
||||
actionCreateInstance->setData(instance_action_data);
|
||||
}
|
||||
|
||||
connect(actionCreateInstance, SIGNAL(triggered(bool)), SLOT(on_actionAddInstance_triggered()));
|
||||
@ -525,11 +526,12 @@ void MainWindow::showInstanceContextMenu(const QPoint& pos)
|
||||
actions.prepend(actionSep);
|
||||
actions.prepend(actionVoid);
|
||||
actions.append(actionCreateInstance);
|
||||
if (!group.isNull()) {
|
||||
QAction* actionDeleteGroup = new QAction(tr("Delete group '%1'").arg(group), this);
|
||||
QVariantMap data;
|
||||
data["group"] = group;
|
||||
actionDeleteGroup->setData(data);
|
||||
if(!group.isNull())
|
||||
{
|
||||
QAction *actionDeleteGroup = new QAction(tr("Delete group '%1'").arg(group), this);
|
||||
QVariantMap delete_group_action_data;
|
||||
delete_group_action_data["group"] = group;
|
||||
actionDeleteGroup->setData(delete_group_action_data);
|
||||
connect(actionDeleteGroup, SIGNAL(triggered(bool)), SLOT(deleteGroup()));
|
||||
actions.append(actionDeleteGroup);
|
||||
}
|
||||
@ -744,10 +746,10 @@ void MainWindow::changeActiveAccount()
|
||||
if (sAction->data().type() != QVariant::Type::Int)
|
||||
return;
|
||||
|
||||
QVariant data = sAction->data();
|
||||
QVariant action_data = sAction->data();
|
||||
bool valid = false;
|
||||
int index = data.toInt(&valid);
|
||||
if (!valid) {
|
||||
int index = action_data.toInt(&valid);
|
||||
if(!valid) {
|
||||
index = -1;
|
||||
}
|
||||
auto accounts = APPLICATION->accounts();
|
||||
@ -1060,10 +1062,11 @@ void MainWindow::on_actionChangeInstIcon_triggered()
|
||||
|
||||
void MainWindow::iconUpdated(QString icon)
|
||||
{
|
||||
if (icon == m_currentInstIcon) {
|
||||
auto icon = APPLICATION->icons()->getIcon(m_currentInstIcon);
|
||||
ui->actionChangeInstIcon->setIcon(icon);
|
||||
changeIconButton->setIcon(icon);
|
||||
if (icon == m_currentInstIcon)
|
||||
{
|
||||
auto new_icon = APPLICATION->icons()->getIcon(m_currentInstIcon);
|
||||
ui->actionChangeInstIcon->setIcon(new_icon);
|
||||
changeIconButton->setIcon(new_icon);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1590,7 +1593,7 @@ void MainWindow::startTask(Task* task)
|
||||
task->start();
|
||||
}
|
||||
|
||||
void MainWindow::instanceChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
void MainWindow::instanceChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
if (!current.isValid()) {
|
||||
APPLICATION->settings()->set("SelectedInstance", QString());
|
||||
@ -1725,8 +1728,9 @@ void MainWindow::setInstanceActionsEnabled(bool enabled)
|
||||
ui->actionCreateInstanceShortcut->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void MainWindow::refreshCurrentInstance(bool running)
|
||||
void MainWindow::refreshCurrentInstance([[maybe_unused]] bool running)
|
||||
{
|
||||
auto current = view->selectionModel()->currentIndex();
|
||||
instanceChanged(current, current);
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ void CopyInstanceDialog::on_iconButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void CopyInstanceDialog::on_instNameTextBox_textChanged(const QString& arg1)
|
||||
void CopyInstanceDialog::on_instNameTextBox_textChanged([[maybe_unused]] const QString& arg1)
|
||||
{
|
||||
updateDialogState();
|
||||
}
|
||||
|
@ -195,8 +195,8 @@ void ExportInstanceDialog::loadPackIgnore()
|
||||
if (!ignoreFile.open(QIODevice::ReadOnly)) {
|
||||
return;
|
||||
}
|
||||
auto data = ignoreFile.readAll();
|
||||
auto string = QString::fromUtf8(data);
|
||||
auto ignoreData = ignoreFile.readAll();
|
||||
auto string = QString::fromUtf8(ignoreData);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
proxyModel->setBlockedPaths(string.split('\n', Qt::SkipEmptyParts));
|
||||
#else
|
||||
@ -206,10 +206,10 @@ void ExportInstanceDialog::loadPackIgnore()
|
||||
|
||||
void ExportInstanceDialog::savePackIgnore()
|
||||
{
|
||||
auto data = proxyModel->blockedPaths().toStringList().join('\n').toUtf8();
|
||||
auto ignoreData = proxyModel->blockedPaths().toStringList().join('\n').toUtf8();
|
||||
auto filename = ignoreFileName();
|
||||
try {
|
||||
FS::write(filename, data);
|
||||
FS::write(filename, ignoreData);
|
||||
} catch (const Exception& e) {
|
||||
qWarning() << e.cause();
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ void NewInstanceDialog::on_iconButton_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void NewInstanceDialog::on_instNameTextBox_textChanged(const QString& arg1)
|
||||
void NewInstanceDialog::on_instNameTextBox_textChanged([[maybe_unused]] const QString& arg1)
|
||||
{
|
||||
updateDialogState();
|
||||
}
|
||||
|
@ -167,14 +167,14 @@ void ProfileSetupDialog::checkName(const QString &name) {
|
||||
|
||||
void ProfileSetupDialog::checkFinished(
|
||||
QNetworkReply::NetworkError error,
|
||||
QByteArray data,
|
||||
QList<QNetworkReply::RawHeaderPair> headers
|
||||
QByteArray profileData,
|
||||
[[maybe_unused]] QList<QNetworkReply::RawHeaderPair> headers
|
||||
) {
|
||||
auto requestor = qobject_cast<AuthRequest *>(QObject::sender());
|
||||
requestor->deleteLater();
|
||||
|
||||
if(error == QNetworkReply::NoError) {
|
||||
auto doc = QJsonDocument::fromJson(data);
|
||||
auto doc = QJsonDocument::fromJson(profileData);
|
||||
auto root = doc.object();
|
||||
auto statusValue = root.value("status").toString("INVALID");
|
||||
if(statusValue == "AVAILABLE") {
|
||||
@ -210,11 +210,11 @@ void ProfileSetupDialog::setupProfile(const QString &profileName) {
|
||||
request.setRawHeader("Authorization", QString("Bearer %1").arg(token).toUtf8());
|
||||
|
||||
QString payloadTemplate("{\"profileName\":\"%1\"}");
|
||||
auto data = payloadTemplate.arg(profileName).toUtf8();
|
||||
auto profileData = payloadTemplate.arg(profileName).toUtf8();
|
||||
|
||||
AuthRequest *requestor = new AuthRequest(this);
|
||||
connect(requestor, &AuthRequest::finished, this, &ProfileSetupDialog::setupProfileFinished);
|
||||
requestor->post(request, data);
|
||||
requestor->post(request, profileData);
|
||||
isWorking = true;
|
||||
|
||||
auto button = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||
@ -251,8 +251,8 @@ struct MojangError{
|
||||
|
||||
void ProfileSetupDialog::setupProfileFinished(
|
||||
QNetworkReply::NetworkError error,
|
||||
QByteArray data,
|
||||
QList<QNetworkReply::RawHeaderPair> headers
|
||||
QByteArray errorData,
|
||||
[[maybe_unused]] QList<QNetworkReply::RawHeaderPair> headers
|
||||
) {
|
||||
auto requestor = qobject_cast<AuthRequest *>(QObject::sender());
|
||||
requestor->deleteLater();
|
||||
@ -266,7 +266,7 @@ void ProfileSetupDialog::setupProfileFinished(
|
||||
accept();
|
||||
}
|
||||
else {
|
||||
auto parsedError = MojangError::fromJSON(data);
|
||||
auto parsedError = MojangError::fromJSON(errorData);
|
||||
ui->errorLabel->setVisible(true);
|
||||
ui->errorLabel->setText(tr("The server returned the following error:") + "\n\n" + parsedError.errorMessage);
|
||||
qDebug() << parsedError.rawError;
|
||||
|
@ -87,7 +87,7 @@ void ProgressDialog::on_skipButton_clicked(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked);
|
||||
if (ui->skipButton->isEnabled()) // prevent other triggers from aborting
|
||||
task->abort();
|
||||
m_task->abort();
|
||||
}
|
||||
|
||||
ProgressDialog::~ProgressDialog()
|
||||
@ -132,7 +132,7 @@ void ProgressDialog::updateSize(bool recenterParent)
|
||||
|
||||
int ProgressDialog::execWithTask(Task* task)
|
||||
{
|
||||
this->task = task;
|
||||
this->m_task = task;
|
||||
|
||||
if (!task) {
|
||||
qDebug() << "Programmer error: Progress dialog created with null task.";
|
||||
@ -184,8 +184,8 @@ int ProgressDialog::execWithTask(std::unique_ptr<Task>& task)
|
||||
|
||||
bool ProgressDialog::handleImmediateResult(QDialog::DialogCode& result)
|
||||
{
|
||||
if (task->isFinished()) {
|
||||
if (task->wasSuccessful()) {
|
||||
if (m_task->isFinished()) {
|
||||
if (m_task->wasSuccessful()) {
|
||||
result = QDialog::Accepted;
|
||||
} else {
|
||||
result = QDialog::Rejected;
|
||||
@ -197,12 +197,12 @@ bool ProgressDialog::handleImmediateResult(QDialog::DialogCode& result)
|
||||
|
||||
Task* ProgressDialog::getTask()
|
||||
{
|
||||
return task;
|
||||
return m_task;
|
||||
}
|
||||
|
||||
void ProgressDialog::onTaskStarted() {}
|
||||
|
||||
void ProgressDialog::onTaskFailed(QString failure)
|
||||
void ProgressDialog::onTaskFailed([[maybe_unused]] QString failure)
|
||||
{
|
||||
reject();
|
||||
hide();
|
||||
@ -214,13 +214,14 @@ void ProgressDialog::onTaskSucceeded()
|
||||
hide();
|
||||
}
|
||||
|
||||
void ProgressDialog::changeStatus(const QString& status)
|
||||
void ProgressDialog::changeStatus([[maybe_unused]] const QString& status)
|
||||
{
|
||||
ui->globalStatusLabel->setText(task->getStatus());
|
||||
ui->globalStatusLabel->setText(m_task->getStatus());
|
||||
ui->globalStatusLabel->adjustSize();
|
||||
ui->globalStatusDetailsLabel->setText(task->getDetails());
|
||||
ui->globalStatusDetailsLabel->setText(m_task->getDetails());
|
||||
ui->globalStatusDetailsLabel->adjustSize();
|
||||
|
||||
|
||||
updateSize();
|
||||
}
|
||||
|
||||
@ -287,7 +288,7 @@ void ProgressDialog::keyPressEvent(QKeyEvent* e)
|
||||
|
||||
void ProgressDialog::closeEvent(QCloseEvent* e)
|
||||
{
|
||||
if (task && task->isRunning()) {
|
||||
if (m_task && m_task->isRunning()) {
|
||||
e->ignore();
|
||||
} else {
|
||||
QDialog::closeEvent(e);
|
||||
|
@ -98,7 +98,7 @@ private:
|
||||
private:
|
||||
Ui::ProgressDialog *ui;
|
||||
|
||||
Task *task;
|
||||
Task *m_task;
|
||||
|
||||
bool m_is_multi_step = false;
|
||||
QHash<QUuid, SubTaskProgressBar*> taskProgress;
|
||||
|
@ -300,7 +300,7 @@ GetModDependenciesTask::Ptr ModDownloadDialog::getModDependenciesTask()
|
||||
return makeShared<GetModDependenciesTask>(this, m_instance, model, selectedVers);
|
||||
}
|
||||
return nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
ResourcePackDownloadDialog::ResourcePackDownloadDialog(QWidget* parent,
|
||||
const std::shared_ptr<ResourcePackFolderModel>& resource_packs,
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
ReviewMessageBox::ReviewMessageBox(QWidget* parent, QString const& title, QString const& icon)
|
||||
ReviewMessageBox::ReviewMessageBox(QWidget* parent, [[maybe_unused]] QString const& title, [[maybe_unused]] QString const& icon)
|
||||
: QDialog(parent), ui(new Ui::ReviewMessageBox)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -155,15 +155,15 @@ SkinUploadDialog::SkinUploadDialog(MinecraftAccountPtr acct, QWidget *parent)
|
||||
ui->setupUi(this);
|
||||
|
||||
// FIXME: add a model for this, download/refresh the capes on demand
|
||||
auto &data = *acct->accountData();
|
||||
auto &accountData = *acct->accountData();
|
||||
int index = 0;
|
||||
ui->capeCombo->addItem(tr("No Cape"), QVariant());
|
||||
auto currentCape = data.minecraftProfile.currentCape;
|
||||
auto currentCape = accountData.minecraftProfile.currentCape;
|
||||
if(currentCape.isEmpty()) {
|
||||
ui->capeCombo->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
for(auto & cape: data.minecraftProfile.capes) {
|
||||
for(auto & cape: accountData.minecraftProfile.capes) {
|
||||
index++;
|
||||
if(cape.data.size()) {
|
||||
QPixmap capeImage;
|
||||
|
@ -400,7 +400,9 @@ signals:
|
||||
void editingDone();
|
||||
};
|
||||
|
||||
void ListViewDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
void ListViewDelegate::updateEditorGeometry(QWidget* editor,
|
||||
const QStyleOptionViewItem& option,
|
||||
[[maybe_unused]] const QModelIndex& index) const
|
||||
{
|
||||
const int iconSize = 48;
|
||||
QRect textRect = option.rect;
|
||||
@ -412,17 +414,17 @@ void ListViewDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionV
|
||||
void ListViewDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
||||
{
|
||||
auto text = index.data(Qt::EditRole).toString();
|
||||
QTextEdit * realeditor = qobject_cast<NoReturnTextEdit *>(editor);
|
||||
realeditor->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||
realeditor->append(text);
|
||||
realeditor->selectAll();
|
||||
realeditor->document()->clearUndoRedoStacks();
|
||||
QTextEdit* realEditor = qobject_cast<NoReturnTextEdit*>(editor);
|
||||
realEditor->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||
realEditor->append(text);
|
||||
realEditor->selectAll();
|
||||
realEditor->document()->clearUndoRedoStacks();
|
||||
}
|
||||
|
||||
void ListViewDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
|
||||
{
|
||||
QTextEdit * realeditor = qobject_cast<NoReturnTextEdit *>(editor);
|
||||
QString text = realeditor->toPlainText();
|
||||
QTextEdit * realEditor = qobject_cast<NoReturnTextEdit *>(editor);
|
||||
QString text = realEditor->toPlainText();
|
||||
text.replace(QChar('\n'), QChar(' '));
|
||||
text = text.trimmed();
|
||||
// Prevent instance names longer than 128 chars
|
||||
@ -433,7 +435,9 @@ void ListViewDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,
|
||||
}
|
||||
}
|
||||
|
||||
QWidget * ListViewDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
QWidget* ListViewDelegate::createEditor(QWidget* parent,
|
||||
[[maybe_unused]] const QStyleOptionViewItem& option,
|
||||
[[maybe_unused]] const QModelIndex& index) const
|
||||
{
|
||||
auto editor = new NoReturnTextEdit(parent);
|
||||
connect(editor, &NoReturnTextEdit::editingDone, this, &ListViewDelegate::editingDone);
|
||||
|
@ -89,16 +89,18 @@ void InstanceView::setModel(QAbstractItemModel *model)
|
||||
connect(model, &QAbstractItemModel::rowsRemoved, this, &InstanceView::rowsRemoved);
|
||||
}
|
||||
|
||||
void InstanceView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
|
||||
void InstanceView::dataChanged([[maybe_unused]] const QModelIndex& topLeft,
|
||||
[[maybe_unused]] const QModelIndex& bottomRight,
|
||||
[[maybe_unused]] const QVector<int>& roles)
|
||||
{
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
void InstanceView::rowsInserted(const QModelIndex &parent, int start, int end)
|
||||
void InstanceView::rowsInserted([[maybe_unused]] const QModelIndex& parent, [[maybe_unused]] int start, [[maybe_unused]] int end)
|
||||
{
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
|
||||
void InstanceView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
|
||||
void InstanceView::rowsAboutToBeRemoved([[maybe_unused]] const QModelIndex& parent, [[maybe_unused]] int start, [[maybe_unused]] int end)
|
||||
{
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
@ -264,9 +266,9 @@ QString InstanceView::groupNameAt(const QPoint &point)
|
||||
{
|
||||
executeDelayedItemsLayout();
|
||||
|
||||
VisualGroup::HitResults hitresult;
|
||||
auto group = categoryAt(point + offset(), hitresult);
|
||||
if(group && (hitresult & (VisualGroup::HeaderHit | VisualGroup::BodyHit)))
|
||||
VisualGroup::HitResults hitResult;
|
||||
auto group = categoryAt(point + offset(), hitResult);
|
||||
if(group && (hitResult & (VisualGroup::HeaderHit | VisualGroup::BodyHit)))
|
||||
{
|
||||
return group->text;
|
||||
}
|
||||
@ -301,9 +303,9 @@ void InstanceView::mousePressEvent(QMouseEvent *event)
|
||||
m_pressedAlreadySelected = selectionModel()->isSelected(m_pressedIndex);
|
||||
m_pressedPosition = geometryPos;
|
||||
|
||||
VisualGroup::HitResults hitresult;
|
||||
m_pressedCategory = categoryAt(geometryPos, hitresult);
|
||||
if (m_pressedCategory && hitresult & VisualGroup::CheckboxHit)
|
||||
VisualGroup::HitResults hitResult;
|
||||
m_pressedCategory = categoryAt(geometryPos, hitResult);
|
||||
if (m_pressedCategory && hitResult & VisualGroup::CheckboxHit)
|
||||
{
|
||||
setState(m_pressedCategory->collapsed ? ExpandingState : CollapsingState);
|
||||
event->accept();
|
||||
@ -403,10 +405,10 @@ void InstanceView::mouseReleaseEvent(QMouseEvent *event)
|
||||
QPoint geometryPos = event->pos() + offset();
|
||||
QPersistentModelIndex index = indexAt(visualPos);
|
||||
|
||||
VisualGroup::HitResults hitresult;
|
||||
VisualGroup::HitResults hitResult;
|
||||
|
||||
bool click = (index == m_pressedIndex && index.isValid()) ||
|
||||
(m_pressedCategory && m_pressedCategory == categoryAt(geometryPos, hitresult));
|
||||
(m_pressedCategory && m_pressedCategory == categoryAt(geometryPos, hitResult));
|
||||
|
||||
if (click && m_pressedCategory)
|
||||
{
|
||||
@ -499,6 +501,7 @@ void InstanceView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InstanceView::setPaintCat(bool visible)
|
||||
{
|
||||
m_catVisible = visible;
|
||||
@ -508,7 +511,7 @@ void InstanceView::setPaintCat(bool visible)
|
||||
m_catPixmap = QPixmap();
|
||||
}
|
||||
|
||||
void InstanceView::paintEvent(QPaintEvent* event)
|
||||
void InstanceView::paintEvent([[maybe_unused]] QPaintEvent *event)
|
||||
{
|
||||
executeDelayedItemsLayout();
|
||||
|
||||
@ -612,7 +615,7 @@ void InstanceView::paintEvent(QPaintEvent* event)
|
||||
#endif
|
||||
}
|
||||
|
||||
void InstanceView::resizeEvent(QResizeEvent *event)
|
||||
void InstanceView::resizeEvent([[maybe_unused]] QResizeEvent *event)
|
||||
{
|
||||
int newItemsPerRow = calculateItemsPerRow();
|
||||
if(newItemsPerRow != m_currentItemsPerRow)
|
||||
@ -653,7 +656,7 @@ void InstanceView::dragMoveEvent(QDragMoveEvent *event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void InstanceView::dragLeaveEvent(QDragLeaveEvent *event)
|
||||
void InstanceView::dragLeaveEvent([[maybe_unused]] QDragLeaveEvent *event)
|
||||
{
|
||||
executeDelayedItemsLayout();
|
||||
|
||||
@ -678,9 +681,9 @@ void InstanceView::dropEvent(QDropEvent *event)
|
||||
{
|
||||
std::pair<VisualGroup *, VisualGroup::HitResults> dropPos = rowDropPos(event->pos());
|
||||
const VisualGroup *group = dropPos.first;
|
||||
auto hitresult = dropPos.second;
|
||||
auto hitResult = dropPos.second;
|
||||
|
||||
if (hitresult == VisualGroup::HitResult::NoHit)
|
||||
if (hitResult == VisualGroup::HitResult::NoHit)
|
||||
{
|
||||
viewport()->update();
|
||||
return;
|
||||
@ -720,8 +723,8 @@ void InstanceView::startDrag(Qt::DropActions supportedActions)
|
||||
if(indexes.count() == 0)
|
||||
return;
|
||||
|
||||
QMimeData *data = model()->mimeData(indexes);
|
||||
if (!data)
|
||||
QMimeData *mimeData = model()->mimeData(indexes);
|
||||
if (!mimeData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -729,7 +732,7 @@ void InstanceView::startDrag(Qt::DropActions supportedActions)
|
||||
QPixmap pixmap = renderToPixmap(indexes, &rect);
|
||||
QDrag *drag = new QDrag(this);
|
||||
drag->setPixmap(pixmap);
|
||||
drag->setMimeData(data);
|
||||
drag->setMimeData(mimeData);
|
||||
drag->setHotSpot(m_pressedPosition - rect.topLeft());
|
||||
Qt::DropAction defaultDropAction = Qt::IgnoreAction;
|
||||
if (this->defaultDropAction() != Qt::IgnoreAction && (supportedActions & this->defaultDropAction()))
|
||||
@ -856,16 +859,16 @@ QList<std::pair<QRect, QModelIndex>> InstanceView::draggablePaintPairs(const QMo
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool InstanceView::isDragEventAccepted(QDropEvent *event)
|
||||
bool InstanceView::isDragEventAccepted([[maybe_unused]] QDropEvent *event)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::pair<VisualGroup *, VisualGroup::HitResults> InstanceView::rowDropPos(const QPoint &pos)
|
||||
{
|
||||
VisualGroup::HitResults hitresult;
|
||||
auto group = categoryAt(pos + offset(), hitresult);
|
||||
return std::make_pair(group, hitresult);
|
||||
VisualGroup::HitResults hitResult;
|
||||
auto group = categoryAt(pos + offset(), hitResult);
|
||||
return std::make_pair(group, hitResult);
|
||||
}
|
||||
|
||||
QPoint InstanceView::offset() const
|
||||
@ -894,7 +897,7 @@ QRegion InstanceView::visualRegionForSelection(const QItemSelection &selection)
|
||||
return region;
|
||||
}
|
||||
|
||||
QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
|
||||
QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorAction, [[maybe_unused]] Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
auto current = currentIndex();
|
||||
if(!current.isValid())
|
||||
@ -919,23 +922,23 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio
|
||||
{
|
||||
if(row == 0)
|
||||
{
|
||||
int prevgroupindex = group_index-1;
|
||||
while(prevgroupindex >= 0)
|
||||
int prevGroupIndex = group_index-1;
|
||||
while(prevGroupIndex >= 0)
|
||||
{
|
||||
auto prevgroup = m_groups[prevgroupindex];
|
||||
if(prevgroup->collapsed)
|
||||
auto prevGroup = m_groups[prevGroupIndex];
|
||||
if(prevGroup->collapsed)
|
||||
{
|
||||
prevgroupindex--;
|
||||
prevGroupIndex--;
|
||||
continue;
|
||||
}
|
||||
int newRow = prevgroup->numRows() - 1;
|
||||
int newRowSize = prevgroup->rows[newRow].size();
|
||||
int newRow = prevGroup->numRows() - 1;
|
||||
int newRowSize = prevGroup->rows[newRow].size();
|
||||
int newColumn = m_currentCursorColumn;
|
||||
if (m_currentCursorColumn >= newRowSize)
|
||||
{
|
||||
newColumn = newRowSize - 1;
|
||||
}
|
||||
return prevgroup->rows[newRow][newColumn];
|
||||
return prevGroup->rows[newRow][newColumn];
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -955,22 +958,22 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio
|
||||
{
|
||||
if(row == cat->rows.size() - 1)
|
||||
{
|
||||
int nextgroupindex = group_index+1;
|
||||
while (nextgroupindex < m_groups.size())
|
||||
int nextGroupIndex = group_index+1;
|
||||
while (nextGroupIndex < m_groups.size())
|
||||
{
|
||||
auto nextgroup = m_groups[nextgroupindex];
|
||||
if(nextgroup->collapsed)
|
||||
auto nextGroup = m_groups[nextGroupIndex];
|
||||
if(nextGroup->collapsed)
|
||||
{
|
||||
nextgroupindex++;
|
||||
nextGroupIndex++;
|
||||
continue;
|
||||
}
|
||||
int newRowSize = nextgroup->rows[0].size();
|
||||
int newRowSize = nextGroup->rows[0].size();
|
||||
int newColumn = m_currentCursorColumn;
|
||||
if (m_currentCursorColumn >= newRowSize)
|
||||
{
|
||||
newColumn = newRowSize - 1;
|
||||
}
|
||||
return nextgroup->rows[0][newColumn];
|
||||
return nextGroup->rows[0][newColumn];
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1054,7 +1057,7 @@ void InstanceView::scrollTo(const QModelIndex &index, ScrollHint hint)
|
||||
verticalScrollBar()->setValue(verticalScrollToValue(index, rect, hint));
|
||||
}
|
||||
|
||||
int InstanceView::verticalScrollToValue(const QModelIndex &index, const QRect &rect, QListView::ScrollHint hint) const
|
||||
int InstanceView::verticalScrollToValue([[maybe_unused]] const QModelIndex &index, const QRect &rect, QListView::ScrollHint hint) const
|
||||
{
|
||||
const QRect area = viewport()->rect();
|
||||
const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top());
|
||||
|
@ -84,9 +84,8 @@ AccountListPage::AccountListPage(QWidget *parent)
|
||||
|
||||
QItemSelectionModel *selectionModel = ui->listView->selectionModel();
|
||||
|
||||
connect(selectionModel, &QItemSelectionModel::selectionChanged, [this](const QItemSelection &sel, const QItemSelection &dsel) {
|
||||
updateButtonStates();
|
||||
});
|
||||
connect(selectionModel, &QItemSelectionModel::selectionChanged,
|
||||
[this]([[maybe_unused]] const QItemSelection& sel, [[maybe_unused]] const QItemSelection& dsel) { updateButtonStates(); });
|
||||
connect(ui->listView, &VersionListView::customContextMenuRequested, this, &AccountListPage::ShowContextMenu);
|
||||
|
||||
connect(m_accounts.get(), &AccountList::listChanged, this, &AccountListPage::listChanged);
|
||||
|
@ -176,7 +176,7 @@ void JavaPage::on_javaTestBtn_clicked()
|
||||
checker->run();
|
||||
}
|
||||
|
||||
void JavaPage::on_maxMemSpinBox_valueChanged(int i)
|
||||
void JavaPage::on_maxMemSpinBox_valueChanged([[maybe_unused]] int i)
|
||||
{
|
||||
updateThresholds();
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ void ProxyPage::updateCheckboxStuff()
|
||||
ui->proxyAuthBox->setEnabled(enableEditing);
|
||||
}
|
||||
|
||||
void ProxyPage::proxyGroupChanged(QAbstractButton *button)
|
||||
void ProxyPage::proxyGroupChanged([[maybe_unused]] QAbstractButton *button)
|
||||
{
|
||||
updateCheckboxStuff();
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ bool ExternalResourcesPage::current(const QModelIndex& current, const QModelInde
|
||||
return onSelectionChanged(current, previous);
|
||||
}
|
||||
|
||||
bool ExternalResourcesPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
bool ExternalResourcesPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
auto sourceCurrent = m_filterModel->mapToSource(current);
|
||||
int row = sourceCurrent.row();
|
||||
|
@ -491,7 +491,7 @@ void InstanceSettingsPage::changeInstanceAccount(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceSettingsPage::on_maxMemSpinBox_valueChanged(int i)
|
||||
void InstanceSettingsPage::on_maxMemSpinBox_valueChanged([[maybe_unused]] int i)
|
||||
{
|
||||
updateThresholds();
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ bool ModFolderPage::shouldDisplay() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModFolderPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
bool ModFolderPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
auto sourceCurrent = m_filterModel->mapToSource(current);
|
||||
int row = sourceCurrent.row();
|
||||
|
@ -287,23 +287,23 @@ void OtherLogsPage::on_btnClean_clicked()
|
||||
}
|
||||
if(!failed.empty())
|
||||
{
|
||||
QMessageBox *messageBox = new QMessageBox(this);
|
||||
messageBox->setWindowTitle(tr("Error"));
|
||||
QMessageBox *messageBoxFailure = new QMessageBox(this);
|
||||
messageBoxFailure->setWindowTitle(tr("Error"));
|
||||
if(failed.size() > 5)
|
||||
{
|
||||
messageBox->setText(tr("Couldn't delete some files!"));
|
||||
messageBox->setDetailedText(failed.join('\n'));
|
||||
messageBoxFailure->setText(tr("Couldn't delete some files!"));
|
||||
messageBoxFailure->setDetailedText(failed.join('\n'));
|
||||
}
|
||||
else
|
||||
{
|
||||
messageBox->setText(tr("Couldn't delete some files:\n%1").arg(failed.join('\n')));
|
||||
messageBoxFailure->setText(tr("Couldn't delete some files:\n%1").arg(failed.join('\n')));
|
||||
}
|
||||
messageBox->setStandardButtons(QMessageBox::Ok);
|
||||
messageBox->setDefaultButton(QMessageBox::Ok);
|
||||
messageBox->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
messageBox->setIcon(QMessageBox::Critical);
|
||||
messageBox->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
messageBox->exec();
|
||||
messageBoxFailure->setStandardButtons(QMessageBox::Ok);
|
||||
messageBoxFailure->setDefaultButton(QMessageBox::Ok);
|
||||
messageBoxFailure->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
messageBoxFailure->setIcon(QMessageBox::Critical);
|
||||
messageBoxFailure->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||
messageBoxFailure->exec();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ ResourcePackPage::ResourcePackPage(MinecraftInstance* instance, std::shared_ptr<
|
||||
ui->actionViewConfigs->setVisible(false);
|
||||
}
|
||||
|
||||
bool ResourcePackPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
bool ResourcePackPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
auto sourceCurrent = m_filterModel->mapToSource(current);
|
||||
int row = sourceCurrent.row();
|
||||
|
@ -684,7 +684,7 @@ void ServersPage::runningStateChanged(bool running)
|
||||
updateState();
|
||||
}
|
||||
|
||||
void ServersPage::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
void ServersPage::currentChanged(const QModelIndex ¤t, [[maybe_unused]] const QModelIndex &previous)
|
||||
{
|
||||
int nextServer = -1;
|
||||
if (!current.isValid())
|
||||
@ -700,7 +700,7 @@ void ServersPage::currentChanged(const QModelIndex ¤t, const QModelIndex &
|
||||
}
|
||||
|
||||
// WARNING: this is here because currentChanged is not accurate when removing rows. the current item needs to be fixed up after removal.
|
||||
void ServersPage::rowsRemoved(const QModelIndex& parent, int first, int last)
|
||||
void ServersPage::rowsRemoved([[maybe_unused]] const QModelIndex& parent, int first, int last)
|
||||
{
|
||||
if(currentServer < first)
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ TexturePackPage::TexturePackPage(MinecraftInstance* instance, std::shared_ptr<Te
|
||||
ui->actionViewConfigs->setVisible(false);
|
||||
}
|
||||
|
||||
bool TexturePackPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous)
|
||||
bool TexturePackPage::onSelectionChanged(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
auto sourceCurrent = m_filterModel->mapToSource(current);
|
||||
int row = sourceCurrent.row();
|
||||
|
@ -189,7 +189,8 @@ void VersionPage::showContextMenu(const QPoint& pos)
|
||||
delete menu;
|
||||
}
|
||||
|
||||
void VersionPage::packageCurrent(const QModelIndex& current, const QModelIndex& previous)
|
||||
|
||||
void VersionPage::packageCurrent(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
if (!current.isValid()) {
|
||||
ui->frame->clear();
|
||||
@ -459,7 +460,7 @@ void VersionPage::on_actionMinecraftFolder_triggered()
|
||||
DesktopServices::openDirectory(m_inst->gameRoot(), true);
|
||||
}
|
||||
|
||||
void VersionPage::versionCurrent(const QModelIndex& current, const QModelIndex& previous)
|
||||
void VersionPage::versionCurrent(const QModelIndex& current, [[maybe_unused]] const QModelIndex& previous)
|
||||
{
|
||||
currentIdx = current.row();
|
||||
updateButtons(currentIdx);
|
||||
|
@ -353,7 +353,7 @@ void WorldListPage::mceditState(LoggedProcess::State state)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldListPage::worldChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
void WorldListPage::worldChanged([[maybe_unused]] const QModelIndex ¤t, [[maybe_unused]] const QModelIndex &previous)
|
||||
{
|
||||
QModelIndex index = getSelectedWorld();
|
||||
bool enable = index.isValid();
|
||||
|
@ -50,7 +50,7 @@ class UrlValidator : public QValidator
|
||||
public:
|
||||
using QValidator::QValidator;
|
||||
|
||||
State validate(QString &in, int &pos) const
|
||||
State validate(QString &in, [[maybe_unused]] int &pos) const
|
||||
{
|
||||
const QUrl url(in);
|
||||
if (url.isValid() && !url.isRelative() && !url.isEmpty())
|
||||
@ -118,8 +118,8 @@ void ImportPage::updateState()
|
||||
|
||||
if(fi.exists() && (isZip || isMRPack))
|
||||
{
|
||||
QFileInfo fi(url.fileName());
|
||||
dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url,this));
|
||||
QFileInfo file_info(url.fileName());
|
||||
dialog->setSuggestedPack(file_info.completeBaseName(), new InstanceImportTask(url,this));
|
||||
dialog->setSuggestedIcon("default");
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ QHash<int, QByteArray> ResourceModel::roleNames() const
|
||||
return roles;
|
||||
}
|
||||
|
||||
bool ResourceModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
bool ResourceModel::setData(const QModelIndex& index, const QVariant& value, [[maybe_unused]] int role)
|
||||
{
|
||||
int pos = index.row();
|
||||
if (pos >= m_packs.size() || pos < 0 || !index.isValid())
|
||||
@ -310,7 +310,7 @@ std::optional<QIcon> ResourceModel::getIcon(QModelIndex& index, const QUrl& url)
|
||||
#define NEED_FOR_CALLBACK_ASSERT(name) \
|
||||
Q_ASSERT_X(0 != 0, #name, "You NEED to re-implement this if you intend on using the default callbacks.")
|
||||
|
||||
QJsonArray ResourceModel::documentToArray(QJsonDocument& doc) const
|
||||
QJsonArray ResourceModel::documentToArray([[maybe_unused]] QJsonDocument& doc) const
|
||||
{
|
||||
NEED_FOR_CALLBACK_ASSERT("documentToArray");
|
||||
return {};
|
||||
@ -372,7 +372,7 @@ void ResourceModel::searchRequestSucceeded(QJsonDocument& doc)
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void ResourceModel::searchRequestFailed(QString reason, int network_error_code)
|
||||
void ResourceModel::searchRequestFailed([[maybe_unused]] QString reason, int network_error_code)
|
||||
{
|
||||
switch (network_error_code) {
|
||||
default:
|
||||
|
@ -9,7 +9,8 @@
|
||||
namespace ResourceDownload {
|
||||
|
||||
ResourcePackResourceModel::ResourcePackResourceModel(BaseInstance const& base_inst, ResourceAPI* api)
|
||||
: ResourceModel(api), m_base_instance(base_inst){};
|
||||
: ResourceModel(api), m_base_instance(base_inst)
|
||||
{}
|
||||
|
||||
/******** Make data requests ********/
|
||||
|
||||
|
@ -280,7 +280,7 @@ void ResourcePage::updateVersionList()
|
||||
updateSelectionButton();
|
||||
}
|
||||
|
||||
void ResourcePage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
|
||||
void ResourcePage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelIndex prev)
|
||||
{
|
||||
if (!curr.isValid()) {
|
||||
return;
|
||||
@ -307,9 +307,9 @@ void ResourcePage::onSelectionChanged(QModelIndex curr, QModelIndex prev)
|
||||
updateUi();
|
||||
}
|
||||
|
||||
void ResourcePage::onVersionSelectionChanged(QString data)
|
||||
void ResourcePage::onVersionSelectionChanged(QString versionData)
|
||||
{
|
||||
if (data.isNull() || data.isEmpty()) {
|
||||
if (versionData.isNull() || versionData.isEmpty()) {
|
||||
m_selected_version_index = -1;
|
||||
return;
|
||||
}
|
||||
|
@ -97,7 +97,10 @@ class ResourcePage : public QWidget, public BasePage {
|
||||
virtual void openUrl(const QUrl&);
|
||||
|
||||
/** Whether the version is opted out or not. Currently only makes sense in CF. */
|
||||
virtual bool optedOut(ModPlatform::IndexedVersion& ver) const { return false; };
|
||||
virtual bool optedOut(ModPlatform::IndexedVersion& ver) const {
|
||||
Q_UNUSED(ver);
|
||||
return false;
|
||||
};
|
||||
|
||||
public:
|
||||
BaseInstance& m_base_instance;
|
||||
|
@ -9,7 +9,8 @@
|
||||
namespace ResourceDownload {
|
||||
|
||||
ShaderPackResourceModel::ShaderPackResourceModel(BaseInstance const& base_inst, ResourceAPI* api)
|
||||
: ResourceModel(api), m_base_instance(base_inst){};
|
||||
: ResourceModel(api), m_base_instance(base_inst)
|
||||
{}
|
||||
|
||||
/******** Make data requests ********/
|
||||
|
||||
|
@ -116,7 +116,7 @@ QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const
|
||||
return {};
|
||||
}
|
||||
|
||||
bool AtlOptionalModListModel::setData(const QModelIndex &index, const QVariant &value, int role) {
|
||||
bool AtlOptionalModListModel::setData(const QModelIndex &index, [[maybe_unused]] const QVariant &value, int role) {
|
||||
if (role == Qt::CheckStateRole) {
|
||||
auto row = index.row();
|
||||
auto mod = m_mods.at(row);
|
||||
@ -208,7 +208,7 @@ void AtlOptionalModListModel::shareCodeSuccess() {
|
||||
AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
|
||||
}
|
||||
|
||||
void AtlOptionalModListModel::shareCodeFailure(const QString& reason) {
|
||||
void AtlOptionalModListModel::shareCodeFailure([[maybe_unused]] const QString& reason) {
|
||||
m_jobPtr.reset();
|
||||
|
||||
// fixme: plumb in an error message
|
||||
@ -279,16 +279,16 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
|
||||
// if the dependency is 'effectively hidden', then track which mods
|
||||
// depend on it - so we can efficiently disable it when no more dependents
|
||||
// depend on it.
|
||||
auto dependants = m_dependants[dependencyName];
|
||||
auto dependents = m_dependents[dependencyName];
|
||||
|
||||
if (enable) {
|
||||
dependants.append(mod.name);
|
||||
dependents.append(mod.name);
|
||||
}
|
||||
else {
|
||||
dependants.removeAll(mod.name);
|
||||
dependents.removeAll(mod.name);
|
||||
|
||||
// if there are no longer any dependents, let's disable the mod
|
||||
if (dependencyMod.effectively_hidden && dependants.isEmpty()) {
|
||||
if (dependencyMod.effectively_hidden && dependents.isEmpty()) {
|
||||
setMod(dependencyMod, dependencyIndex, false, shouldEmit);
|
||||
}
|
||||
}
|
||||
@ -296,8 +296,8 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
|
||||
|
||||
// disable mods that depend on this one, if disabling
|
||||
if (!enable) {
|
||||
auto dependants = m_dependants[mod.name];
|
||||
for (const auto& dependencyName : dependants) {
|
||||
auto dependents = m_dependents[mod.name];
|
||||
for (const auto& dependencyName : dependents) {
|
||||
auto dependencyIndex = m_index[dependencyName];
|
||||
auto dependencyMod = m_mods.at(dependencyIndex);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user