1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2025-01-31 02:01:19 +00:00

Refactoring: port non visual components from Item to QtObject.

This commit is contained in:
Filippo Scognamiglio 2014-12-23 00:49:33 +01:00
parent e5174fdb08
commit 7dcf98c395
5 changed files with 19 additions and 31 deletions

View File

@ -22,7 +22,7 @@ import QtQuick 2.2
import "utils.js" as Utils import "utils.js" as Utils
Item{ QtObject{
property string version: "0.9" property string version: "0.9"
// GENERAL SETTINGS /////////////////////////////////////////////////// // GENERAL SETTINGS ///////////////////////////////////////////////////
@ -76,7 +76,6 @@ Item{
property int rasterization: no_rasterization property int rasterization: no_rasterization
property alias profiles_list: profileslist
property int profiles_index: 0 property int profiles_index: 0
// FONTS ////////////////////////////////////////////////////////////////// // FONTS //////////////////////////////////////////////////////////////////
@ -89,9 +88,7 @@ Item{
signal terminalFontChanged(string fontSource, int pixelSize, int lineSpacing, real screenScaling, real fontWidth) signal terminalFontChanged(string fontSource, int pixelSize, int lineSpacing, real screenScaling, real fontWidth)
Loader{ property Loader fontManager: Loader{
id: fontManager
states: [ states: [
State { when: rasterization == no_rasterization State { when: rasterization == no_rasterization
PropertyChanges {target: fontManager; source: "Fonts.qml" } }, PropertyChanges {target: fontManager; source: "Fonts.qml" } },
@ -146,11 +143,10 @@ Item{
// FRAMES ///////////////////////////////////////////////////////////////// // FRAMES /////////////////////////////////////////////////////////////////
property bool _frameReflections: false property bool _frameReflections: false
property bool reflectionsAllowed: framelist.get(frames_index).reflections property bool reflectionsAllowed: frames_list.get(frames_index).reflections
property bool frameReflections: _frameReflections && reflectionsAllowed property bool frameReflections: _frameReflections && reflectionsAllowed
ListModel{ property ListModel frames_list: ListModel{
id: framelist
ListElement{text: "No frame"; source: ""; reflections: false} ListElement{text: "No frame"; source: ""; reflections: false}
ListElement{text: "Simple white frame"; source: "./frames/WhiteSimpleFrame.qml"; reflections: true} ListElement{text: "Simple white frame"; source: "./frames/WhiteSimpleFrame.qml"; reflections: true}
ListElement{text: "Rough black frame"; source: "./frames/BlackRoughFrame.qml"; reflections: true} ListElement{text: "Rough black frame"; source: "./frames/BlackRoughFrame.qml"; reflections: true}
@ -158,11 +154,10 @@ Item{
property string frame_source: frames_list.get(frames_index).source property string frame_source: frames_list.get(frames_index).source
property int frames_index: 1 property int frames_index: 1
property alias frames_list: framelist
// DB STORAGE ///////////////////////////////////////////////////////////// // DB STORAGE /////////////////////////////////////////////////////////////
Storage{id: storage} property Storage storage: Storage{ }
function stringify(obj) { function stringify(obj) {
var replacer = function(key, val) { var replacer = function(key, val) {
@ -314,8 +309,8 @@ Item{
function composeCustomProfilesString(){ function composeCustomProfilesString(){
var customProfiles = [] var customProfiles = []
for(var i=0; i<profileslist.count; i++){ for(var i=0; i<profiles_list.count; i++){
var profile = profileslist.get(i); var profile = profiles_list.get(i);
if(profile.builtin) continue; if(profile.builtin) continue;
customProfiles.push({text: profile.text, obj_string: profile.obj_string, builtin: false}) customProfiles.push({text: profile.text, obj_string: profile.obj_string, builtin: false})
} }
@ -327,19 +322,18 @@ Item{
} }
function loadProfile(index){ function loadProfile(index){
var profile = profileslist.get(index); var profile = profiles_list.get(index);
loadProfileString(profile.obj_string); loadProfileString(profile.obj_string);
} }
function addNewCustomProfile(name){ function addNewCustomProfile(name){
var profileString = composeProfileString(); var profileString = composeProfileString();
profileslist.append({text: name, obj_string: profileString, builtin: false}); profiles_list.append({text: name, obj_string: profileString, builtin: false});
} }
// PROFILES /////////////////////////////////////////////////////////////// // PROFILES ///////////////////////////////////////////////////////////////
ListModel{ property ListModel profiles_list: ListModel{
id: profileslist
ListElement{ ListElement{
text: "Default Amber" text: "Default Amber"
obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.65,"brightness":0.5,"brightness_flickering":0.1,"contrast":0.85,"fontName":"TERMINUS","font_color":"#ff8100","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.08,"jitter":0.18,"motion_blur":0.4,"noise_strength":0.1,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0,"rgb_shift":0,"fontWidth":1.0}' obj_string: '{"ambient_light":0.2,"background_color":"#000000","bloom_strength":0.65,"brightness":0.5,"brightness_flickering":0.1,"contrast":0.85,"fontName":"TERMINUS","font_color":"#ff8100","frames_index":1,"glowing_line_strength":0.2,"horizontal_sincronization":0.08,"jitter":0.18,"motion_blur":0.4,"noise_strength":0.1,"rasterization":0,"screen_distortion":0.1,"windowOpacity":1,"chroma_color":0,"saturation_color":0,"rgb_shift":0,"fontWidth":1.0}'
@ -388,8 +382,8 @@ Item{
} }
function getProfileIndexByName(name) { function getProfileIndexByName(name) {
for (var i = 0; i < profileslist.count; i++) { for (var i = 0; i < profiles_list.count; i++) {
if(profileslist.get(i).text === name) if(profiles_list.get(i).text === name)
return i; return i;
} }
return -1; return -1;

View File

@ -20,10 +20,9 @@
import QtQuick 2.2 import QtQuick 2.2
Item{ QtObject{
property int selectedFontIndex property int selectedFontIndex
property real scaling property real scaling
property alias fontlist: fontlist
property var _font: fontlist.get(selectedFontIndex) property var _font: fontlist.get(selectedFontIndex)
property var source: _font.source property var source: _font.source
property int pixelSize: _font.pixelSize property int pixelSize: _font.pixelSize
@ -31,8 +30,7 @@ Item{
property real screenScaling: scaling * _font.baseScaling property real screenScaling: scaling * _font.baseScaling
property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth
ListModel{ property ListModel fontlist: ListModel{
id: fontlist
ListElement{ ListElement{
name: "COMMODORE_PET" name: "COMMODORE_PET"
text: "Commodore PET (1977)" text: "Commodore PET (1977)"

View File

@ -20,10 +20,9 @@
import QtQuick 2.2 import QtQuick 2.2
Item{ QtObject{
property int selectedFontIndex property int selectedFontIndex
property real scaling property real scaling
property alias fontlist: fontlist
property var _font: fontlist.get(selectedFontIndex) property var _font: fontlist.get(selectedFontIndex)
property var source: _font.source property var source: _font.source
property int pixelSize: _font.pixelSize property int pixelSize: _font.pixelSize
@ -31,8 +30,7 @@ Item{
property real screenScaling: scaling * _font.baseScaling property real screenScaling: scaling * _font.baseScaling
property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth
ListModel{ property ListModel fontlist: ListModel{
id: fontlist
ListElement{ ListElement{
name: "COMMODORE_PET" name: "COMMODORE_PET"
text: "Commodore PET (1977)" text: "Commodore PET (1977)"

View File

@ -20,10 +20,9 @@
import QtQuick 2.2 import QtQuick 2.2
Item{ QtObject{
property int selectedFontIndex property int selectedFontIndex
property real scaling property real scaling
property alias fontlist: fontlist
property var source: fontlist.get(selectedFontIndex).source property var source: fontlist.get(selectedFontIndex).source
property var _font: fontlist.get(selectedFontIndex) property var _font: fontlist.get(selectedFontIndex)
property int pixelSize: _font.pixelSize * scaling property int pixelSize: _font.pixelSize * scaling
@ -33,8 +32,7 @@ Item{
//In this configuration lineSpacing is proportional to pixelSize. //In this configuration lineSpacing is proportional to pixelSize.
ListModel{ property ListModel fontlist: ListModel{
id: fontlist
ListElement{ ListElement{
name: "TERMINUS" name: "TERMINUS"
text: "Terminus (Modern)" text: "Terminus (Modern)"

View File

@ -21,7 +21,7 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.LocalStorage 2.0 import QtQuick.LocalStorage 2.0
Item { QtObject {
property bool initialized: false property bool initialized: false
function getDatabase() { function getDatabase() {