Compare commits
	
		
			1 Commits
		
	
	
		
			a683c5ad85
			...
			unstable
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					3d99b1d29c | 
							
								
								
									
										39
									
								
								app/qml/ApplicationConstants.qml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								app/qml/ApplicationConstants.qml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,39 @@
 | 
			
		||||
/*******************************************************************************
 | 
			
		||||
* Copyright (c) 2013-2021 "Filippo Scognamiglio"
 | 
			
		||||
* https://github.com/Swordfish90/cool-retro-term
 | 
			
		||||
*
 | 
			
		||||
* This file is part of cool-retro-term.
 | 
			
		||||
*
 | 
			
		||||
* cool-retro-term is free software: you can redistribute it and/or modify
 | 
			
		||||
* 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/>.
 | 
			
		||||
*******************************************************************************/
 | 
			
		||||
import QtQuick 2.2
 | 
			
		||||
 | 
			
		||||
QtObject {
 | 
			
		||||
    readonly property string version: appVersion
 | 
			
		||||
    readonly property int profileVersion: 2
 | 
			
		||||
 | 
			
		||||
    readonly property real screenCurvatureSize: 0.4
 | 
			
		||||
    readonly property real minimumFontScaling: 0.25
 | 
			
		||||
    readonly property real maximumFontScaling: 2.50
 | 
			
		||||
 | 
			
		||||
    readonly property real minBurnInFadeTime: 160
 | 
			
		||||
    readonly property real maxBurnInFadeTime: 1600
 | 
			
		||||
 | 
			
		||||
    readonly property int no_rasterization: 0
 | 
			
		||||
    readonly property int scanline_rasterization: 1
 | 
			
		||||
    readonly property int pixel_rasterization: 2
 | 
			
		||||
    readonly property int subpixel_rasterization: 3
 | 
			
		||||
 | 
			
		||||
    readonly property real baseFontScaling: 0.75
 | 
			
		||||
}
 | 
			
		||||
@@ -23,18 +23,8 @@ import QtQuick.Controls 2.0
 | 
			
		||||
import "utils.js" as Utils
 | 
			
		||||
 | 
			
		||||
