1
0
mirror of https://github.com/Swordfish90/cool-retro-term.git synced 2025-01-18 12:15:27 +00:00

Migrate from QtQuick.Controls 1.x to QtQuick.Controls 2.x. Updated QMLTermWidget submodule.

This commit is contained in:
Filippo Scognamiglio 2021-06-30 08:33:31 +02:00
parent dac2b4ff16
commit dae1a56691
21 changed files with 682 additions and 603 deletions

View File

@ -79,6 +79,9 @@ int main(int argc, char *argv[])
app.setWindowIcon(QIcon(":../icons/32x32/cool-retro-term.png")); app.setWindowIcon(QIcon(":../icons/32x32/cool-retro-term.png"));
#endif #endif
app.setOrganizationName("cool-retro-term");
app.setOrganizationDomain("cool-retro-term");
// Manage command line arguments from the cpp side // Manage command line arguments from the cpp side
QStringList args = app.arguments(); QStringList args = app.arguments();

View File

@ -1,5 +1,5 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Window 2.0 import QtQuick.Window 2.0
@ -86,24 +86,28 @@ Window{
} }
Component{ Component{
id: licenseComponent id: licenseComponent
TextArea{ ScrollView {
anchors.fill: parent anchors.fill: parent
readOnly: true clip: true
text: "Copyright (c) 2013 Filippo Scognamiglio <flscogna@gmail.com>\n\n" + TextArea{
"https://github.com/Swordfish90/cool-retro-term\n\n" + readOnly: true
wrapMode: TextEdit.Wrap
text: "Copyright (c) 2013 Filippo Scognamiglio <flscogna@gmail.com>\n\n" +
"https://github.com/Swordfish90/cool-retro-term\n\n" +
"cool-retro-term is free software: you can redistribute it and/or modify " + "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 " + "it under the terms of the GNU General Public License as published by " +
"the Free Software Foundation, either version 3 of the License, or " + "the Free Software Foundation, either version 3 of the License, or " +
"(at your option) any later version.\n\n" + "(at your option) any later version.\n\n" +
"This program is distributed in the hope that it will be useful, " + "This program is distributed in the hope that it will be useful, " +
"but WITHOUT ANY WARRANTY; without even the implied warranty of " + "but WITHOUT ANY WARRANTY; without even the implied warranty of " +
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " +
"GNU General Public License for more details.\n\n" + "GNU General Public License for more details.\n\n" +
"You should have received a copy of the GNU General Public License " + "You should have received a copy of the GNU General Public License " +
"along with this program. If not, see <http://www.gnu.org/licenses/>." "along with this program. If not, see <http://www.gnu.org/licenses/>."
}
} }
} }
} }

View File

@ -19,7 +19,7 @@
*******************************************************************************/ *******************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.0 import QtQuick.Controls 2.0
import "utils.js" as Utils import "utils.js" as Utils
@ -336,6 +336,7 @@ QtObject{
_margin = settings.margin !== undefined ? settings.margin : _margin; _margin = settings.margin !== undefined ? settings.margin : _margin;
handleFontChanged(); handleFontChanged();
} }

View File

@ -19,7 +19,7 @@
*******************************************************************************/ *******************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import "Components" import "Components"
@ -28,8 +28,8 @@ RowLayout {
property alias name: check.text property alias name: check.text
property double value property double value
property alias min_value: slider.minimumValue property alias min_value: slider.from
property alias max_value: slider.maximumValue property alias max_value: slider.to
property alias stepSize: slider.stepSize property alias stepSize: slider.stepSize
signal newValue(real newValue); signal newValue(real newValue);
@ -67,7 +67,6 @@ RowLayout {
} }
} }
SizedLabel { SizedLabel {
Layout.fillHeight: true
text: Math.round(((value - min_value) / (max_value - min_value)) * 100) + "%" text: Math.round(((value - min_value) / (max_value - min_value)) * 100) + "%"
} }
} }

View File

