1
0

UI stuffs

This commit is contained in:
Scott E. Graves
2017-03-22 10:59:07 -05:00
parent a6c6de75c3
commit 9efbae3fb9
10 changed files with 47 additions and 31 deletions

View File

@@ -7,7 +7,7 @@ set PATH=%ROOT%depot_tools;%PATH%
call create_common.cmd
set CEF_USE_GN=1
if ("%MODE%" EQ "Debug") (
if ("%MODE%"=="Debug") (
set GN_DEFINES=is_win_fastlink=true fatal_linker_warnings=false
) else (
set GN_DEFINES=fatal_linker_warnings=false

Submodule 3rd_party/CEF/depot_tools updated: c07db62152...7a1f04d377

View File

@@ -195,7 +195,7 @@ select {
outline: 1px;
background: rgba(64, 142, 62, 0.04);
color: var(--default-font-color);
padding: 5px 35px 5px 5px;
padding: 5px 15px;
height: 33px;
font-size: var(--default-font-size);
-webkit-appearance: none;

View File

@@ -86,7 +86,7 @@
const UiState = (()=> {
function _clientVersion() {
return window.uiState.clientVersion;
return 'v' + window.uiState.clientVersion;
}
function _isOnline() {

View File

@@ -21,7 +21,7 @@ public:
static const SString DirSep;
public:
static FilePath FinalizePath(const SString& path);
static SString FinalizePath(const SString& path);
private:
SString _path;

View File

@@ -2,6 +2,7 @@
#define _SIACOMMON_H
#define SIDRIVE_VERSION_STRING "0.0.1"
#define COMPAT_SIAD_VERSION "1.1.2"
#ifdef _WIN32
// Unicode for Win32
@@ -76,6 +77,7 @@ public:
};
#define DEFAULT_CONFIG_FILE_PATH L"./config/siadriveconfig.json"
#define DEFAULT_RENTER_DB_FILE_PATH L"./config/renter_upload.db3"
#define Property(type, name, get_access, set_access) \
private:\

View File

@@ -15,10 +15,11 @@ public:
~CSiaDriveConfig();
Property(SString, FilePath, public, private)
JProperty(std::uint8_t, UI_Main_TabIndex, public, private, _configDocument)
JProperty(std::string, Renter_UploadDbFilePath, public, private, _configDocument)
JProperty(std::string, TempFolder, public, private, _configDocument)
JProperty(std::string, CacheFolder, public, public, _configDocument)
JProperty(std::uint16_t, HostPort, public, public, _configDocument)
JProperty(std::string, HostNameOrIp, public, public, _configDocument)
private:
json _configDocument;

View File

@@ -8,8 +8,8 @@
#include <siacurl.h>
#include <siadriveconfig.h>
#include "siadrivehandler.h"
/*
exotic stylishly alchemy deodorant rally younger ouch sensible rated boss nestle wipeout viking blip pairing rural dwarf rebel mumble shelter pager yodel object titans tidy virtual orders peculiar after
/* Work Laptop
vitals thirsty tattoo unjustly already lexicon ruthless rated skater voyage avoid jeers aunt tawny richly glass menu kidneys went wounded wounded trendy towel lipstick raking bacon dozen blip aggravate
*/
using namespace Sia;
using namespace Sia::Api;
@@ -29,9 +29,8 @@ private:
bool& _appStarted;
private:
void UnlockCallback(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> cb, const SString& password) const
void UnlockCallback(SiaApiError error, CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> cb, const SString& password) const
{
SiaApiError error = _siaApi.GetWallet()->Unlock(password);
CefV8ValueList args;
args.push_back(CefV8Value::CreateBool(ApiSuccess(error)));
if (!args[0]->GetBoolValue())
@@ -72,8 +71,13 @@ public:
retval = CefV8Value::CreateBool(true);
SString password = arguments[0]->GetStringValue().ToWString();
CefRefPtr<CefV8Value> cb = arguments[1];
CefPostTask(TID_RENDERER, base::Bind(&FunctionHandler::UnlockCallback, this, context, cb, password));
// Don't hang UI while unlocking
std::thread([this, context, password, cb]()
{
CefPostTask(TID_RENDERER, base::Bind(&FunctionHandler::UnlockCallback, this, _siaApi.GetWallet()->Unlock(password), context, cb, password));
}).detach();
return true;
}
else if (name == "createWallet")
@@ -147,9 +151,9 @@ CSiaDriveApp::CSiaDriveApp()
{
_siaDriveConfig.reset(new CSiaDriveConfig());
SiaHostConfig hostConfig;
hostConfig.HostName = "127.0.0.1";
hostConfig.HostPort = 9980;
hostConfig.RequiredVersion = "1.1.2";
hostConfig.HostName = _siaDriveConfig->GetHostNameOrIp();
hostConfig.HostPort = _siaDriveConfig->GetHostPort();
hostConfig.RequiredVersion = COMPAT_SIAD_VERSION;
_siaCurl.reset(new CSiaCurl(hostConfig));
_siaApi.reset(new CSiaApi(hostConfig, _siaDriveConfig.get()));
}

View File

@@ -3,10 +3,15 @@
using namespace Sia::Api;
FilePath FilePath::FinalizePath(const SString& path)
SString FilePath::FinalizePath(const SString& path)
{
#ifdef _WIN32
std::wregex r(L"/+");
return FilePath(std::regex_replace(path.str(), r, L"/"));
return std::regex_replace(path.str(), r, L"\\");
#else
std::wregex r(L"\\+");
return std::regex_replace(path.str(), r, L"/");
#endif
}
FilePath::FilePath()

View File

@@ -1,5 +1,6 @@
#include <siadriveconfig.h>
#include <fstream>
#include <filepath.h>
#ifdef _WIN32
#include <Shlobj.h>
#endif
@@ -29,13 +30,13 @@ CSiaDriveConfig::~CSiaDriveConfig()
void CSiaDriveConfig::LoadDefaults()
{
SetRenter_UploadDbFilePath(static_cast<SString>(FilePath(DEFAULT_RENTER_DB_FILE_PATH)));
#ifdef _WIN32
SetUI_Main_TabIndex(0);
SetRenter_UploadDbFilePath("./config/renter_upload.db3");
SString tempFolder;
tempFolder.Resize(MAX_PATH + 1);
::GetTempPath(MAX_PATH, &tempFolder[0]);
tempFolder = tempFolder.str().c_str();
SetTempFolder(tempFolder);
PWSTR localAppData = nullptr;
@@ -45,20 +46,26 @@ void CSiaDriveConfig::LoadDefaults()
sdFolder.Resize(MAX_PATH + 1);
::PathCombine(&sdFolder[0], localAppData, L"SiaDrive");
::CreateDirectory(sdFolder.str().c_str(), nullptr);
sdFolder = sdFolder.str().c_str();
SString cacheFolder;
cacheFolder.Resize(MAX_PATH + 1);
::PathCombine(&cacheFolder[0], &sdFolder[0], L"Cache");
::CreateDirectory(cacheFolder.str().c_str(), nullptr);
cacheFolder = cacheFolder.str().c_str();
SetCacheFolder(cacheFolder);
#else
a
#endif
SetHostNameOrIp("localhost");
SetHostPort(9980);
}
void CSiaDriveConfig::Load( )
{
std::ifstream myfile(GetFilePath().str().c_str());
FilePath filePath = GetFilePath();
std::ifstream myfile(static_cast<SString>(filePath).str().c_str());
if (myfile.is_open())
{
std::stringstream ss;
@@ -76,16 +83,13 @@ void CSiaDriveConfig::Load( )
void CSiaDriveConfig::Save() const
{
#ifdef _WIN32
SString folder = GetFilePath();
::PathRemoveFileSpec(&folder[0]);
FilePath filePath = GetFilePath();
FilePath folder = filePath;
folder.RemoveFileName();
if (!::PathIsDirectory(folder.str().c_str()))
if (!folder.IsDirectory())
{
::CreateDirectory(folder.str().c_str(), nullptr);
folder.CreateDirectory();
}
#else
#endif
std::ofstream(SString::ToUtf8(GetFilePath()).c_str()) << std::setw(2) << _configDocument << std::endl;
std::ofstream(SString::ToUtf8(static_cast<SString>(filePath)).c_str()) << std::setw(2) << _configDocument << std::endl;
}