From 013f0be81f1ac5250e12c82dbb1369386befe044 Mon Sep 17 00:00:00 2001 From: Filippo Scognamiglio Date: Sun, 22 Dec 2013 18:32:01 +0100 Subject: [PATCH] Added dialog to setup colors of the terminal. --- cool-old-term.pro | 3 ++- qml/cool-old-term/MyColorDialog.qml | 25 ++++++++++++++++++++ qml/cool-old-term/SettingsWindow.qml | 34 ++++++++++++++++++++++++---- qml/cool-old-term/ShaderSettings.qml | 4 ++-- qml/cool-old-term/main.qml | 1 - 5 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 qml/cool-old-term/MyColorDialog.qml diff --git a/cool-old-term.pro b/cool-old-term.pro index 9238dbc..c9dc5be 100644 --- a/cool-old-term.pro +++ b/cool-old-term.pro @@ -21,4 +21,5 @@ OTHER_FILES += \ $$PWD/qml/cool-old-term/HighlightArea.qml \ $$PWD/qml/cool-old-term/ShaderSettings.qml \ $$PWD/qml/images/frame.png \ - qml/cool-old-term/SettingsWindow.qml + qml/cool-old-term/SettingsWindow.qml \ + qml/cool-old-term/MyColorDialog.qml diff --git a/qml/cool-old-term/MyColorDialog.qml b/qml/cool-old-term/MyColorDialog.qml new file mode 100644 index 0000000..5062f72 --- /dev/null +++ b/qml/cool-old-term/MyColorDialog.qml @@ -0,0 +1,25 @@ +import QtQuick 2.1 +import QtQuick.Dialogs 1.1 + +ColorDialog { + id: colorDialog + title: qsTr("Choose a color") + modality: Qt.ApplicationModal + + property string color_to_change + + color: "green" + + //This is a workaround to a Qt 5.2 bug. + onCurrentColorChanged: colorDialog.color = colorDialog.currentColor; + + onAccepted: { + console.log("[MyColorDialog.qml] Color chosen: " + colorDialog.color); + shadersettings[color_to_change] = colorDialog.color; + } + onRejected: { + console.log("[MyColorDialog.qml] No color selected") + } + + Component.onCompleted: visible = true +} diff --git a/qml/cool-old-term/SettingsWindow.qml b/qml/cool-old-term/SettingsWindow.qml index ed649be..ad088b4 100644 --- a/qml/cool-old-term/SettingsWindow.qml +++ b/qml/cool-old-term/SettingsWindow.qml @@ -2,8 +2,10 @@ import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Window 2.1 import QtQuick.Layouts 1.0 +import QtQuick.Dialogs 1.1 ApplicationWindow { + id: settings_window title: qsTr("Settings") width: 640 height: 480 @@ -17,18 +19,42 @@ ApplicationWindow { Tab{ title: qsTr("Settings") anchors.fill: parent + anchors.margins: 20 + 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: " "; + Rectangle{ + anchors.fill: parent; + color: shadersettings.font_color + } + MouseArea{ + anchors.fill: parent; + onClicked: { + var component = Qt.createComponent("MyColorDialog.qml"); + component.createObject(settings_window, {"color_to_change": "font_color"}); + } + } } Text{text: "Backgroud color"} - Text{text: " "; Rectangle{anchors.fill: parent; color: shadersettings.background_color}} + Text{text: " "; + Rectangle{ + anchors.fill: parent; + color: shadersettings.background_color + } + MouseArea{ + anchors.fill: parent + onClicked: { + var component = Qt.createComponent("MyColorDialog.qml"); + component.createObject(settings_window, {"color_to_change": "background_color"}); + } + } + } } GridLayout{ diff --git a/qml/cool-old-term/ShaderSettings.qml b/qml/cool-old-term/ShaderSettings.qml index 25c0b78..f62e796 100644 --- a/qml/cool-old-term/ShaderSettings.qml +++ b/qml/cool-old-term/ShaderSettings.qml @@ -4,11 +4,11 @@ Item{ property real ambient_light: 0.2 property color background_color: "#000000" - property color font_color: "#ffff77" + property color font_color: "#77ff77" property real brightness_flickering: 0.4 property real noise_strength: 0.1 - property real screen_distortion: 0.20 + property real screen_distortion: 0.2 property real glowing_line_strength: 0.4 //property real faulty_screen_prob: 1.0 } diff --git a/qml/cool-old-term/main.qml b/qml/cool-old-term/main.qml index 034c98c..9733ee4 100644 --- a/qml/cool-old-term/main.qml +++ b/qml/cool-old-term/main.qml @@ -48,7 +48,6 @@ ApplicationWindow{ onTriggered: { var component = Qt.createComponent("SettingsWindow.qml"); component.createObject(mainwindow); - component.show(); } } }