mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-11-04 00:52:11 +00:00 
			
		
		
		
	Improvement: port profile selector to TableView.
This commit is contained in:
		@@ -76,8 +76,6 @@ QtObject{
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    property int rasterization: no_rasterization
 | 
					    property int rasterization: no_rasterization
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    property int profilesIndex: 0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // FONTS //////////////////////////////////////////////////////////////////
 | 
					    // FONTS //////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    property real fontScaling: 1.0
 | 
					    property real fontScaling: 1.0
 | 
				
			||||||
@@ -349,10 +347,6 @@ QtObject{
 | 
				
			|||||||
        return stringify(customProfiles);
 | 
					        return stringify(customProfiles);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function loadCurrentProfile(){
 | 
					 | 
				
			||||||
        loadProfile(profilesIndex);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    function loadProfile(index){
 | 
					    function loadProfile(index){
 | 
				
			||||||
        var profile = profilesList.get(index);
 | 
					        var profile = profilesList.get(index);
 | 
				
			||||||
        loadProfileString(profile.obj_string);
 | 
					        loadProfileString(profile.obj_string);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,40 +26,55 @@ Tab{
 | 
				
			|||||||
    ColumnLayout{
 | 
					    ColumnLayout{
 | 
				
			||||||
        anchors.fill: parent
 | 
					        anchors.fill: parent
 | 
				
			||||||
        GroupBox{
 | 
					        GroupBox{
 | 
				
			||||||
 | 
					            anchors {left: parent.left; right: parent.right}
 | 
				
			||||||
            Layout.fillWidth: true
 | 
					            Layout.fillWidth: true
 | 
				
			||||||
 | 
					            Layout.fillHeight: true
 | 
				
			||||||
            title: qsTr("Profile")
 | 
					            title: qsTr("Profile")
 | 
				
			||||||
            ColumnLayout{
 | 
					            RowLayout {
 | 
				
			||||||
                anchors.fill: parent
 | 
					                anchors.fill: parent
 | 
				
			||||||
                ComboBox{
 | 
					                TableView {
 | 
				
			||||||
                    id: profilesbox
 | 
					                    id: profilesView
 | 
				
			||||||
                    Layout.fillWidth: true
 | 
					                    Layout.fillWidth: true
 | 
				
			||||||
 | 
					                    anchors { top: parent.top; bottom: parent.bottom; }
 | 
				
			||||||
                    model: appSettings.profilesList
 | 
					                    model: appSettings.profilesList
 | 
				
			||||||
                    currentIndex: appSettings.profilesIndex
 | 
					                    headerVisible: false
 | 
				
			||||||
 | 
					                    TableViewColumn {
 | 
				
			||||||
 | 
					                        title: qsTr("Profile")
 | 
				
			||||||
 | 
					                        role: "text"
 | 
				
			||||||
 | 
					                        width: parent.width * 0.5
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                RowLayout{
 | 
					                    onActivated: {
 | 
				
			||||||
                    Layout.fillWidth: true
 | 
					                        appSettings.loadProfile(row);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                ColumnLayout {
 | 
				
			||||||
 | 
					                    anchors { top: parent.top; bottom: parent.bottom }
 | 
				
			||||||
 | 
					                    Layout.fillWidth: false
 | 
				
			||||||
                    Button{
 | 
					                    Button{
 | 
				
			||||||
                        Layout.fillWidth: true
 | 
					                        Layout.fillWidth: true
 | 
				
			||||||
 | 
					                        property alias currentIndex: profilesView.currentRow
 | 
				
			||||||
 | 
					                        enabled: currentIndex >= 0
 | 
				
			||||||
                        text: qsTr("Load")
 | 
					                        text: qsTr("Load")
 | 
				
			||||||
                        onClicked: {
 | 
					                        onClicked: {
 | 
				
			||||||
                            appSettings.profilesIndex = profilesbox.currentIndex
 | 
					                            var index = profilesView.currentRow;
 | 
				
			||||||
                            appSettings.loadCurrentProfile();
 | 
					                            if (index >= 0)
 | 
				
			||||||
                            appSettings.handleFontChanged();
 | 
					                                appSettings.loadProfile(index);
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    Button{
 | 
					                    Button{
 | 
				
			||||||
                        Layout.fillWidth: true
 | 
					                        Layout.fillWidth: true
 | 
				
			||||||
                        text: qsTr("Save New Profile")
 | 
					                        text: qsTr("New")
 | 
				
			||||||
                        onClicked: insertname.show()
 | 
					                        onClicked: insertname.show()
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    Button{
 | 
					                    Button{
 | 
				
			||||||
                        Layout.fillWidth: true
 | 
					                        Layout.fillWidth: true
 | 
				
			||||||
                        text: qsTr("Remove Selected")
 | 
					                        text: qsTr("Remove")
 | 
				
			||||||
                        enabled: !appSettings.profilesList.get(profilesbox.currentIndex).builtin
 | 
					                        property alias currentIndex: profilesView.currentRow
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        enabled: currentIndex >= 0 && !appSettings.profilesList.get(currentIndex).builtin
 | 
				
			||||||
                        onClicked: {
 | 
					                        onClicked: {
 | 
				
			||||||
                            appSettings.profilesList.remove(profilesbox.currentIndex)
 | 
					                            appSettings.profilesList.remove(profilesView.currentRow);
 | 
				
			||||||
                            profilesbox.currentIndex = profilesbox.currentIndex - 1
 | 
					                            profilesView.activated(currentIndex);
 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    InsertNameDialog{
 | 
					                    InsertNameDialog{
 | 
				
			||||||
@@ -68,6 +83,7 @@ Tab{
 | 
				
			|||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        GroupBox{
 | 
					        GroupBox{
 | 
				
			||||||
            title: qsTr("Lights")
 | 
					            title: qsTr("Lights")
 | 
				
			||||||
            Layout.fillWidth: true
 | 
					            Layout.fillWidth: true
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user