@ -42,8 +42,7 @@ Item {
anchors.fill: parent anchors.fill: parent
radius: 10 radius: 10
color: rootItem.color color: rootItem.color
border.color: "black"
Glossy {}
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
anchors.margins: parent.height * 0.25 anchors.margins: parent.height * 0.25

View File

@ -20,16 +20,14 @@
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 1.0 import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
// This component is simply a label with a predefined size. // This component is simply a label with a predefined size.
// Used to improve alignment. // Used to improve alignment.
Item { Label {
property alias text: textfield.text id: textfield
Layout.minimumWidth: appSettings.labelWidth
width: appSettings.labelWidth width: appSettings.labelWidth
Label{
id: textfield
anchors { right: parent.right; verticalCenter: parent.verticalCenter }
}
} }

View File

@ -1,21 +0,0 @@
import QtQuick 2.2
Rectangle {
anchors.centerIn: parent
width: parent.width - parent.border.width
height: parent.height - parent.border.width
radius:parent.radius - parent.border.width/2
smooth: true
border.width: parent.border.width/2
border.color: "#22FFFFFF"
gradient: Gradient {
GradientStop { position: 0; color: "#88FFFFFF" }
GradientStop { position: .1; color: "#55FFFFFF" }
GradientStop { position: .5; color: "#33FFFFFF" }
GradientStop { position: .501; color: "#11000000" }
GradientStop { position: .8; color: "#11FFFFFF" }
GradientStop { position: 1; color: "#55FFFFFF" }
}
}

View File

@ -20,7 +20,7 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Window 2.0 import QtQuick.Window 2.0
import QtQuick.Controls 1.1 import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1

View File

@ -19,10 +19,11 @@
*******************************************************************************/ *******************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.0
import QMLTermWidget 1.0 import QMLTermWidget 1.0
import "menus"
import "utils.js" as Utils import "utils.js" as Utils
Item{ Item{
@ -156,31 +157,23 @@ Item{
Component.onCompleted: { Component.onCompleted: {
appSettings.terminalFontChanged.connect(handleFontChanged); appSettings.terminalFontChanged.connect(handleFontChanged);
appSettings.initializedSettings.connect(startSession); appSettings.initializedSettings.connect(startSession);
appSettings.handleFontChanged()
} }
} }
Component { Component {
id: linuxContextMenu id: shortContextMenu
Menu{ ShortContextMenu { }
id: contextmenu
MenuItem { action: copyAction }
MenuItem { action: pasteAction }
MenuSeparator { visible: !appSettings.showMenubar }
MenuItem { action: showsettingsAction ; visible: !appSettings.showMenubar}
MenuSeparator { visible: !appSettings.showMenubar }
CRTMainMenuBar { visible: !appSettings.showMenubar }
}
} }
Component { Component {
id: osxContextMenu id: fullContextMenu
Menu{ FullContextMenu { }
id: contextmenu
MenuItem{action: copyAction}
MenuItem{action: pasteAction}
}
} }
Loader { Loader {
id: menuLoader id: menuLoader
sourceComponent: (Qt.platform.os === "osx" ? osxContextMenu : linuxContextMenu) sourceComponent: (Qt.platform.os === "osx" || appSettings.showMenubar ? shortContextMenu : fullContextMenu)
} }
property alias contextmenu: menuLoader.item property alias contextmenu: menuLoader.item

View File

@ -19,127 +19,128 @@
*******************************************************************************/ *******************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQml 2.0
import "Components" import "Components"
Tab{ ColumnLayout{
ColumnLayout{ GroupBox{
anchors.fill: parent Layout.fillWidth: true
title: qsTr("Command")
GroupBox{ ColumnLayout {
Layout.fillWidth: true anchors.fill: parent
title: qsTr("Command") CheckBox{
ColumnLayout { id: useCustomCommand
anchors.fill: parent text: qsTr("Use custom command instead of shell at startup")
CheckBox{ checked: appSettings.useCustomCommand
id: useCustomCommand onCheckedChanged: appSettings.useCustomCommand = checked
text: qsTr("Use custom command instead of shell at startup") }
checked: appSettings.useCustomCommand // Workaround for QTBUG-31627 for pre 5.3.0
onCheckedChanged: appSettings.useCustomCommand = checked Binding{
} target: useCustomCommand
// Workaround for QTBUG-31627 for pre 5.3.0 property: "checked"
Binding{ value: appSettings.useCustomCommand
target: useCustomCommand }
property: "checked" TextField{
value: appSettings.useCustomCommand id: customCommand
} Layout.fillWidth: true
TextField{ text: appSettings.customCommand
id: customCommand enabled: useCustomCommand.checked
Layout.fillWidth: true onEditingFinished: appSettings.customCommand = text
text: appSettings.customCommand
enabled: useCustomCommand.checked
onEditingFinished: appSettings.customCommand = text
// Save text even if user forgets to press enter or unfocus // Save text even if user forgets to press enter or unfocus
function saveSetting() { function saveSetting() {
appSettings.customCommand = text; appSettings.customCommand = text;
}
Component.onCompleted: settings_window.closing.connect(saveSetting)
} }
Component.onCompleted: settings_window.closing.connect(saveSetting)
} }
} }
}
GroupBox{ GroupBox{
title: qsTr("Performance") title: qsTr("Performance")
Layout.fillWidth: true Layout.fillWidth: true
GridLayout{ GridLayout{
anchors.fill: parent anchors.fill: parent
rows: 2 columns: 4
columns: 3
Label{text: qsTr("Effects FPS")} Label{text: qsTr("Effects FPS")}
Slider{ Slider{
Layout.fillWidth: true Layout.fillWidth: true
id: fpsSlider Layout.columnSpan: 2
onValueChanged: { id: fpsSlider
if (enabled) { onValueChanged: {
appSettings.fps = value !== 60 ? value + 1 : 0; if (enabled) {
} appSettings.fps = value !== 60 ? value + 1 : 0;
}
stepSize: 1
enabled: false
Component.onCompleted: {
minimumValue = 0;
maximumValue = 60;
value = appSettings.fps !== 0 ? appSettings.fps - 1 : 60;
enabled = true;
} }
} }
stepSize: 1
enabled: false
Component.onCompleted: {
from = 0;
to = 60;
value = appSettings.fps !== 0 ? appSettings.fps - 1 : 60;
enabled = true;
}
}
SizedLabel{text: appSettings.fps !== 0 ? appSettings.fps : qsTr("Max")} Label{text: appSettings.fps !== 0 ? appSettings.fps : qsTr("Max")}
Label{text: qsTr("Texture Quality")} Label{text: qsTr("Texture Quality")}
Slider{ Slider{
Layout.fillWidth: true id: txtslider
id: txtslider Layout.fillWidth: true
onValueChanged: if (enabled) appSettings.windowScaling = value; Layout.columnSpan: 2
stepSize: 0.05 onValueChanged: if (enabled) appSettings.windowScaling = value;
enabled: false stepSize: 0.05
Component.onCompleted: { enabled: false
minimumValue = 0.25 //Without this value gets set to 0.5 Component.onCompleted: {
value = appSettings.windowScaling; from = 0.25 //Without this value gets set to 0.5
enabled = true; value = appSettings.windowScaling;
} enabled = true;
} }
SizedLabel{text: Math.round(txtslider.value * 100) + "%"} }
Label{text: Math.round(txtslider.value * 100) + "%"}
Label{text: qsTr("Bloom Quality")} Label{text: qsTr("Bloom Quality")}
Slider{ Slider{
Layout.fillWidth: true Layout.fillWidth: true
id: bloomSlider Layout.columnSpan: 2
onValueChanged: if (enabled) appSettings.bloomQuality = value; id: bloomSlider
stepSize: 0.05 onValueChanged: if (enabled) appSettings.bloomQuality = value;
enabled: false stepSize: 0.05
Component.onCompleted: { enabled: false
minimumValue = 0.25 Component.onCompleted: {
value = appSettings.bloomQuality; from = 0.25
enabled = true; value = appSettings.bloomQuality;
} enabled = true;
} }
SizedLabel{text: Math.round(bloomSlider.value * 100) + "%"} }
Label{text: Math.round(bloomSlider.value * 100) + "%"}
Label{text: qsTr("BurnIn Quality")} Label{text: qsTr("BurnIn Quality")}
Slider{ Slider{
Layout.fillWidth: true Layout.fillWidth: true
id: burnInSlider id: burnInSlider
onValueChanged: if (enabled) appSettings.burnInQuality = value; Layout.columnSpan: 2
stepSize: 0.05 onValueChanged: if (enabled) appSettings.burnInQuality = value;
enabled: false stepSize: 0.05
Component.onCompleted: { enabled: false
minimumValue = 0.25 Component.onCompleted: {
value = appSettings.burnInQuality; from = 0.25
enabled = true; value = appSettings.burnInQuality;
} enabled = true;
}
SizedLabel{text: Math.round(burnInSlider.value * 100) + "%"}
CheckBox{
Layout.columnSpan: 2
text: qsTr("Burnin optimization (Might display timing artifacts)")
checked: appSettings.useFastBurnIn
onCheckedChanged: appSettings.useFastBurnIn = checked
} }
} }
Label{text: Math.round(burnInSlider.value * 100) + "%"}
CheckBox{
Layout.columnSpan: 2
text: qsTr("Burnin optimization (Might display timing artifacts)")
checked: appSettings.useFastBurnIn
onCheckedChanged: appSettings.useFastBurnIn = checked
}
} }
} }
} }

View File

@ -19,72 +19,69 @@
*******************************************************************************/ *******************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
Tab{ ColumnLayout{
ColumnLayout{ spacing: 2
anchors.fill: parent
spacing: 2
GroupBox{ GroupBox{
title: qsTr("Effects") title: qsTr("Effects")
Layout.fillWidth: true Layout.fillWidth: true
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
CheckableSlider{ CheckableSlider{
name: qsTr("Bloom") name: qsTr("Bloom")
onNewValue: appSettings.bloom = newValue onNewValue: appSettings.bloom = newValue
value: appSettings.bloom value: appSettings.bloom
} }
CheckableSlider{ CheckableSlider{
name: qsTr("BurnIn") name: qsTr("BurnIn")
onNewValue: appSettings.burnIn = newValue onNewValue: appSettings.burnIn = newValue
value: appSettings.burnIn value: appSettings.burnIn
} }
CheckableSlider{ CheckableSlider{
name: qsTr("Static Noise") name: qsTr("Static Noise")
onNewValue: appSettings.staticNoise = newValue onNewValue: appSettings.staticNoise = newValue
value: appSettings.staticNoise value: appSettings.staticNoise
} }
CheckableSlider{ CheckableSlider{
name: qsTr("Jitter") name: qsTr("Jitter")
onNewValue: appSettings.jitter = newValue onNewValue: appSettings.jitter = newValue
value: appSettings.jitter value: appSettings.jitter
} }
CheckableSlider{ CheckableSlider{
name: qsTr("Glow Line") name: qsTr("Glow Line")
onNewValue: appSettings.glowingLine = newValue; onNewValue: appSettings.glowingLine = newValue;
value: appSettings.glowingLine value: appSettings.glowingLine
} }
CheckableSlider{ CheckableSlider{
name: qsTr("Screen Curvature") name: qsTr("Screen Curvature")
onNewValue: appSettings.screenCurvature = newValue; onNewValue: appSettings.screenCurvature = newValue;
value: appSettings.screenCurvature; value: appSettings.screenCurvature;
} }
CheckableSlider{ CheckableSlider{
name: qsTr("Ambient Light") name: qsTr("Ambient Light")
onNewValue: appSettings.ambientLight = newValue; onNewValue: appSettings.ambientLight = newValue;
value: appSettings.ambientLight value: appSettings.ambientLight
enabled: appSettings.framesIndex !== 0 enabled: appSettings.framesIndex !== 0
} }
CheckableSlider{ CheckableSlider{
name: qsTr("Flickering") name: qsTr("Flickering")
onNewValue: appSettings.flickering = newValue; onNewValue: appSettings.flickering = newValue;
value: appSettings.flickering; value: appSettings.flickering;
} }
CheckableSlider{ CheckableSlider{
name: qsTr("Horizontal Sync") name: qsTr("Horizontal Sync")
onNewValue: appSettings.horizontalSync = newValue; onNewValue: appSettings.horizontalSync = newValue;
value: appSettings.horizontalSync; value: appSettings.horizontalSync;
} }
CheckableSlider{ CheckableSlider{
name: qsTr("RGB Shift") name: qsTr("RGB Shift")
onNewValue: appSettings.rbgShift = newValue; onNewValue: appSettings.rbgShift = newValue;
value: appSettings.rbgShift; value: appSettings.rbgShift;
}
} }
} }
} }

View File

@ -19,216 +19,217 @@
*******************************************************************************/ *******************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.4
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
Tab{ ColumnLayout{
ColumnLayout{ GroupBox{
anchors.fill: parent Layout.fillWidth: true
GroupBox{ title: qsTr("Profile")
Layout.fillWidth: true RowLayout {
Layout.fillHeight: true anchors.fill: parent
title: qsTr("Profile") ListView {
RowLayout { id: profilesView
anchors.fill: parent Layout.fillWidth: true
TableView { Layout.fillHeight: true
id: profilesView model: appSettings.profilesList
delegate: Rectangle {
width: label.width
height: label.height
color: (index == profilesView.currentIndex) ? palette.highlight : palette.base
Label {
id: label
text: appSettings.profilesList.get(index).text
MouseArea {
anchors.fill: parent
onClicked: profilesView.currentIndex = index
onDoubleClicked: appSettings.loadProfile(index)
}
}
}
}
ColumnLayout {
Layout.fillHeight: true
Layout.fillWidth: false
Button{
Layout.fillWidth: true Layout.fillWidth: true
text: qsTr("Save")
onClicked: {
insertname.profileName = "";
insertname.show()
}
}
Button{
Layout.fillWidth: true
property alias currentIndex: profilesView.currentIndex
enabled: currentIndex >= 0
text: qsTr("Load")
onClicked: {
var index = currentIndex;
if (index >= 0)
appSettings.loadProfile(index);
}
}
Button{
Layout.fillWidth: true
text: qsTr("Remove")
property alias currentIndex: profilesView.currentIndex
enabled: currentIndex >= 0 && !appSettings.profilesList.get(currentIndex).builtin
onClicked: {
appSettings.profilesList.remove(currentIndex);
profilesView.selection.clear();
// TODO This is a very ugly workaround. The view didn't update on Qt 5.3.2.
profilesView.model = 0;
profilesView.model = appSettings.profilesList;
}
}
Item {
// Spacing
Layout.fillHeight: true Layout.fillHeight: true
model: appSettings.profilesList
headerVisible: false
TableViewColumn {
title: qsTr("Profile")
role: "text"
width: parent.width * 0.5
}
onActivated: {
appSettings.loadProfile(row);
}
} }
ColumnLayout { Button{
Layout.fillHeight: true Layout.fillWidth: true
Layout.fillWidth: false text: qsTr("Import")
Button{ onClicked: {
Layout.fillWidth: true fileDialog.selectExisting = true;
text: qsTr("Save") fileDialog.callBack = function (url) {loadFile(url);};
onClicked: { fileDialog.open();
insertname.profileName = "";
insertname.show()
}
} }
Button{ function loadFile(url) {
Layout.fillWidth: true try {
property alias currentIndex: profilesView.currentRow if (appSettings.verbose)
enabled: currentIndex >= 0 console.log("Loading file: " + url);
text: qsTr("Load")
onClicked: {
var index = profilesView.currentRow;
if (index >= 0)
appSettings.loadProfile(index);
}
}
Button{
Layout.fillWidth: true
text: qsTr("Remove")
property alias currentIndex: profilesView.currentRow
enabled: currentIndex >= 0 && !appSettings.profilesList.get(currentIndex).builtin var profileObject = JSON.parse(fileIO.read(url));
onClicked: { var name = profileObject.name;
appSettings.profilesList.remove(currentIndex);
profilesView.selection.clear();
// TODO This is a very ugly workaround. The view didn't update on Qt 5.3.2. if (!name)
profilesView.model = 0; throw "Profile doesn't have a name";
profilesView.model = appSettings.profilesList;
}
}
Item {
// Spacing
Layout.fillHeight: true
}
Button{
Layout.fillWidth: true
text: qsTr("Import")
onClicked: {
fileDialog.selectExisting = true;
fileDialog.callBack = function (url) {loadFile(url);};
fileDialog.open();
}
function loadFile(url) {
try {
if (appSettings.verbose)
console.log("Loading file: " + url);
var profileObject = JSON.parse(fileIO.read(url)); var version = profileObject.version !== undefined ? profileObject.version : 1;
var name = profileObject.name; if (version !== appSettings.profileVersion)
throw "This profile is not supported on this version of CRT.";
if (!name) delete profileObject.name;
throw "Profile doesn't have a name";
var version = profileObject.version !== undefined ? profileObject.version : 1; appSettings.appendCustomProfile(name, JSON.stringify(profileObject));
if (version !== appSettings.profileVersion) } catch (err) {
throw "This profile is not supported on this version of CRT."; messageDialog.text = qsTr(err)
messageDialog.open();
delete profileObject.name;
appSettings.appendCustomProfile(name, JSON.stringify(profileObject));
} catch (err) {
messageDialog.text = qsTr(err)
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.profilesList.get(currentIndex);
var profileSettings = JSON.parse(profileObject.obj_string);
profileSettings["name"] = profileObject.text;
profileSettings["version"] = appSettings.profileVersion;
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();
}
} }
} }
} }
} Button{
} property alias currentIndex: profilesView.currentIndex
GroupBox{ Layout.fillWidth: true
title: qsTr("Screen")
Layout.fillWidth: true text: qsTr("Export")
GridLayout{ enabled: currentIndex >= 0 && !appSettings.profilesList.get(currentIndex).builtin
anchors.fill: parent onClicked: {
columns: 2 fileDialog.selectExisting = false;
Label{ text: qsTr("Brightness") } fileDialog.callBack = function (url) {storeFile(url);};
SimpleSlider{ fileDialog.open();
onValueChanged: appSettings.brightness = value }
value: appSettings.brightness 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.profilesList.get(currentIndex);
var profileSettings = JSON.parse(profileObject.obj_string);
profileSettings["name"] = profileObject.text;
profileSettings["version"] = appSettings.profileVersion;
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();
}
}
} }
Label{ text: qsTr("Contrast") }
SimpleSlider{
onValueChanged: appSettings.contrast = value
value: appSettings.contrast
}
Label{ text: qsTr("Margin") }
SimpleSlider{
onValueChanged: appSettings._margin = value
value: appSettings._margin
}
Label{ text: qsTr("Opacity") }
SimpleSlider{
onValueChanged: appSettings.windowOpacity = value
value: appSettings.windowOpacity
}
}
}
// DIALOGS ////////////////////////////////////////////////////////////////
InsertNameDialog{
id: insertname
onNameSelected: {
appSettings.appendCustomProfile(name, appSettings.composeProfileString());
}
}
MessageDialog {
id: messageDialog
title: qsTr("File Error")
onAccepted: {
messageDialog.close();
}
}
Loader {
property var callBack
property bool selectExisting: false
id: fileDialog
sourceComponent: FileDialog{
nameFilters: ["Json files (*.json)"]
selectMultiple: false
selectFolder: false
selectExisting: fileDialog.selectExisting
onAccepted: callBack(fileUrl);
}
onSelectExistingChanged: reload()
function open() {
item.open();
}
function reload() {
active = false;
active = true;
} }
} }
} }
GroupBox{
title: qsTr("Screen")
Layout.fillWidth: true
GridLayout{
anchors.fill: parent
columns: 2
Label{ text: qsTr("Brightness") }
SimpleSlider{
onValueChanged: appSettings.brightness = value
value: appSettings.brightness
}
Label{ text: qsTr("Contrast") }
SimpleSlider{
onValueChanged: appSettings.contrast = value
value: appSettings.contrast
}
Label{ text: qsTr("Margin") }
SimpleSlider{
onValueChanged: appSettings._margin = value
value: appSettings._margin
}
Label{ text: qsTr("Opacity") }
SimpleSlider{
onValueChanged: appSettings.windowOpacity = value
value: appSettings.windowOpacity
}
}
}
// DIALOGS ////////////////////////////////////////////////////////////////
InsertNameDialog{
id: insertname
onNameSelected: {
appSettings.appendCustomProfile(name, appSettings.composeProfileString());
}
}
MessageDialog {
id: messageDialog
title: qsTr("File Error")
onAccepted: {
messageDialog.close();
}
}
Loader {
property var callBack
property bool selectExisting: false
id: fileDialog
sourceComponent: FileDialog{
nameFilters: ["Json files (*.json)"]
selectMultiple: false
selectFolder: false
selectExisting: fileDialog.selectExisting
onAccepted: callBack(fileUrl);
}
onSelectExistingChanged: reload()
function open() {
item.open();
}
function reload() {
active = false;
active = true;
}
}
} }

