Changes
This commit is contained in:
@@ -185,21 +185,21 @@
|
||||
<div class="box" id="sia_settings">
|
||||
<h1>Sia Settings</h1>
|
||||
<h2>Lock Wallet on Application Exit</h2>
|
||||
<input type="checkbox" id="ID_SettingsLockWalletOnExit"><br><br>
|
||||
<input type="checkbox" id="ID_Settings_LockWalletOnExit"><br><br>
|
||||
<h2>Auto-start on Logon</h2>
|
||||
<input type="checkbox" id="ID_SettingsAutoStart"><br><br>
|
||||
<input type="checkbox" id="ID_Settings_AutoStartOnLogon"><br><br>
|
||||
<h2>Launch file manager on mount</h2>
|
||||
<input type="checkbox" id="ID_SettingsLaunchFileManager"><br><br>
|
||||
<input type="checkbox" id="ID_Settings_LaunchFileMgrOnMount"><br><br>
|
||||
<h2>Close to system tray</h2>
|
||||
<input type="checkbox" id="ID_SettingsCloseToTray"><br><br>
|
||||
<input type="checkbox" id="ID_Settings_CloseToTray"><br><br>
|
||||
<h2>Use Bundled siad</h2>
|
||||
<input type="checkbox" id="ID_SettingsLaunchServer"><br><br>
|
||||
<input type="checkbox" id="ID_Settings_LaunchBundledSiad"><br><br>
|
||||
<h2>API Port</h2>
|
||||
<input type="number" id="ID_SettingsApiPort"><br><br>
|
||||
<input type="number" id="ID_Settings_ApiPort"><br><br>
|
||||
<h2>Host Port</h2>
|
||||
<input type="number" id="ID_SettingsHostPort"><br><br>
|
||||
<input type="number" id="ID_Settings_HostPort"><br><br>
|
||||
<h2>RPC Port</h2>
|
||||
<input type="number" id="ID_SettingsRPCPort"><br><br>
|
||||
<input type="number" id="ID_Settings_RpcPort"><br><br>
|
||||
<button id="ID_SiaSettingsOK" type="button">Save</button>
|
||||
<button id="ID_SiaSettingsCancel" type="button">Cancel</button>
|
||||
</div>
|
||||
|
@@ -157,39 +157,20 @@
|
||||
},
|
||||
notifyDriveUnmounted: _notifyDriveUnmounted,
|
||||
reloadApplication: reloadApplication,
|
||||
setAutoStartOnLogon: (start) => {
|
||||
setSiaSettings: (settings) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setChecked('ID_SettingsAutoStart', start);
|
||||
}
|
||||
},
|
||||
setLaunchBundledSiad: (launch) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setChecked('ID_SettingsLaunchServer', launch);
|
||||
}
|
||||
},
|
||||
setApiPort: (port) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setValue('ID_SettingsApiPort', port);
|
||||
}
|
||||
},
|
||||
setHostPort: (port) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setValue('ID_SettingsHostPort', port);
|
||||
}
|
||||
},
|
||||
setRpcPort: (port) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setValue('ID_SettingsRPCPort', port);
|
||||
}
|
||||
},
|
||||
setLaunchFileManager: (launch) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setChecked('ID_SettingsLaunchFileManager', launch);
|
||||
}
|
||||
},
|
||||
setCloseToTray: (closeToTray) => {
|
||||
if (document.getElementById('sia_settings_window').classList.contains('hidden-element')) {
|
||||
setChecked('ID_SettingsCloseToTray', closeToTray);
|
||||
const j = JSON.parse(settings);
|
||||
for (const s in j) {
|
||||
if (j.hasOwnProperty(s)) {
|
||||
const id = 'ID_Settings_' + s;
|
||||
const input = document.getElementById(id);
|
||||
if (input.type === 'checkbox') {
|
||||
setChecked(id, j[s]);
|
||||
} else {
|
||||
setValue(id, j[s]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
displayShutdownWindow: () => {
|
||||
@@ -346,14 +327,14 @@
|
||||
saveButton.onclick = null;
|
||||
cancelButton.onclick = null;
|
||||
AppActions.setSiaSettings({
|
||||
'UnlockOnExit': getChecked('ID_SettingsLockWalletOnExit'),
|
||||
'AutoStartOnLogon': getChecked('ID_SettingsAutoStart'),
|
||||
'UseBundledSiad': getChecked('ID_SettingsLaunchServer'),
|
||||
'ApiPort': getValue('ID_SettingsApiPort'),
|
||||
'HostPort': getValue('ID_SettingsHostPort'),
|
||||
'RpcPort': getValue('ID_SettingsRPCPort'),
|
||||
'LaunchFileManager': getChecked('ID_SettingsLaunchFileManager'),
|
||||
'CloseToTray': getChecked('ID_SettingsCloseToTray')
|
||||
'LockWalletOnExit': getChecked('ID_Settings_LockWalletOnExit'),
|
||||
'AutoStartOnLogon': getChecked('ID_Settings_AutoStartOnLogon'),
|
||||
'LaunchBundledSiad': getChecked('ID_Settings_LaunchBundledSiad'),
|
||||
'ApiPort': getValue('ID_Settings_ApiPort'),
|
||||
'HostPort': getValue('ID_Settings_HostPort'),
|
||||
'RpcPort': getValue('ID_Settings_RpcPort'),
|
||||
'LaunchFileMgrOnMount': getChecked('ID_Settings_LaunchFileMgrOnMount'),
|
||||
'CloseToTray': getChecked('ID_Settings_CloseToTray')
|
||||
}, (success, reason) => {
|
||||
if (success) {
|
||||
beginMainApplication();
|
||||
|
@@ -8,6 +8,10 @@
|
||||
#include <include/cef_display_handler.h>
|
||||
|
||||
NS_BEGIN(Sia)
|
||||
NS_BEGIN(Api)
|
||||
class CSiaDriveConfig;
|
||||
NS_END(1)
|
||||
|
||||
class CSiaDriveHandler :
|
||||
public CefClient,
|
||||
public CefDisplayHandler,
|
||||
@@ -59,6 +63,7 @@ private:
|
||||
const bool _useViews;
|
||||
bool _isClosing;
|
||||
bool _active;
|
||||
std::shared_ptr<Api::CSiaDriveConfig> _siaDriveConfig;
|
||||
typedef std::list<CefRefPtr<CefBrowser> > BrowserList;
|
||||
BrowserList _browserList;
|
||||
|
||||
|
@@ -11,6 +11,8 @@ public:
|
||||
|
||||
CSiaDriveConfig(const bool& autoSave, const SString& filePath);
|
||||
|
||||
explicit CSiaDriveConfig(const json& configDoc);
|
||||
|
||||
public:
|
||||
~CSiaDriveConfig();
|
||||
|
||||
@@ -43,6 +45,9 @@ private:
|
||||
void OnAutoStartOnLogonChanged(const bool& value);
|
||||
|
||||
void Save() const;
|
||||
|
||||
public:
|
||||
SString ToString() const;
|
||||
};
|
||||
|
||||
NS_END(2)
|
@@ -206,13 +206,18 @@ public:
|
||||
{
|
||||
CefRefPtr<CefV8Value> settings = arguments[0];
|
||||
CefRefPtr<CefV8Value> cb = arguments[1];
|
||||
_siaDriveConfig->SetLaunchFileMgrOnMount(settings->GetValue("LaunchFileManager")->GetBoolValue());
|
||||
_siaDriveConfig->SetLaunchFileMgrOnMount(settings->GetValue("LaunchFileMgrOnMount")->GetBoolValue());
|
||||
_siaDriveConfig->SetAutoStartOnLogon(settings->GetValue("AutoStartOnLogon")->GetBoolValue());
|
||||
_siaDriveConfig->SetLaunchBundledSiad(settings->GetValue("UseBundledSiad")->GetBoolValue());
|
||||
_siaDriveConfig->SetLockWalletOnExit(settings->GetValue("UnlockOnExit")->GetBoolValue());
|
||||
_siaDriveConfig->SetLaunchBundledSiad(settings->GetValue("LaunchBundledSiad")->GetBoolValue());
|
||||
_siaDriveConfig->SetLockWalletOnExit(settings->GetValue("LockWalletOnExit")->GetBoolValue());
|
||||
_siaDriveConfig->SetApiPort(SString::ToUInt32(settings->GetValue("ApiPort")->GetStringValue().ToWString()));
|
||||
_siaDriveConfig->SetHostPort(SString::ToUInt32(settings->GetValue("HostPort")->GetStringValue().ToWString()));
|
||||
_siaDriveConfig->SetRpcPort(SString::ToUInt32(settings->GetValue("RpcPort")->GetStringValue().ToWString()));
|
||||
_siaDriveConfig->SetCloseToTray(settings->GetValue("CloseToTray")->GetBoolValue());
|
||||
|
||||
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("settingsUpdated");
|
||||
msg->GetArgumentList()->SetString(0, _siaDriveConfig->ToString().str());
|
||||
context->GetBrowser()->SendProcessMessage(PID_BROWSER, msg);
|
||||
|
||||
CefV8ValueList args;
|
||||
args.push_back(CefV8Value::CreateBool(true));
|
||||
@@ -478,12 +483,18 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
||||
if (created && !locked)
|
||||
{
|
||||
uiState->SetValue("allocatedRenterFunds", CefV8Value::CreateString(_siaApi->GetRenter()->GetFunds().ToString()), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
ExecuteSetter(context, uiActions, "setAutoStartOnLogon", CefV8Value::CreateBool(_siaDriveConfig->GetAutoStartOnLogon()));
|
||||
ExecuteSetter(context, uiActions, "setLaunchBundledSiad", CefV8Value::CreateBool(_siaDriveConfig->GetLaunchBundledSiad()));
|
||||
ExecuteSetter(context, uiActions, "setLaunchFileManager", CefV8Value::CreateBool(_siaDriveConfig->GetLaunchFileMgrOnMount()));
|
||||
ExecuteSetter(context, uiActions, "setApiPort", CefV8Value::CreateUInt(_siaDriveConfig->GetApiPort()));
|
||||
ExecuteSetter(context, uiActions, "setHostPort", CefV8Value::CreateUInt(_siaDriveConfig->GetHostPort()));
|
||||
ExecuteSetter(context, uiActions, "setRpcPort", CefV8Value::CreateUInt(_siaDriveConfig->GetRpcPort()));
|
||||
|
||||
json settings = {
|
||||
{ "AutoStartOnLogon", _siaDriveConfig->GetAutoStartOnLogon() },
|
||||
{ "LaunchBundledSiad", _siaDriveConfig->GetLaunchBundledSiad() },
|
||||
{ "LaunchFileMgrOnMount", _siaDriveConfig->GetLaunchFileMgrOnMount() },
|
||||
{ "LockWalletOnExit", _siaDriveConfig->GetLockWalletOnExit() },
|
||||
{ "ApiPort", _siaDriveConfig->GetApiPort() },
|
||||
{ "HostPort", _siaDriveConfig->GetHostPort() },
|
||||
{ "RpcPort", _siaDriveConfig->GetRpcPort() },
|
||||
{ "CloseToTray", _siaDriveConfig->GetCloseToTray() }
|
||||
};
|
||||
ExecuteSetter(context, uiActions, "setSiaSettings", CefV8Value::CreateString(settings.dump()));
|
||||
|
||||
// Display wallet data
|
||||
auto confirmedBalance = _siaApi->GetWallet()->GetConfirmedBalance();
|
||||
|
@@ -112,7 +112,8 @@ static LRESULT CALLBACK SiaWndProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lpa
|
||||
CSiaDriveHandler::CSiaDriveHandler(const bool& useViews) :
|
||||
_useViews(useViews),
|
||||
_isClosing(false),
|
||||
_active(true)
|
||||
_active(true),
|
||||
_siaDriveConfig(new CSiaDriveConfig(false))
|
||||
{
|
||||
DCHECK(!g_instance);
|
||||
g_instance = this;
|
||||
@@ -156,6 +157,11 @@ bool CSiaDriveHandler::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser, C
|
||||
browser->GetHost()->CloseBrowser(false);
|
||||
return true;
|
||||
}
|
||||
else if (message->GetName() == "settingsUpdated")
|
||||
{
|
||||
json configDoc = json::parse(message->GetArgumentList()->GetString(0).ToString().c_str());
|
||||
_siaDriveConfig.reset(new CSiaDriveConfig(configDoc));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -199,14 +205,21 @@ bool CSiaDriveHandler::DoClose(CefRefPtr<CefBrowser> browser)
|
||||
|
||||
if (!_isClosing && (_browserList.size() == 1))
|
||||
{
|
||||
CSiaDriveConfig cfg(false);
|
||||
if (!cfg.GetCloseToTray() || g_trayClose)
|
||||
if (!_siaDriveConfig->GetCloseToTray() || g_trayClose)
|
||||
{
|
||||
// Set a flag to indicate that the window close should be allowed.
|
||||
_isClosing = true;
|
||||
CefRefPtr<CefProcessMessage> msg = CefProcessMessage::Create("shutdownServices");
|
||||
browser->SendProcessMessage(PID_RENDERER, msg);
|
||||
}
|
||||
else if (_siaDriveConfig->GetCloseToTray())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
::ShowWindow(browser->GetHost()->GetWindowHandle(), SW_HIDE);
|
||||
#else
|
||||
a
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -6,15 +6,21 @@
|
||||
using namespace Sia::Api;
|
||||
|
||||
CSiaDriveConfig::CSiaDriveConfig(const bool& autoSave) :
|
||||
CSiaDriveConfig(autoSave, DEFAULT_CONFIG_FILE_PATH)
|
||||
CSiaDriveConfig(autoSave, SString(DEFAULT_CONFIG_FILE_PATH))
|
||||
{
|
||||
}
|
||||
|
||||
CSiaDriveConfig::CSiaDriveConfig(const bool& autoSave, const SString& filePath) :
|
||||
_autoSave(autoSave),
|
||||
_FilePath(FilePath(filePath).Resolve())
|
||||
_FilePath(FilePath(filePath).Resolve())
|
||||
{
|
||||
Load();
|
||||
}
|
||||
|
||||
CSiaDriveConfig::CSiaDriveConfig(const json& configDoc) :
|
||||
_autoSave(false),
|
||||
_configDocument(configDoc)
|
||||
{
|
||||
Load();
|
||||
}
|
||||
|
||||
CSiaDriveConfig::~CSiaDriveConfig()
|
||||
@@ -220,4 +226,9 @@ void CSiaDriveConfig::Save() const
|
||||
folder.CreateDirectory();
|
||||
}
|
||||
std::ofstream(SString::ToUtf8(static_cast<SString>(filePath)).c_str()) << std::setw(2) << _configDocument << std::endl;
|
||||
}
|
||||
|
||||
SString CSiaDriveConfig::ToString() const
|
||||
{
|
||||
return _configDocument.dump();
|
||||
}
|
Reference in New Issue
Block a user