From 3f41a9f2fce2f5483df8f793dc3017a1b0b9aedc Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Mon, 25 Nov 2013 19:05:31 +0100 Subject: [PATCH] added settings --- cool-old-term.pro | 4 +- qml/cool-old-term/SettingsWindow.qml | 134 +++++++++++++++++++++++++++ qml/cool-old-term/main.qml | 23 ++++- 3 files changed, 156 insertions(+), 5 deletions(-) create mode 100644 qml/cool-old-term/SettingsWindow.qml diff --git a/cool-old-term.pro b/cool-old-term.pro index 548c1e5..9238dbc 100644 --- a/cool-old-term.pro +++ b/cool-old-term.pro @@ -19,4 +19,6 @@ OTHER_FILES += \ $$PWD/qml/cool-old-term/TerminalScreen.qml \ $$PWD/qml/cool-old-term/TerminalText.qml \ $$PWD/qml/cool-old-term/HighlightArea.qml \ - qml/cool-old-term/ShaderSettings.qml + $$PWD/qml/cool-old-term/ShaderSettings.qml \ + $$PWD/qml/images/frame.png \ + qml/cool-old-term/SettingsWindow.qml diff --git a/qml/cool-old-term/SettingsWindow.qml b/qml/cool-old-term/SettingsWindow.qml new file mode 100644 index 0000000..ed649be --- /dev/null +++ b/qml/cool-old-term/SettingsWindow.qml @@ -0,0 +1,134 @@ +import QtQuick 2.1 +import QtQuick.Controls 1.0 +import QtQuick.Window 2.1 +import QtQuick.Layouts 1.0 + +ApplicationWindow { + title: qsTr("Settings") + width: 640 + height: 480 + + visible: true + modality: Qt.ApplicationModal + + TabView{ + anchors.fill: parent + + Tab{ + title: qsTr("Settings") + anchors.fill: parent + ColumnLayout{ + anchors.fill: parent + GridLayout{ + width: parent.width + columns: 2 + Text{text: "Font color"} + Text{text: " "; + Rectangle{anchors.fill: parent; color: shadersettings.font_color} + MouseArea{anchors.fill: parent} + } + Text{text: "Backgroud color"} + Text{text: " "; Rectangle{anchors.fill: parent; color: shadersettings.background_color}} + } + + GridLayout{ + columns: 4 + CheckBox{ + id: noisecheck + onCheckedChanged: + if(checked) shadersettings.noise_strength = noiseslider.value; + else shadersettings.noise_strength = 0; + Component.onCompleted: checked = shadersettings.noise_strength !== 0; + } + Text{ + text: qsTr("Noise") + } + Slider{ + id: noiseslider + stepSize: 0.01 + minimumValue: 0.0 + maximumValue: 1.0 + onValueChanged: shadersettings.noise_strength = value; + Component.onCompleted: value = shadersettings.noise_strength; + } + TextArea{ + text: noiseslider.value.toFixed(2); + enabled: false + } + + + CheckBox{ + id: glowcheck + onCheckedChanged: + if(checked) shadersettings.glowing_line_strength = glowslider.value; + else shadersettings.glowing_line_strength = 0; + Component.onCompleted: checked = shadersettings.glowing_line_strength !== 0; + } + Text{ + text: qsTr("Glow") + } + Slider{ + id: glowslider + stepSize: 0.01 + minimumValue: 0.0 + maximumValue: 1.0 + onValueChanged: shadersettings.glowing_line_strength = value; + Component.onCompleted: value = shadersettings.glowing_line_strength; + } + TextArea{ + text: glowslider.value.toFixed(2); + enabled: false + } + + + CheckBox{ + id: ambientcheck + onCheckedChanged: + if(checked) shadersettings.ambient_light = ambientslider.value; + else shadersettings.ambient_light = 0; + Component.onCompleted: checked = shadersettings.ambient_light !== 0; + } + Text{ + text: qsTr("Ambient light") + } + Slider{ + id: ambientslider + stepSize: 0.01 + minimumValue: 0.1 + maximumValue: 0.5 + onValueChanged: shadersettings.ambient_light = value; + Component.onCompleted: value = shadersettings.ambient_light; + } + TextArea{ + text: ambientslider.value.toFixed(2); + enabled: false + } + + // CheckBox{ + // id: distortioncheck + // onCheckedChanged: + // if(checked) shadersettings.screen_distortion = distortionslider.value; + // else shadersettings.screen_distortion = 0; + // Component.onCompleted: checked = shadersettings.screen_distortion !== 0; + // } + // Text{ + // text: qsTr("Distortion") + // } + // Slider{ + // id: distortionslider + // stepSize: 0.01 + // minimumValue: 0.0 + // maximumValue: 1.0 + // onValueChanged: shadersettings.screen_distortion = value; + // Component.onCompleted: value = shadersettings.screen_distortion; + // } + // TextArea{ + // text: distortionslider.value.toFixed(2); + // enabled: false + // } + } + + } + } + } +} diff --git a/qml/cool-old-term/main.qml b/qml/cool-old-term/main.qml index 69cf8f7..2faed3d 100644 --- a/qml/cool-old-term/main.qml +++ b/qml/cool-old-term/main.qml @@ -38,10 +38,21 @@ ApplicationWindow{ menuBar: MenuBar { Menu { - title: "File" - MenuItem { text: "Open..." } - MenuItem { text: "Close" } + title: qsTr("File") + MenuItem { text: "Close"; onTriggered: mainwindow.close()} } + Menu { + title: qsTr("Edit") + MenuItem { + text: qsTr("Settings") + onTriggered: { + var component = Qt.createComponent("SettingsWindow.qml"); + component.createObject(mainwindow); + component.show(); + } + } + } + } @@ -71,6 +82,8 @@ ApplicationWindow{ property real noise_strength: shadersettings.noise_strength property real screen_distorsion: shadersettings.screen_distortion property real glowing_line_strength: shadersettings.glowing_line_strength + property real brightness: 1.0 + property real deltay: 1.0 / terminal.height property real deltax: 1.0 / terminal.width //property real faulty_screen_prob: shadersettings.faulty_screen_prob @@ -92,9 +105,11 @@ ApplicationWindow{ uniform highp vec4 font_color; uniform highp vec4 background_color; + uniform highp float noise_strength; uniform highp float screen_distorsion; uniform highp float glowing_line_strength; + uniform highp float deltax; uniform highp float deltay; @@ -162,7 +177,7 @@ ApplicationWindow{ Image{ id: frame - source: "/home/swordfish/Pictures/frame.png" + source: "../images/frame.png" anchors.centerIn: parent width: parent.width * 1.05 height: parent.height * 1.05