mirror of https://github.com/odrling/Aegisub
Fix reading of aegisub config values.
Originally committed to SVN as r5122.
This commit is contained in:
parent
a0e760c9da
commit
010f3c14e5
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include "aegisub.h"
|
#include "aegisub.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
#include "../src/config.h"
|
#include "../src/config.h"
|
||||||
#else
|
#else
|
||||||
|
@ -35,14 +36,34 @@ Aegisub::Aegisub() {
|
||||||
wxStandardPathsBase &paths = wxStandardPaths::Get();
|
wxStandardPathsBase &paths = wxStandardPaths::Get();
|
||||||
// Using ifdefs is a pain but it's much easier to centralise this.
|
// Using ifdefs is a pain but it's much easier to centralise this.
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
std::string configdir(wxString::Format("%s-%s", paths.GetUserDataDir(), _T(AEGISUB_VERSION_DATA)));
|
std::string conf_user(wxString::Format("%s-%s/config.json", paths.GetUserDataDir(), _T(AEGISUB_VERSION_DATA)));
|
||||||
#elif defined(__UNIX__)
|
#elif defined(__UNIX__)
|
||||||
std::string configdir(wxString::Format("%s/.aegisub-%s", paths.GetUserConfigDir(), _T(AEGISUB_VERSION_DATA)));
|
std::string conf_user(wxString::Format("%s/.aegisub-%s/config.json", paths.GetUserConfigDir(), _T(AEGISUB_VERSION_DATA)));
|
||||||
#else
|
#else
|
||||||
std::string configdir(wxString::Format("%s/Aegisub", paths.GetUserConfigDir()));
|
std::string conf_user(wxString::Format("%s/Aegisub/config.json", paths.GetUserConfigDir()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::cout << conf_user << std::endl;
|
||||||
|
std::string default_config("{}");
|
||||||
|
opt = new agi::Options(conf_user, default_config, agi::Options::FLUSH_SKIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Aegisub::Read(std::string key) {
|
|
||||||
|
Aegisub::~Aegisub() {
|
||||||
|
delete opt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::string Aegisub::GetString(std::string key) {
|
||||||
|
return opt->Get(key)->GetString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int64_t Aegisub::GetInt(std::string key) {
|
||||||
|
return opt->Get(key)->GetInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Aegisub::GetBool(std::string key) {
|
||||||
|
return opt->Get(key)->GetBool();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,17 +19,20 @@
|
||||||
/// @ingroup base
|
/// @ingroup base
|
||||||
|
|
||||||
#ifndef R_PRECOMP
|
#ifndef R_PRECOMP
|
||||||
#include <wx/fileconf.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <libaegisub/option.h>
|
||||||
|
|
||||||
/// @class Aegisub
|
/// @class Aegisub
|
||||||
/// @brief Gather Aegisub information from the config file or otherwise.
|
/// @brief Gather Aegisub information from the config file or otherwise.
|
||||||
class Aegisub {
|
class Aegisub {
|
||||||
private:
|
private:
|
||||||
wxFileConfig *conf;
|
agi::Options *opt;
|
||||||
public:
|
public:
|
||||||
Aegisub();
|
Aegisub();
|
||||||
~Aegisub();
|
~Aegisub();
|
||||||
void Config(std::string config);
|
const agi::OptionValue* Read(std::string key);
|
||||||
std::string Read(std::string key);
|
const std::string GetString(std::string key);
|
||||||
|
int64_t GetInt(std::string key);
|
||||||
|
bool GetBool(std::string key);
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,6 +38,7 @@ Report::Report() {
|
||||||
json::Object root;
|
json::Object root;
|
||||||
|
|
||||||
Platform *p = Platform::GetPlatform();
|
Platform *p = Platform::GetPlatform();
|
||||||
|
Aegisub a;
|
||||||
|
|
||||||
json::Object general;
|
json::Object general;
|
||||||
general["Signature"] = json::String(p->Signature());
|
general["Signature"] = json::String(p->Signature());
|
||||||
|
@ -54,25 +55,30 @@ Report::Report() {
|
||||||
root["General"] = general;
|
root["General"] = general;
|
||||||
|
|
||||||
|
|
||||||
json::Object aegisub;
|
|
||||||
|
|
||||||
/// I'll fix these at the end.
|
|
||||||
/*
|
try {
|
||||||
Last Version
|
json::Object aegisub;
|
||||||
Spelling Language
|
aegisub["Last Version"] = json::String(a.GetString("Version/Last Version"));
|
||||||
Thesaurus Language
|
aegisub["Spelling Language"] = json::String(a.GetString("Tool/Spell Checker/Language"));
|
||||||
Audio Player
|
aegisub["Thesaurus Language"] = json::String(a.GetString("Tool/Thesaurus/Language"));
|
||||||
Audio Provider
|
aegisub["Audio Player"] = json::String(a.GetString("Audio/Player"));
|
||||||
Video Provider
|
aegisub["Audio Provider"] = json::String(a.GetString("Audio/Provider"));
|
||||||
Subtitles Provider
|
aegisub["Video Provider"] = json::String(a.GetString("Video/Provider"));
|
||||||
Save Charset
|
aegisub["Subtitles Provider"] = json::String(a.GetString("Subtitle/Provider"));
|
||||||
Grid Font Size
|
aegisub["Save Charset"] = json::String(a.GetString("App/Save Charset"));
|
||||||
Edit Font Size
|
aegisub["Grid Font Size"] = json::Number(a.GetInt("Grid/Font Size"));
|
||||||
Spectrum Enabled
|
aegisub["Edit Font Size"] = json::Number(a.GetInt("Subtitle/Edit Box/Font Size"));
|
||||||
Spectrum Quality
|
aegisub["Spectrum Enabled"] = json::Boolean(a.GetBool("Audio/Spectrum"));
|
||||||
Call Tips Enabled
|
aegisub["Spectrum Quality"] = json::Number(a.GetInt("Audio/Renderer/Spectrum/Quality"));
|
||||||
Medusa Hotkeys Enabled
|
aegisub["Call Tips Enabled"] = json::Boolean(a.GetBool("App/Call Tips"));
|
||||||
*/
|
aegisub["Medusa Hotkeys Enabled"] = json::Boolean(a.GetBool("Audio/Medusa Timing Hotkeys"));
|
||||||
|
|
||||||
|
root["Aegisub"] = aegisub;
|
||||||
|
} catch(...) {
|
||||||
|
root["Aegisub"]["Error"] = json::String("Config file is corrupted");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
json::Object hardware;
|
json::Object hardware;
|
||||||
|
|
Loading…
Reference in New Issue