mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-01-31 02:01:19 +00:00
Settings window seems to work nicely.
This commit is contained in:
parent
9795b5d9d2
commit
372bceb186
@ -10,28 +10,38 @@ Tab{
|
||||
Layout.fillWidth: true
|
||||
ComboBox {
|
||||
id: rasterizationBox
|
||||
property string selectedElement: model[currentIndex]
|
||||
anchors.fill: parent
|
||||
model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels")]
|
||||
currentIndex: shadersettings.rasterization
|
||||
onCurrentIndexChanged: shadersettings.rasterization = currentIndex
|
||||
onCurrentIndexChanged: {
|
||||
scalingChanger.enabled = false;
|
||||
shadersettings.rasterization = currentIndex
|
||||
fontChanger.updateIndex();
|
||||
scalingChanger.updateIndex();
|
||||
scalingChanger.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
GroupBox{
|
||||
title: qsTr("Font")
|
||||
title: qsTr("Font") + " (" + rasterizationBox.selectedElement + ")"
|
||||
Layout.fillWidth: true
|
||||
GridLayout{
|
||||
anchors.fill: parent
|
||||
columns: 2
|
||||
Text{ text: qsTr("Name") }
|
||||
ComboBox{
|
||||
id: fontChanged
|
||||
id: fontChanger
|
||||
Layout.fillWidth: true
|
||||
model: shadersettings.fontlist
|
||||
currentIndex: shadersettings.fontIndexes[shadersettings.rasterization]
|
||||
onCurrentIndexChanged: {
|
||||
shadersettings.fontIndexes[shadersettings.rasterization] = currentIndex;
|
||||
currentIndex: updateIndex()
|
||||
onActivated: {
|
||||
shadersettings.fontIndexes[shadersettings.rasterization] = index;
|
||||
shadersettings.handleFontChanged();
|
||||
}
|
||||
function updateIndex(){
|
||||
currentIndex = shadersettings.fontIndexes[shadersettings.rasterization];
|
||||
}
|
||||
}
|
||||
Text{ text: qsTr("Scaling") }
|
||||
RowLayout{
|
||||
@ -42,12 +52,16 @@ Tab{
|
||||
minimumValue: 0
|
||||
maximumValue: shadersettings.fontScalingList.length - 1
|
||||
stepSize: 1
|
||||
value: shadersettings.fontScalingIndexes[shadersettings.rasterization]
|
||||
tickmarksEnabled: true
|
||||
value: updateIndex()
|
||||
onValueChanged: {
|
||||
if(!enabled) return; //Ugly and hacky solution. Look for a better solution.
|
||||
shadersettings.fontScalingIndexes[shadersettings.rasterization] = value;
|
||||
console.log(shadersettings.fontScalingIndexes);
|
||||
shadersettings.handleFontChanged();
|
||||
}
|
||||
function updateIndex(){
|
||||
value = shadersettings.fontScalingIndexes[shadersettings.rasterization];
|
||||
}
|
||||
}
|
||||
Text{
|
||||
text: shadersettings.fontScalingList[scalingChanger.value].toFixed(2)
|
||||
|
@ -70,17 +70,23 @@ Item{
|
||||
readonly property int pixel_rasterization: 2
|
||||
|
||||
property int rasterization: no_rasterization
|
||||
onRasterizationChanged: handleFontChanged()
|
||||
|
||||
ListModel{
|
||||
id: framelist
|
||||
ListElement{text: "No frame"; source: "./frames/NoFrame.qml"; reflections: false}
|
||||
ListElement{text: "Simple white frame"; source: "./frames/WhiteSimpleFrame.qml"; reflections: true}
|
||||
ListElement{text: "Rough black frame"; source: "./frames/BlackRoughFrame.qml"; reflections: true}
|
||||
}
|
||||
|
||||
property string frame_source: frames_list.get(frames_index).source
|
||||
property int frames_index: 1
|
||||
property var frames_list: framelist
|
||||
|
||||
signal terminalFontChanged
|
||||
|
||||
signal terminalFontChanged(string fontSource, int pixelSize, int lineSpacing, size virtualCharSize)
|
||||
|
||||
Loader{
|
||||
id: fontManager
|
||||
onSourceChanged: console.log(source)
|
||||
|
||||
states: [
|
||||
State { when: rasterization == no_rasterization
|
||||
@ -94,38 +100,23 @@ Item{
|
||||
onLoaded: handleFontChanged()
|
||||
}
|
||||
|
||||
Text{id: fontMetrics; text: "B"; visible: false}
|
||||
|
||||
FontLoader{
|
||||
property int pixelSize
|
||||
property real lineSpacing
|
||||
property size paintedSize
|
||||
property size virtualCharSize
|
||||
id: currentfont
|
||||
}
|
||||
|
||||
property var fontlist: fontManager.item.fontlist
|
||||
property var fontScalingList: fontManager.item.fontScalingList
|
||||
property alias font: currentfont
|
||||
|
||||
property var fontIndexes: [0,1,1]
|
||||
property var fontIndexes: [1,1,1]
|
||||
property var fontScalingIndexes: [5,1,1]
|
||||
|
||||
function handleFontChanged(){
|
||||
if(!fontManager.item) return;
|
||||
fontManager.item.selectedFontIndex = fontIndexes[rasterization];
|
||||
fontManager.item.selectedScalingIndex = fontScalingIndexes[rasterization];
|
||||
currentfont.source = fontManager.item.source;
|
||||
currentfont.pixelSize = fontManager.item.pixelSize;
|
||||
currentfont.lineSpacing = fontManager.item.lineSpacing;
|
||||
fontMetrics.font = currentfont.name;
|
||||
fontMetrics.font.pixelSize = currentfont.pixelSize;
|
||||
currentfont.paintedSize = Qt.size(fontMetrics.paintedWidth, fontMetrics.paintedHeight)
|
||||
currentfont.virtualCharSize = fontManager.item.virtualCharSize !== undefined ?
|
||||
fontManager.item.virtualCharSize :
|
||||
Qt.size(currentfont.paintedSize.width * 0.5,
|
||||
currentfont.paintedSize.height * 0.5);
|
||||
terminalFontChanged();
|
||||
|
||||
var fontSource = fontManager.item.source;
|
||||
var pixelSize = fontManager.item.pixelSize;
|
||||
var lineSpacing = fontManager.item.lineSpacing;
|
||||
var virtualCharSize = fontManager.item.virtualCharSize;
|
||||
|
||||
terminalFontChanged(fontSource, pixelSize, lineSpacing, virtualCharSize);
|
||||
}
|
||||
|
||||
property bool frame_reflections: true
|
||||
@ -134,13 +125,6 @@ Item{
|
||||
property alias profiles_list: profileslist
|
||||
property int profiles_index: 0
|
||||
|
||||
ListModel{
|
||||
id: framelist
|
||||
ListElement{text: "No frame"; source: "./frames/NoFrame.qml"; reflections: false}
|
||||
ListElement{text: "Simple white frame"; source: "./frames/WhiteSimpleFrame.qml"; reflections: true}
|
||||
ListElement{text: "Rough black frame"; source: "./frames/BlackRoughFrame.qml"; reflections: true}
|
||||
}
|
||||
|
||||
Storage{id: storage}
|
||||
|
||||
function composeSettingsString(){
|
||||
@ -151,7 +135,8 @@ Item{
|
||||
brightness: brightness,
|
||||
contrast: contrast,
|
||||
ambient_light: ambient_light,
|
||||
font_scaling_index: font_scaling_index,
|
||||
fontScalingIndexes: fontScalingIndexes,
|
||||
fontIndexes: fontIndexes
|
||||
}
|
||||
return JSON.stringify(settings);
|
||||
}
|
||||
@ -166,11 +151,11 @@ Item{
|
||||
screen_distortion: screen_distortion,
|
||||
glowing_line_strength: glowing_line_strength,
|
||||
frames_index: frames_index,
|
||||
font_index: font_index,
|
||||
motion_blur: motion_blur,
|
||||
bloom_strength: bloom_strength,
|
||||
rasterization: rasterization,
|
||||
jitter: jitter
|
||||
jitter: jitter,
|
||||
fontIndex: fontIndexes[rasterization]
|
||||
}
|
||||
return JSON.stringify(settings);
|
||||
}
|
||||
@ -211,7 +196,8 @@ Item{
|
||||
fps = settings.fps !== undefined ? settings.fps: fps
|
||||
window_scaling = settings.window_scaling ? settings.window_scaling : window_scaling
|
||||
|
||||
//font_scaling_index = settings.font_scaling_index !== undefined ? settings.font_scaling_index: font_scaling_index;
|
||||
fontIndexes = settings.fontIndexes ? settings.fontIndexes : fontIndexes
|
||||
fontScalingIndexes = settings.fontScalingIndexes ? settings.fontScalingIndexes : fontScalingIndexes
|
||||
}
|
||||
|
||||
function loadProfileString(profileString){
|
||||
@ -231,11 +217,11 @@ Item{
|
||||
|
||||
frames_index = settings.frames_index !== undefined ? settings.frames_index : frames_index;
|
||||
|
||||
//font_index = settings.font_index !== undefined ? settings.font_index : font_index;
|
||||
|
||||
rasterization = settings.rasterization !== undefined ? settings.rasterization : rasterization;
|
||||
|
||||
jitter = settings.jitter !== undefined ? settings.jitter : jitter
|
||||
jitter = settings.jitter !== undefined ? settings.jitter : jitter;
|
||||
|
||||
fontIndexes[rasterization] = settings.fontIndex ? settings.fontIndex : fontIndexes[rasterization];
|
||||
}
|
||||
|
||||
function storeCustomProfiles(){
|
||||
|
@ -56,8 +56,6 @@ Item{
|
||||
property size terminalSize: kterminal.terminalSize
|
||||
property size paintedTextSize
|
||||
|
||||
onPaintedTextSizeChanged: console.log(paintedTextSize)
|
||||
|
||||
//Force reload of the blursource when settings change
|
||||
onMBlurChanged: restartBlurredSource()
|
||||
|
||||
@ -76,8 +74,6 @@ Item{
|
||||
KTerminal {
|
||||
id: kterminal
|
||||
anchors.fill: parent
|
||||
font.pixelSize: shadersettings.font.pixelSize
|
||||
font.family: shadersettings.font.name
|
||||
|
||||
colorScheme: "MyWhiteOnBlack"
|
||||
|
||||
@ -90,33 +86,38 @@ Item{
|
||||
}
|
||||
}
|
||||
|
||||
function handleFontChange(){
|
||||
var newFont = shadersettings.font;
|
||||
var font_size = newFont.pixelSize * shadersettings.window_scaling;
|
||||
font.pixelSize = font_size;
|
||||
font.family = newFont.name;
|
||||
FontLoader{ id: fontLoader }
|
||||
Text{id: fontMetrics; text: "B"; visible: false}
|
||||
|
||||
var virtualCharSize = newFont.virtualCharSize;
|
||||
var virtualPxSize = Qt.size(newFont.paintedSize.width / virtualCharSize.width,
|
||||
newFont.paintedSize.height / virtualCharSize.height)
|
||||
function getPaintedSize(pixelSize){
|
||||
fontMetrics.font.family = fontLoader.name;
|
||||
fontMetrics.font.pixelSize = pixelSize;
|
||||
return Qt.size(fontMetrics.paintedWidth, fontMetrics.paintedHeight);
|
||||
}
|
||||
function isValid(size){
|
||||
return size.width >= 0 && size.height >= 0;
|
||||
}
|
||||
|
||||
var scanline_spacing = shadersettings.font.lineSpacing;
|
||||
var line_spacing = Math.round(scanline_spacing);
|
||||
function handleFontChange(fontSource, pixelSize, lineSpacing, virtualCharSize){
|
||||
fontLoader.source = fontSource;
|
||||
font.pixelSize = pixelSize * shadersettings.window_scaling;
|
||||
font.family = fontLoader.name;
|
||||
|
||||
console.log(kterminal.paintedFontSize)
|
||||
var paintedSize = getPaintedSize(pixelSize);
|
||||
var charSize = isValid(virtualCharSize)
|
||||
? virtualCharSize
|
||||
: Qt.size(paintedSize.width / 2, paintedSize.height / 2);
|
||||
|
||||
// console.log("Font height: " + fontMetrics.paintedHeight)
|
||||
// console.log("Scanline Height: " + scanline_height)
|
||||
// console.log("Line Spacing: " + line_spacing)
|
||||
var virtualPxSize = Qt.size(paintedSize.width / charSize.width,
|
||||
paintedSize.height / charSize.height)
|
||||
|
||||
terminalContainer.virtualPxSize = virtualPxSize;
|
||||
|
||||
setLineSpacing(newFont.lineSpacing);
|
||||
setLineSpacing(lineSpacing);
|
||||
restartBlurredSource();
|
||||
}
|
||||
Component.onCompleted: {
|
||||
shadersettings.terminalFontChanged.connect(handleFontChange);
|
||||
handleFontChange();
|
||||
forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 3.0.1, 2014-06-24T10:46:32. -->
|
||||
<!-- Written by QtCreator 3.0.1, 2014-06-25T13:18:19. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
|
@ -159,4 +159,5 @@ ApplicationWindow{
|
||||
terminalSize: terminal.terminalSize
|
||||
}
|
||||
}
|
||||
Component.onCompleted: shadersettings.handleFontChanged();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user