Atlas Game Manager
A game manager for f95 and dlsite written in c++
Loading...
Searching...
No Matches
config.hpp File Reference
#include <QObject>
#include <QSettings>
#include <QVariant>
#include <filesystem>
#include "ConfigNotification.hpp"
#include "core/exceptions.hpp"
#include "core/logging/formatters.hpp"
#include "core/logging/logging.hpp"

Go to the source code of this file.

Macros

#define ATLAS_CONFIG_HPP
 
#define STR(val)
 
#define KEY_VALUE(group, name)
 
#define SETTINGS_D(group, name, type, default_value)
 
#define SETTINGS_PATH(group, name, default_path)
 
#define SETTINGS_FILE(group, name, default_path)
 
#define SETTINGS(group, name, type)
 
#define SETTINGS_DE(group, name, type, default_value)
 
#define SETTINGS_GEO(name)
 
#define SETTINGS_STATE(name)
 
#define CONFIG_ATTACH_THIS
 

Enumerations

enum  SCALE_TYPE : int {
  IGNORE_ASPECT_RATIO = Qt::IgnoreAspectRatio , KEEP_ASPECT_RATIO = Qt::KeepAspectRatio , KEEP_ASPECT_RATIO_BY_EXPANDING = Qt::KeepAspectRatioByExpanding , FIT_BLUR_EXPANDING = 3 ,
  FIT_BLUR_STRETCH = 4
}
 
enum  BLUR_TYPE : int { BACKGROUND_ONLY = 0 , FEATHER_IMAGE = 1 , SQUARE = 2 }
 
enum  PreviewType {
  PREVIEW_UNKNOWN = 0 , PREVIEW_BANNER = 1 , PREVIEW_PREVIEW = 2 , PREVIEW_BANNER_WIDE = 3 ,
  PREVIEW_COVER = 4 , PREVIEW_LOGO = 5
}
 
enum  BannerType {
  Error = -1 , Normal = 0 , Wide = 1 , Cover = 2 ,
  Logo = 3 , SENTINEL
}
 
enum  BannerMask { MASK_NORMAL = 1 << 0 , MASK_WIDE = 1 << 1 , MASK_COVER = 1 << 2 , MASK_LOGO = 1 << 3 }
 
enum  LOCATION : int {
  NONE = 0 , TOP_LEFT = 1 , TOP_CENTER = 2 , TOP_RIGHT = 3 ,
  BOTTOM_LEFT = 4 , BOTTOM_CENTER = 5 , BOTTOM_RIGHT = 6
}
 

Functions

QSettings getSettingsObject ()
 

Macro Definition Documentation

◆ ATLAS_CONFIG_HPP

#define ATLAS_CONFIG_HPP

◆ CONFIG_ATTACH_THIS

#define CONFIG_ATTACH_THIS
Value:
connect( \
this, \
&std::remove_pointer_t< decltype( this ) >::reloadConfig )
ConfigNotification & getNotifier()
Definition ConfigNotification.cpp:17

◆ KEY_VALUE

#define KEY_VALUE ( group,
name )
Value:
STR( group ) "/" STR( name )
#define STR(val)
Definition config.hpp:31

◆ SETTINGS

#define SETTINGS ( group,
name,
type )
Value:
namespace config::group::name \
{ \
inline bool hasValue() \
{ \
return getSettingsObject().contains( KEY_VALUE( group, name ) ); \
} \
\
inline type get() \
{ \
return { getSettingsObject().value( KEY_VALUE( group, name ) ).value< type >() }; \
} \
\
inline void set( const type val ) \
{ \
getSettingsObject().setValue( KEY_VALUE( group, name ), val ); \
} \
}
QSettings getSettingsObject()
Definition config.hpp:26
#define KEY_VALUE(group, name)
Definition config.hpp:32

◆ SETTINGS_D

#define SETTINGS_D ( group,
name,
type,
default_value )
Value:
namespace config::group::name \
{ \
inline void set( const type& val ) \
{ \
getSettingsObject().setValue( KEY_VALUE( group, name ), val ); \
} \
\
inline void setDefault() \
{ \
set( default_value ); \
} \
\
inline type get() \
{ \
if ( !getSettingsObject().contains( KEY_VALUE( group, name ) ) ) setDefault(); \
\
if ( const auto settings_obj = getSettingsObject().value( KEY_VALUE( group, name ) ); \
settings_obj.canConvert< type >() ) \
return settings_obj.value< type >(); \
else \
throw SettingsException( "Failed to convert key " KEY_VALUE( group, name ) " to desired type" ); \
} \
}
std::shared_ptr< AtlasData > get(const AtlasID id)
Definition AtlasData.cpp:85

