Move settings lib into the main code, fixing error logging in it.
This commit is contained in:
parent
8b86306d48
commit
18a342ef14
@ -252,11 +252,6 @@ add_definitions(-DLIBUTIL_STATIC)
|
|||||||
add_subdirectory(depends/util)
|
add_subdirectory(depends/util)
|
||||||
include_directories(${LIBUTIL_INCLUDE_DIR})
|
include_directories(${LIBUTIL_INCLUDE_DIR})
|
||||||
|
|
||||||
# Add the settings library.
|
|
||||||
add_definitions(-DLIBSETTINGS_STATIC)
|
|
||||||
add_subdirectory(depends/settings)
|
|
||||||
include_directories(${LIBSETTINGS_INCLUDE_DIR})
|
|
||||||
|
|
||||||
# Add the updater
|
# Add the updater
|
||||||
add_subdirectory(mmc_updater)
|
add_subdirectory(mmc_updater)
|
||||||
|
|
||||||
@ -553,6 +548,18 @@ SET(MULTIMC_SOURCES
|
|||||||
logic/tasks/SequentialTask.h
|
logic/tasks/SequentialTask.h
|
||||||
logic/tasks/SequentialTask.cpp
|
logic/tasks/SequentialTask.cpp
|
||||||
|
|
||||||
|
# Settings
|
||||||
|
logic/settings/INIFile.cpp
|
||||||
|
logic/settings/INIFile.h
|
||||||
|
logic/settings/INISettingsObject.cpp
|
||||||
|
logic/settings/INISettingsObject.h
|
||||||
|
logic/settings/OverrideSetting.cpp
|
||||||
|
logic/settings/OverrideSetting.h
|
||||||
|
logic/settings/Setting.cpp
|
||||||
|
logic/settings/Setting.h
|
||||||
|
logic/settings/SettingsObject.cpp
|
||||||
|
logic/settings/SettingsObject.h
|
||||||
|
|
||||||
# Java related code
|
# Java related code
|
||||||
logic/java/JavaChecker.h
|
logic/java/JavaChecker.h
|
||||||
logic/java/JavaChecker.cpp
|
logic/java/JavaChecker.cpp
|
||||||
@ -698,7 +705,7 @@ add_executable(MultiMC MACOSX_BUNDLE WIN32 main.cpp ${MULTIMC_RCS})
|
|||||||
|
|
||||||
# Link
|
# Link
|
||||||
target_link_libraries(MultiMC MultiMC_common)
|
target_link_libraries(MultiMC MultiMC_common)
|
||||||
target_link_libraries(MultiMC_common xz-embedded unpack200 quazip libUtil libSettings ${MultiMC_LINK_ADDITIONAL_LIBS})
|
target_link_libraries(MultiMC_common xz-embedded unpack200 quazip libUtil ${MultiMC_LINK_ADDITIONAL_LIBS})
|
||||||
qt5_use_modules(MultiMC Core Widgets Network Xml Concurrent ${MultiMC_QT_ADDITIONAL_MODULES})
|
qt5_use_modules(MultiMC Core Widgets Network Xml Concurrent ${MultiMC_QT_ADDITIONAL_MODULES})
|
||||||
qt5_use_modules(MultiMC_common Core Widgets Network Xml Concurrent ${MultiMC_QT_ADDITIONAL_MODULES})
|
qt5_use_modules(MultiMC_common Core Widgets Network Xml Concurrent ${MultiMC_QT_ADDITIONAL_MODULES})
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@
|
|||||||
|
|
||||||
#include "pathutils.h"
|
#include "pathutils.h"
|
||||||
#include "cmdutils.h"
|
#include "cmdutils.h"
|
||||||
#include <inisettingsobject.h>
|
#include "logic/settings/INISettingsObject.h"
|
||||||
#include <setting.h>
|
#include "logic/settings/Setting.h"
|
||||||
#include "logger/QsLog.h"
|
#include "logger/QsLog.h"
|
||||||
#include <logger/QsLogDest.h>
|
#include "logger/QsLogDest.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@ -219,7 +219,7 @@ MultiMC::MultiMC(int &argc, char **argv, bool root_override)
|
|||||||
m_instances.reset(new InstanceList(InstDirSetting->get().toString(), this));
|
m_instances.reset(new InstanceList(InstDirSetting->get().toString(), this));
|
||||||
QLOG_INFO() << "Loading Instances...";
|
QLOG_INFO() << "Loading Instances...";
|
||||||
m_instances->loadList();
|
m_instances->loadList();
|
||||||
connect(InstDirSetting.get(), SIGNAL(settingChanged(const Setting &, QVariant)),
|
connect(InstDirSetting.get(), SIGNAL(SettingChanged(const Setting &, QVariant)),
|
||||||
m_instances.get(), SLOT(on_InstFolderChanged(const Setting &, QVariant)));
|
m_instances.get(), SLOT(on_InstFolderChanged(const Setting &, QVariant)));
|
||||||
|
|
||||||
// and accounts
|
// and accounts
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
project(libSettings)
|
|
||||||
|
|
||||||
# Find Qt
|
|
||||||
find_package(Qt5Core REQUIRED)
|
|
||||||
|
|
||||||
# Include Qt headers.
|
|
||||||
include_directories(${Qt5Base_INCLUDE_DIRS})
|
|
||||||
|
|
||||||
include(UseCXX11)
|
|
||||||
include(Coverage)
|
|
||||||
|
|
||||||
set(LIBSETTINGS_SOURCES
|
|
||||||
libsettings_config.h
|
|
||||||
|
|
||||||
inifile.h
|
|
||||||
inifile.cpp
|
|
||||||
|
|
||||||
settingsobject.h
|
|
||||||
settingsobject.cpp
|
|
||||||
inisettingsobject.h
|
|
||||||
inisettingsobject.cpp
|
|
||||||
|
|
||||||
setting.h
|
|
||||||
setting.cpp
|
|
||||||
overridesetting.h
|
|
||||||
overridesetting.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# Set the include dir path.
|
|
||||||
set(LIBSETTINGS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE)
|
|
||||||
|
|
||||||
# Static link!
|
|
||||||
add_definitions(-DLIBSETTINGS_STATIC)
|
|
||||||
|
|
||||||
add_definitions(-DLIBSETTINGS_LIBRARY)
|
|
||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
||||||
|
|
||||||
add_library(libSettings STATIC ${LIBSETTINGS_SOURCES})
|
|
||||||
qt5_use_modules(libSettings Core)
|
|
||||||
target_link_libraries(libSettings)
|
|
@ -1,29 +0,0 @@
|
|||||||
/* Copyright 2013 MultiMC Contributors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
|
||||||
|
|
||||||
#ifdef LIBSETTINGS_STATIC
|
|
||||||
#define LIBSETTINGS_EXPORT
|
|
||||||
#else
|
|
||||||
#ifdef LIBSETTINGS_LIBRARY
|
|
||||||
#define LIBSETTINGS_EXPORT Q_DECL_EXPORT
|
|
||||||
#else
|
|
||||||
#define LIBSETTINGS_EXPORT Q_DECL_IMPORT
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include "logic/tools/BaseProfiler.h"
|
#include "logic/tools/BaseProfiler.h"
|
||||||
|
|
||||||
#include <settingsobject.h>
|
#include "logic/settings/SettingsObject.h"
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include "PageDialog.h"
|
#include "PageDialog.h"
|
||||||
#include "gui/Platform.h"
|
#include "gui/Platform.h"
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
#include <settingsobject.h>
|
#include "logic/settings/SettingsObject.h"
|
||||||
|
|
||||||
#include <gui/widgets/IconLabel.h>
|
#include <gui/widgets/IconLabel.h>
|
||||||
#include <gui/widgets/PageContainer.h>
|
#include <gui/widgets/PageContainer.h>
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <settingsobject.h>
|
#include "logic/settings/SettingsObject.h"
|
||||||
|
|
||||||
#include "PageContainer_p.h"
|
#include "PageContainer_p.h"
|
||||||
#include <gui/widgets/IconLabel.h>
|
#include <gui/widgets/IconLabel.h>
|
||||||
|
@ -21,9 +21,9 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
|
||||||
#include "inisettingsobject.h"
|
#include "logic/settings/INISettingsObject.h"
|
||||||
#include "setting.h"
|
#include "logic/settings/Setting.h"
|
||||||
#include "overridesetting.h"
|
#include "logic/settings/OverrideSetting.h"
|
||||||
|
|
||||||
#include "pathutils.h"
|
#include "pathutils.h"
|
||||||
#include <cmdutils.h>
|
#include <cmdutils.h>
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
#include <settingsobject.h>
|
#include "logic/settings/SettingsObject.h"
|
||||||
|
|
||||||
#include "inifile.h"
|
#include "logic/settings/INIFile.h"
|
||||||
#include "logic/BaseVersionList.h"
|
#include "logic/BaseVersionList.h"
|
||||||
#include "logic/auth/MojangAccount.h"
|
#include "logic/auth/MojangAccount.h"
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
#include <settingsobject.h>
|
#include "logic/settings/SettingsObject.h"
|
||||||
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
|
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <inifile.h>
|
|
||||||
#include <inisettingsobject.h>
|
#include "logic/settings/INIFile.h"
|
||||||
#include <setting.h>
|
#include "logic/settings/INISettingsObject.h"
|
||||||
|
#include "logic/settings/Setting.h"
|
||||||
|
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include "logger/QsLog.h"
|
#include "logger/QsLog.h"
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <setting.h>
|
#include <logic/settings/Setting.h>
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <cmdutils.h>
|
#include <cmdutils.h>
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <settingsobject.h>
|
#include "logic/settings/SettingsObject.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "BaseInstance_p.h"
|
#include "BaseInstance_p.h"
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "Mod.h"
|
#include "Mod.h"
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <inifile.h>
|
#include "logic/settings/INIFile.h"
|
||||||
#include "logger/QsLog.h"
|
#include "logger/QsLog.h"
|
||||||
|
|
||||||
Mod::Mod(const QFileInfo &file)
|
Mod::Mod(const QFileInfo &file)
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
|
|
||||||
#include "IconList.h"
|
#include "IconList.h"
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
#include <settingsobject.h>
|
#include "logic/settings/SettingsObject.h"
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
#include <MultiMC.h>
|
#include <MultiMC.h>
|
||||||
#include <setting.h>
|
#include <logic/settings/Setting.h>
|
||||||
|
|
||||||
#define MAX_SIZE 1024
|
#define MAX_SIZE 1024
|
||||||
|
|
||||||
@ -45,8 +45,8 @@ IconList::IconList(QObject *parent) : QAbstractListModel(parent)
|
|||||||
|
|
||||||
auto setting = MMC->settings()->getSetting("IconsDir");
|
auto setting = MMC->settings()->getSetting("IconsDir");
|
||||||
QString path = setting->get().toString();
|
QString path = setting->get().toString();
|
||||||
connect(setting.get(), SIGNAL(settingChanged(const Setting &, QVariant)),
|
connect(setting.get(), SIGNAL(SettingChanged(const Setting &, QVariant)),
|
||||||
SLOT(settingChanged(const Setting &, QVariant)));
|
SLOT(SettingChanged(const Setting &, QVariant)));
|
||||||
directoryChanged(path);
|
directoryChanged(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ void IconList::fileChanged(const QString &path)
|
|||||||
emit iconUpdated(key);
|
emit iconUpdated(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconList::settingChanged(const Setting &setting, QVariant value)
|
void IconList::SettingChanged(const Setting &setting, QVariant value)
|
||||||
{
|
{
|
||||||
if(setting.id() != "IconsDir")
|
if(setting.id() != "IconsDir")
|
||||||
return;
|
return;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <QtGui/QIcon>
|
#include <QtGui/QIcon>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "MMCIcon.h"
|
#include "MMCIcon.h"
|
||||||
#include "setting.h"
|
#include "logic/settings/Setting.h"
|
||||||
|
|
||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ protected
|
|||||||
slots:
|
slots:
|
||||||
void directoryChanged(const QString &path);
|
void directoryChanged(const QString &path);
|
||||||
void fileChanged(const QString &path);
|
void fileChanged(const QString &path);
|
||||||
void settingChanged(const Setting & setting, QVariant value);
|
void SettingChanged(const Setting & setting, QVariant value);
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<QFileSystemWatcher> m_watcher;
|
std::shared_ptr<QFileSystemWatcher> m_watcher;
|
||||||
bool is_watching;
|
bool is_watching;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include <setting.h>
|
#include <logic/settings/Setting.h>
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
|
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "inifile.h"
|
#include "logic/settings/INIFile.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
@ -19,10 +19,8 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
|
|
||||||
#include "libsettings_config.h"
|
|
||||||
|
|
||||||
// Sectionless INI parser (for instance config files)
|
// Sectionless INI parser (for instance config files)
|
||||||
class LIBSETTINGS_EXPORT INIFile : public QMap<QString, QVariant>
|
class INIFile : public QMap<QString, QVariant>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit INIFile();
|
explicit INIFile();
|
@ -13,8 +13,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "inisettingsobject.h"
|
#include "INISettingsObject.h"
|
||||||
#include "setting.h"
|
#include "Setting.h"
|
||||||
|
|
||||||
INISettingsObject::INISettingsObject(const QString &path, QObject *parent)
|
INISettingsObject::INISettingsObject(const QString &path, QObject *parent)
|
||||||
: SettingsObject(parent)
|
: SettingsObject(parent)
|
@ -17,16 +17,14 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "inifile.h"
|
#include "logic/settings/INIFile.h"
|
||||||
|
|
||||||
#include "settingsobject.h"
|
#include "logic/settings/SettingsObject.h"
|
||||||
|
|
||||||
#include "libsettings_config.h"
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief A settings object that stores its settings in an INIFile.
|
* \brief A settings object that stores its settings in an INIFile.
|
||||||
*/
|
*/
|
||||||
class LIBSETTINGS_EXPORT INISettingsObject : public SettingsObject
|
class INISettingsObject : public SettingsObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "overridesetting.h"
|
#include "OverrideSetting.h"
|
||||||
|
|
||||||
OverrideSetting::OverrideSetting(std::shared_ptr<Setting> other)
|
OverrideSetting::OverrideSetting(std::shared_ptr<Setting> other)
|
||||||
: Setting(other->configKeys(), QVariant())
|
: Setting(other->configKeys(), QVariant())
|
@ -18,9 +18,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "setting.h"
|
#include "Setting.h"
|
||||||
|
|
||||||
#include "libsettings_config.h"
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief A setting that 'overrides another.'
|
* \brief A setting that 'overrides another.'
|
||||||
@ -28,7 +26,7 @@
|
|||||||
* The other setting can be (and usually is) a part of a different SettingsObject
|
* The other setting can be (and usually is) a part of a different SettingsObject
|
||||||
* than this one.
|
* than this one.
|
||||||
*/
|
*/
|
||||||
class LIBSETTINGS_EXPORT OverrideSetting : public Setting
|
class OverrideSetting : public Setting
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
@ -13,8 +13,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "setting.h"
|
#include "Setting.h"
|
||||||
#include "settingsobject.h"
|
#include "logic/settings/SettingsObject.h"
|
||||||
|
|
||||||
Setting::Setting(QStringList synonyms, QVariant defVal)
|
Setting::Setting(QStringList synonyms, QVariant defVal)
|
||||||
: QObject(), m_synonyms(synonyms), m_defVal(defVal)
|
: QObject(), m_synonyms(synonyms), m_defVal(defVal)
|
||||||
@ -44,7 +44,7 @@ QVariant Setting::defValue() const
|
|||||||
|
|
||||||
void Setting::set(QVariant value)
|
void Setting::set(QVariant value)
|
||||||
{
|
{
|
||||||
emit settingChanged(*this, value);
|
emit SettingChanged(*this, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Setting::reset()
|
void Setting::reset()
|
@ -20,14 +20,12 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "libsettings_config.h"
|
|
||||||
|
|
||||||
class SettingsObject;
|
class SettingsObject;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class LIBSETTINGS_EXPORT Setting : public QObject
|
class Setting : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -86,7 +84,7 @@ signals:
|
|||||||
* \param setting A reference to the Setting that changed.
|
* \param setting A reference to the Setting that changed.
|
||||||
* \param value This Setting object's new value.
|
* \param value This Setting object's new value.
|
||||||
*/
|
*/
|
||||||
void settingChanged(const Setting &setting, QVariant value);
|
void SettingChanged(const Setting &setting, QVariant value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Signal emitted when this Setting object's value resets to default.
|
* \brief Signal emitted when this Setting object's value resets to default.
|
||||||
@ -98,7 +96,7 @@ public
|
|||||||
slots:
|
slots:
|
||||||
/*!
|
/*!
|
||||||
* \brief Changes the setting's value.
|
* \brief Changes the setting's value.
|
||||||
* This is done by emitting the settingChanged() signal which will then be
|
* This is done by emitting the SettingChanged() signal which will then be
|
||||||
* handled by the SettingsObject object and cause the setting to change.
|
* handled by the SettingsObject object and cause the setting to change.
|
||||||
* \param value The new value.
|
* \param value The new value.
|
||||||
*/
|
*/
|
@ -13,9 +13,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "settingsobject.h"
|
#include "logic/settings/SettingsObject.h"
|
||||||
#include "setting.h"
|
#include "logic/settings/Setting.h"
|
||||||
#include "overridesetting.h"
|
#include "logic/settings/OverrideSetting.h"
|
||||||
|
#include "logger/QsLog.h"
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
@ -32,9 +33,8 @@ std::shared_ptr<Setting> SettingsObject::registerOverride(std::shared_ptr<Settin
|
|||||||
{
|
{
|
||||||
if (contains(original->id()))
|
if (contains(original->id()))
|
||||||
{
|
{
|
||||||
qDebug(QString("Failed to register setting %1. ID already exists.")
|
QLOG_ERROR() << QString("Failed to register setting %1. ID already exists.")
|
||||||
.arg(original->id())
|
.arg(original->id());
|
||||||
.toUtf8());
|
|
||||||
return nullptr; // Fail
|
return nullptr; // Fail
|
||||||
}
|
}
|
||||||
auto override = std::make_shared<OverrideSetting>(original);
|
auto override = std::make_shared<OverrideSetting>(original);
|
||||||
@ -50,9 +50,8 @@ std::shared_ptr<Setting> SettingsObject::registerSetting(QStringList synonyms, Q
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
if (contains(synonyms.first()))
|
if (contains(synonyms.first()))
|
||||||
{
|
{
|
||||||
qDebug(QString("Failed to register setting %1. ID already exists.")
|
QLOG_ERROR() << QString("Failed to register setting %1. ID already exists.")
|
||||||
.arg(synonyms.first())
|
.arg(synonyms.first());
|
||||||
.toUtf8());
|
|
||||||
return nullptr; // Fail
|
return nullptr; // Fail
|
||||||
}
|
}
|
||||||
auto setting = std::make_shared<Setting>(synonyms, defVal);
|
auto setting = std::make_shared<Setting>(synonyms, defVal);
|
||||||
@ -62,28 +61,6 @@ std::shared_ptr<Setting> SettingsObject::registerSetting(QStringList synonyms, Q
|
|||||||
return setting;
|
return setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
bool SettingsObject::registerSetting(Setting *setting)
|
|
||||||
{
|
|
||||||
if (contains(setting->id()))
|
|
||||||
{
|
|
||||||
qDebug(QString("Failed to register setting %1. ID already exists.")
|
|
||||||
.arg(setting->id())
|
|
||||||
.toUtf8());
|
|
||||||
return false; // Fail
|
|
||||||
}
|
|
||||||
|
|
||||||
m_settings.insert(setting->id(), setting);
|
|
||||||
setting->setParent(this); // Take ownership.
|
|
||||||
|
|
||||||
// Connect signals.
|
|
||||||
connectSignals(*setting);
|
|
||||||
|
|
||||||
// qDebug(QString("Registered setting %1.").arg(setting->id()).toUtf8());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
std::shared_ptr<Setting> SettingsObject::getSetting(const QString &id) const
|
std::shared_ptr<Setting> SettingsObject::getSetting(const QString &id) const
|
||||||
{
|
{
|
||||||
// Make sure there is a setting with the given ID.
|
// Make sure there is a setting with the given ID.
|
||||||
@ -104,7 +81,7 @@ bool SettingsObject::set(const QString &id, QVariant value)
|
|||||||
auto setting = getSetting(id);
|
auto setting = getSetting(id);
|
||||||
if (!setting)
|
if (!setting)
|
||||||
{
|
{
|
||||||
qDebug(QString("Error changing setting %1. Setting doesn't exist.").arg(id).toUtf8());
|
QLOG_ERROR() << QString("Error changing setting %1. Setting doesn't exist.").arg(id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -137,10 +114,10 @@ bool SettingsObject::reload()
|
|||||||
|
|
||||||
void SettingsObject::connectSignals(const Setting &setting)
|
void SettingsObject::connectSignals(const Setting &setting)
|
||||||
{
|
{
|
||||||
connect(&setting, SIGNAL(settingChanged(const Setting &, QVariant)),
|
connect(&setting, SIGNAL(SettingChanged(const Setting &, QVariant)),
|
||||||
SLOT(changeSetting(const Setting &, QVariant)));
|
SLOT(changeSetting(const Setting &, QVariant)));
|
||||||
connect(&setting, SIGNAL(settingChanged(const Setting &, QVariant)),
|
connect(&setting, SIGNAL(SettingChanged(const Setting &, QVariant)),
|
||||||
SIGNAL(settingChanged(const Setting &, QVariant)));
|
SIGNAL(SettingChanged(const Setting &, QVariant)));
|
||||||
|
|
||||||
connect(&setting, SIGNAL(settingReset(Setting)), SLOT(resetSetting(const Setting &)));
|
connect(&setting, SIGNAL(settingReset(Setting)), SLOT(resetSetting(const Setting &)));
|
||||||
connect(&setting, SIGNAL(settingReset(Setting)), SIGNAL(settingReset(const Setting &)));
|
connect(&setting, SIGNAL(settingReset(Setting)), SIGNAL(settingReset(const Setting &)));
|
@ -21,8 +21,6 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "libsettings_config.h"
|
|
||||||
|
|
||||||
class Setting;
|
class Setting;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -37,7 +35,7 @@ class Setting;
|
|||||||
*
|
*
|
||||||
* \sa Setting
|
* \sa Setting
|
||||||
*/
|
*/
|
||||||
class LIBSETTINGS_EXPORT SettingsObject : public QObject
|
class SettingsObject : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -123,11 +121,11 @@ signals:
|
|||||||
/*!
|
/*!
|
||||||
* \brief Signal emitted when one of this SettingsObject object's settings changes.
|
* \brief Signal emitted when one of this SettingsObject object's settings changes.
|
||||||
* This is usually just connected directly to each Setting object's
|
* This is usually just connected directly to each Setting object's
|
||||||
* settingChanged() signals.
|
* SettingChanged() signals.
|
||||||
* \param setting A reference to the Setting object that changed.
|
* \param setting A reference to the Setting object that changed.
|
||||||
* \param value The Setting object's new value.
|
* \param value The Setting object's new value.
|
||||||
*/
|
*/
|
||||||
void settingChanged(const Setting &setting, QVariant value);
|
void SettingChanged(const Setting &setting, QVariant value);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Signal emitted when one of this SettingsObject object's settings resets.
|
* \brief Signal emitted when one of this SettingsObject object's settings resets.
|
||||||
@ -142,7 +140,7 @@ slots:
|
|||||||
/*!
|
/*!
|
||||||
* \brief Changes a setting.
|
* \brief Changes a setting.
|
||||||
* This slot is usually connected to each Setting object's
|
* This slot is usually connected to each Setting object's
|
||||||
* settingChanged() signal. The signal is emitted, causing this slot
|
* SettingChanged() signal. The signal is emitted, causing this slot
|
||||||
* to update the setting's value in the config file.
|
* to update the setting's value in the config file.
|
||||||
* \param setting A reference to the Setting object that changed.
|
* \param setting A reference to the Setting object that changed.
|
||||||
* \param value The setting's new value.
|
* \param value The setting's new value.
|
@ -3,7 +3,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "settingsobject.h"
|
#include "logic/settings/SettingsObject.h"
|
||||||
#include "logic/MinecraftProcess.h"
|
#include "logic/MinecraftProcess.h"
|
||||||
#include "logic/BaseInstance.h"
|
#include "logic/BaseInstance.h"
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include "settingsobject.h"
|
#include "logic/settings/SettingsObject.h"
|
||||||
#include "logic/MinecraftProcess.h"
|
#include "logic/MinecraftProcess.h"
|
||||||
#include "logic/BaseInstance.h"
|
#include "logic/BaseInstance.h"
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "settingsobject.h"
|
#include "logic/settings/SettingsObject.h"
|
||||||
#include "logic/BaseInstance.h"
|
#include "logic/BaseInstance.h"
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
|
||||||
#include <settingsobject.h>
|
#include "logic/settings/SettingsObject.h"
|
||||||
|
|
||||||
#define API_VERSION 0
|
#define API_VERSION 0
|
||||||
#define CHANLIST_FORMAT 0
|
#define CHANLIST_FORMAT 0
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
|
|
||||||
#include "depends/settings/settingsobject.h"
|
#include "logic/settings/SettingsObject.h"
|
||||||
#include "depends/settings/setting.h"
|
#include "logic/settings/Setting.h"
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
#include "TestUtil.h"
|
#include "TestUtil.h"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include "TestUtil.h"
|
#include "TestUtil.h"
|
||||||
|
|
||||||
#include "depends/settings/inifile.h"
|
#include "logic/settings/INIFile.h"
|
||||||
|
|
||||||
class IniFileTest : public QObject
|
class IniFileTest : public QObject
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user