mirror of
				https://github.com/Swordfish90/cool-retro-term.git
				synced 2025-10-31 15:12:28 +00:00 
			
		
		
		
	
							
								
								
									
										10
									
								
								app/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								app/main.cpp
									
									
									
									
									
								
							| @@ -24,7 +24,16 @@ QString getNamedArgument(QStringList args, QString name) | |||||||
|  |  | ||||||
| int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||||||
| { | { | ||||||
|  |     // Some environmental variable are necessary on certain platforms. | ||||||
|  |  | ||||||
|  |     // This disables QT appmenu under Ubuntu, which is not working with QML apps. | ||||||
|     setenv("QT_QPA_PLATFORMTHEME", "", 1); |     setenv("QT_QPA_PLATFORMTHEME", "", 1); | ||||||
|  |  | ||||||
|  | #if defined(Q_OS_MAC) | ||||||
|  |     // This allows UTF-8 characters usage in OSX. | ||||||
|  |     setenv("LC_CTYPE", "UTF-8", 1); | ||||||
|  | #endif | ||||||
|  |  | ||||||
|     QApplication app(argc, argv); |     QApplication app(argc, argv); | ||||||
|     QQmlApplicationEngine engine; |     QQmlApplicationEngine engine; | ||||||
|     FileIO fileIO; |     FileIO fileIO; | ||||||
| @@ -60,6 +69,7 @@ int main(int argc, char *argv[]) | |||||||
|     QStringList importPathList = engine.importPathList(); |     QStringList importPathList = engine.importPathList(); | ||||||
|     importPathList.prepend(QCoreApplication::applicationDirPath() + "/qmltermwidget"); |     importPathList.prepend(QCoreApplication::applicationDirPath() + "/qmltermwidget"); | ||||||
|     importPathList.prepend(QCoreApplication::applicationDirPath() + "/../PlugIns"); |     importPathList.prepend(QCoreApplication::applicationDirPath() + "/../PlugIns"); | ||||||
|  |     importPathList.prepend(QCoreApplication::applicationDirPath() + "/../../../qmltermwidget"); | ||||||
|     engine.setImportPathList(importPathList); |     engine.setImportPathList(importPathList); | ||||||
|  |  | ||||||
|     engine.load(QUrl("qrc:/main.qml")); |     engine.load(QUrl("qrc:/main.qml")); | ||||||
|   | |||||||
| @@ -81,6 +81,8 @@ QtObject{ | |||||||
|     property real fontScaling: 1.0 |     property real fontScaling: 1.0 | ||||||
|     property real fontWidth: 1.0 |     property real fontWidth: 1.0 | ||||||
|  |  | ||||||
|  |     property bool lowResolutionFont: false | ||||||
|  |  | ||||||
|     property var fontNames: ["HERMIT", "COMMODORE_PET", "COMMODORE_PET"] |     property var fontNames: ["HERMIT", "COMMODORE_PET", "COMMODORE_PET"] | ||||||
|     property var fontlist: fontManager.item.fontlist |     property var fontlist: fontManager.item.fontlist | ||||||
|  |  | ||||||
| @@ -135,6 +137,8 @@ QtObject{ | |||||||
|         var screenScaling = fontManager.item.screenScaling; |         var screenScaling = fontManager.item.screenScaling; | ||||||
|         var fontWidth = fontManager.item.defaultFontWidth * appSettings.fontWidth; |         var fontWidth = fontManager.item.defaultFontWidth * appSettings.fontWidth; | ||||||
|  |  | ||||||
|  |         lowResolutionFont = fontManager.item.lowResolutionFont; | ||||||
|  |  | ||||||
|         terminalFontChanged(fontSource, pixelSize, lineSpacing, screenScaling, fontWidth); |         terminalFontChanged(fontSource, pixelSize, lineSpacing, screenScaling, fontWidth); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -367,12 +371,12 @@ QtObject{ | |||||||
|     property ListModel profilesList: ListModel{ |     property ListModel profilesList: ListModel{ | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Default Amber" |             text: "Default Amber" | ||||||
|             obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.65,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"HERMIT","fontColor":"#ff8100","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.16,"jitter":0.18,"burnIn":0.4,"staticNoise":0.1,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' |             obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.65,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"TERMINUS_SCALED","fontColor":"#ff8100","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.16,"jitter":0.18,"burnIn":0.4,"staticNoise":0.1,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' | ||||||
|             builtin: true |             builtin: true | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Default Green" |             text: "Default Green" | ||||||
|             obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.4,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"HERMIT","fontColor":"#0ccc68","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.16,"jitter":0.18,"burnIn":0.45,"staticNoise":0.1,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' |             obj_string: '{"ambientLight":0.16,"backgroundColor":"#000000","bloom":0.4,"brightness":0.5,"flickering":0.1,"contrast":0.85,"fontName":"TERMINUS_SCALED","fontColor":"#0ccc68","frameName":"SIMPLE_WHITE_FRAME","glowingLine":0.2,"horizontalSync":0.16,"jitter":0.18,"burnIn":0.45,"staticNoise":0.1,"rasterization":0,"screenCurvature":0.1,"windowOpacity":1,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' | ||||||
|             builtin: true |             builtin: true | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
| @@ -407,7 +411,7 @@ QtObject{ | |||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             text: "Transparent Green" |             text: "Transparent Green" | ||||||
|             obj_string: '{"ambientLight":0.2,"backgroundColor":"#000000","bloom":0.45,"brightness":0.5,"flickering":0.20,"contrast":0.85,"fontName":"HERMIT","fontColor":"#0ccc68","frameName":"NO_FRAME","glowingLine":0.16,"horizontalSync":0.1,"jitter":0.20,"burnIn":0.25,"staticNoise":0.20,"rasterization":0,"screenCurvature":0.05,"windowOpacity":0.60,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' |             obj_string: '{"ambientLight":0.2,"backgroundColor":"#000000","bloom":0.45,"brightness":0.5,"flickering":0.20,"contrast":0.85,"fontName":"TERMINUS_SCALED","fontColor":"#0ccc68","frameName":"NO_FRAME","glowingLine":0.16,"horizontalSync":0.1,"jitter":0.20,"burnIn":0.25,"staticNoise":0.20,"rasterization":0,"screenCurvature":0.05,"windowOpacity":0.60,"chromaColor":0,"saturationColor":0,"rbgShift":0,"fontWidth":1.0}' | ||||||
|             builtin: true |             builtin: true | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -22,8 +22,10 @@ import QtQuick 2.2 | |||||||
| import QtQuick.Dialogs 1.1 | import QtQuick.Dialogs 1.1 | ||||||
|  |  | ||||||
| Item { | Item { | ||||||
|  |     id: rootItem | ||||||
|  |  | ||||||
|     signal colorSelected (color color) |     signal colorSelected (color color) | ||||||
|     property color button_color |     property color color | ||||||
|     property string name |     property string name | ||||||
|  |  | ||||||
|     ColorDialog { |     ColorDialog { | ||||||
| @@ -33,13 +35,13 @@ Item { | |||||||
|         visible: false |         visible: false | ||||||
|  |  | ||||||
|         //This is a workaround to a Qt 5.2 bug. |         //This is a workaround to a Qt 5.2 bug. | ||||||
|         onCurrentColorChanged: colorDialog.color = colorDialog.currentColor; |         onColorChanged: if (Qt.platform.os !== "osx") colorSelected(color) | ||||||
|         onAccepted: colorSelected(color) |         onAccepted: if (Qt.platform.os === "osx") colorSelected(color) | ||||||
|     } |     } | ||||||
|     Rectangle{ |     Rectangle{ | ||||||
|         anchors.fill: parent |         anchors.fill: parent | ||||||
|         radius: 10 |         radius: 10 | ||||||
|         color: button_color |         color: rootItem.color | ||||||
|         border.color: "black" |         border.color: "black" | ||||||
|         Glossy {} |         Glossy {} | ||||||
|         Rectangle { |         Rectangle { | ||||||
| @@ -52,7 +54,7 @@ Item { | |||||||
|         Text{ |         Text{ | ||||||
|             anchors.centerIn: parent |             anchors.centerIn: parent | ||||||
|             z: parent.z + 1 |             z: parent.z + 1 | ||||||
|             text: name + ":  " + button_color |             text: name + ":  " + rootItem.color | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     MouseArea{ |     MouseArea{ | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ QtObject{ | |||||||
|     property int lineSpacing: _font.lineSpacing |     property int lineSpacing: _font.lineSpacing | ||||||
|     property real screenScaling: scaling * _font.baseScaling |     property real screenScaling: scaling * _font.baseScaling | ||||||
|     property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth |     property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth | ||||||
|  |     property bool lowResolutionFont: true | ||||||
|  |  | ||||||
|     property ListModel fontlist: ListModel{ |     property ListModel fontlist: ListModel{ | ||||||
|         ListElement{ |         ListElement{ | ||||||
| @@ -49,6 +50,24 @@ QtObject{ | |||||||
|             baseScaling: 4.0 |             baseScaling: 4.0 | ||||||
|             fontWidth: 0.9 |             fontWidth: 0.9 | ||||||
|         } |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "TERMINUS_SCALED" | ||||||
|  |             text: "Terminus (Modern)" | ||||||
|  |             source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf" | ||||||
|  |             lineSpacing: 1 | ||||||
|  |             pixelSize: 12 | ||||||
|  |             baseScaling: 3.0 | ||||||
|  |             fontWidth: 1.0 | ||||||
|  |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "PRO_FONT_SCALED" | ||||||
|  |             text: "Pro Font (Modern)" | ||||||
|  |             source: "fonts/modern-pro-font-win-tweaked/ProFontWindows.ttf" | ||||||
|  |             lineSpacing: 1 | ||||||
|  |             pixelSize: 12 | ||||||
|  |             baseScaling: 3.0 | ||||||
|  |             fontWidth: 1.0 | ||||||
|  |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "APPLE_II" |             name: "APPLE_II" | ||||||
|             text: "Apple ][ (1977)" |             text: "Apple ][ (1977)" | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ QtObject{ | |||||||
|     property int lineSpacing: _font.lineSpacing |     property int lineSpacing: _font.lineSpacing | ||||||
|     property real screenScaling: scaling * _font.baseScaling |     property real screenScaling: scaling * _font.baseScaling | ||||||
|     property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth |     property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth | ||||||
|  |     property bool lowResolutionFont: true | ||||||
|  |  | ||||||
|     property ListModel fontlist: ListModel{ |     property ListModel fontlist: ListModel{ | ||||||
|         ListElement{ |         ListElement{ | ||||||
| @@ -49,6 +50,24 @@ QtObject{ | |||||||
|             baseScaling: 4.0 |             baseScaling: 4.0 | ||||||
|             fontWidth: 0.9 |             fontWidth: 0.9 | ||||||
|         } |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "TERMINUS_SCALED" | ||||||
|  |             text: "Terminus (Modern)" | ||||||
|  |             source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf" | ||||||
|  |             lineSpacing: 1 | ||||||
|  |             pixelSize: 12 | ||||||
|  |             baseScaling: 3.0 | ||||||
|  |             fontWidth: 1.0 | ||||||
|  |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "PRO_FONT_SCALED" | ||||||
|  |             text: "Pro Font (Modern)" | ||||||
|  |             source: "fonts/modern-pro-font-win-tweaked/ProFontWindows.ttf" | ||||||
|  |             lineSpacing: 1 | ||||||
|  |             pixelSize: 12 | ||||||
|  |             baseScaling: 3.0 | ||||||
|  |             fontWidth: 1.0 | ||||||
|  |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "APPLE_II" |             name: "APPLE_II" | ||||||
|             text: "Apple ][ (1977)" |             text: "Apple ][ (1977)" | ||||||
|   | |||||||
| @@ -25,117 +25,183 @@ QtObject{ | |||||||
|     property real scaling |     property real scaling | ||||||
|     property var source: fontlist.get(selectedFontIndex).source |     property var source: fontlist.get(selectedFontIndex).source | ||||||
|     property var _font: fontlist.get(selectedFontIndex) |     property var _font: fontlist.get(selectedFontIndex) | ||||||
|     property int pixelSize: _font.pixelSize * scaling |     property bool lowResolutionFont: _font.lowResolutionFont | ||||||
|     property int lineSpacing: pixelSize * _font.lineSpacing |  | ||||||
|     property real screenScaling: 1.0 |     property int pixelSize: lowResolutionFont | ||||||
|  |                                  ? _font.pixelSize | ||||||
|  |                                  : _font.pixelSize * scaling | ||||||
|  |  | ||||||
|  |     property int lineSpacing: lowResolutionFont | ||||||
|  |                                   ? _font.lineSpacing | ||||||
|  |                                   : pixelSize * _font.lineSpacing | ||||||
|  |  | ||||||
|  |     property real screenScaling: lowResolutionFont | ||||||
|  |                                      ? _font.baseScaling * scaling | ||||||
|  |                                      : 1.0 | ||||||
|  |  | ||||||
|     property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth |     property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth | ||||||
|  |  | ||||||
|     //In this configuration lineSpacing is proportional to pixelSize. |     // There are two kind of fonts: low resolution and high resolution. | ||||||
|  |     // Low resolution font sets the lowResolutionFont property to true. | ||||||
|  |     // They are rendered at a fixed pixel size and the texture is upscaled | ||||||
|  |     // to fill the screen (they are much faster to render). | ||||||
|  |     // High resolution fonts are instead drawn on a texture which has the | ||||||
|  |     // size of the screen, and the scaling directly controls their pixels size. | ||||||
|  |     // Those are slower to render but are not pixelated. | ||||||
|  |  | ||||||
|     property ListModel fontlist: ListModel{ |     property ListModel fontlist: ListModel{ | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "HERMIT" |             name: "TERMINUS_SCALED" | ||||||
|             text: "Hermit (Modern)" |  | ||||||
|             source: "fonts/modern-hermit/Hermit-medium.otf" |  | ||||||
|             lineSpacing: 0.05 |  | ||||||
|             pixelSize: 28 |  | ||||||
|             fontWidth: 1.0 |  | ||||||
|         } |  | ||||||
|         ListElement{ |  | ||||||
|             name: "TERMINUS" |  | ||||||
|             text: "Terminus (Modern)" |             text: "Terminus (Modern)" | ||||||
|             source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf" |             source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf" | ||||||
|             lineSpacing: 0.1 |             lineSpacing: 1 | ||||||
|             pixelSize: 35 |             pixelSize: 12 | ||||||
|  |             baseScaling: 3.0 | ||||||
|             fontWidth: 1.0 |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: true | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "ENVY_CODE_R" |             name: "PRO_FONT_SCALED" | ||||||
|             text: "Envy Code R (Modern)" |  | ||||||
|             source: "fonts/modern-envy-code-r/Envy Code R.ttf" |  | ||||||
|             lineSpacing: 0.1 |  | ||||||
|             pixelSize: 30 |  | ||||||
|             fontWidth: 1.0 |  | ||||||
|         } |  | ||||||
|         ListElement{ |  | ||||||
|             name: "PRO_FONT" |  | ||||||
|             text: "Pro Font (Modern)" |             text: "Pro Font (Modern)" | ||||||
|             source: "fonts/modern-pro-font-win-tweaked/ProFontWindows.ttf" |             source: "fonts/modern-pro-font-win-tweaked/ProFontWindows.ttf" | ||||||
|             lineSpacing: 0.1 |             lineSpacing: 1 | ||||||
|             pixelSize: 35 |             pixelSize: 12 | ||||||
|  |             baseScaling: 3.0 | ||||||
|             fontWidth: 1.0 |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: true | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "MONACO" |             name: "COMMODORE_PET_SCALED" | ||||||
|             text: "Monaco (Modern)" |  | ||||||
|             source: "fonts/modern-monaco/monaco.ttf" |  | ||||||
|             lineSpacing: 0.1 |  | ||||||
|             pixelSize: 30 |  | ||||||
|             fontWidth: 1.0 |  | ||||||
|         } |  | ||||||
|         ListElement{ |  | ||||||
|             name: "INCONSOLATA" |  | ||||||
|             text: "Inconsolata (Modern)" |  | ||||||
|             source: "fonts/modern-inconsolata/Inconsolata.otf" |  | ||||||
|             lineSpacing: 0.1 |  | ||||||
|             pixelSize: 35 |  | ||||||
|             fontWidth: 1.0 |  | ||||||
|         } |  | ||||||
|         ListElement{ |  | ||||||
|             name: "COMMODORE_PET" |  | ||||||
|             text: "Commodore PET (1977)" |             text: "Commodore PET (1977)" | ||||||
|             source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" |             source: "fonts/1977-commodore-pet/COMMODORE_PET.ttf" | ||||||
|             lineSpacing: 0.2 |             lineSpacing: 2 | ||||||
|             pixelSize: 26 |             pixelSize: 8 | ||||||
|  |             baseScaling: 3.5 | ||||||
|             fontWidth: 0.7 |             fontWidth: 0.7 | ||||||
|  |             lowResolutionFont: true | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "APPLE_II" |             name: "PROGGY_TINY_SCALED" | ||||||
|  |             text: "Proggy Tiny (Modern)" | ||||||
|  |             source: "fonts/modern-proggy-tiny/ProggyTiny.ttf" | ||||||
|  |             lineSpacing: 1 | ||||||
|  |             pixelSize: 16 | ||||||
|  |             baseScaling: 3.0 | ||||||
|  |             fontWidth: 0.9 | ||||||
|  |             lowResolutionFont: true | ||||||
|  |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "APPLE_II_SCALED" | ||||||
|             text: "Apple ][ (1977)" |             text: "Apple ][ (1977)" | ||||||
|             source: "fonts/1977-apple2/PrintChar21.ttf" |             source: "fonts/1977-apple2/PrintChar21.ttf" | ||||||
|             lineSpacing: 0.2 |             lineSpacing: 2 | ||||||
|             pixelSize: 26 |             pixelSize: 8 | ||||||
|  |             baseScaling: 3.5 | ||||||
|             fontWidth: 0.8 |             fontWidth: 0.8 | ||||||
|  |             lowResolutionFont: true | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "ATARI_400" |             name: "ATARI_400_SCALED" | ||||||
|             text: "Atari 400-800 (1979)" |             text: "Atari 400-800 (1979)" | ||||||
|             source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" |             source: "fonts/1979-atari-400-800/ATARI400800_original.TTF" | ||||||
|             lineSpacing: 0.3 |             lineSpacing: 3 | ||||||
|             pixelSize: 26 |             pixelSize: 8 | ||||||
|  |             baseScaling: 3.5 | ||||||
|             fontWidth: 0.7 |             fontWidth: 0.7 | ||||||
|  |             lowResolutionFont: true | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "COMMODORE_64" |             name: "COMMODORE_64_SCALED" | ||||||
|             text: "Commodore 64 (1982)" |             text: "Commodore 64 (1982)" | ||||||
|             source: "fonts/1982-commodore64/C64_Pro_Mono_v1.0-STYLE.ttf" |             source: "fonts/1982-commodore64/C64_Pro_Mono_v1.0-STYLE.ttf" | ||||||
|             lineSpacing: 0.3 |             lineSpacing: 3 | ||||||
|             pixelSize: 26 |             pixelSize: 8 | ||||||
|  |             baseScaling: 3.5 | ||||||
|             fontWidth: 0.7 |             fontWidth: 0.7 | ||||||
|  |             lowResolutionFont: true | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "ATARI_ST" |             name: "ATARI_ST_SCALED" | ||||||
|             text: "Atari ST (1985)" |             text: "Atari ST (1985)" | ||||||
|             source: "fonts/1985-atari-st/AtariST8x16SystemFont.ttf" |             source: "fonts/1985-atari-st/AtariST8x16SystemFont.ttf" | ||||||
|             lineSpacing: 0.2 |             lineSpacing: 3 | ||||||
|             pixelSize: 32 |             pixelSize: 16 | ||||||
|  |             baseScaling: 2.0 | ||||||
|             fontWidth: 1.0 |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: true | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "IBM_DOS" |             name: "IBM_DOS" | ||||||
|             text: "IBM DOS (1985)" |             text: "IBM DOS (1985)" | ||||||
|             source: "fonts/1985-ibm-pc-vga/Perfect DOS VGA 437 Win.ttf" |             source: "fonts/1985-ibm-pc-vga/Perfect DOS VGA 437 Win.ttf" | ||||||
|             lineSpacing: 0.2 |             lineSpacing: 3 | ||||||
|             pixelSize: 32 |             pixelSize: 16 | ||||||
|  |             baseScaling: 2.0 | ||||||
|             fontWidth: 1.0 |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: true | ||||||
|  |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "HERMIT" | ||||||
|  |             text: "HD: Hermit (Modern)" | ||||||
|  |             source: "fonts/modern-hermit/Hermit-medium.otf" | ||||||
|  |             lineSpacing: 0.05 | ||||||
|  |             pixelSize: 28 | ||||||
|  |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: false | ||||||
|  |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "TERMINUS" | ||||||
|  |             text: "HD: Terminus (Modern)" | ||||||
|  |             source: "fonts/modern-terminus/TerminusTTF-4.38.2.ttf" | ||||||
|  |             lineSpacing: 0.1 | ||||||
|  |             pixelSize: 35 | ||||||
|  |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: false | ||||||
|  |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "PRO_FONT" | ||||||
|  |             text: "HD: Pro Font (Modern)" | ||||||
|  |             source: "fonts/modern-pro-font-win-tweaked/ProFontWindows.ttf" | ||||||
|  |             lineSpacing: 0.1 | ||||||
|  |             pixelSize: 35 | ||||||
|  |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: false | ||||||
|  |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "ENVY_CODE_R" | ||||||
|  |             text: "HD: Envy Code R (Modern)" | ||||||
|  |             source: "fonts/modern-envy-code-r/Envy Code R.ttf" | ||||||
|  |             lineSpacing: 0.1 | ||||||
|  |             pixelSize: 30 | ||||||
|  |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: false | ||||||
|  |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "MONACO" | ||||||
|  |             text: "HD: Monaco (Modern)" | ||||||
|  |             source: "fonts/modern-monaco/monaco.ttf" | ||||||
|  |             lineSpacing: 0.1 | ||||||
|  |             pixelSize: 30 | ||||||
|  |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: false | ||||||
|  |         } | ||||||
|  |         ListElement{ | ||||||
|  |             name: "INCONSOLATA" | ||||||
|  |             text: "HD: Inconsolata (Modern)" | ||||||
|  |             source: "fonts/modern-inconsolata/Inconsolata.otf" | ||||||
|  |             lineSpacing: 0.1 | ||||||
|  |             pixelSize: 35 | ||||||
|  |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: false | ||||||
|         } |         } | ||||||
|         ListElement{ |         ListElement{ | ||||||
|             name: "IBM_3278" |             name: "IBM_3278" | ||||||
|             text: "IBM 3278 (1971)" |             text: "HD: IBM 3278 (1971)" | ||||||
|             source: "fonts/1971-ibm-3278/3270Medium.ttf" |             source: "fonts/1971-ibm-3278/3270Medium.ttf" | ||||||
|             lineSpacing: 0.2 |             lineSpacing: 0.2 | ||||||
|             pixelSize: 32 |             pixelSize: 32 | ||||||
|             fontWidth: 1.0 |             fontWidth: 1.0 | ||||||
|  |             lowResolutionFont: false | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -23,6 +23,8 @@ import QtQuick.Controls 1.1 | |||||||
|  |  | ||||||
| import QMLTermWidget 1.0 | import QMLTermWidget 1.0 | ||||||
|  |  | ||||||
|  | import "utils.js" as Utils | ||||||
|  |  | ||||||
| Item{ | Item{ | ||||||
|     id: terminalContainer |     id: terminalContainer | ||||||
|  |  | ||||||
| @@ -43,10 +45,10 @@ Item{ | |||||||
|     anchors.bottomMargin: frame.displacementBottom * appSettings.windowScaling |     anchors.bottomMargin: frame.displacementBottom * appSettings.windowScaling | ||||||
|  |  | ||||||
|     //The blur effect has to take into account the framerate |     //The blur effect has to take into account the framerate | ||||||
|     property real mBlur: appSettings.burnIn |     property real mBlur: Math.sqrt(appSettings.burnIn) | ||||||
|     property real motionBlurCoefficient: (_maxBlurCoefficient * Math.sqrt(mBlur) + _minBlurCoefficient * (1 - Math.sqrt(mBlur))) |     property real motionBlurCoefficient: Utils.lint(_minBlurCoefficient, _maxBlurCoefficient, mBlur) | ||||||
|     property real _minBlurCoefficient: 0.50 |     property real _minBlurCoefficient: 0.2 | ||||||
|     property real _maxBlurCoefficient: 0.90 |     property real _maxBlurCoefficient: 0.02 | ||||||
|  |  | ||||||
|     property size terminalSize: kterminal.terminalSize |     property size terminalSize: kterminal.terminalSize | ||||||
|     property size fontMetrics: kterminal.fontMetrics |     property size fontMetrics: kterminal.fontMetrics | ||||||
| @@ -83,7 +85,7 @@ Item{ | |||||||
|  |  | ||||||
|         colorScheme: "cool-retro-term" |         colorScheme: "cool-retro-term" | ||||||
|  |  | ||||||
|         smooth: appSettings.rasterization === appSettings.no_rasterization |         smooth: !appSettings.lowResolutionFont | ||||||
|         enableBold: false |         enableBold: false | ||||||
|         fullCursorHeight: true |         fullCursorHeight: true | ||||||
|  |  | ||||||
| @@ -115,13 +117,13 @@ Item{ | |||||||
|         function handleFontChange(fontSource, pixelSize, lineSpacing, screenScaling, fontWidth){ |         function handleFontChange(fontSource, pixelSize, lineSpacing, screenScaling, fontWidth){ | ||||||
|             fontLoader.source = fontSource; |             fontLoader.source = fontSource; | ||||||
|  |  | ||||||
|             kterminal.antialiasText = appSettings.rasterization === appSettings.no_rasterization |             kterminal.antialiasText = !appSettings.lowResolutionFont; | ||||||
|             font.pixelSize = pixelSize; |             font.pixelSize = pixelSize; | ||||||
|             font.family = fontLoader.name; |             font.family = fontLoader.name; | ||||||
|  |  | ||||||
|             terminalContainer.fontWidth = fontWidth; |             terminalContainer.fontWidth = fontWidth; | ||||||
|             terminalContainer.screenScaling= screenScaling; |             terminalContainer.screenScaling = screenScaling; | ||||||
|             scaleTexture = Math.max(1.0, Math.round(screenScaling / 2)); |             scaleTexture = Math.max(1.0, Math.floor(screenScaling * appSettings.windowScaling)); | ||||||
|  |  | ||||||
|             kterminal.lineSpacing = lineSpacing; |             kterminal.lineSpacing = lineSpacing; | ||||||
|         } |         } | ||||||
| @@ -174,6 +176,7 @@ Item{ | |||||||
|     MouseArea{ |     MouseArea{ | ||||||
|         acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton |         acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton | ||||||
|         anchors.fill: parent |         anchors.fill: parent | ||||||
|  |         cursorShape: Qt.IBeamCursor | ||||||
|         onWheel:{ |         onWheel:{ | ||||||
|             if(wheel.modifiers & Qt.ControlModifier){ |             if(wheel.modifiers & Qt.ControlModifier){ | ||||||
|                wheel.angleDelta.y > 0 ? zoomIn.trigger() : zoomOut.trigger(); |                wheel.angleDelta.y > 0 ? zoomIn.trigger() : zoomOut.trigger(); | ||||||
| @@ -243,6 +246,12 @@ Item{ | |||||||
|  |  | ||||||
|             Timer{ |             Timer{ | ||||||
|                 id: livetimer |                 id: livetimer | ||||||
|  |  | ||||||
|  |                 // The interval assumes 60 fps. This is the time needed burnout a white pixel. | ||||||
|  |                 // We multiply 1.1 to have a little bit of margin over the theoretical value. | ||||||
|  |                 // This solution is not extremely clean, but it's probably the best to avoid measuring fps. | ||||||
|  |  | ||||||
|  |                 interval: (1 / motionBlurCoefficient) * 60 * 1.1 | ||||||
|                 running: true |                 running: true | ||||||
|                 onTriggered: _blurredSourceEffect.live = false; |                 onTriggered: _blurredSourceEffect.live = false; | ||||||
|             } |             } | ||||||
| @@ -271,15 +280,22 @@ Item{ | |||||||
|     Loader{ |     Loader{ | ||||||
|         id: blurredTerminalLoader |         id: blurredTerminalLoader | ||||||
|  |  | ||||||
|         width: kterminal.width * scaleTexture * appSettings.burnInQuality |         property int burnInScaling: scaleTexture * appSettings.burnInQuality | ||||||
|         height: kterminal.height * scaleTexture * appSettings.burnInQuality |  | ||||||
|  |         width: appSettings.lowResolutionFont | ||||||
|  |                   ? kterminal.width * Math.max(1, burnInScaling) | ||||||
|  |                   : kterminal.width * scaleTexture * appSettings.burnInQuality | ||||||
|  |         height: appSettings.lowResolutionFont | ||||||
|  |                     ? kterminal.height * Math.max(1, burnInScaling) | ||||||
|  |                     : kterminal.height * scaleTexture * appSettings.burnInQuality | ||||||
|  |  | ||||||
|         active: mBlur !== 0 |         active: mBlur !== 0 | ||||||
|         asynchronous: true |         asynchronous: true | ||||||
|  |  | ||||||
|         sourceComponent: ShaderEffect { |         sourceComponent: ShaderEffect { | ||||||
|             property variant txt_source: kterminalSource |             property variant txt_source: kterminalSource | ||||||
|             property variant blurredSource: blurredSourceLoader.item |             property variant blurredSource: blurredSourceLoader.item | ||||||
|             property real blurCoefficient: (1.0 - motionBlurCoefficient) |             property real blurCoefficient: motionBlurCoefficient | ||||||
|  |  | ||||||
|             blending: false |             blending: false | ||||||
|  |  | ||||||
| @@ -299,10 +315,10 @@ Item{ | |||||||
|                 "void main() {" + |                 "void main() {" + | ||||||
|                     "vec2 coords = qt_TexCoord0;" + |                     "vec2 coords = qt_TexCoord0;" + | ||||||
|                     "vec3 origColor = texture2D(txt_source, coords).rgb;" + |                     "vec3 origColor = texture2D(txt_source, coords).rgb;" + | ||||||
|                     "vec3 blur_color = texture2D(blurredSource, coords).rgb * (1.0 - blurCoefficient);" + |                     "vec3 blur_color = texture2D(blurredSource, coords).rgb - vec3(blurCoefficient);" + | ||||||
|                     "vec3 color = min(origColor + blur_color, max(origColor, blur_color));" + |                     "vec3 color = min(origColor + blur_color, max(origColor, blur_color));" + | ||||||
|  |  | ||||||
|                     "gl_FragColor = vec4(color, step(0.02, rgb2grey(color - origColor)));" + |                     "gl_FragColor = vec4(color, rgb2grey(color - origColor));" + | ||||||
|                 "}" |                 "}" | ||||||
|  |  | ||||||
|             onStatusChanged: if (log) console.log(log) //Print warning messages |             onStatusChanged: if (log) console.log(log) //Print warning messages | ||||||
|   | |||||||
| @@ -55,10 +55,10 @@ Tab{ | |||||||
|                     Layout.fillWidth: true |                     Layout.fillWidth: true | ||||||
|                     id: txtslider |                     id: txtslider | ||||||
|                     onValueChanged: if (enabled) appSettings.windowScaling = value; |                     onValueChanged: if (enabled) appSettings.windowScaling = value; | ||||||
|                     stepSize: 0.10 |                     stepSize: 0.05 | ||||||
|                     enabled: false |                     enabled: false | ||||||
|                     Component.onCompleted: { |                     Component.onCompleted: { | ||||||
|                         minimumValue = 0.3 //Without this value gets set to 0.5 |                         minimumValue = 0.25 //Without this value gets set to 0.5 | ||||||
|                         value = appSettings.windowScaling; |                         value = appSettings.windowScaling; | ||||||
|                         enabled = true; |                         enabled = true; | ||||||
|                     } |                     } | ||||||
| @@ -80,10 +80,10 @@ Tab{ | |||||||
|                     Layout.fillWidth: true |                     Layout.fillWidth: true | ||||||
|                     id: bloomSlider |                     id: bloomSlider | ||||||
|                     onValueChanged: if (enabled) appSettings.bloomQuality = value; |                     onValueChanged: if (enabled) appSettings.bloomQuality = value; | ||||||
|                     stepSize: 0.10 |                     stepSize: 0.05 | ||||||
|                     enabled: false |                     enabled: false | ||||||
|                     Component.onCompleted: { |                     Component.onCompleted: { | ||||||
|                         minimumValue = 0.3 |                         minimumValue = 0.25 | ||||||
|                         value = appSettings.bloomQuality; |                         value = appSettings.bloomQuality; | ||||||
|                         enabled = true; |                         enabled = true; | ||||||
|                     } |                     } | ||||||
| @@ -105,10 +105,10 @@ Tab{ | |||||||
|                     Layout.fillWidth: true |                     Layout.fillWidth: true | ||||||
|                     id: burnInSlider |                     id: burnInSlider | ||||||
|                     onValueChanged: if (enabled) appSettings.burnInQuality = value; |                     onValueChanged: if (enabled) appSettings.burnInQuality = value; | ||||||
|                     stepSize: 0.10 |                     stepSize: 0.05 | ||||||
|                     enabled: false |                     enabled: false | ||||||
|                     Component.onCompleted: { |                     Component.onCompleted: { | ||||||
|                         minimumValue = 0.3 |                         minimumValue = 0.25 | ||||||
|                         value = appSettings.burnInQuality; |                         value = appSettings.burnInQuality; | ||||||
|                         enabled = true; |                         enabled = true; | ||||||
|                     } |                     } | ||||||
|   | |||||||
| @@ -125,14 +125,14 @@ Tab{ | |||||||
|                         height: 50 |                         height: 50 | ||||||
|                         Layout.fillWidth: true |                         Layout.fillWidth: true | ||||||
|                         onColorSelected: appSettings._fontColor = color; |                         onColorSelected: appSettings._fontColor = color; | ||||||
|                         button_color: appSettings._fontColor |                         color: appSettings._fontColor | ||||||
|                     } |                     } | ||||||
|                     ColorButton{ |                     ColorButton{ | ||||||
|                         name: qsTr("Background") |                         name: qsTr("Background") | ||||||
|                         height: 50 |                         height: 50 | ||||||
|                         Layout.fillWidth: true |                         Layout.fillWidth: true | ||||||
|                         onColorSelected: appSettings._backgroundColor = color; |                         onColorSelected: appSettings._backgroundColor = color; | ||||||
|                         button_color: appSettings._backgroundColor |                         color: appSettings._backgroundColor | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -26,6 +26,8 @@ ShaderEffect { | |||||||
|     property ShaderEffectSource blurredSource |     property ShaderEffectSource blurredSource | ||||||
|     property ShaderEffectSource bloomSource |     property ShaderEffectSource bloomSource | ||||||
|  |  | ||||||
|  |     property real liveBlur: blurredSource && blurredSource.live ? 1.0 : 0.0 | ||||||
|  |  | ||||||
|     property color fontColor: appSettings.fontColor |     property color fontColor: appSettings.fontColor | ||||||
|     property color backgroundColor: appSettings.backgroundColor |     property color backgroundColor: appSettings.backgroundColor | ||||||
|     property real bloom: appSettings.bloom * 2.5 |     property real bloom: appSettings.bloom * 2.5 | ||||||
| @@ -160,7 +162,8 @@ ShaderEffect { | |||||||
|             uniform highp sampler2D bloomSource; |             uniform highp sampler2D bloomSource; | ||||||
|             uniform lowp float bloom;" : "") + |             uniform lowp float bloom;" : "") + | ||||||
|         (burnIn !== 0 ? " |         (burnIn !== 0 ? " | ||||||
|             uniform sampler2D blurredSource;" : "") + |             uniform sampler2D blurredSource; | ||||||
|  |             uniform lowp float liveBlur;" : "") + | ||||||
|         (staticNoise !== 0 ? " |         (staticNoise !== 0 ? " | ||||||
|             uniform highp float staticNoise;" : "") + |             uniform highp float staticNoise;" : "") + | ||||||
|         (((staticNoise !== 0 || jitter !== 0 || rbgShift) |         (((staticNoise !== 0 || jitter !== 0 || rbgShift) | ||||||
| @@ -266,7 +269,7 @@ ShaderEffect { | |||||||
|             "vec3 txt_color = texture2D(source, txt_coords).rgb;" + |             "vec3 txt_color = texture2D(source, txt_coords).rgb;" + | ||||||
|  |  | ||||||
|             (burnIn !== 0 ? " |             (burnIn !== 0 ? " | ||||||
|                 vec4 txt_blur = texture2D(blurredSource, txt_coords); |                 vec4 txt_blur = liveBlur * texture2D(blurredSource, txt_coords); | ||||||
|                 txt_color = txt_color + txt_blur.rgb * txt_blur.a;" |                 txt_color = txt_color + txt_blur.rgb * txt_blur.a;" | ||||||
|             : "") + |             : "") + | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
| import QtQuick 2.2 | import QtQuick 2.2 | ||||||
| import QtGraphicalEffects 1.0 | import QtGraphicalEffects 1.0 | ||||||
|  |  | ||||||
|  | import "utils.js" as Utils | ||||||
|  |  | ||||||
| ShaderTerminal{ | ShaderTerminal{ | ||||||
|     property alias title: terminal.title |     property alias title: terminal.title | ||||||
|     property alias terminalSize: terminal.terminalSize |     property alias terminalSize: terminal.terminalSize | ||||||
| @@ -45,9 +47,10 @@ ShaderTerminal{ | |||||||
|         asynchronous: true |         asynchronous: true | ||||||
|         width: parent.width * appSettings.bloomQuality |         width: parent.width * appSettings.bloomQuality | ||||||
|         height: parent.height * appSettings.bloomQuality |         height: parent.height * appSettings.bloomQuality | ||||||
|  |  | ||||||
|         sourceComponent: FastBlur{ |         sourceComponent: FastBlur{ | ||||||
|             radius: 48 * appSettings.bloomQuality * appSettings.windowScaling |             radius: Utils.lint(16, 48, appSettings.bloomQuality * appSettings.windowScaling); | ||||||
|             source: terminal.mainTerminal |             source: terminal.mainSource | ||||||
|             transparentBorder: true |             transparentBorder: true | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -67,8 +70,8 @@ ShaderTerminal{ | |||||||
|     bloomSource: bloomSourceLoader.item |     bloomSource: bloomSourceLoader.item | ||||||
|  |  | ||||||
|     // This shader might be useful in the future. Since we used it only for a couple |     // This shader might be useful in the future. Since we used it only for a couple | ||||||
|     // of calculations is probably best to move those in the main shader. If in |     // of calculations is probably best to move those in the main shader. If in the future | ||||||
|     // we will need to store another fullScreen channel this might be handy. |     // we need to store another fullScreen channel this might be handy. | ||||||
|  |  | ||||||
| //    ShaderEffect { | //    ShaderEffect { | ||||||
| //        id: rasterizationEffect | //        id: rasterizationEffect | ||||||
|   | |||||||
| @@ -83,7 +83,7 @@ Item{ | |||||||
|         sourceComponent: FastBlur{ |         sourceComponent: FastBlur{ | ||||||
|             id: frameReflectionEffect |             id: frameReflectionEffect | ||||||
|             radius: 128 |             radius: 128 | ||||||
|             source: terminal.kterminal |             source: terminal.mainSource | ||||||
|             smooth: false |             smooth: false | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,5 +1,8 @@ | |||||||
| .pragma library | .pragma library | ||||||
|  |  | ||||||
|  | function lint(a, b, t) { | ||||||
|  |     return (1 - t) * a + (t) * b; | ||||||
|  | } | ||||||
| function mix(c1, c2, alpha){ | function mix(c1, c2, alpha){ | ||||||
|     return Qt.rgba(c1.r * alpha + c2.r * (1-alpha), |     return Qt.rgba(c1.r * alpha + c2.r * (1-alpha), | ||||||
|                    c1.g * alpha + c2.g * (1-alpha), |                    c1.g * alpha + c2.g * (1-alpha), | ||||||
|   | |||||||
 Submodule qmltermwidget updated: b03e96edb5...4b3fd2729b
									
								
							
		Reference in New Issue
	
	Block a user