Setting scaling stepSize to 0.05 instead of 0.1. Refactored scaling handling.

This commit is contained in:
Filippo Scognamiglio 2014-09-29 22:38:33 +02:00
parent 2ff6c71c23
commit e815fe2787
3 changed files with 28 additions and 39 deletions

View File

@ -119,30 +119,29 @@ Item{
onLoaded: handleFontChanged()
}
signal fontScalingChanged
property var fontScalingList: [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5]
property int fontScalingIndex: 5
property real fontScaling: 1.0
onFontScalingChanged: handleFontChanged();
property real fontWidth: 1.0
onFontWidthChanged: handleFontChanged();
function setScalingIndex(newScaling){
fontScalingIndex = newScaling;
fontScalingChanged();
function incrementScaling(){
fontScaling = Math.min(fontScaling + 0.05, 2.50);
handleFontChanged();
}
function getScalingIndex(){
return fontScalingIndex;
function decrementScaling(){
fontScaling = Math.max(fontScaling - 0.05, 0.50);
handleFontChanged();
}
property real fontWidth: 1.0
onFontWidthChanged: handleFontChanged();
property var fontIndexes: [0,0,0]
property var fontlist: fontManager.item.fontlist
function handleFontChanged(){
if(!fontManager.item) return;
fontManager.item.selectedFontIndex = fontIndexes[rasterization];
fontManager.item.scaling = fontScalingList[fontScalingIndex];
fontManager.item.scaling = fontScaling;
var fontSource = fontManager.item.source;
var pixelSize = fontManager.item.pixelSize;
@ -170,7 +169,7 @@ Item{
fps: fps,
window_scaling: window_scaling,
show_terminal_size: show_terminal_size,
fontScalingIndex: fontScalingIndex,
fontScaling: fontScaling,
fontIndexes: fontIndexes,
frameReflections: _frameReflections,
showMenubar: showMenubar,
@ -239,7 +238,7 @@ Item{
window_scaling = settings.window_scaling !== undefined ? settings.window_scaling : window_scaling
fontIndexes = settings.fontIndexes !== undefined ? settings.fontIndexes : fontIndexes
fontScalingIndex = settings.fontScalingIndex !== undefined ? settings.fontScalingIndex : fontScalingIndex
fontScaling = settings.fontScaling !== undefined ? settings.fontScaling : fontScaling
_frameReflections = settings.frameReflections !== undefined ? settings.frameReflections : _frameReflections;

View File

@ -35,11 +35,8 @@ Tab{
model: [qsTr("Default"), qsTr("Scanlines"), qsTr("Pixels")]
currentIndex: shadersettings.rasterization
onCurrentIndexChanged: {
scalingChanger.enabled = false;
shadersettings.rasterization = currentIndex
fontChanger.updateIndex();
scalingChanger.updateIndex();
scalingChanger.enabled = true;
}
}
}
@ -67,24 +64,24 @@ Tab{
RowLayout{
Layout.fillWidth: true
Slider{
id: scalingChanger
Layout.fillWidth: true
minimumValue: 0
maximumValue: shadersettings.fontScalingList.length - 1
stepSize: 1
tickmarksEnabled: true
value: updateIndex()
onValueChanged: {
if(!enabled) return; //Ugly and hacky solution. Look for a better solution.
shadersettings.setScalingIndex(value);
id: fontScalingChanger
onValueChanged: if(enabled) shadersettings.fontScaling = value
stepSize: 0.05
enabled: false // Another trick to fix initial bad behavior.
Component.onCompleted: {
minimumValue = 0.5;
maximumValue = 2.5;
value = shadersettings.fontScaling;
enabled = true;
}
function updateIndex(){
value = shadersettings.getScalingIndex();
Connections{
target: shadersettings
onFontScalingChanged: fontScalingChanger.value = shadersettings.fontScaling;
}
Component.onCompleted: shadersettings.fontScalingChanged.connect(updateIndex);
}
Text{
text: shadersettings.fontScalingList[scalingChanger.value].toFixed(2)
text: Math.round(fontScalingChanger.value * 100) + "%"
}
}
Text{ text: qsTr("Font Width") }

View File

@ -85,20 +85,13 @@ ApplicationWindow{
id: zoomIn
text: qsTr("Zoom In")
shortcut: "Ctrl++"
onTriggered: {
var oldScaling = shadersettings.fontScalingIndex;
var maxScalingIndex = shadersettings.fontScalingList.length - 1;
shadersettings.setScalingIndex(Math.min(oldScaling + 1, maxScalingIndex));
}
onTriggered: shadersettings.incrementScaling();
}
Action{
id: zoomOut
text: qsTr("Zoom Out")
shortcut: "Ctrl+-"
onTriggered: {
var oldScaling = shadersettings.fontScalingIndex;
shadersettings.setScalingIndex(Math.max(oldScaling - 1, 0));
}
onTriggered: shadersettings.decrementScaling();
}
Action{
id: showAboutAction