View File

@ -19,154 +19,142 @@
*******************************************************************************/ *******************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.1
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQml 2.0
import "Components" import "Components"
Tab{ ColumnLayout{
ColumnLayout{
anchors.fill: parent
GroupBox{ GroupBox{
title: qsTr("Font") title: qsTr("Font")
Layout.fillWidth: true Layout.fillWidth: true
GridLayout{ GridLayout{
anchors.fill: parent anchors.fill: parent
columns: 2 columns: 2
Label { text: qsTr("Rasterization") } Label { text: qsTr("Rasterization") }
ComboBox { ComboBox {
id: rasterizationBox id: rasterizationBox
property string selectedElement: model[currentIndex] property string selectedElement: model[currentIndex]
Layout.fillWidth: true Layout.fillWidth: true
model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels")] model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels")]
currentIndex: appSettings.rasterization currentIndex: appSettings.rasterization
onCurrentIndexChanged: { onCurrentIndexChanged: {
appSettings.rasterization = currentIndex appSettings.rasterization = currentIndex
}
} }
Label{ text: qsTr("Name") } }
ComboBox{ Label{ text: qsTr("Name") }
id: fontChanger ComboBox{
Layout.fillWidth: true id: fontChanger
model: appSettings.fontlist Layout.fillWidth: true
onActivated: { model: appSettings.fontlist
var name = appSettings.fontlist.get(index).name; textRole: "text"
appSettings.fontNames[appSettings.rasterization] = name; onActivated: {
appSettings.handleFontChanged(); var name = appSettings.fontlist.get(index).name;
} appSettings.fontNames[appSettings.rasterization] = name;
function updateIndex(){ appSettings.handleFontChanged();
var name = appSettings.fontNames[appSettings.rasterization];
var index = appSettings.getIndexByName(name);
if (index !== undefined)
currentIndex = index;
}
Connections{
target: appSettings
onTerminalFontChanged: fontChanger.updateIndex();
}
Component.onCompleted: updateIndex();
} }
Label{ text: qsTr("Scaling") } function updateIndex(){
RowLayout{ var name = appSettings.fontNames[appSettings.rasterization];
Layout.fillWidth: true var index = appSettings.getIndexByName(name);
Slider{ if (index !== undefined)
Layout.fillWidth: true currentIndex = index;
id: fontScalingChanger
onValueChanged: if(enabled) appSettings.fontScaling = value
stepSize: 0.05
enabled: false // Another trick to fix initial bad behavior.
Component.onCompleted: {
minimumValue = appSettings.minimumFontScaling;
maximumValue = appSettings.maximumFontScaling;
value = appSettings.fontScaling;
enabled = true;
}
Connections{
target: appSettings
onFontScalingChanged: fontScalingChanger.value = appSettings.fontScaling;
}
}
SizedLabel{
text: Math.round(fontScalingChanger.value * 100) + "%"
}
} }
Label{ text: qsTr("Font Width") } Connections{
RowLayout{ target: appSettings
onTerminalFontChanged: fontChanger.updateIndex();
}
Component.onCompleted: updateIndex();
}
Label{ text: qsTr("Scaling") }
RowLayout{
Layout.fillWidth: true
Slider{
Layout.fillWidth: true Layout.fillWidth: true
Slider{ id: fontScalingChanger
Layout.fillWidth: true onValueChanged: appSettings.fontScaling = value
id: widthChanger value: appSettings.fontScaling
onValueChanged: appSettings.fontWidth = value; stepSize: 0.05
value: appSettings.fontWidth from: appSettings.minimumFontScaling;
stepSize: 0.05 to: appSettings.maximumFontScaling;
Component.onCompleted: { }
// This is needed to avoid unnecessary chnaged events. SizedLabel{
minimumValue = 0.5; text: Math.round(fontScalingChanger.value * 100) + "%"
maximumValue = 1.5; }
} }
} Label{ text: qsTr("Font Width") }
SizedLabel{ RowLayout{
text: Math.round(widthChanger.value * 100) + "%" Layout.fillWidth: true
} Slider{
Layout.fillWidth: true
id: widthChanger
onValueChanged: appSettings.fontWidth = value;
value: appSettings.fontWidth
stepSize: 0.05
from: 0.5
to: 1.5
}
SizedLabel{
text: Math.round(widthChanger.value * 100) + "%"
} }
} }
} }
GroupBox{ }
title: qsTr("Cursor") GroupBox{
Layout.fillWidth: true title: qsTr("Cursor")
ColumnLayout { Layout.fillWidth: true
anchors.fill: parent ColumnLayout {
CheckBox{ anchors.fill: parent
id: blinkingCursor CheckBox{
text: qsTr("Blinking Cursor") id: blinkingCursor
checked: appSettings.blinkingCursor text: qsTr("Blinking Cursor")
onCheckedChanged: appSettings.blinkingCursor = checked checked: appSettings.blinkingCursor
} onCheckedChanged: appSettings.blinkingCursor = checked
Binding{ }
target: blinkingCursor Binding{
property: "checked" target: blinkingCursor
value: appSettings.blinkingCursor property: "checked"
} value: appSettings.blinkingCursor
} }
} }
GroupBox{ }
title: qsTr("Colors") GroupBox{
Layout.fillWidth: true title: qsTr("Colors")
Layout.fillWidth: true
ColumnLayout{
anchors.fill: parent
ColumnLayout{ ColumnLayout{
anchors.fill: parent Layout.fillWidth: true
ColumnLayout{ CheckableSlider{
Layout.fillWidth: true name: qsTr("Chroma Color")
CheckableSlider{ onNewValue: appSettings.chromaColor = newValue
name: qsTr("Chroma Color") value: appSettings.chromaColor
onNewValue: appSettings.chromaColor = newValue
value: appSettings.chromaColor
}
CheckableSlider{
name: qsTr("Saturation Color")
onNewValue: appSettings.saturationColor = newValue
value: appSettings.saturationColor
enabled: appSettings.chromaColor !== 0
}
} }
RowLayout{ CheckableSlider{
name: qsTr("Saturation Color")
onNewValue: appSettings.saturationColor = newValue
value: appSettings.saturationColor
enabled: appSettings.chromaColor !== 0
}
}
RowLayout{
Layout.fillWidth: true
ColorButton{
name: qsTr("Font")
height: 50
Layout.fillWidth: true Layout.fillWidth: true
ColorButton{ onColorSelected: appSettings._fontColor = color;
name: qsTr("Font") color: appSettings._fontColor
height: 50 }
Layout.fillWidth: true ColorButton{
onColorSelected: appSettings._fontColor = color; name: qsTr("Background")
color: appSettings._fontColor height: 50
} Layout.fillWidth: true
ColorButton{ onColorSelected: appSettings._backgroundColor = color;
name: qsTr("Background") color: appSettings._backgroundColor
height: 50
Layout.fillWidth: true
onColorSelected: appSettings._backgroundColor = color;
color: appSettings._backgroundColor
}
} }
} }
} }

View File

@ -19,46 +19,50 @@
*******************************************************************************/ *******************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.1
import QtQuick.Window 2.1 import QtQuick.Window 2.1
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
Window { Window {
id: settings_window id: settings_window
title: qsTr("Settings") title: qsTr("Settings")
width: 580 width: 800
height: 400 height: 600
property int tabmargins: 15 property int tabmargins: 15
TabView{ TabBar {
id: tabView id: bar
anchors.fill: parent width: parent.width
anchors.margins: 10 TabButton {
SettingsGeneralTab { text: qsTr("General")
id: generalTab
title: qsTr("General")
anchors.fill: parent
anchors.margins: tabmargins
} }
SettingsTerminalTab { TabButton {
id: terminalTab text: qsTr("Terminal")
title: qsTr("Terminal")
anchors.fill: parent
anchors.margins: tabmargins
} }
SettingsEffectsTab { TabButton {
id: effectsTab text: qsTr("Effects")
title: qsTr("Effects")
anchors.fill: parent
anchors.margins: tabmargins
} }
SettingsAdvancedTab { TabButton {
id: performanceTab text: qsTr("Advanced")
title: qsTr("Advanced")
anchors.fill: parent
anchors.margins: tabmargins
} }
} }
StackLayout {
anchors {
top: bar.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
margins: tabmargins
}
currentIndex: bar.currentIndex
SettingsGeneralTab { }
SettingsTerminalTab { }
SettingsEffectsTab { }
SettingsAdvancedTab { }
}
} }

View File

@ -19,7 +19,7 @@
*******************************************************************************/ *******************************************************************************/
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.0
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import "Components" import "Components"
@ -27,8 +27,8 @@ import "Components"
RowLayout { RowLayout {
property alias value: slider.value property alias value: slider.value
property alias stepSize: slider.stepSize property alias stepSize: slider.stepSize
property alias minimumValue: slider.minimumValue property alias minimumValue: slider.from
property alias maximumValue: slider.maximumValue property alias maximumValue: slider.to
property real maxMultiplier: 100 property real maxMultiplier: 100
id: setting_component id: setting_component

View File

@ -20,8 +20,9 @@
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Window 2.1 import QtQuick.Window 2.1
import QtQuick.Controls 1.1 import QtQuick.Controls 2.3
import QtGraphicalEffects 1.0
import "menus"
ApplicationWindow{ ApplicationWindow{
id: terminalWindow id: terminalWindow
@ -37,8 +38,6 @@ ApplicationWindow{
// Load saved window geometry and show the window // Load saved window geometry and show the window
Component.onCompleted: { Component.onCompleted: {
appSettings.handleFontChanged();
x = appSettings.x x = appSettings.x
y = appSettings.y y = appSettings.y
width = appSettings.width width = appSettings.width
@ -55,11 +54,9 @@ ApplicationWindow{
property bool fullscreen: appSettings.fullscreen property bool fullscreen: appSettings.fullscreen
onFullscreenChanged: visibility = (fullscreen ? Window.FullScreen : Window.Windowed) onFullscreenChanged: visibility = (fullscreen ? Window.FullScreen : Window.Windowed)
//Workaround: Without __contentItem a ugly thin border is visible. menuBar: WindowMenu {
menuBar: CRTMainMenuBar{
id: mainMenu id: mainMenu
visible: (Qt.platform.os === "osx" || appSettings.showMenubar) visible: (Qt.platform.os === "osx" || appSettings.showMenubar)
__contentItem.visible: mainMenu.visible
} }
property string wintitle: appSettings.wintitle property string wintitle: appSettings.wintitle
@ -136,7 +133,6 @@ ApplicationWindow{
} }
TerminalContainer{ TerminalContainer{
id: terminalContainer id: terminalContainer
y: appSettings.showMenubar ? 0 : -2 // Workaroud to hide the margin in the menubar.
width: parent.width width: parent.width
height: (parent.height + Math.abs(y)) height: (parent.height + Math.abs(y))
} }

View File

@ -0,0 +1,72 @@
/*******************************************************************************
* Copyright (c) 2013-2021 "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 2.3
Menu{
id: contextmenu
MenuItem { action: copyAction }
MenuItem { action: pasteAction }
MenuItem { action: showsettingsAction }
MenuSeparator { }
Menu {
title: qsTr("File")
MenuItem {
action: quitAction
}
}
Menu {
title: qsTr("Edit")
MenuItem {action: copyAction}
MenuItem {action: pasteAction}
MenuSeparator { }
MenuItem {action: showsettingsAction}
}
Menu{
title: qsTr("View")
MenuItem {action: fullscreenAction; visible: fullscreenAction.enabled}
MenuItem {action: showMenubarAction; visible: showMenubarAction.enabled}
MenuItem {action: zoomIn}
MenuItem {action: zoomOut}
}
Menu{
id: profilesMenu
title: qsTr("Profiles")
Instantiator{
model: appSettings.profilesList
delegate: MenuItem {
text: model.text
onTriggered: {
appSettings.loadProfileString(obj_string);
appSettings.handleFontChanged();
}
}
onObjectAdded: profilesMenu.insertItem(index, object)
onObjectRemoved: profilesMenu.removeItem(object)
}
}
Menu{
title: qsTr("Help")
MenuItem {action: showAboutAction}
}
}

View File

@ -0,0 +1,28 @@
/*******************************************************************************
* Copyright (c) 2013-2021 "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 2.3
Menu{
id: contextmenu
MenuItem { action: copyAction }
MenuItem { action: pasteAction }
}

View File

@ -1,35 +1,51 @@
/*******************************************************************************
* Copyright (c) 2013-2021 "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 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 2.3
MenuBar { MenuBar {
id: defaultMenuBar id: defaultMenuBar
property bool visible: true visible: appSettings.showMenubar
Menu { Menu {
title: qsTr("File") title: qsTr("File")
visible: defaultMenuBar.visible
MenuItem {action: quitAction} MenuItem {action: quitAction}
} }
Menu { Menu {
title: qsTr("Edit") title: qsTr("Edit")
visible: defaultMenuBar.visible && appSettings.showMenubar
MenuItem {action: copyAction} MenuItem {action: copyAction}
MenuItem {action: pasteAction} MenuItem {action: pasteAction}
MenuSeparator{visible: Qt.platform.os !== "osx"} MenuSeparator { }
MenuItem {action: showsettingsAction} MenuItem {action: showsettingsAction}
} }
Menu{ Menu{
title: qsTr("View") title: qsTr("View")
visible: defaultMenuBar.visible
MenuItem {action: fullscreenAction; visible: fullscreenAction.enabled} MenuItem {action: fullscreenAction; visible: fullscreenAction.enabled}
MenuItem {action: showMenubarAction; visible: showMenubarAction.enabled} MenuItem {action: showMenubarAction; visible: showMenubarAction.enabled}
MenuSeparator{visible: showMenubarAction.enabled}
MenuItem {action: zoomIn} MenuItem {action: zoomIn}
MenuItem {action: zoomOut} MenuItem {action: zoomOut}
} }
Menu{ Menu{
id: profilesMenu id: profilesMenu
title: qsTr("Profiles") title: qsTr("Profiles")
visible: defaultMenuBar.visible
Instantiator{ Instantiator{
model: appSettings.profilesList model: appSettings.profilesList
delegate: MenuItem { delegate: MenuItem {
@ -45,7 +61,6 @@ MenuBar {
} }
Menu{ Menu{
title: qsTr("Help") title: qsTr("Help")
visible: defaultMenuBar.visible
MenuItem {action: showAboutAction} MenuItem {action: showAboutAction}
} }
} }

View File

@ -12,7 +12,6 @@
<file>TimeManager.qml</file> <file>TimeManager.qml</file>
<file>SimpleSlider.qml</file> <file>SimpleSlider.qml</file>
<file>ColorButton.qml</file> <file>ColorButton.qml</file>
<file>Glossy.qml</file>
<file>AboutDialog.qml</file> <file>AboutDialog.qml</file>
<file>InsertNameDialog.qml</file> <file>InsertNameDialog.qml</file>
<file>SettingsEffectsTab.qml</file> <file>SettingsEffectsTab.qml</file>
@ -22,7 +21,6 @@
<file>fonts/1977-apple2/PrintChar21.ttf</file> <file>fonts/1977-apple2/PrintChar21.ttf</file>
<file>fonts/1971-ibm-3278/3270Medium.ttf</file> <file>fonts/1971-ibm-3278/3270Medium.ttf</file>
<file>Storage.qml</file> <file>Storage.qml</file>
<file>CRTMainMenuBar.qml</file>
<file>SettingsAdvancedTab.qml</file> <file>SettingsAdvancedTab.qml</file>
<file>TerminalContainer.qml</file> <file>TerminalContainer.qml</file>
<file>images/crt256.png</file> <file>images/crt256.png</file>
@ -44,5 +42,8 @@
<file>fonts/modern-terminus/TerminusTTF-4.46.0.ttf</file> <file>fonts/modern-terminus/TerminusTTF-4.46.0.ttf</file>
<file>NewTerminalFrame.qml</file> <file>NewTerminalFrame.qml</file>
<file>SlowBurnIn.qml</file> <file>SlowBurnIn.qml</file>
<file>menus/WindowMenu.qml</file>
<file>menus/FullContextMenu.qml</file>
<file>menus/ShortContextMenu.qml</file>
</qresource> </qresource>
</RCC> </RCC>

@ -1 +1 @@
Subproject commit 59f967d5e1f6e9ce8e1632d9405422b071d93d30 Subproject commit 5c47d1f49455394226e0e595f79c148f0c098006