diff --git a/app/SettingsWindow.qml b/app/SettingsWindow.qml index 10105ae..f11210f 100644 --- a/app/SettingsWindow.qml +++ b/app/SettingsWindow.qml @@ -50,9 +50,8 @@ ApplicationWindow { ComboBox{ anchors.fill: parent model: shadersettings.profiles_list - onCurrentIndexChanged: { - shadersettings.loadProfile(shadersettings.profiles_list.get(currentIndex).obj_name); - } + onCurrentIndexChanged: shadersettings.profiles_index = currentIndex + currentIndex: shadersettings.profiles_index } } @@ -87,7 +86,7 @@ ApplicationWindow { Layout.fillWidth: true Layout.columnSpan: 2 onButton_colorChanged: shadersettings._font_color = button_color; - Component.onCompleted: button_color = shadersettings._font_color; + button_color: shadersettings._font_color; } } } @@ -113,24 +112,29 @@ ApplicationWindow { Layout.columnSpan: 2 onButton_colorChanged: shadersettings._background_color= button_color - Component.onCompleted: button_color = shadersettings._background_color; + button_color: shadersettings._background_color; } } } GroupBox{ title: qsTr("Background") Layout.fillWidth: true - Layout.fillHeight:true + Layout.columnSpan: 2 + anchors.left: parent.left + anchors.right: parent.right ColumnLayout{ - SettingComponent{ + Layout.columnSpan: 2 + anchors.left: parent.left + anchors.right: parent.right + SimpleSlider{ name: "Contrast" onValueChanged: shadersettings.contrast = value - _value: shadersettings.contrast + value: shadersettings.contrast } - SettingComponent{ + SimpleSlider{ name: "Brightness" onValueChanged: shadersettings.brightness = value - _value: shadersettings.brightness + value: shadersettings.brightness } } } diff --git a/app/ShaderSettings.qml b/app/ShaderSettings.qml index 270a98d..6fe6db8 100644 --- a/app/ShaderSettings.qml +++ b/app/ShaderSettings.qml @@ -34,12 +34,18 @@ Item{ c1.b * alpha + c2.b * (1-alpha), c1.a * alpha + c2.a * (1-alpha)) } + function strToColor(s){ + var r = parseInt(s.substring(1,3), 16) / 256; + var g = parseInt(s.substring(3,5), 16) / 256; + var b = parseInt(s.substring(5,7), 16) / 256; + return Qt.rgba(r, g, b, 1.0); + } - //Private atttributes might need processing - property color _background_color: "#000000" - property color _font_color: "#00ff00" - property color font_color: mix(_font_color, _background_color, 0.5 + (contrast * 0.5)) - property color background_color: mix(_background_color, _font_color, 0.5 + (contrast * 0.5)) + //Probably there is a better way to cast string to colors. + property string _background_color: "#000000" + property string _font_color: "#00ff00" + property color font_color: mix(strToColor(_font_color), strToColor(_background_color), 0.7 + (contrast * 0.3)) + property color background_color: mix(strToColor(_background_color), strToColor(_font_color), 0.7 + (contrast * 0.3)) property real noise_strength: 0.1 property real screen_distortion: 0.15 @@ -53,7 +59,7 @@ Item{ property real scanlines: 0.0 property string frame_source: frames_list.get(frames_index).source - property int frames_index: 2 + property int frames_index: 1 property var frames_list: framelist property real font_scaling: 1.0 @@ -63,6 +69,8 @@ Item{ property var fonts_list: fontlist property var profiles_list: profileslist + property int profiles_index: 0 + onProfiles_indexChanged: loadProfile(profiles_list.get(profiles_index).obj_name); onFont_indexChanged: handleFontChanged(); onFont_scalingChanged: handleFontChanged(); @@ -140,14 +148,15 @@ Item{ function loadProfile(profilename){ var settings = storage.getSetting(profilename); if(!settings) return; - + console.log(profilename + settings); settings = JSON.parse(settings); contrast = settings.contrast ? settings.contrast : contrast; + brightness = settings.brightness ? settings.brightness : brightness ambient_light = settings.ambient_light ? settings.ambient_light : ambient_light; - background_color = settings.background_color ? settings.background_color : background_color; - font_color = settings.font_color ? settings.font_color : font_color; + _background_color = settings.background_color ? settings.background_color : _background_color; + _font_color = settings.font_color ? settings.font_color : _font_color; brightness_flickering = settings.brightness_flickering ? settings.brightness_flickering : brightness_flickering; noise_strength = settings.noise_strength ? settings.noise_strength : noise_strength; @@ -167,9 +176,10 @@ Item{ function storeCurrentSettings(){ var settings = { ambient_light : ambient_light, + brightness : brightness, contrast : contrast, - background_color: background_color, - font_color: font_color, + background_color: _background_color, + font_color: _font_color, brightness_flickering: brightness_flickering, noise_strength: noise_strength, screen_distortion: screen_distortion, @@ -197,7 +207,7 @@ Item{ } Component.onDestruction: { storeCurrentSettings(); - storage.dropSettings(); + //storage.dropSettings(); //DROPS THE SETTINGS!.. REMEMBER TO DISABLE ONCE ENABLED!! } diff --git a/app/SimpleSlider.qml b/app/SimpleSlider.qml new file mode 100644 index 0000000..2028a1d --- /dev/null +++ b/app/SimpleSlider.qml @@ -0,0 +1,48 @@ +/******************************************************************************* +* Copyright (c) 2013 "Filippo Scognamiglio" +* https://github.com/Swordifish90/cool-old-term +* +* This file is part of cool-old-term. +* +* cool-old-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 . +*******************************************************************************/ + +import QtQuick 2.1 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 + +RowLayout { + property string name + property double value: 0.0 + property double stepSize: 0.01 + + id: setting_component + anchors.left: parent.left + anchors.right: parent.right + spacing: 10 + Text{ + text: name + } + Slider{ + id: slider + stepSize: parent.stepSize + onValueChanged: setting_component.value = slider.value; + Layout.fillWidth: true + value: setting_component.value + } + Text{ + id: textfield + text: Math.round(value * 100) + "%" + } +} diff --git a/app/Terminal.qml b/app/Terminal.qml index e83fb69..4264ef5 100644 --- a/app/Terminal.qml +++ b/app/Terminal.qml @@ -1,3 +1,23 @@ +/******************************************************************************* +* Copyright (c) 2013 "Filippo Scognamiglio" +* https://github.com/Swordifish90/cool-old-term +* +* This file is part of cool-old-term. +* +* cool-old-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 . +*******************************************************************************/ + import QtQuick 2.0 import QtGraphicalEffects 1.0 diff --git a/app/app.qmlproject.user b/app/app.qmlproject.user index b027a03..735006b 100644 --- a/app/app.qmlproject.user +++ b/app/app.qmlproject.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff --git a/app/main.qml b/app/main.qml index c875139..418c02e 100644 --- a/app/main.qml +++ b/app/main.qml @@ -49,7 +49,7 @@ ApplicationWindow{ Action{ id: showsettingsAction text: "&Settings" - onTriggered: settingswindow.show(); + onTriggered: settingswindowloader.active = true; } menuBar: MenuBar { @@ -132,8 +132,13 @@ ApplicationWindow{ id: shadersettings Component.onCompleted: terminal.loadKTerminal(); } - SettingsWindow{ - id: settingswindow - visible: false + Loader{ + id: settingswindowloader + active: false + sourceComponent: SettingsWindow{ + id: settingswindow + visible: true + onClosing: settingswindowloader.active = false; + } } }