◆ SETTINGS_DE

#define SETTINGS_DE ( group,
name,
type,
default_value )

◆ SETTINGS_FILE

#define SETTINGS_FILE ( group,
name,
default_path )
Value:
SETTINGS_D( group, name, QString, default_path ) \
namespace config::group::name \
{ \
inline std::filesystem::path getPath() \
{ \
const std::filesystem::path filepath { group::name::get().toStdString() }; \
std::filesystem::create_directories( filepath.parent_path() ); \
return std::filesystem::canonical( filepath ); \
} \
\
inline void setPath( const std::filesystem::path path ) \
{ \
group::name::set( QString::fromStdString( path.string() ) ); \
} \
}
#define SETTINGS_D(group, name, type, default_value)
Definition config.hpp:34

◆ SETTINGS_GEO

#define SETTINGS_GEO ( name)
Value:
namespace config::geometry::name \
{ \
inline bool hasValue() \
{ \
return getSettingsObject().contains( KEY_VALUE( geometry, name ) ); \
} \
\
inline QByteArray get() \
{ \
return { getSettingsObject().value( KEY_VALUE( geometry, name ) ).toByteArray() }; \
} \
\
inline void set( const QByteArray val ) \
{ \
getSettingsObject().setValue( KEY_VALUE( geometry, name ), val ); \
} \
}

◆ SETTINGS_PATH

#define SETTINGS_PATH ( group,
name,
default_path )
Value:
SETTINGS_D( group, name, QString, default_path ) \
namespace config::group::name \
{ \
inline std::filesystem::path getPath() \
{ \
const std::filesystem::path filepath { group::name::get().toStdString() }; \
std::filesystem::create_directories( filepath ); \
return std::filesystem::canonical( filepath ); \
} \
\
inline void setPath( const std::filesystem::path path ) \
{ \
group::name::set( QString::fromStdString( path.string() ) ); \
} \
}

◆ SETTINGS_STATE

#define SETTINGS_STATE ( name)
Value:
namespace config::state::name \
{ \
inline bool hasValue() \
{ \
return getSettingsObject().contains( KEY_VALUE( state, name ) ); \
} \
\
inline QByteArray get() \
{ \
return getSettingsObject().value( KEY_VALUE( state, name ) ).toByteArray(); \
} \
\
inline void set( const QByteArray val ) \
{ \
getSettingsObject().setValue( KEY_VALUE( state, name ), val ); \
} \
}

◆ STR

#define STR ( val)
Value:
#val

Enumeration Type Documentation

◆ BannerMask

enum BannerMask
Enumerator
MASK_NORMAL 
MASK_WIDE 
MASK_COVER 
MASK_LOGO 

◆ BannerType

enum BannerType
Enumerator
Error 
Normal 
Wide 
Cover 
Logo 
SENTINEL 

◆ BLUR_TYPE

enum BLUR_TYPE : int
Enumerator
BACKGROUND_ONLY 
FEATHER_IMAGE 
SQUARE 

◆ LOCATION

enum LOCATION : int
Enumerator
NONE 
TOP_LEFT 
TOP_CENTER 
TOP_RIGHT 
BOTTOM_LEFT 
BOTTOM_CENTER 
BOTTOM_RIGHT 

◆ PreviewType

Enumerator
PREVIEW_UNKNOWN 
PREVIEW_BANNER 
PREVIEW_PREVIEW 
PREVIEW_BANNER_WIDE 
PREVIEW_COVER 
PREVIEW_LOGO 

◆ SCALE_TYPE

enum SCALE_TYPE : int
Enumerator
IGNORE_ASPECT_RATIO 
KEEP_ASPECT_RATIO 
KEEP_ASPECT_RATIO_BY_EXPANDING 
FIT_BLUR_EXPANDING 
FIT_BLUR_STRETCH 

Function Documentation

◆ getSettingsObject()

QSettings getSettingsObject ( )
inline