Skip to content

Commit

Permalink
Sumokoin GUI Wallet v0.0.6
Browse files Browse the repository at this point in the history
- Updated with Sumokoin binaries v0.3.3.0 (binaries not included)

- Add upload/download rate limit options

- Optional close to system tray

Signed-off-by: Sumoshi Tanaka <sumoshi.tanaka@gmail.com>
  • Loading branch information
sumoprojects committed Jun 21, 2018
1 parent b10b384 commit 6b398da
Show file tree
Hide file tree
Showing 7 changed files with 192 additions and 58 deletions.
17 changes: 17 additions & 0 deletions app/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,23 @@ def update_wallet_loading_height(self):
if h > self.current_block_height:
self.on_update_wallet_loading_height_event.emit(h, self.ui.target_height)
self.current_block_height = h

@Slot(bool)
def change_minimize_to_tray(self, status):
self.ui.close_to_system_tray = status
self.ui.app_settings.settings['application']['minimize_to_tray'] = status
self.ui.app_settings.save()

@Slot(int)
def change_limit_rate_up(self, limit_rate_up):
self.ui.app_settings.settings['daemon']['limit_rate_up'] = limit_rate_up
self.ui.app_settings.save()


@Slot(int)
def change_limit_rate_down(self, limit_rate_down):
self.ui.app_settings.settings['daemon']['limit_rate_down'] = limit_rate_down
self.ui.app_settings.save()


def update_daemon_status(self, status):
Expand Down
56 changes: 49 additions & 7 deletions classes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,36 @@ def reset(self):
self.bc_height = -1


def set_default_settings(default_settings, settings):
for k, v in default_settings.iteritems():
settings.setdefault(k, v)
if type(v) is dict: set_default_settings(default_settings[k], settings[k])

