2013-12-28 14:52:10 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2013 "Filippo Scognamiglio"
|
2014-09-03 22:19:34 +02:00
|
|
|
* https://github.com/Swordfish90/cool-retro-term
|
2013-12-28 14:52:10 +01:00
|
|
|
*
|
2014-09-03 22:19:34 +02:00
|
|
|
* This file is part of cool-retro-term.
|
2013-12-28 14:52:10 +01:00
|
|
|
*
|
2014-09-03 22:19:34 +02:00
|
|
|
* cool-retro-term is free software: you can redistribute it and/or modify
|
2013-12-28 14:52:10 +01:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2014-04-17 13:56:13 +02:00
|
|
|
import QtQuick 2.2
|
2015-01-08 03:55:19 +01:00
|
|
|
import QtQuick.Controls 1.0
|
2013-11-23 16:09:46 +01:00
|
|
|
|
2014-12-12 21:31:19 +01:00
|
|
|
import "utils.js" as Utils
|
|
|
|
|
2014-12-23 00:49:33 +01:00
|
|
|
QtObject{
|
2017-10-27 18:28:43 +02:00
|
|
|
property string version: "1.0.1"
|
2014-06-27 23:54:17 +02:00
|
|
|
|
2015-01-20 00:57:23 +01:00
|
|
|
// STATIC CONSTANTS ////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
readonly property real minimumFontScaling: 0.25
|
|
|
|
readonly property real maximumFontScaling: 2.50
|
|
|
|
|
|
|
|
// GENERAL SETTINGS ///////////////////////////////////////////////////////
|
2014-06-27 23:54:17 +02:00
|
|
|
|
2016-08-06 13:43:04 -05:00
|
|
|
property int x: 100
|
|
|
|
property int y: 100
|
|
|
|
property int width: 1024
|
|
|
|
property int height: 768
|
|
|
|
|
2013-12-30 02:28:30 +01:00
|
|
|
property bool fullscreen: false
|
2014-08-01 00:07:54 +02:00
|
|
|
property bool showMenubar: true
|
2013-12-30 02:28:30 +01:00
|
|
|
|
2018-01-06 20:17:28 +01:00
|
|
|
property string wintitle: "cool-retro-term"
|
|
|
|
|
2014-07-14 02:23:22 +02:00
|
|
|
property real windowOpacity: 1.0
|
2014-12-23 18:13:34 +01:00
|
|
|
property real ambientLight: 0.2
|
2014-04-03 15:29:07 +02:00
|
|
|
property real contrast: 0.85
|
2014-06-27 03:00:31 +02:00
|
|
|
property real brightness: 0.5
|
2014-03-31 17:26:51 +02:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
property bool showTerminalSize: true
|
|
|
|
property real windowScaling: 1.0
|
2014-04-02 22:07:37 +02:00
|
|
|
|
2014-11-11 15:19:03 +01:00
|
|
|
property real fps: 24
|
2014-12-12 21:10:53 +01:00
|
|
|
property bool verbose: false
|
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
onWindowScalingChanged: handleFontChanged();
|
2014-12-12 21:10:53 +01:00
|
|
|
|
2014-06-27 23:54:17 +02:00
|
|
|
// PROFILE SETTINGS ///////////////////////////////////////////////////////
|
|
|
|
|
2016-03-20 14:54:29 -07:00
|
|
|
property bool useCustomCommand: false
|
|
|
|
property string customCommand: ""
|
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
property string _backgroundColor: "#000000"
|
|
|
|
property string _fontColor: "#ff8100"
|
|
|
|
property string saturatedColor: Utils.mix(Utils.strToColor("#FFFFFF"), Utils.strToColor(_fontColor), saturationColor * 0.5)
|
|
|
|
property color fontColor: Utils.mix(Utils.strToColor(saturatedColor), Utils.strToColor(_backgroundColor), 0.7 + (contrast * 0.3))
|
|
|
|
property color backgroundColor: Utils.mix(Utils.strToColor(_backgroundColor), Utils.strToColor(saturatedColor), 0.7 + (contrast * 0.3))
|
2013-11-25 02:19:44 +01:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
property real staticNoise: 0.1
|
|
|
|
property real screenCurvature: 0.1
|
|
|
|
property real glowingLine: 0.2
|
|
|
|
property real burnIn: 0.40
|
|
|
|
property real bloom: 0.65
|
2013-12-25 02:26:18 +01:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
property real bloomQuality: 0.5
|
|
|
|
property real burnInQuality: 0.5
|
2014-09-30 00:57:57 +02:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
property real chromaColor: 0.0
|
|
|
|
property real saturationColor: 0.0
|
2014-08-01 00:04:59 +02:00
|
|
|
|
2014-06-27 03:00:31 +02:00
|
|
|
property real jitter: 0.18
|
2014-06-20 12:30:42 +02:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
property real horizontalSync: 0.08
|
|
|
|
property real flickering: 0.1
|
2014-03-25 16:30:07 +01:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
property real rbgShift: 0.0
|
2014-08-11 19:23:03 +02:00
|
|
|
|
2014-04-03 15:06:16 +02:00
|
|
|
readonly property int no_rasterization: 0
|
|
|
|
readonly property int scanline_rasterization: 1
|
|
|
|
readonly property int pixel_rasterization: 2
|
|
|
|
|
|
|
|
property int rasterization: no_rasterization
|
2014-06-25 14:29:10 +02:00
|
|
|
|
2014-06-27 23:54:17 +02:00
|
|
|
// FONTS //////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-11-17 23:17:36 +01:00
|
|
|
readonly property real baseFontScaling: 0.75
|
2014-12-12 01:38:32 +01:00
|
|
|
property real fontScaling: 1.0
|
2018-11-17 23:17:36 +01:00
|
|
|
property real totalFontScaling: baseFontScaling * fontScaling
|
|
|
|
|
2014-12-12 01:38:32 +01:00
|
|
|
property real fontWidth: 1.0
|
|
|
|
|
2014-12-31 13:46:03 +01:00
|
|
|
property bool lowResolutionFont: false
|
|
|
|
|
2015-01-24 19:11:54 +01:00
|
|
|
property var fontNames: ["TERMINUS_SCALED", "COMMODORE_PET", "COMMODORE_PET"]
|
2014-12-12 01:38:32 +01:00
|
|
|
property var fontlist: fontManager.item.fontlist
|
|
|
|
|
2018-10-22 00:04:31 +02:00
|
|
|
signal terminalFontChanged(string fontFamily, int pixelSize, int lineSpacing, real screenScaling, real fontWidth)
|
2014-05-31 19:28:35 +02:00
|
|
|
|
2016-03-21 12:55:09 -07:00
|
|
|
signal initializedSettings()
|
|
|
|
|
2014-12-23 00:49:33 +01:00
|
|
|
property Loader fontManager: Loader{
|
2014-06-23 16:25:41 +02:00
|
|
|
states: [
|
|
|
|
State { when: rasterization == no_rasterization
|
|
|
|
PropertyChanges {target: fontManager; source: "Fonts.qml" } },
|
|
|
|
State { when: rasterization == scanline_rasterization
|
|
|
|
PropertyChanges {target: fontManager; source: "FontScanlines.qml" } },
|
|
|
|
State { when: rasterization == pixel_rasterization;
|
|
|
|
PropertyChanges {target: fontManager; source: "FontPixels.qml" } }
|
|
|
|
]
|
2014-04-05 15:14:52 +02:00
|
|
|
|
2014-06-23 16:25:41 +02:00
|
|
|
onLoaded: handleFontChanged()
|
2013-12-27 22:25:33 +01:00
|
|
|
}
|
|
|
|
|
2018-10-22 00:04:31 +02:00
|
|
|
property FontLoader fontLoader: FontLoader { }
|
|
|
|
|
2014-09-29 22:38:33 +02:00
|
|
|
onFontScalingChanged: handleFontChanged();
|
2014-12-12 01:38:32 +01:00
|
|
|
onFontWidthChanged: handleFontChanged();
|
2014-07-14 00:53:17 +02:00
|
|
|
|
2014-12-16 01:22:46 +01:00
|
|
|
function getIndexByName(name) {
|
|
|
|
for (var i = 0; i < fontlist.count; i++) {
|
2018-10-22 00:04:31 +02:00
|
|
|
var requestedName = fontlist.get(i).name;
|
|
|
|
if (name === requestedName)
|
2014-12-16 01:22:46 +01:00
|
|
|
return i;
|
|
|
|
}
|
2014-12-26 00:00:35 +01:00
|
|
|
return 0; // If the font is not available default to 0.
|
2014-12-16 01:22:46 +01:00
|
|
|
}
|
|
|
|
|
2014-09-29 22:38:33 +02:00
|
|
|
function incrementScaling(){
|
2015-01-20 00:57:23 +01:00
|
|
|
fontScaling = Math.min(fontScaling + 0.05, maximumFontScaling);
|
2014-07-14 00:53:17 +02:00
|
|
|
handleFontChanged();
|
|
|
|
}
|
|
|
|
|
2014-09-29 22:38:33 +02:00
|
|
|
function decrementScaling(){
|
2015-01-20 00:57:23 +01:00
|
|
|
fontScaling = Math.max(fontScaling - 0.05, minimumFontScaling);
|
2014-09-29 22:38:33 +02:00
|
|
|
handleFontChanged();
|
2014-07-14 00:53:17 +02:00
|
|
|
}
|
2014-06-23 16:25:41 +02:00
|
|
|
|
|
|
|
function handleFontChanged(){
|
2014-12-16 01:22:46 +01:00
|
|
|
if (!fontManager.item) return;
|
|
|
|
|
|
|
|
var index = getIndexByName(fontNames[rasterization]);
|
|
|
|
if (index === undefined) return;
|
|
|
|
|
|
|
|
fontManager.item.selectedFontIndex = index;
|
2018-11-17 23:17:36 +01:00
|
|
|
fontManager.item.scaling = totalFontScaling * windowScaling;
|
2014-06-25 14:29:10 +02:00
|
|
|
|
|
|
|
var fontSource = fontManager.item.source;
|
|
|
|
var pixelSize = fontManager.item.pixelSize;
|
|
|
|
var lineSpacing = fontManager.item.lineSpacing;
|
2014-09-10 00:59:53 +02:00
|
|
|
var screenScaling = fontManager.item.screenScaling;
|
2014-12-12 01:38:32 +01:00
|
|
|
var fontWidth = fontManager.item.defaultFontWidth * appSettings.fontWidth;
|
2018-10-22 00:04:31 +02:00
|
|
|
var fontFamily = fontManager.item.family;
|
|
|
|
var isSystemFont = fontManager.item.isSystemFont;
|
2014-06-25 14:29:10 +02:00
|
|
|
|
2014-12-31 13:46:03 +01:00
|
|
|
lowResolutionFont = fontManager.item.lowResolutionFont;
|
|
|
|
|
2018-10-22 00:04:31 +02:00
|
|
|
if (!isSystemFont) {
|
|
|
|
fontLoader.source = fontSource;
|
|
|
|
fontFamily = fontLoader.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
terminalFontChanged(fontFamily, pixelSize, lineSpacing, screenScaling, fontWidth);
|
2013-12-27 19:11:11 +01:00
|
|
|
}
|
|
|
|
|
2014-06-27 23:54:17 +02:00
|
|
|
// FRAMES /////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-12-26 00:00:35 +01:00
|
|
|
property ListModel framesList: ListModel{
|
|
|
|
ListElement{
|
|
|
|
name: "NO_FRAME"
|
|
|
|
text: "No frame"
|
|
|
|
source: ""
|
|
|
|
reflections: false
|
|
|
|
}
|
|
|
|
ListElement{
|
|
|
|
name: "SIMPLE_WHITE_FRAME"
|
|
|
|
text: "Simple white frame"
|
|
|
|
source: "./frames/WhiteSimpleFrame.qml"
|
|
|
|
reflections: true
|
|
|
|
}
|
|
|
|
ListElement{
|
|
|
|
name: "ROUGH_BLACK_FRAME"
|
|
|
|
text: "Rough black frame"
|
|
|
|
source: "./frames/BlackRoughFrame.qml"
|
|
|
|
reflections: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFrameIndexByName(name) {
|
|
|
|
for (var i = 0; i < framesList.count; i++) {
|
|
|
|
if (name === framesList.get(i).name)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return 0; // If the frame is not available default to 0.
|
|
|
|
}
|
|
|
|
|
|
|
|
property string frameSource: "./frames/WhiteSimpleFrame.qml"
|
|
|
|
property string frameName: "SIMPLE_WHITE_FRAME"
|
|
|
|
|
2014-12-20 14:58:57 +01:00
|
|
|
property bool _frameReflections: false
|
2014-12-26 00:00:35 +01:00
|
|
|
property bool reflectionsAllowed: true
|
2014-07-06 23:57:47 +02:00
|
|
|
property bool frameReflections: _frameReflections && reflectionsAllowed
|
2014-06-23 16:25:41 +02:00
|
|
|
|
2014-12-26 00:00:35 +01:00
|
|
|
onFrameNameChanged: {
|
|
|
|
var index = getFrameIndexByName(frameName);
|
|
|
|
frameSource = framesList.get(index).source;
|
|
|
|
reflectionsAllowed = framesList.get(index).reflections;
|
2014-12-20 18:05:30 +01:00
|
|
|
}
|
|
|
|
|
2014-06-27 23:54:17 +02:00
|
|
|
// DB STORAGE /////////////////////////////////////////////////////////////
|
|
|
|
|
2014-12-23 00:49:33 +01:00
|
|
|
property Storage storage: Storage{ }
|
2013-12-28 00:21:12 +01:00
|
|
|
|
2014-12-12 21:10:53 +01:00
|
|
|
function stringify(obj) {
|
|
|
|
var replacer = function(key, val) {
|
|
|
|
return val.toFixed ? Number(val.toFixed(4)) : val;
|
|
|
|
}
|
|
|
|
return JSON.stringify(obj, replacer, 2);
|
|
|
|
}
|
|
|
|
|
2014-05-18 22:23:19 +02:00
|
|
|
function composeSettingsString(){
|
|
|
|
var settings = {
|
|
|
|
fps: fps,
|
2016-08-06 13:43:04 -05:00
|
|
|
x: x,
|
|
|
|
y: y,
|
|
|
|
width: width,
|
|
|
|
height: height,
|
2014-12-23 18:13:34 +01:00
|
|
|
windowScaling: windowScaling,
|
|
|
|
showTerminalSize: showTerminalSize,
|
2014-09-29 22:38:33 +02:00
|
|
|
fontScaling: fontScaling,
|
2014-12-16 01:22:46 +01:00
|
|
|
fontNames: fontNames,
|
2014-07-14 02:23:22 +02:00
|
|
|
frameReflections: _frameReflections,
|
2014-09-29 21:26:41 +02:00
|
|
|
showMenubar: showMenubar,
|
2014-12-23 18:13:34 +01:00
|
|
|
bloomQuality: bloomQuality,
|
|
|
|
burnInQuality: burnInQuality
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
2014-12-12 21:10:53 +01:00
|
|
|
return stringify(settings);
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
|
|
|
|
2014-12-26 02:54:38 +01:00
|
|
|
function composeProfileObject(){
|
2014-05-18 22:23:19 +02:00
|
|
|
var settings = {
|
2014-12-23 18:13:34 +01:00
|
|
|
backgroundColor: _backgroundColor,
|
|
|
|
fontColor: _fontColor,
|
|
|
|
flickering: flickering,
|
|
|
|
horizontalSync: horizontalSync,
|
|
|
|
staticNoise: staticNoise,
|
|
|
|
chromaColor: chromaColor,
|
|
|
|
saturationColor: saturationColor,
|
|
|
|
screenCurvature: screenCurvature,
|
|
|
|
glowingLine: glowingLine,
|
2014-12-26 00:00:35 +01:00
|
|
|
frameName: frameName,
|
2014-12-23 18:13:34 +01:00
|
|
|
burnIn: burnIn,
|
|
|
|
bloom: bloom,
|
2014-06-20 12:30:42 +02:00
|
|
|
rasterization: rasterization,
|
2014-06-25 14:29:10 +02:00
|
|
|
jitter: jitter,
|
2014-12-23 18:13:34 +01:00
|
|
|
rbgShift: rbgShift,
|
2014-07-16 00:38:16 +02:00
|
|
|
brightness: brightness,
|
|
|
|
contrast: contrast,
|
2014-12-23 18:13:34 +01:00
|
|
|
ambientLight: ambientLight,
|
2014-07-16 00:38:16 +02:00
|
|
|
windowOpacity: windowOpacity,
|
2014-12-16 01:22:46 +01:00
|
|
|
fontName: fontNames[rasterization],
|
2016-03-20 14:54:29 -07:00
|
|
|
fontWidth: fontWidth,
|
|
|
|
useCustomCommand: useCustomCommand,
|
|
|
|
customCommand: customCommand
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
2014-12-26 02:54:38 +01:00
|
|
|
return settings;
|
|
|
|
}
|
|
|
|
|
|
|
|
function composeProfileString() {
|
|
|
|
return stringify(composeProfileObject());
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadSettings(){
|
|
|
|
var settingsString = storage.getSetting("_CURRENT_SETTINGS");
|
|
|
|
var profileString = storage.getSetting("_CURRENT_PROFILE");
|
|
|
|
|
|
|
|
if(!settingsString) return;
|
|
|
|
if(!profileString) return;
|
|
|
|
|
|
|
|
loadSettingsString(settingsString);
|
|
|
|
loadProfileString(profileString);
|
|
|
|
|
2014-12-12 21:10:53 +01:00
|
|
|
if (verbose)
|
|
|
|
console.log("Loading settings: " + settingsString + profileString);
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function storeSettings(){
|
|
|
|
var settingsString = composeSettingsString();
|
|
|
|
var profileString = composeProfileString();
|
|
|
|
|
|
|
|
storage.setSetting("_CURRENT_SETTINGS", settingsString);
|
|
|
|
storage.setSetting("_CURRENT_PROFILE", profileString);
|
|
|
|
|
2014-12-12 21:10:53 +01:00
|
|
|
if (verbose) {
|
|
|
|
console.log("Storing settings: " + settingsString);
|
|
|
|
console.log("Storing profile: " + profileString);
|
|
|
|
}
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadSettingsString(settingsString){
|
|
|
|
var settings = JSON.parse(settingsString);
|
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
showTerminalSize = settings.showTerminalSize !== undefined ? settings.showTerminalSize : showTerminalSize
|
2014-04-17 13:27:41 +02:00
|
|
|
|
2014-04-03 18:44:23 +02:00
|
|
|
fps = settings.fps !== undefined ? settings.fps: fps
|
2014-12-23 18:13:34 +01:00
|
|
|
windowScaling = settings.windowScaling !== undefined ? settings.windowScaling : windowScaling
|
2014-04-03 18:44:23 +02:00
|
|
|
|
2016-08-06 13:43:04 -05:00
|
|
|
x = settings.x !== undefined ? settings.x : x
|
|
|
|
y = settings.y !== undefined ? settings.y : y
|
|
|
|
width = settings.width !== undefined ? settings.width : width
|
|
|
|
height = settings.height !== undefined ? settings.height : height
|
|
|
|
|
2014-12-16 01:22:46 +01:00
|
|
|
fontNames = settings.fontNames !== undefined ? settings.fontNames : fontNames
|
2014-09-29 22:38:33 +02:00
|
|
|
fontScaling = settings.fontScaling !== undefined ? settings.fontScaling : fontScaling
|
2014-07-06 23:57:47 +02:00
|
|
|
|
|
|
|
_frameReflections = settings.frameReflections !== undefined ? settings.frameReflections : _frameReflections;
|
2014-08-01 00:07:54 +02:00
|
|
|
|
|
|
|
showMenubar = settings.showMenubar !== undefined ? settings.showMenubar : showMenubar;
|
2014-09-29 21:26:41 +02:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
bloomQuality = settings.bloomQuality !== undefined ? settings.bloomQuality : bloomQuality;
|
|
|
|
burnInQuality = settings.burnInQuality !== undefined ? settings.burnInQuality : burnInQuality;
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadProfileString(profileString){
|
|
|
|
var settings = JSON.parse(profileString);
|
2014-03-27 13:59:48 +01:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
_backgroundColor = settings.backgroundColor !== undefined ? settings.backgroundColor : _backgroundColor;
|
|
|
|
_fontColor = settings.fontColor !== undefined ? settings.fontColor : _fontColor;
|
2013-12-28 00:21:12 +01:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
horizontalSync = settings.horizontalSync !== undefined ? settings.horizontalSync : horizontalSync
|
|
|
|
flickering = settings.flickering !== undefined ? settings.flickering : flickering;
|
|
|
|
staticNoise = settings.staticNoise !== undefined ? settings.staticNoise : staticNoise;
|
|
|
|
chromaColor = settings.chromaColor !== undefined ? settings.chromaColor : chromaColor;
|
|
|
|
saturationColor = settings.saturationColor !== undefined ? settings.saturationColor : saturationColor;
|
|
|
|
screenCurvature = settings.screenCurvature !== undefined ? settings.screenCurvature : screenCurvature;
|
|
|
|
glowingLine = settings.glowingLine !== undefined ? settings.glowingLine : glowingLine;
|
2013-12-28 00:21:12 +01:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
burnIn = settings.burnIn !== undefined ? settings.burnIn : burnIn
|
|
|
|
bloom = settings.bloom !== undefined ? settings.bloom : bloom
|
2014-03-22 11:11:27 +01:00
|
|
|
|
2014-12-26 00:00:35 +01:00
|
|
|
frameName = settings.frameName !== undefined ? settings.frameName : frameName;
|
2013-12-28 02:42:24 +01:00
|
|
|
|
2014-04-03 18:08:07 +02:00
|
|
|
rasterization = settings.rasterization !== undefined ? settings.rasterization : rasterization;
|
2014-06-20 12:30:42 +02:00
|
|
|
|
2014-06-25 14:29:10 +02:00
|
|
|
jitter = settings.jitter !== undefined ? settings.jitter : jitter;
|
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
rbgShift = settings.rbgShift !== undefined ? settings.rbgShift : rbgShift;
|
2014-08-11 19:23:03 +02:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
ambientLight = settings.ambientLight !== undefined ? settings.ambientLight : ambientLight;
|
2014-07-16 00:38:16 +02:00
|
|
|
contrast = settings.contrast !== undefined ? settings.contrast : contrast;
|
|
|
|
brightness = settings.brightness !== undefined ? settings.brightness : brightness;
|
|
|
|
windowOpacity = settings.windowOpacity !== undefined ? settings.windowOpacity : windowOpacity;
|
|
|
|
|
2014-12-16 01:22:46 +01:00
|
|
|
fontNames[rasterization] = settings.fontName !== undefined ? settings.fontName : fontNames[rasterization];
|
2014-09-29 01:41:43 +02:00
|
|
|
fontWidth = settings.fontWidth !== undefined ? settings.fontWidth : fontWidth;
|
2014-12-26 19:47:11 +01:00
|
|
|
|
2016-03-20 14:54:29 -07:00
|
|
|
useCustomCommand = settings.useCustomCommand !== undefined ? settings.useCustomCommand : useCustomCommand
|
|
|
|
customCommand = settings.customCommand !== undefined ? settings.customCommand : customCommand
|
|
|
|
|
2014-12-26 19:47:11 +01:00
|
|
|
handleFontChanged();
|
2013-12-28 00:21:12 +01:00
|
|
|
}
|
|
|
|
|
2014-05-18 22:23:19 +02:00
|
|
|
function storeCustomProfiles(){
|
|
|
|
storage.setSetting("_CUSTOM_PROFILES", composeCustomProfilesString());
|
|
|
|
}
|
2013-12-28 00:21:12 +01:00
|
|
|
|
2014-05-18 22:23:19 +02:00
|
|
|
function loadCustomProfiles(){
|
|
|
|
var customProfileString = storage.getSetting("_CUSTOM_PROFILES");
|
|
|
|
if(customProfileString === undefined) customProfileString = "[]";
|
|
|
|
loadCustomProfilesString(customProfileString);
|
2013-12-28 00:21:12 +01:00
|
|
|
}
|
|
|
|
|
2014-05-18 22:23:19 +02:00
|
|
|
function loadCustomProfilesString(customProfilesString){
|
|
|
|
var customProfiles = JSON.parse(customProfilesString);
|
|
|
|
for (var i=0; i<customProfiles.length; i++) {
|
|
|
|
var profile = customProfiles[i];
|
2014-12-26 00:44:32 +01:00
|
|
|
|
|
|
|
if (verbose)
|
|
|
|
console.log("Loading custom profile: " + stringify(profile));
|
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
profilesList.append(profile);
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function composeCustomProfilesString(){
|
|
|
|
var customProfiles = []
|
2014-12-23 18:13:34 +01:00
|
|
|
for(var i=0; i<profilesList.count; i++){
|
|
|
|
var profile = profilesList.get(i);
|
2014-05-18 22:23:19 +02:00
|
|
|
if(profile.builtin) continue;
|
|
|
|
customProfiles.push({text: profile.text, obj_string: profile.obj_string, builtin: false})
|
2013-12-28 03:40:45 +01:00
|
|
|
}
|
2014-12-12 21:10:53 +01:00
|
|
|
return stringify(customProfiles);
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
2013-12-28 03:40:45 +01:00
|
|
|
|
2014-05-18 22:23:19 +02:00
|
|
|
function loadProfile(index){
|
2014-12-23 18:13:34 +01:00
|
|
|
var profile = profilesList.get(index);
|
2014-05-18 22:23:19 +02:00
|
|
|
loadProfileString(profile.obj_string);
|
|
|
|
}
|
|
|
|
|
2014-12-26 17:19:34 +01:00
|
|
|
function appendCustomProfile(name, profileString) {
|
2014-12-23 18:13:34 +01:00
|
|
|
profilesList.append({text: name, obj_string: profileString, builtin: false});
|
2014-05-18 22:23:19 +02:00
|
|
|
}
|
|
|
|
|
2014-06-27 23:54:17 +02:00
|
|
|
// PROFILES ///////////////////////////////////////////////////////////////
|
2013-12-28 03:40:45 +01:00
|
|
|
|
2014-12-23 18:13:34 +01:00
|
|
|
property ListModel profilesList: ListModel{
|
2014-03-22 11:11:27 +01:00
|
|
|
ListElement{
|
2014-06-27 03:00:31 +02:00
|
|
|
text: "Default Amber"
|
2016-03-20 14:54:29 -07:00
|
|
|
obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.65,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"TERMINUS_SCALED","fontColor":"#ff8100","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.16,"jitter":0.18,"burnIn":0.4,"staticNoise":0.1,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0,"useCustomCommand":false,"customCommand":""}'
|
2014-05-18 22:23:19 +02:00
|
|
|
builtin: true
|
|
|
|
}
|
|
|
|
ListElement{
|
2014-06-27 03:00:31 +02:00
|
|
|
text: "Default Green"
|
2016-03-20 14:54:29 -07:00
|
|
|
obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.4,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"TERMINUS_SCALED","fontColor":"#0ccc68","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.16,"jitter":0.18,"burnIn":0.45,"staticNoise":0.1,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0,"useCustomCommand":false,"customCommand":""}'
|
2014-06-27 03:00:31 +02:00
|
|
|
builtin: true
|
|
|
|
}
|
|
|
|
ListElement{
|
|
|
|
text: "Default Scanlines"
|
2016-03-20 14:54:29 -07:00
|
|
|
obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.4,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"COMMODORE_PET","fontColor":"#00ff5b","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.14,"jitter":0.11,"burnIn":0.4,"staticNoise":0.05,"rasterization":1,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0,"useCustomCommand":false,"customCommand":""}'
|
2014-06-27 03:00:31 +02:00
|
|
|
builtin: true
|
|
|
|
}
|
|
|
|
ListElement{
|
|
|
|
text: "Default Pixelated"
|
2016-03-20 14:54:29 -07:00
|
|
|
obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0,"brightness":0.5,"flickering":0.2,"contrast":0.85,"fontName":"COMMODORE_PET","fontColor":"#ffffff","frameName":"ROUGH_BLACK_FRAME","glowingLine":0.2,"horizontalSync":0.2,"jitter":0,"burnIn":0.45,"staticNoise":0.19,"rasterization":2,"screenCurvature":0.05,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0,"useCustomCommand":false,"customCommand":""}'
|
2014-06-27 03:00:31 +02:00
|
|
|
builtin: true
|
|
|
|
}
|
|
|
|
ListElement{
|
|
|
|
text: "Apple ]["
|
2016-03-20 14:54:29 -07:00
|
|
|
obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.5,"brightness":0.5,"flickering":0.2,"contrast":0.85,"fontName":"APPLE_II","fontColor":"#2fff91","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.22,"horizontalSync":0.16,"jitter":0.1,"burnIn":0.65,"staticNoise":0.08,"rasterization":1,"screenCurvature":0.18,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0,"useCustomCommand":false,"customCommand":""}'
|
2014-06-27 03:00:31 +02:00
|
|
|
builtin: true
|
|
|
|
}
|
|
|
|
ListElement{
|
|
|
|
text: "Vintage"
|
2016-03-20 14:54:29 -07:00
|
|
|
obj_string: '{"ambientLight":0.5,"backgroundColor":"#000000","bloom":0.4,"brightness":0.5,"flickering":0.9,"contrast":0.80,"fontName":"COMMODORE_PET","fontColor":"#00ff3e","frameName":"ROUGH_BLACK_FRAME","glowingLine":0.3,"horizontalSync":0.42,"jitter":0.4,"burnIn":0.75,"staticNoise":0.2,"rasterization":1,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0,"useCustomCommand":false,"customCommand":""}'
|
2014-05-18 22:23:19 +02:00
|
|
|
builtin: true
|
|
|
|
}
|
|
|
|
ListElement{
|
|
|
|
text: "IBM Dos"
|
2016-03-20 14:54:29 -07:00
|
|
|
obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.4,"brightness":0.5,"flickering":0.07,"contrast":0.85,"fontName":"IBM_DOS","fontColor":"#ffffff","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.13,"horizontalSync":0,"jitter":0.16,"burnIn":0.3,"staticNoise":0.03,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":1,"saturationColor":0,"rbgShift":0.35,"fontWidth":1.0,"useCustomCommand":false,"customCommand":""}'
|
2014-07-16 00:38:16 +02:00
|
|
|
builtin: true
|
|
|
|
}
|
2014-08-07 00:13:59 -03:00
|
|
|
ListElement{
|
|
|
|
text: "IBM 3278"
|
2016-03-20 14:54:29 -07:00
|
|
|
obj_string: '{"ambientLight":0.1,"backgroundColor":"#000000","bloom":0.15,"brightness":0.5,"flickering":0,"contrast":0.85,"fontName":"IBM_3278","fontColor":"#0ccc68","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0,"horizontalSync":0,"jitter":0,"burnIn":0.6,"staticNoise":0,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0,"useCustomCommand":false,"customCommand":""}'
|
2014-08-07 00:13:59 -03:00
|
|
|
builtin: true
|
|
|
|
}
|
2014-07-16 00:38:16 +02:00
|
|
|
ListElement{
|
2018-01-24 21:58:34 +01:00
|
|
|
text: "Knight TV"
|
|
|
|
obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.45,"brightness":0.5,"burnIn":0.3,"chromaColor":0,"contrast":0.85,"customCommand":"","flickering":0.1,"fontColor":"#0ccc68","fontName":"Knight_TV","fontWidth":1,"frameName":"SIMPLE_WHITE_FRAME","glowingLine":0,"horizontalSync":0.16,"jitter":0,"rasterization":0,"rbgShift":0,"saturationColor":0,"screenCurvature":0.07,"staticNoise":0,"useCustomCommand":false,"windowOpacity":1}'
|
|
|
|
builtin: true
|
|
|
|
}
|
|
|
|
ListElement{
|
2014-07-16 00:38:16 +02:00
|
|
|
text: "Transparent Green"
|
2016-03-20 14:54:29 -07:00
|
|
|
obj_string: '{"ambientLight":0.2,"backgroundColor":"#000000","bloom":0.45,"brightness":0.5,"flickering":0.20,"contrast":0.85,"fontName":"TERMINUS_SCALED","fontColor":"#0ccc68","frameName":"NO_FRAME","glowingLine":0.16,"horizontalSync":0.1,"jitter":0.20,"burnIn":0.25,"staticNoise":0.20,"rasterization":0,"screenCurvature":0.05,"windowOpacity":0.60,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0,"useCustomCommand":false,"customCommand":""}'
|
2014-05-18 22:23:19 +02:00
|
|
|
builtin: true
|
2014-03-22 11:11:27 +01:00
|
|
|
}
|
2013-12-28 00:21:12 +01:00
|
|
|
}
|
2014-06-27 23:54:17 +02:00
|
|
|
|
2014-10-04 00:43:15 +02:00
|
|
|
function getProfileIndexByName(name) {
|
2014-12-23 18:13:34 +01:00
|
|
|
for (var i = 0; i < profilesList.count; i++) {
|
|
|
|
if(profilesList.get(i).text === name)
|
2014-10-04 00:43:15 +02:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-06-27 23:54:17 +02:00
|
|
|
Component.onCompleted: {
|
2014-10-04 00:43:15 +02:00
|
|
|
// Manage the arguments from the QML side.
|
|
|
|
var args = Qt.application.arguments;
|
2014-12-12 21:10:53 +01:00
|
|
|
if (args.indexOf("--verbose") !== -1) {
|
|
|
|
verbose = true;
|
|
|
|
}
|
2014-10-04 00:43:15 +02:00
|
|
|
if (args.indexOf("--default-settings") === -1) {
|
|
|
|
loadSettings();
|
|
|
|
}
|
|
|
|
|
2014-06-27 23:54:17 +02:00
|
|
|
loadCustomProfiles();
|
2014-10-04 00:43:15 +02:00
|
|
|
|
|
|
|
var profileArgPosition = args.indexOf("--profile");
|
|
|
|
if (profileArgPosition !== -1) {
|
|
|
|
var profileIndex = getProfileIndexByName(args[profileArgPosition + 1]);
|
|
|
|
if (profileIndex !== -1)
|
|
|
|
loadProfile(profileIndex);
|
|
|
|
else
|
|
|
|
console.log("Warning: selected profile is not valid; ignoring it");
|
|
|
|
}
|
2014-10-10 00:40:31 +02:00
|
|
|
|
|
|
|
if (args.indexOf("--fullscreen") !== -1) {
|
|
|
|
fullscreen = true;
|
|
|
|
showMenubar = false;
|
|
|
|
}
|
2016-03-21 12:55:09 -07:00
|
|
|
|
2018-01-06 20:17:28 +01:00
|
|
|
if (args.indexOf("-T") !== -1) {
|
|
|
|
wintitle = args[args.indexOf("-T") + 1]
|
|
|
|
}
|
|
|
|
|
2016-03-21 12:55:09 -07:00
|
|
|
initializedSettings();
|
2014-06-27 23:54:17 +02:00
|
|
|
}
|
|
|
|
Component.onDestruction: {
|
|
|
|
storeSettings();
|
|
|
|
storeCustomProfiles();
|
2018-10-22 00:04:31 +02:00
|
|
|
// storage.dropSettings(); //DROPS THE SETTINGS!.. REMEMBER TO DISABLE ONCE ENABLED!!
|
2014-06-27 23:54:17 +02:00
|
|
|
}
|
2015-01-08 03:55:19 +01:00
|
|
|
|
|
|
|
// VARS ///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
property Label _sampleLabel: Label {
|
|
|
|
text: "100%"
|
|
|
|
}
|
|
|
|
property real labelWidth: _sampleLabel.width
|
2013-11-23 16:09:46 +01:00
|
|
|
}
|