1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2025-03-20 09:39:07 +00:00

Fix: improve profile and settings printing and disable it by default.

This commit is contained in:
Filippo Scognamiglio 2014-12-12 21:10:53 +01:00
parent c58f85c6ac
commit 64fb980ae4
2 changed files with 25 additions and 8 deletions

View File

@ -37,6 +37,7 @@ int main(int argc, char *argv[])
qDebug() << " --fullscreen Run cool-retro-term in fullscreen.";
qDebug() << " -p|--profile <prof> Run cool-retro-term with the given profile.";
qDebug() << " -h|--help Print this help.";
qDebug() << " --verbose Print additional informations such as profiles and settings.";
return 0;
}

View File

@ -36,10 +36,13 @@ Item{
property bool show_terminal_size: true
property real window_scaling: 1.0
onWindow_scalingChanged: handleFontChanged();
property real fps: 24
property bool verbose: false
onWindow_scalingChanged: handleFontChanged();
function mix(c1, c2, alpha){
return Qt.rgba(c1.r * alpha + c2.r * (1-alpha),
c1.g * alpha + c2.g * (1-alpha),
@ -165,6 +168,13 @@ Item{
Storage{id: storage}
function stringify(obj) {
var replacer = function(key, val) {
return val.toFixed ? Number(val.toFixed(4)) : val;
}
return JSON.stringify(obj, replacer, 2);
}
function composeSettingsString(){
var settings = {
fps: fps,
@ -177,7 +187,7 @@ Item{
scanline_quality: scanline_quality,
bloom_quality: bloom_quality
}
return JSON.stringify(settings);
return stringify(settings);
}
function composeProfileString(){
@ -204,7 +214,7 @@ Item{
fontIndex: fontIndexes[rasterization],
fontWidth: fontWidth
}
return JSON.stringify(settings);
return stringify(settings);
}
function loadSettings(){
@ -217,7 +227,8 @@ Item{
loadSettingsString(settingsString);
loadProfileString(profileString);
console.log("Loading settings: " + settingsString + profileString);
if (verbose)
console.log("Loading settings: " + settingsString + profileString);
}
function storeSettings(){
@ -227,8 +238,10 @@ Item{
storage.setSetting("_CURRENT_SETTINGS", settingsString);
storage.setSetting("_CURRENT_PROFILE", profileString);
console.log("Storing settings: " + settingsString);
console.log("Storing profile: " + profileString);
if (verbose) {
console.log("Storing settings: " + settingsString);
console.log("Storing profile: " + profileString);
}
}
function loadSettingsString(settingsString){
@ -298,7 +311,7 @@ Item{
var customProfiles = JSON.parse(customProfilesString);
for (var i=0; i<customProfiles.length; i++) {
var profile = customProfiles[i];
console.log("Loading custom profile: " + JSON.stringify(profile));
console.log("Loading custom profile: " + stringify(profile));
profiles_list.append(profile);
}
}
@ -310,7 +323,7 @@ Item{
if(profile.builtin) continue;
customProfiles.push({text: profile.text, obj_string: profile.obj_string, builtin: false})
}
return JSON.stringify(customProfiles);
return stringify(customProfiles);
}
function loadCurrentProfile(){
@ -389,6 +402,9 @@ Item{
Component.onCompleted: {
// Manage the arguments from the QML side.
var args = Qt.application.arguments;
if (args.indexOf("--verbose") !== -1) {
verbose = true;
}
if (args.indexOf("--default-settings") === -1) {
loadSettings();
}