From 64fb980ae4a5bfad02920dba342bd2aa9f840f38 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Fri, 12 Dec 2014 21:10:53 +0100 Subject: [PATCH] Fix: improve profile and settings printing and disable it by default. --- app/main.cpp | 1 + app/qml/ApplicationSettings.qml | 32 ++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 8809b3b..aceb981 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -37,6 +37,7 @@ int main(int argc, char *argv[]) qDebug() << " --fullscreen Run cool-retro-term in fullscreen."; qDebug() << " -p|--profile 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; } diff --git a/app/qml/ApplicationSettings.qml b/app/qml/ApplicationSettings.qml index 8316a8a..c85c7c6 100644 --- a/app/qml/ApplicationSettings.qml +++ b/app/qml/ApplicationSettings.qml @@ -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