6#ifndef ATLAS_CONFIG_HPP
7#define ATLAS_CONFIG_HPP
21#pragma GCC diagnostic push
22#pragma GCC diagnostic ignored "-Wsign-promo"
28 return {
"./data/config.ini", QSettings::IniFormat };
31#define STR( val ) #val
32#define KEY_VALUE( group, name ) STR( group ) "/" STR( name )
34#define SETTINGS_D( group, name, type, default_value ) \
35 namespace config::group::name \
37 inline void set( const type& val ) \
39 getSettingsObject().setValue( KEY_VALUE( group, name ), val ); \
42 inline void setDefault() \
44 set( default_value ); \
49 if ( !getSettingsObject().contains( KEY_VALUE( group, name ) ) ) setDefault(); \
51 if ( const auto settings_obj = getSettingsObject().value( KEY_VALUE( group, name ) ); \
52 settings_obj.canConvert< type >() ) \
53 return settings_obj.value< type >(); \
55 throw SettingsException( "Failed to convert key " KEY_VALUE( group, name ) " to desired type" ); \
59#define SETTINGS_PATH( group, name, default_path ) \
60 SETTINGS_D( group, name, QString, default_path ) \
61 namespace config::group::name \
63 inline std::filesystem::path getPath() \
65 const std::filesystem::path filepath { group::name::get().toStdString() }; \
66 std::filesystem::create_directories( filepath ); \
67 return std::filesystem::canonical( filepath ); \
70 inline void setPath( const std::filesystem::path path ) \
72 group::name::set( QString::fromStdString( path.string() ) ); \
76#define SETTINGS_FILE( group, name, default_path ) \
77 SETTINGS_D( group, name, QString, default_path ) \
78 namespace config::group::name \
80 inline std::filesystem::path getPath() \
82 const std::filesystem::path filepath { group::name::get().toStdString() }; \
83 std::filesystem::create_directories( filepath.parent_path() ); \
84 return std::filesystem::canonical( filepath ); \
87 inline void setPath( const std::filesystem::path path ) \
89 group::name::set( QString::fromStdString( path.string() ) ); \
93#define SETTINGS( group, name, type ) \
94 namespace config::group::name \
96 inline bool hasValue() \
98 return getSettingsObject().contains( KEY_VALUE( group, name ) ); \
103 return { getSettingsObject().value( KEY_VALUE( group, name ) ).value< type >() }; \
106 inline void set( const type val ) \
108 getSettingsObject().setValue( KEY_VALUE( group, name ), val ); \
112#define SETTINGS_DE( group, name, type, default_value ) \
113 namespace config::group::name \
115 namespace de_internal \
117 inline void set( const int& val ) \
119 getSettingsObject().setValue( KEY_VALUE( group, name ), val ); \
122 inline void setDefault() \
124 set( static_cast< int >( default_value ) ); \
129 if ( !getSettingsObject().contains( KEY_VALUE( group, name ) ) ) setDefault(); \
131 if ( const auto settings_obj = getSettingsObject().value( KEY_VALUE( group, name ) ); \
132 settings_obj.canConvert< int >() ) \
133 return settings_obj.value< int >(); \
135 throw SettingsException( "Failed to convert key " KEY_VALUE( group, name ) " to desired type" ); \
138 SETTINGS_D( group, name, int, default_value ) \
143 return static_cast< type >( de_internal::get() ); \
146 inline void set( const type val ) \
148 de_internal::set( static_cast< int >( val ) ); \
152#define SETTINGS_GEO( name ) \
153 namespace config::geometry::name \
155 inline bool hasValue() \
157 return getSettingsObject().contains( KEY_VALUE( geometry, name ) ); \
160 inline QByteArray get() \
162 return { getSettingsObject().value( KEY_VALUE( geometry, name ) ).toByteArray() }; \
165 inline void set( const QByteArray val ) \
167 getSettingsObject().setValue( KEY_VALUE( geometry, name ), val ); \
171#define SETTINGS_STATE( name ) \
172 namespace config::state::name \
174 inline bool hasValue() \
176 return getSettingsObject().contains( KEY_VALUE( state, name ) ); \
179 inline QByteArray get() \
181 return getSettingsObject().value( KEY_VALUE( state, name ) ).toByteArray(); \
184 inline void set( const QByteArray val ) \
186 getSettingsObject().setValue( KEY_VALUE( state, name ), val ); \
190#define CONFIG_ATTACH_THIS \
192 &( config::internal::getNotifier() ), \
193 &config::ConfigNotification::notification, \
195 &std::remove_pointer_t< decltype( this ) >::reloadConfig )
202SETTINGS_D( importer, pathparse, QString,
"{creator}/{title}/{version}" )
203SETTINGS_D( importer, skipFilesize,
bool, false )
204SETTINGS_D( importer, searchGameInfo,
bool, true )
205SETTINGS_D( importer, downloadBanner,
bool, false )
206SETTINGS_D( importer, downloadVNDB,
bool, false )
207SETTINGS_D( importer, moveImported,
bool, true )
216SETTINGS_D( ui, use_system_theme,
bool, false )
269SETTINGS_D( grid_ui, selectedColor, QString,
"0,0,255" )
270SETTINGS_D( grid_ui, selectedOpacity,
int, 50 )
271SETTINGS_D( grid_ui, enableCapsuleBorder,
bool, true )
272SETTINGS_D( grid_ui, borderColor, QString,
"180,180,180" )
274SETTINGS_D( grid_ui, enableTopOverlay,
bool, true )
275SETTINGS_D( grid_ui, enableBottomOverlay,
bool, true )
277SETTINGS_D( grid_ui, overlayOpacity,
int, 200 )
278SETTINGS_D( grid_ui, overlayColor, QString,
"0,0,0" )
283SETTINGS_D( grid_ui, itemViewWidth,
int, 1266 )
284SETTINGS_D( grid_ui, itemViewHeight,
int, 694 )
303SETTINGS_D( grid_ui, gameIconLocation,
int, 0 )
304SETTINGS_D( grid_ui, ratingIconLocation,
int, 0 )
305SETTINGS_D( grid_ui, downloadIconLocation,
int, 0 )
306SETTINGS_D( grid_ui, engineIconLocation,
int, 0 )
308SETTINGS_D( grid_ui, showFavIcon,
bool, false )
309SETTINGS_D( grid_ui, showGameIcon,
bool, false )
310SETTINGS_D( grid_ui, showRatingIcon,
bool, false )
311SETTINGS_D( grid_ui, showDownloadIcon,
bool, false )
312SETTINGS_D( grid_ui, showEngineIcon,
bool, false )
313SETTINGS_D( grid_ui, centerWidgets,
bool, false )
315SETTINGS_D( ui, stretch_banner_images,
bool, false )
316SETTINGS_D( ui, use_simple_layout,
bool, true )
321SETTINGS_D( application, update_channel, QString,
"stable" )
326 remote, check_rate,
int, std::chrono::duration_cast< std::chrono::seconds >( std::chrono::hours( 24 ) ).count() )
329SETTINGS_D( threads, image_import_threads,
int, 4 )
330SETTINGS_D( threads, image_loader_threads,
int, 2 )
331SETTINGS_D( threads, import_pre_loader_threads,
int, 4 )
333SETTINGS_D( experimental, local_match,
bool, false )
334SETTINGS_D( experimental, loading_preview,
bool, false )
335SETTINGS_D( experimental, loading_preview_blur,
int, 90 )
336SETTINGS_D( experimental, use_blurhash,
bool, false )
339#pragma GCC diagnostic pop
#define SETTINGS_DE(group, name, type, default_value)
Definition config.hpp:112
BannerMask
Definition config.hpp:255
@ MASK_COVER
Definition config.hpp:258
@ MASK_WIDE
Definition config.hpp:257
@ MASK_NORMAL
Definition config.hpp:256
@ MASK_LOGO
Definition config.hpp:259
PreviewType
Definition config.hpp:235
@ PREVIEW_PREVIEW
Definition config.hpp:238
@ PREVIEW_UNKNOWN
Definition config.hpp:236
@ PREVIEW_COVER
Definition config.hpp:240
@ PREVIEW_BANNER
Definition config.hpp:237
@ PREVIEW_LOGO
Definition config.hpp:241
@ PREVIEW_BANNER_WIDE
Definition config.hpp:239
BLUR_TYPE
Definition config.hpp:228
@ SQUARE
Definition config.hpp:231
@ FEATHER_IMAGE
Definition config.hpp:230
@ BACKGROUND_ONLY
Definition config.hpp:229
#define SETTINGS_D(group, name, type, default_value)
Definition config.hpp:34
QSettings getSettingsObject()
Definition config.hpp:26
LOCATION
Definition config.hpp:287
@ TOP_CENTER
Definition config.hpp:290
@ BOTTOM_RIGHT
Definition config.hpp:294
@ TOP_LEFT
Definition config.hpp:289
@ BOTTOM_LEFT
Definition config.hpp:292
@ BOTTOM_CENTER
Definition config.hpp:293
@ TOP_RIGHT
Definition config.hpp:291
@ NONE
Definition config.hpp:288
#define SETTINGS_GEO(name)
Definition config.hpp:152
#define SETTINGS_STATE(name)
Definition config.hpp:171
SCALE_TYPE
Definition config.hpp:219
@ KEEP_ASPECT_RATIO_BY_EXPANDING
Definition config.hpp:222
@ IGNORE_ASPECT_RATIO
Definition config.hpp:220
@ KEEP_ASPECT_RATIO
Definition config.hpp:221
@ FIT_BLUR_STRETCH
Definition config.hpp:224
@ FIT_BLUR_EXPANDING
Definition config.hpp:223
BannerType
Definition config.hpp:245
@ Logo
Definition config.hpp:250
@ Error
Definition config.hpp:246
@ Normal
Definition config.hpp:247
@ SENTINEL
Definition config.hpp:251
@ Wide
Definition config.hpp:248
@ Cover
Definition config.hpp:249
#define SETTINGS_PATH(group, name, default_path)
Definition config.hpp:59
#define SETTINGS_FILE(group, name, default_path)
Definition config.hpp:76