openMSX
SettingsConfig.hh
Go to the documentation of this file.
1 #ifndef SETTINGSCONFIG_HH
2 #define SETTINGSCONFIG_HH
3 
4 #include "SettingsManager.hh"
5 #include "Command.hh"
6 #include "XMLElement.hh"
7 #include <string>
8 #include <string_view>
9 
10 namespace openmsx {
11 
12 class FileContext;
13 class HotKey;
14 class GlobalCommandController;
15 class CommandController;
16 
18 {
19 public:
20  SettingsConfig(GlobalCommandController& globalCommandController,
21  HotKey& hotKey);
23 
24  void loadSetting(const FileContext& context, std::string_view filename);
25  void saveSetting(std::string_view filename = {});
26  void setSaveSettings(bool save) { mustSaveSettings = save; }
27  void setSaveFilename(const FileContext& context, std::string_view filename);
28 
29  SettingsManager& getSettingsManager() { return settingsManager; }
30  XMLElement& getXMLElement() { return xmlElement; }
31 
32 private:
33  CommandController& commandController;
34 
35  struct SaveSettingsCommand final : Command {
36  explicit SaveSettingsCommand(CommandController& commandController);
37  void execute(span<const TclObject> tokens, TclObject& result) override;
38  std::string help(const std::vector<std::string>& tokens) const override;
39  void tabCompletion(std::vector<std::string>& tokens) const override;
40  } saveSettingsCommand;
41 
42  struct LoadSettingsCommand final : Command {
43  explicit LoadSettingsCommand(CommandController& commandController);
44  void execute(span<const TclObject> tokens, TclObject& result) override;
45  std::string help(const std::vector<std::string>& tokens) const override;
46  void tabCompletion(std::vector<std::string>& tokens) const override;
47  } loadSettingsCommand;
48 
49  SettingsManager settingsManager;
50  XMLElement xmlElement;
51  HotKey& hotKey;
52  std::string saveName;
53  bool mustSaveSettings;
54 };
55 
56 } // namespace openmsx
57 
58 #endif
openmsx::SettingsConfig::SettingsConfig
SettingsConfig(GlobalCommandController &globalCommandController, HotKey &hotKey)
Definition: SettingsConfig.cc:19
openmsx::SettingsConfig::loadSetting
void loadSetting(const FileContext &context, std::string_view filename)
Definition: SettingsConfig.cc:43
openmsx::SettingsConfig::setSaveFilename
void setSaveFilename(const FileContext &context, std::string_view filename)
Definition: SettingsConfig.cc:53
openmsx::CommandController
Definition: CommandController.hh:18
openmsx::SettingsConfig::setSaveSettings
void setSaveSettings(bool save)
Definition: SettingsConfig.hh:26
openmsx::XMLElement
XMLElement
Definition: XMLElement.cc:350
XMLElement.hh
openmsx::SettingsConfig::getSettingsManager
SettingsManager & getSettingsManager()
Definition: SettingsConfig.hh:29
openmsx::FileContext
Definition: FileContext.hh:10
span
Definition: span.hh:126
openmsx::SettingsConfig
Definition: SettingsConfig.hh:18
openmsx::XMLElement
Definition: XMLElement.hh:16
openmsx::filename
constexpr const char *const filename
Definition: FirmwareSwitch.cc:10
openmsx::FileContext
FileContext
Definition: FileContext.cc:123
openmsx::SettingsConfig::getXMLElement
XMLElement & getXMLElement()
Definition: SettingsConfig.hh:30
openmsx::HotKey
Definition: HotKey.hh:22
openmsx::SettingsConfig::~SettingsConfig
~SettingsConfig()
Definition: SettingsConfig.cc:31
gl::context
std::unique_ptr< Context > context
Definition: GLContext.cc:9
Command.hh
openmsx::Command
Definition: Command.hh:41
SettingsManager.hh
openmsx::TclObject
Definition: TclObject.hh:22
openmsx::SettingsConfig::saveSetting
void saveSetting(std::string_view filename={})
Definition: SettingsConfig.cc:58
openmsx::GlobalCommandController
Definition: GlobalCommandController.hh:37
openmsx::SettingsManager
Manages all settings.
Definition: SettingsManager.hh:19
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5