mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-31 02:01:19 +00:00
Improve profiles management, redesign a bit the settings window.
This commit is contained in:
parent
88079a3ee4
commit
a62645f0b7
@ -356,8 +356,7 @@ QtObject{
|
||||
loadProfileString(profile.obj_string);
|
||||
}
|
||||
|
||||
function addNewCustomProfile(name){
|
||||
var profileString = composeProfileString();
|
||||
function appendCustomProfile(name, profileString) {
|
||||
profilesList.append({text: name, obj_string: profileString, builtin: false});
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ Window{
|
||||
modality: Qt.ApplicationModal
|
||||
title: qsTr("Save new profile")
|
||||
|
||||
property alias profileName: namefield.text
|
||||
signal nameSelected(string name)
|
||||
|
||||
MessageDialog {
|
||||
|
@ -28,6 +28,7 @@ Tab{
|
||||
anchors.fill: parent
|
||||
ColumnLayout{
|
||||
anchors.fill: parent
|
||||
spacing: 2
|
||||
CheckableSlider{
|
||||
name: qsTr("Bloom")
|
||||
onNewValue: appSettings.bloom = newValue
|
||||
|
@ -51,6 +51,14 @@ Tab{
|
||||
ColumnLayout {
|
||||
anchors { top: parent.top; bottom: parent.bottom }
|
||||
Layout.fillWidth: false
|
||||
Button{
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("New")
|
||||
onClicked: {
|
||||
insertname.profileName = "";
|
||||
insertname.show()
|
||||
}
|
||||
}
|
||||
Button{
|
||||
Layout.fillWidth: true
|
||||
property alias currentIndex: profilesView.currentRow
|
||||
@ -62,11 +70,6 @@ Tab{
|
||||
appSettings.loadProfile(index);
|
||||
}
|
||||
}
|
||||
Button{
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("New")
|
||||
onClicked: insertname.show()
|
||||
}
|
||||
Button{
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Remove")
|
||||
@ -74,11 +77,12 @@ Tab{
|
||||
|
||||
enabled: currentIndex >= 0 && !appSettings.profilesList.get(currentIndex).builtin
|
||||
onClicked: {
|
||||
appSettings.profilesList.remove(profilesView.currentRow);
|
||||
profilesView.activated(currentIndex);
|
||||
appSettings.profilesList.remove(currentIndex);
|
||||
currentIndex = -1; // Unselect the profile.
|
||||
}
|
||||
}
|
||||
Button{
|
||||
Layout.fillWidth: true
|
||||
text: qsTr("Import")
|
||||
onClicked: {
|
||||
fileDialog.selectExisting = true;
|
||||
@ -86,29 +90,80 @@ Tab{
|
||||
fileDialog.open();
|
||||
}
|
||||
function loadFile(url) {
|
||||
if (true)
|
||||
try {
|
||||
if (appSettings.verbose)
|
||||
console.log("Loading file: " + url);
|
||||
var profileStirng = fileIO.read(url);
|
||||
appSettings.loadProfileString(profileStirng);
|
||||
|
||||
var profileObject = JSON.parse(fileIO.read(url));
|
||||
var name = profileObject.name;
|
||||
|
||||
if (!name)
|
||||
throw "Profile doesn't have a name";
|
||||
|
||||
delete profileObject.name;
|
||||
|
||||
appSettings.appendCustomProfile(name, JSON.stringify(profileObject));
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
messageDialog.text = qsTr("There has been an error reading the file.")
|
||||
messageDialog.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
Button{
|
||||
property alias currentIndex: profilesView.currentRow
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
text: qsTr("Export")
|
||||
enabled: currentIndex >= 0 && !appSettings.profilesList.get(currentIndex).builtin
|
||||
onClicked: {
|
||||
fileDialog.selectExisting = false;
|
||||
fileDialog.callBack = function (url) {storeFile(url);};
|
||||
fileDialog.open();
|
||||
}
|
||||
function storeFile(url) {
|
||||
try {
|
||||
var urlString = url.toString();
|
||||
|
||||
// Fix the extension if it's missing.
|
||||
var extension = urlString.substring(urlString.length - 5, urlString.length);
|
||||
var urlTail = (extension === ".json" ? "" : ".json");
|
||||
url += urlTail;
|
||||
|
||||
if (true)
|
||||
console.log("Storing file: " + url);
|
||||
var profileObject = appSettings.composeProfileObject();
|
||||
fileIO.write(url, JSON.stringify(profileObject, undefined, 2));
|
||||
|
||||
var profileObject = appSettings.profilesList.get(currentIndex);
|
||||
var profileSettings = JSON.parse(profileObject.obj_string);
|
||||
profileSettings["name"] = profileObject.text;
|
||||
|
||||
var result = fileIO.write(url, JSON.stringify(profileSettings, undefined, 2));
|
||||
if (!result)
|
||||
throw "The file could not be written.";
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
messageDialog.text = qsTr("There has been an error storing the file.")
|
||||
messageDialog.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// DIALOGS ////////////////////////////////////////////////////////////////
|
||||
InsertNameDialog{
|
||||
id: insertname
|
||||
onNameSelected: appSettings.addNewCustomProfile(name)
|
||||
onNameSelected: {
|
||||
appSettings.appendCustomProfile(name, appSettings.composeProfileString());
|
||||
}
|
||||
}
|
||||
MessageDialog {
|
||||
id: messageDialog
|
||||
title: qsTr("File Error")
|
||||
onAccepted: {
|
||||
messageDialog.close();
|
||||
}
|
||||
}
|
||||
Loader {
|
||||
property var callBack
|
||||
@ -135,57 +190,4 @@ Tab{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GroupBox{
|
||||
title: qsTr("Lights")
|
||||
Layout.fillWidth: true
|
||||
GridLayout{
|
||||
anchors.fill: parent
|
||||
columns: 2
|
||||
Text{ text: qsTr("Brightness") }
|
||||
SimpleSlider{
|
||||
onValueChanged: appSettings.brightness = value
|
||||
value: appSettings.brightness
|
||||
}
|
||||
Text{ text: qsTr("Contrast") }
|
||||
SimpleSlider{
|
||||
onValueChanged: appSettings.contrast = value
|
||||
value: appSettings.contrast
|
||||
}
|
||||
Text{ text: qsTr("Opacity") }
|
||||
SimpleSlider{
|
||||
onValueChanged: appSettings.windowOpacity = value
|
||||
value: appSettings.windowOpacity
|
||||
}
|
||||
}
|
||||
}
|
||||
GroupBox{
|
||||
title: qsTr("Frame")
|
||||
Layout.fillWidth: true
|
||||
RowLayout{
|
||||
anchors.fill: parent
|
||||
ComboBox{
|
||||
id: framescombobox
|
||||
Layout.fillWidth: true
|
||||
model: appSettings.framesList
|
||||
currentIndex: appSettings.framesIndex
|
||||
onActivated: {
|
||||
appSettings.frameName = appSettings.framesList.get(index).name;
|
||||
}
|
||||
function updateIndex(){
|
||||
var name = appSettings.frameName;
|
||||
var index = appSettings.getFrameIndexByName(name);
|
||||
if (index !== undefined)
|
||||
currentIndex = index;
|
||||
}
|
||||
Component.onCompleted: updateIndex();
|
||||
Connections {
|
||||
target: appSettings
|
||||
onFrameNameChanged: framescombobox.updateIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
94
app/qml/SettingsScreenTab.qml
Normal file
94
app/qml/SettingsScreenTab.qml
Normal file
@ -0,0 +1,94 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 "Filippo Scognamiglio"
|
||||
* https://github.com/Swordfish90/cool-retro-term
|
||||
*
|
||||
* This file is part of cool-retro-term.
|
||||
*
|
||||
* cool-retro-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 <http://www.gnu.org/licenses/>.
|
||||
*******************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.1
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Dialogs 1.1
|
||||
|
||||
Tab{
|
||||
ColumnLayout{
|
||||
anchors.fill: parent
|
||||
GroupBox{
|
||||
title: qsTr("Rasterization Mode")
|
||||
Layout.fillWidth: true
|
||||
ComboBox {
|
||||
id: rasterizationBox
|
||||
property string selectedElement: model[currentIndex]
|
||||
anchors.fill: parent
|
||||
model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels")]
|
||||
currentIndex: appSettings.rasterization
|
||||
onCurrentIndexChanged: {
|
||||
appSettings.rasterization = currentIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
GroupBox{
|
||||
title: qsTr("Lights")
|
||||
Layout.fillWidth: true
|
||||
GridLayout{
|
||||
anchors.fill: parent
|
||||
columns: 2
|
||||
Text{ text: qsTr("Brightness") }
|
||||
SimpleSlider{
|
||||
onValueChanged: appSettings.brightness = value
|
||||
value: appSettings.brightness
|
||||
}
|
||||
Text{ text: qsTr("Contrast") }
|
||||
SimpleSlider{
|
||||
onValueChanged: appSettings.contrast = value
|
||||
value: appSettings.contrast
|
||||
}
|
||||
Text{ text: qsTr("Opacity") }
|
||||
SimpleSlider{
|
||||
onValueChanged: appSettings.windowOpacity = value
|
||||
value: appSettings.windowOpacity
|
||||
}
|
||||
}
|
||||
}
|
||||
GroupBox{
|
||||
title: qsTr("Frame")
|
||||
Layout.fillWidth: true
|
||||
RowLayout{
|
||||
anchors.fill: parent
|
||||
ComboBox{
|
||||
id: framescombobox
|
||||
Layout.fillWidth: true
|
||||
model: appSettings.framesList
|
||||
currentIndex: appSettings.framesIndex
|
||||
onActivated: {
|
||||
appSettings.frameName = appSettings.framesList.get(index).name;
|
||||
}
|
||||
function updateIndex(){
|
||||
var name = appSettings.frameName;
|
||||
var index = appSettings.getFrameIndexByName(name);
|
||||
if (index !== undefined)
|
||||
currentIndex = index;
|
||||
}
|
||||
Component.onCompleted: updateIndex();
|
||||
Connections {
|
||||
target: appSettings
|
||||
onFrameNameChanged: framescombobox.updateIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -26,21 +26,8 @@ Tab{
|
||||
ColumnLayout{
|
||||
anchors.fill: parent
|
||||
GroupBox{
|
||||
title: qsTr("Rasterization Mode")
|
||||
Layout.fillWidth: true
|
||||
ComboBox {
|
||||
id: rasterizationBox
|
||||
property string selectedElement: model[currentIndex]
|
||||
anchors.fill: parent
|
||||
model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels")]
|
||||
currentIndex: appSettings.rasterization
|
||||
onCurrentIndexChanged: {
|
||||
appSettings.rasterization = currentIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
GroupBox{
|
||||
title: qsTr("Font") + " (" + rasterizationBox.selectedElement + ")"
|
||||
property var rasterization: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels")][appSettings.rasterization]
|
||||
title: qsTr("Font" + "(" + rasterization + ")")
|
||||
Layout.fillWidth: true
|
||||
GridLayout{
|
||||
anchors.fill: parent
|
||||
|
@ -42,6 +42,12 @@ Window {
|
||||
anchors.fill: parent
|
||||
anchors.margins: tabmargins
|
||||
}
|
||||
SettingsScreenTab{
|
||||
id: screenTab
|
||||
title: qsTr("Screen")
|
||||
anchors.fill: parent
|
||||
anchors.margins: tabmargins
|
||||
}
|
||||
SettingsTerminalTab{
|
||||
id: terminalTab
|
||||
title: qsTr("Terminal")
|
||||
|
@ -49,5 +49,6 @@
|
||||
<file>fonts/modern-hermit/Hermit-medium.otf</file>
|
||||
<file>fonts/modern-envy-code-r/Envy Code R.ttf</file>
|
||||
<file>fonts/modern-inconsolata/Inconsolata.otf</file>
|
||||
<file>SettingsScreenTab.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
x
Reference in New Issue
Block a user