Elaztek Developer Hub
Blamite Game Engine - Keystone  00386.06.16.23.0646.blamite
A library that enables the use of Qt in Blamite's editing tools.
themes.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 #include <map>
6 #include <Strings/components/resources/resources.h>
7 
8 #ifndef KEYSTONE
9 #define KEYSTONE
10 #endif
11 
15 #define DEFAULT_QT_STYLE "windowsvista"
16 
17 #define THEME_RESOURCE(group_id, id) BlamKeystone::Themes::GetActiveTheme()->GetResource(group_id, id)
18 
23 {
25  User,
27 };
28 
35 {
36  std::string name;
37  std::map<std::string, std::string> properties;
38 };
39 
48 {
49 private:
50  std::string name = "";
51  std::string author = "";
52  std::string description = "";
53  std::string version = "";
54  std::string base_qt_style = "";
55 
56  BlamEditorThemeType theme_type;
57 
58  std::string stylesheet = "";
59  std::string content_dir = "";
60 
61  std::vector<BlamEditorThemeVariant> variants;
62  std::map<std::string, BlamResourceGroup> resource_group_overrides;
63 
64  std::string EvaluateVariantPlaceholders(std::map<std::string, std::string> properties, std::string base_stylesheet);
65  std::string EvaluateResourcePlaceholders(std::string base_stylesheet);
66 
67 public:
68 
81  BlamEditorTheme(std::string _name, std::string _author, std::string _desc, std::string _ver, BlamEditorThemeType type, std::string _content_dir);
82 
95  BlamEditorTheme(std::string _name, std::string _author, std::string _desc, std::string _ver, BlamEditorThemeType type, std::string _stylesheet,
96  std::string _qt_style, std::vector<BlamEditorThemeVariant> _variants, std::string _content_dir,
97  std::map<std::string, BlamResourceGroup> _resource_group_overrides);
98 
104  bool ApplyTheme();
105 
113  bool ApplyVariant(std::string variant_name);
114 
120  std::string GetName();
121 
127  std::string GetAuthor();
128 
134  std::string GetDescription();
135 
141  std::string GetVersion();
142 
149 
155  std::string GetStylesheet();
156 
162  std::vector<BlamEditorThemeVariant> GetVariants();
163 
173  std::string GetResource(std::string group_id, std::string id);
174 };
175 
180 {
186  KEYSTONE bool LoadThemes();
187 
195  KEYSTONE bool ApplyTheme(std::string name);
196 
202  KEYSTONE std::vector<BlamEditorTheme>* GetThemeList();
203 
211  KEYSTONE BlamEditorTheme* GetTheme(std::string name);
212 
219 
228 }
DEFAULT_QT_STYLE
#define DEFAULT_QT_STYLE
The default Qt style.
Definition: themes.h:15
editor_data.h
BlamEditorThemeVariant::properties
std::map< std::string, std::string > properties
The list of properties for this theme variant.
Definition: themes.h:37
BlamEditorTheme::GetResource
std::string GetResource(std::string group_id, std::string id)
Retrieves a resource path from the theme.
Definition: BlamEditorTheme.cpp:158
active_theme_index
int active_theme_index
The index of the currently active theme.
Definition: themes.cpp:15
BlamEditorTheme::GetAuthor
std::string GetAuthor()
Retrieves the theme author.
Definition: BlamEditorTheme.cpp:128
themes
std::vector< BlamEditorTheme > themes
The current list of loaded themes.
Definition: themes.cpp:14
BlamKeystone::Themes::UpdateActiveTheme
KEYSTONE void UpdateActiveTheme(BlamEditorTheme *theme)
Updates the stored index of the current active theme.
Definition: themes.cpp:345
BlamKeystone::Themes
Namespace containing functions for the Keystone theme component.
Definition: themes.h:179
BlamEditorThemeType
BlamEditorThemeType
Enumerator for all possible theme types.
Definition: themes.h:22
BuiltIn
@ BuiltIn
Indicates the theme is a built-in theme, provided by Elaztek.
Definition: themes.h:24
BlamEditorTheme::ApplyVariant
bool ApplyVariant(std::string variant_name)
Applies a specified theme variant to the application.
Definition: BlamEditorTheme.cpp:78
BlamKeystone::GetQApplication
KEYSTONE QApplication * GetQApplication()
Retrieves the pointer to the current Qt application.
Definition: keystone_main.cpp:92
keystone_main.h
themes.h
BlamEditorTheme
Class representing a Blamite Editor Theme.
Definition: themes.h:47
BlamEditorThemeVariant::name
std::string name
The name of this theme variant.
Definition: themes.h:36
KEYSTONE
#define KEYSTONE
Definition: themes.h:9
BlamEditorTheme::GetVariants
std::vector< BlamEditorThemeVariant > GetVariants()
Retrieves the list of theme variants.
Definition: BlamEditorTheme.cpp:153
BlamEditorThemeVariant
Structure representing a theme variant.
Definition: themes.h:34
BlamKeystone::Themes::ApplyTheme
KEYSTONE bool ApplyTheme(std::string name)
Applies a new theme to the application.
Definition: themes.cpp:300
BlamEditorTheme::GetVersion
std::string GetVersion()
Retrieves the theme version.
Definition: BlamEditorTheme.cpp:138
BlamKeystone::Themes::GetActiveTheme
KEYSTONE BlamEditorTheme * GetActiveTheme()
Retrieves the currently selected theme.
Definition: themes.cpp:335
BlamEditorTheme::ApplyTheme
bool ApplyTheme()
Applies this theme to the application.
Definition: BlamEditorTheme.cpp:37
load_xml_theme
bool load_xml_theme(rapidxml::xml_document<> *theme_document, std::string folder_path, std::string xml_file_path, BlamEditorThemeType theme_type)
Loads a theme from an XML file.
Definition: themes.cpp:27
BlamKeystone::Themes::LoadThemes
KEYSTONE bool LoadThemes()
Loads all themes from Qt and the keystone theme folders.
Definition: themes.cpp:259
BlamKeystone::EditorData::GetMainEditorWindow
KEYSTONE BlamEditorWindow * GetMainEditorWindow()
Retrieves the main editor window.
Definition: editor_data.cpp:32
BlamEditorTheme::GetDescription
std::string GetDescription()
Retrieves the theme description.
Definition: BlamEditorTheme.cpp:133
BlamKeystone::Themes::GetTheme
KEYSTONE BlamEditorTheme * GetTheme(std::string name)
Retrieves a theme.
Definition: themes.cpp:320
BlamEditorWindow::OnThemeChange
virtual void OnThemeChange(BlamEditorTheme *new_theme)
Called when the active theme is changed.
Definition: BlamEditorWindow.cpp:94
BlamEditorTheme::GetName
std::string GetName()
Retrieves the theme name.
Definition: BlamEditorTheme.cpp:123
BlamEditorTheme::GetThemeType
BlamEditorThemeType GetThemeType()
Retrieves the theme type.
Definition: BlamEditorTheme.cpp:143
User
@ User
Indicates the theme is a custom theme added by the user.
Definition: themes.h:25
load_themes_in_folder
bool load_themes_in_folder(std::string theme_dir, BlamEditorThemeType theme_type)
Loads all XML themes in a given directory.
Definition: themes.cpp:220
BlamEditorTheme::BlamEditorTheme
BlamEditorTheme(std::string _name, std::string _author, std::string _desc, std::string _ver, BlamEditorThemeType type, std::string _content_dir)
Prepares a new Editor Theme.
Definition: BlamEditorTheme.cpp:25
BlamEditorTheme::GetStylesheet
std::string GetStylesheet()
Retrieves the theme stylesheet.
Definition: BlamEditorTheme.cpp:148
QtTheme
@ QtTheme
Indicates the theme is a default theme made available from Qt.
Definition: themes.h:26
BlamKeystone::Themes::GetThemeList
KEYSTONE std::vector< BlamEditorTheme > * GetThemeList()
Retrieves the list of loaded themes.
Definition: themes.cpp:315