class AppSettings():
settings = {
settings = {}
default_settings = {
"daemon": {
"log_level": 0,
"block_sync_size": 10
"block_sync_size": 10,
"limit_rate_up": 2048,
"limit_rate_down": 8192,
},

"blockchain": {
"height": 0,
},

"application": {
"minimize_to_tray": False,
}
}

log_levels = [0,1,2,3,4]
block_sync_sizes = [10,20,50,100,200]
limit_rate_ups = [512,1024,2048,3072,4096,8192,16384]
limit_rate_downs = [512,1024,2048,4096,8192,12288,16384]


def __init__(self):
self.app_settings_filepath = os.path.join(config_path, 'app_settings.json')

Expand All @@ -101,12 +119,36 @@ def load(self):
if os.path.exists(self.app_settings_filepath):
try:
self.settings = json.loads(readFile(self.app_settings_filepath))
return True
except Exception, err:
log("[AppSettings]>>> Load error:" + str(err), LEVEL_ERROR)
return False
return False

log("[AppSettings]>>> Load config file error:" + str(err), LEVEL_ERROR)

# Set default values:
set_default_settings(self.default_settings, self.settings)

# Validate values
if self.settings["daemon"]["log_level"] not in self.log_levels:
self.settings["daemon"]["log_level"] = self.default_settings["daemon"]["log_level"]

if self.settings["daemon"]["block_sync_size"] not in self.block_sync_sizes:
self.settings["daemon"]["block_sync_size"] = self.default_settings["daemon"]["block_sync_size"]

if self.settings["daemon"]["limit_rate_up"] not in self.limit_rate_ups:
self.settings["daemon"]["limit_rate_up"] = self.default_settings["daemon"]["limit_rate_up"]

if self.settings["daemon"]["limit_rate_down"] not in self.limit_rate_downs:
self.settings["daemon"]["limit_rate_down"] = self.default_settings["daemon"]["limit_rate_down"]

try:
self.settings["blockchain"]["height"] = abs(int(self.settings["blockchain"]["height"]))
except:
self.settings["blockchain"]["height"] = self.default_settings["blockchain"]["height"]

try:
self.settings["application"]["minimize_to_tray"] = bool(self.settings["application"]["minimize_to_tray"])
except:
self.settings["application"]["minimize_to_tray"] = self.default_settings["application"]["minimize_to_tray"]


def save(self):
try:
writeFile(self.app_settings_filepath, \
Expand Down
84 changes: 70 additions & 14 deletions html/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#settings_tab h3{
margin-top: 20px;
margin-bottom: 30px;
margin-bottom: 20px;
}
.syncing{
Expand Down Expand Up @@ -374,6 +374,10 @@
text-align: center;
}
#speed_limit_form select {
font-size: 14px;
}
</style>
<script src="./scripts/jquery-1.9.1.min.js"></script>
Expand All @@ -391,6 +395,11 @@
$('#daemon_log_level_' + log_level).prop('checked', true);
var block_sync_size = app_settings['daemon']['block_sync_size'];
$('#block_sync_size_' + block_sync_size).prop('checked', true);
$('#minimize_to_tray_chk').prop('checked', app_settings['application']['minimize_to_tray']);
$('#up_speed_limit_select').val(app_settings['daemon']['limit_rate_up']);
$('#down_speed_limit_select').val(app_settings['daemon']['limit_rate_down']);
});
app_hub.on_main_wallet_ui_reset_event.connect(function(){
Expand Down Expand Up @@ -754,7 +763,7 @@
var row_rendered = Mustache.render(new_subaddress_row_tmpl,
{ 'address_index': subaddress['address_index'],
'address' : subaddress['address'],
'address_short' : subaddress['address'].substr(0, 70) + '...'
'address_short' : subaddress['address'].substr(0, 60) + '...'
});
Expand All @@ -772,7 +781,7 @@
var row_rendered = Mustache.render(used_subaddress_row_tmpl,
{ 'address_index': subaddress['address_index'],
'address' : subaddress['address'],
'address_short' : subaddress['address'].substr(0, 40) + '...',
'address_short' : subaddress['address'].substr(0, 30) + '...',
'balance': subaddress['balance'],
'unlocked_balance': subaddress['unlocked_balance'],
'row_font_weight': subaddress['address_index'] == 0 ? 'bold' : 'normal'
Expand Down Expand Up @@ -1086,6 +1095,18 @@
}, 1);
}
});
$("#minimize_to_tray_chk").change(function() {
app_hub.change_minimize_to_tray(this.checked);
});
$('#up_speed_limit_select').on('change', function(e) {
app_hub.change_limit_rate_up(this.value);
});
$('#down_speed_limit_select').on('change', function(e) {
app_hub.change_limit_rate_down(this.value);
});
});
</script>
</head>
Expand Down Expand Up @@ -1326,15 +1347,15 @@
<button id="btn_view_spendkey" type="button" class="btn btn-primary" onclick="view_wallet_key('spend_key')"><i class="fa fa-key"></i> Spendkey...</button>
</div>
</div>
<hr style="margin-top:20px;margin-bottom:10px;">
<h3>DAEMON</h3>
<hr style="margin-top:10px;margin-bottom:10px;">
<h3 style="margin-bottom:10px">DAEMON</h3>
<div class="row">
<div class="col-lg-12">
<div class="col-sm-5">
<div class="col-sm-4">
<form class="form-horizontal">
<div class="form-group">
<label class="col-xs-4 control-label">Log level:</label>
<div class="col-xs-8">
<label class="col-xs-12 control-label">Log level:</label>
<div class="col-xs-12">
<div class="radio">
<label>
<input type="radio" name="daemon_log_level" id="daemon_log_level_0" value="0" onclick="set_daemon_log_level(0)" checked="">
Expand Down Expand Up @@ -1369,11 +1390,11 @@
</div>
</form>
</div>
<div class="col-sm-7">
<div class="col-sm-4">
<form class="form-horizontal">
<div class="form-group">
<label class="col-xs-4 control-label">Block sync size:</label>
<div class="col-xs-8">
<label class="col-xs-12 control-label">Block sync size:</label>
<div class="col-xs-12">
<div class="radio">
<label>
<input type="radio" name="daemon_block_sync_size" id="block_sync_size_10" value="10" onclick="set_block_sync_size(10)" checked="">
Expand Down Expand Up @@ -1408,13 +1429,48 @@
</div>
</form>
</div>
<div class="col-sm-12 wallet-settings" style="margin-top: 10px; text-align:center;">
<button id="btn_restart_daemon" type="button" class="btn btn-primary" onclick="restart_daemon()"><i class="fa fa-refresh"></i> Restart Daemon</button>
<div class="col-sm-4">
<form class="form-horizontal" id="speed_limit_form">
<div class="form-group">
<div class="col-xs-12">
<label class="col-xs-12 control-label">Up Speed Limit (kB/s):</label>
<select class="form-control" id="up_speed_limit_select">
<option value="512">512</option>
<option value="1024">1024</option>
<option value="2048" selected>2048</option>
<option value="3072">3072</option>
<option value="4096">4096</option>
<option value="8192">8192</option>
<option value="16384">16384</option>
</select>
</div>
<div class="col-xs-12" style="margin-top: 30px;">
<label class="col-xs-12 control-label">Down Speed Limit (kB/s):</label>
<select class="form-control" id="down_speed_limit_select">
<option value="512">512</option>
<option value="1024">1024</option>
<option value="2048">2048</option>
<option value="4096">4096</option>
<option value="8192" selected>8192</option>
<option value="12288">12288</option>
<option value="16384">16384</option>
</select>
</div>
</div>
</form>
</div>
<div class="col-sm-12 wallet-settings" style="margin-top: 0px; text-align:center;">
<button id="btn_restart_daemon" type="button" class="btn btn-primary" onclick="restart_daemon()"><i class="fa fa-refresh"></i> Apply (Restart Daemon)</button>
<button id="btn_view_log" type="button" class="btn btn-primary" onclick="app_hub.view_daemon_log()"><i class="fa fa-file"></i> View Log...</button>
</div>
</div>
</div>
<hr style="margin-top:10px;margin-bottom:10px;">
<hr style="margin-top:10px;margin-bottom:0px;">
<div class="row">
<div class="col-sm-12 form-group" style="margin-bottom: 0px; margin-top: 20px; text-align: center">
<input id="minimize_to_tray_chk" type="checkbox" value="" checked="checked"> <label class="control-label" for="minimize_to_tray_chk">Close wallet to notification area (system tray)</label>
</div>
</div>
<div class="row">
<div class="col-sm-12" style="margin-top: 10px;text-align: center">
<button id="btn_about" type="button" class="btn btn-primary" onclick="about_app()"><i class="fa fa-user"></i> About...</button>
Expand Down
Loading

0 comments on commit 6b398da

Please sign in to comment.