QtObject {
 | 
			
		||||
    readonly property string version: appVersion
 | 
			
		||||
    readonly property int profileVersion: 2
 | 
			
		||||
 | 
			
		||||
    // STATIC CONSTANTS ////////////////////////////////////////////////////////
 | 
			
		||||
    readonly property real screenCurvatureSize: 0.4
 | 
			
		||||
    readonly property real minimumFontScaling: 0.25
 | 
			
		||||
    readonly property real maximumFontScaling: 2.50
 | 
			
		||||
 | 
			
		||||
    readonly property real minBurnInFadeTime: 160
 | 
			
		||||
    readonly property real maxBurnInFadeTime: 1600
 | 
			
		||||
 | 
			
		||||
    // GENERAL SETTINGS ///////////////////////////////////////////////////////
 | 
			
		||||
    // APPLICATION SETTINGS ///////////////////////////////////////////////////////
 | 
			
		||||
    property int x: 100
 | 
			
		||||
    property int y: 100
 | 
			
		||||
    property int width: 1024
 | 
			
		||||
@@ -56,8 +46,6 @@ QtObject {
 | 
			
		||||
    property real burnInQuality: 0.5
 | 
			
		||||
    property bool useFastBurnIn: Qt.platform.os === "osx" ? false : true
 | 
			
		||||
 | 
			
		||||
    property bool blinkingCursor: false
 | 
			
		||||
 | 
			
		||||
    onWindowScalingChanged: handleFontChanged()
 | 
			
		||||
 | 
			
		||||
    // PROFILE SETTINGS ///////////////////////////////////////////////////////
 | 
			
		||||
@@ -106,17 +94,13 @@ QtObject {
 | 
			
		||||
 | 
			
		||||
    property real totalMargin: frameMargin + margin
 | 
			
		||||
 | 
			
		||||
    readonly property int no_rasterization: 0
 | 
			
		||||
    readonly property int scanline_rasterization: 1
 | 
			
		||||
    readonly property int pixel_rasterization: 2
 | 
			
		||||
    readonly property int subpixel_rasterization: 3
 | 
			
		||||
 | 
			
		||||
    property int rasterization: no_rasterization
 | 
			
		||||
 | 
			
		||||
    property bool blinkingCursor: false
 | 
			
		||||
 | 
			
		||||
    // FONTS //////////////////////////////////////////////////////////////////
 | 
			
		||||
    readonly property real baseFontScaling: 0.75
 | 
			
		||||
    property real fontScaling: 1.0
 | 
			
		||||
    property real totalFontScaling: baseFontScaling * fontScaling
 | 
			
		||||
    property real totalFontScaling: appConstants.baseFontScaling * fontScaling
 | 
			
		||||
 | 
			
		||||
    property real fontWidth: 1.0
 | 
			
		||||
 | 
			
		||||
@@ -132,28 +116,28 @@ QtObject {
 | 
			
		||||
    property Loader fontManager: Loader {
 | 
			
		||||
        states: [
 | 
			
		||||
            State {
 | 
			
		||||
                when: rasterization == no_rasterization
 | 
			
		||||
                when: rasterization == appConstants.no_rasterization
 | 
			
		||||
                PropertyChanges {
 | 
			
		||||
                    target: fontManager
 | 
			
		||||
                    source: "Fonts.qml"
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            State {
 | 
			
		||||
                when: rasterization == scanline_rasterization
 | 
			
		||||
                when: rasterization == appConstants.scanline_rasterization
 | 
			
		||||
                PropertyChanges {
 | 
			
		||||
                    target: fontManager
 | 
			
		||||
                    source: "FontScanlines.qml"
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            State {
 | 
			
		||||
                when: rasterization == pixel_rasterization
 | 
			
		||||
                when: rasterization == appConstants.pixel_rasterization
 | 
			
		||||
                PropertyChanges {
 | 
			
		||||
                    target: fontManager
 | 
			
		||||
                    source: "FontPixels.qml"
 | 
			
		||||
                }
 | 
			
		||||
            },
 | 
			
		||||
            State {
 | 
			
		||||
                when: rasterization == subpixel_rasterization
 | 
			
		||||
                when: rasterization == appConstants.subpixel_rasterization
 | 
			
		||||
                PropertyChanges {
 | 
			
		||||
                    target: fontManager
 | 
			
		||||
                    source: "FontPixels.qml"
 | 
			
		||||
@@ -179,12 +163,12 @@ QtObject {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function incrementScaling() {
 | 
			
		||||
        fontScaling = Math.min(fontScaling + 0.05, maximumFontScaling)
 | 
			
		||||
        fontScaling = Math.min(fontScaling + 0.05, appConstants.maximumFontScaling)
 | 
			
		||||
        handleFontChanged()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function decrementScaling() {
 | 
			
		||||
        fontScaling = Math.max(fontScaling - 0.05, minimumFontScaling)
 | 
			
		||||
        fontScaling = Math.max(fontScaling - 0.05, appConstants.minimumFontScaling)
 | 
			
		||||
        handleFontChanged()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -32,8 +32,8 @@ Loader {
 | 
			
		||||
    property real delay: (1.0 / appSettings.fps) * 1000
 | 
			
		||||
    property real burnIn: appSettings.burnIn
 | 
			
		||||
    property real burnInFadeTime: 1 / Utils.lint(_minBurnInFadeTime, _maxBurnInFadeTime, burnIn)
 | 
			
		||||
    property real _minBurnInFadeTime: appSettings.minBurnInFadeTime
 | 
			
		||||
    property real _maxBurnInFadeTime: appSettings.maxBurnInFadeTime
 | 
			
		||||
    property real _minBurnInFadeTime: appConstants.minBurnInFadeTime
 | 
			
		||||
    property real _maxBurnInFadeTime: appConstants.maxBurnInFadeTime
 | 
			
		||||
 | 
			
		||||
    active: appSettings.useFastBurnIn && appSettings.burnIn !== 0
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -217,7 +217,7 @@ Item{
 | 
			
		||||
            y = (y - margin) / height;
 | 
			
		||||
 | 
			
		||||
            var cc = Qt.size(0.5 - x, 0.5 - y);
 | 
			
		||||
            var distortion = (cc.height * cc.height + cc.width * cc.width) * appSettings.screenCurvature * appSettings.screenCurvatureSize;
 | 
			
		||||
            var distortion = (cc.height * cc.height + cc.width * cc.width) * appSettings.screenCurvature * appConstants.screenCurvatureSize;
 | 
			
		||||
 | 
			
		||||
            return Qt.point((x - cc.width  * (1+distortion) * distortion) * (kterminal.totalWidth),
 | 
			
		||||
                           (y - cc.height * (1+distortion) * distortion) * (kterminal.totalHeight))
 | 
			
		||||
 
 | 
			
		||||
@@ -156,7 +156,7 @@ ColumnLayout {
 | 
			
		||||
            }
 | 
			
		||||
            CheckBox {
 | 
			
		||||
                Layout.columnSpan: 2
 | 
			
		||||
                text: qsTr("Burnin optimization (Might display timing artifacts)")
 | 
			
		||||
                text: qsTr("Burnin optimization (might display timing artifacts)")
 | 
			
		||||
                checked: appSettings.useFastBurnIn
 | 
			
		||||
                onCheckedChanged: appSettings.useFastBurnIn = checked
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -113,7 +113,7 @@ ColumnLayout {
 | 
			
		||||
 | 
			
		||||
                            var version = profileObject.version
 | 
			
		||||
                                    !== undefined ? profileObject.version : 1
 | 
			
		||||
                            if (version !== appSettings.profileVersion)
 | 
			
		||||
                            if (version !== appConstants.profileVersion)
 | 
			
		||||
                                throw "This profile is not supported on this version of CRT."
 | 
			
		||||
 | 
			
		||||
                            delete profileObject.name
 | 
			
		||||
@@ -160,7 +160,7 @@ ColumnLayout {
 | 
			
		||||
                            var profileSettings = JSON.parse(
 | 
			
		||||
                                        profileObject.obj_string)
 | 
			
		||||
                            profileSettings["name"] = profileObject.text
 | 
			
		||||
                            profileSettings["version"] = appSettings.profileVersion
 | 
			
		||||
                            profileSettings["version"] = appConstants.profileVersion
 | 
			
		||||
 | 
			
		||||
                            var result = fileIO.write(url, JSON.stringify(
 | 
			
		||||
                                                          profileSettings,
 | 
			
		||||
 
 | 
			
		||||
@@ -83,8 +83,8 @@ ColumnLayout {
 | 
			
		||||
                    onValueChanged: appSettings.fontScaling = value
 | 
			
		||||
                    value: appSettings.fontScaling
 | 
			
		||||
                    stepSize: 0.05
 | 
			
		||||
                    from: appSettings.minimumFontScaling
 | 
			
		||||
                    to: appSettings.maximumFontScaling
 | 
			
		||||
                    from: appConstants.minimumFontScaling
 | 
			
		||||
                    to: appConstants.maximumFontScaling
 | 
			
		||||
                }
 | 
			
		||||
                SizedLabel {
 | 
			
		||||
                    text: Math.round(fontScalingChanger.value * 100) + "%"
 | 
			
		||||
 
 | 
			
		||||
@@ -2,12 +2,12 @@ import QtQuick 2.0
 | 
			
		||||
 | 
			
		||||
QtObject {
 | 
			
		||||
    property string rasterizationShader:
 | 
			
		||||
        (appSettings.rasterization === appSettings.no_rasterization ? "
 | 
			
		||||
        (appSettings.rasterization === appConstants.no_rasterization ? "
 | 
			
		||||
            lowp vec3 applyRasterization(vec2 screenCoords, lowp vec3 texel, vec2 virtualResolution, float intensity) {
 | 
			
		||||
                return texel;
 | 
			
		||||
            }" : "") +
 | 
			
		||||
 | 
			
		||||
        (appSettings.rasterization === appSettings.scanline_rasterization ? "
 | 
			
		||||
        (appSettings.rasterization === appConstants.scanline_rasterization ? "
 | 
			
		||||
            #define INTENSITY 0.30
 | 
			
		||||
            #define BRIGHTBOOST 0.30
 | 
			
		||||
 | 
			
		||||
@@ -22,7 +22,7 @@ QtObject {
 | 
			
		||||
                return mix(texel, rasterizationColor, intensity);
 | 
			
		||||
            }" : "") +
 | 
			
		||||
 | 
			
		||||
        (appSettings.rasterization === appSettings.pixel_rasterization ? "
 | 
			
		||||
        (appSettings.rasterization === appConstants.pixel_rasterization ? "
 | 
			
		||||
            #define INTENSITY 0.30
 | 
			
		||||
            #define BRIGHTBOOST 0.30
 | 
			
		||||
 | 
			
		||||
@@ -40,7 +40,7 @@ QtObject {
 | 
			
		||||
                return mix(texel, rasterizationColor, intensity);
 | 
			
		||||
            }" : "") +
 | 
			
		||||
 | 
			
		||||
        (appSettings.rasterization === appSettings.subpixel_rasterization ? "
 | 
			
		||||
        (appSettings.rasterization === appConstants.subpixel_rasterization ? "
 | 
			
		||||
            #define INTENSITY 0.30
 | 
			
		||||
            #define BRIGHTBOOST 0.30
 | 
			
		||||
            #define SUBPIXELS 3.0
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ Item {
 | 
			
		||||
    property color fontColor: appSettings.fontColor
 | 
			
		||||
    property color backgroundColor: appSettings.backgroundColor
 | 
			
		||||
 | 
			
		||||
    property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize
 | 
			
		||||
    property real screenCurvature: appSettings.screenCurvature * appConstants.screenCurvatureSize
 | 
			
		||||
 | 
			
		||||
    property real chromaColor: appSettings.chromaColor
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,8 +38,8 @@ Loader {
 | 
			
		||||
            property real fps: appSettings.fps !== 0 ? appSettings.fps : 60
 | 
			
		||||
            property real burnInFadeTime: Utils.lint(minBurnInFadeTime, maxBurnInFadeTime, burnIn)
 | 
			
		||||
            property real burnInCoefficient: 1000 / (fps * burnInFadeTime)
 | 
			
		||||
            property real minBurnInFadeTime: appSettings.minBurnInFadeTime
 | 
			
		||||
            property real maxBurnInFadeTime: appSettings.maxBurnInFadeTime
 | 
			
		||||
            property real minBurnInFadeTime: appConstants.minBurnInFadeTime
 | 
			
		||||
            property real maxBurnInFadeTime: appConstants.maxBurnInFadeTime
 | 
			
		||||
 | 
			
		||||
            id: burnInSourceEffect
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ ShaderEffect {
 | 
			
		||||
    property real _ambientLight: Utils.lint(0.2, 0.8, appSettings.ambientLight)
 | 
			
		||||
 | 
			
		||||
    property color frameColor: Utils.mix(_staticFrameColor, _lightColor, _ambientLight)
 | 
			
		||||
    property real screenCurvature: appSettings.screenCurvature * appSettings.screenCurvatureSize
 | 
			
		||||
    property real screenCurvature: appSettings.screenCurvature * appConstants.screenCurvatureSize
 | 
			
		||||
 | 
			
		||||
    // Coefficient of the log curve used to approximate shadowing
 | 
			
		||||
    property real screenShadowCoeff: Utils.lint(20.0, 10.0, _ambientLight)
 | 
			
		||||
 
 | 
			
		||||
@@ -127,6 +127,9 @@ ApplicationWindow {
 | 
			
		||||
            aboutDialog.raise()
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    ApplicationConstants {
 | 
			
		||||
        id: appConstants
 | 
			
		||||
    }
 | 
			
		||||
    ApplicationSettings {
 | 
			
		||||
        id: appSettings
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -46,5 +46,6 @@
 | 
			
		||||
        <file>menus/FullContextMenu.qml</file>
 | 
			
		||||
        <file>menus/ShortContextMenu.qml</file>
 | 
			
		||||
        <file>ShaderLibrary.qml</file>
 | 
			
		||||
        <file>ApplicationConstants.qml</file>
 | 
			
		||||
    </qresource>
 | 
			
		||||
</RCC>
 | 
			
		||||
 
 | 
			
		||||
 Submodule qmltermwidget updated: 5c47d1f494...65e75bc6ea
									
								
							
		Reference in New Issue
	
	Block a user