mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-10-30 22:54:21 +00:00 
			
		
		
		
	Redisigned color settings...
This commit is contained in:
		| @@ -22,5 +22,5 @@ OTHER_FILES += \ | |||||||
|     $$PWD/qml/cool-old-term/ShaderSettings.qml \ |     $$PWD/qml/cool-old-term/ShaderSettings.qml \ | ||||||
|     $$PWD/qml/images/frame.png \ |     $$PWD/qml/images/frame.png \ | ||||||
|     qml/cool-old-term/SettingsWindow.qml \ |     qml/cool-old-term/SettingsWindow.qml \ | ||||||
|     qml/cool-old-term/MyColorDialog.qml \ |     qml/cool-old-term/SettingComponent.qml \ | ||||||
|     qml/cool-old-term/SettingComponent.qml |     qml/cool-old-term/ColorButton.qml | ||||||
|   | |||||||
							
								
								
									
										43
									
								
								qml/cool-old-term/ColorButton.qml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								qml/cool-old-term/ColorButton.qml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,43 @@ | |||||||
|  | import QtQuick 2.1 | ||||||
|  | import QtQuick.Dialogs 1.1 | ||||||
|  |  | ||||||
|  | Item { | ||||||
|  |     property color button_color; | ||||||
|  |  | ||||||
|  |     ColorDialog { | ||||||
|  |         id: colorDialog | ||||||
|  |         title: qsTr("Choose a color") | ||||||
|  |         modality: Qt.ApplicationModal | ||||||
|  |         visible: false | ||||||
|  |  | ||||||
|  |         //This is a workaround to a Qt 5.2 bug. | ||||||
|  |         onCurrentColorChanged: colorDialog.color = colorDialog.currentColor; | ||||||
|  |         onAccepted: button_color = color; | ||||||
|  |     } | ||||||
|  |     Rectangle{ | ||||||
|  |         radius: 10 | ||||||
|  |         anchors.fill: parent | ||||||
|  |         color: button_color | ||||||
|  |  | ||||||
|  |         Text{ | ||||||
|  |             id: text_color | ||||||
|  |             anchors.centerIn: parent | ||||||
|  |             z: 1.1 | ||||||
|  |             text: button_color | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         Rectangle{ | ||||||
|  |             anchors.centerIn: parent | ||||||
|  |             width: text_color.width * 1.4 | ||||||
|  |             height: text_color.height * 1.4 | ||||||
|  |             radius: 10 | ||||||
|  |             border.color: "black" | ||||||
|  |             border.width: 2 | ||||||
|  |             color: "white" | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     MouseArea{ | ||||||
|  |         anchors.fill: parent | ||||||
|  |         onClicked: colorDialog.visible = true; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -1,25 +0,0 @@ | |||||||
| 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 |  | ||||||
| } |  | ||||||
| @@ -23,40 +23,31 @@ ApplicationWindow { | |||||||
|  |  | ||||||
|             ColumnLayout{ |             ColumnLayout{ | ||||||
|                 anchors.fill: parent |                 anchors.fill: parent | ||||||
|                 GridLayout{ |                 RowLayout{ | ||||||
|                     width: parent.width |                     ColumnLayout{ | ||||||
|                     columns: 2 |                         Text{text: qsTr("Font color")} | ||||||
|                     Text{text: "Font color"} |                         ColorButton{ | ||||||
|                     Text{ |                             height: 200 | ||||||
|                         text: "         "; |                             width: 200 | ||||||
|                         Rectangle{ |  | ||||||
|                             anchors.fill: parent; |                             onButton_colorChanged: shadersettings.font_color = button_color | ||||||
|                             color: shadersettings.font_color |                             Component.onCompleted: button_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"} |                     Item{ | ||||||
|                     Text{text: "         "; |                         Layout.fillWidth: true | ||||||
|                         Rectangle{ |                     } | ||||||
|                             anchors.fill: parent; |                     ColumnLayout{ | ||||||
|                             color: shadersettings.background_color |                         Text{text: qsTr("Backgroud color")} | ||||||
|                         } |                         ColorButton{ | ||||||
|                         MouseArea{ |                             height: 200 | ||||||
|                             anchors.fill: parent |                             width: 200 | ||||||
|                             onClicked: { |  | ||||||
|                                 var component = Qt.createComponent("MyColorDialog.qml"); |                             onButton_colorChanged: shadersettings.background_color= button_color | ||||||
|                                 component.createObject(settings_window, {"color_to_change": "background_color"}); |                             Component.onCompleted: button_color = shadersettings.background_color; | ||||||
|                             } |  | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 ColumnLayout{ |                 ColumnLayout{ | ||||||
|                     anchors.left: parent.left |                     anchors.left: parent.left | ||||||
|                     anchors.right: parent.right |                     anchors.right: parent.right | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user