UI/UX fixes for OSX version.

This commit is contained in:
Filippo Scognamiglio 2022-01-03 18:43:07 +01:00
parent cfe35d7795
commit 28977313da
13 changed files with 189 additions and 38 deletions

View File

@ -1,4 +1,4 @@
QT += qml quick widgets sql
QT += qml quick widgets sql quickcontrols2
TARGET = cool-retro-term
DESTDIR = $$OUT_PWD/../

View File

@ -6,6 +6,7 @@
#include <QtWidgets/QApplication>
#include <QIcon>
#include <QQuickStyle>
#include <QDebug>
#include <stdlib.h>
@ -40,6 +41,9 @@ int main(int argc, char *argv[])
#if defined(Q_OS_MAC)
// This allows UTF-8 characters usage in OSX.
setenv("LC_CTYPE", "UTF-8", 1);
// Force fusion style on macOS
QQuickStyle::setStyle("Fusion");
#endif
if (argc>1 && (!strcmp(argv[1],"-h") || !strcmp(argv[1],"--help"))) {
@ -65,9 +69,7 @@ int main(int argc, char *argv[])
}
QApplication app(argc, argv);
// set application attributes
// Has no effects, see https://bugreports.qt.io/browse/QTBUG-51293
// app.setAttribute(Qt::AA_MacDontSwapCtrlAndMeta, true);
app.setAttribute(Qt::AA_MacDontSwapCtrlAndMeta, true);
QQmlApplicationEngine engine;
FileIO fileIO;

View File

@ -34,6 +34,8 @@ QtObject {
readonly property real minBurnInFadeTime: 160
readonly property real maxBurnInFadeTime: 1600
property bool isMacOS: Qt.platform.os === "osx"
// GENERAL SETTINGS ///////////////////////////////////////////////////////
property int x: 100
property int y: 100
@ -41,7 +43,7 @@ QtObject {
property int height: 768
property bool fullscreen: false
property bool showMenubar: Qt.platform.os === "osx" ? true : false
property bool showMenubar: false
property string wintitle: "cool-retro-term"
@ -54,7 +56,7 @@ QtObject {
property real bloomQuality: 0.5
property real burnInQuality: 0.5
property bool useFastBurnIn: Qt.platform.os === "osx" ? false : true
property bool useFastBurnIn: true
property bool blinkingCursor: false

View File

@ -72,20 +72,38 @@ Loader {
Connections {
target: kterminal
onImagePainted: completelyUpdate()
function onImagePainted() {
completelyUpdate()
}
}
// Restart blurred source settings change.
Connections{
target: appSettings
onBurnInChanged: burnInEffect.restartBlurSource();
onTerminalFontChanged: burnInEffect.restartBlurSource();
onRasterizationChanged: burnInEffect.restartBlurSource();
onBurnInQualityChanged: burnInEffect.restartBlurSource();
function onBurnInChanged() {
burnInEffect.restartBlurSource()
}
function onTerminalFontChanged() {
burnInEffect.restartBlurSource()
}
function onRasterizationChanged() {
burnInEffect.restartBlurSource()
}
function onBurnInQualityChanged() {
burnInEffect.restartBlurSource()
}
}
Connections {
target: kterminalScrollbar
onOpacityChanged: completelyUpdate()
function onOpacityChanged() {
completelyUpdate()
}
}
}

View File

@ -34,10 +34,8 @@ Item {
visible: false
//This is a workaround to a Qt 5.2 bug.
onColorChanged: if (Qt.platform.os !== "osx")
colorSelected(color)
onAccepted: if (Qt.platform.os === "osx")
colorSelected(color)
onColorChanged: if (!appSettings.isMacOS) colorSelected(color)
onAccepted: if (appSettings.isMacOS) colorSelected(color)
}
Rectangle {
anchors.fill: parent

View File

@ -45,28 +45,54 @@ Item{
property size fontMetrics: kterminal.fontMetrics
// Manage copy and paste
Connections{
Connections {
target: copyAction
onTriggered: kterminal.copyClipboard();
function onTriggered() {
kterminal.copyClipboard()
}
}
Connections{
Connections {
target: pasteAction
onTriggered: kterminal.pasteClipboard()
function onTriggered() {
kterminal.pasteClipboard()
}
}
//When settings are updated sources need to be redrawn.
Connections{
Connections {
target: appSettings
onFontScalingChanged: terminalContainer.updateSources();
onFontWidthChanged: terminalContainer.updateSources();
function onFontScalingChanged() {
terminalContainer.updateSources()
}
function onFontWidthChanged() {
terminalContainer.updateSources()
}
}
Connections{
Connections {
target: terminalContainer
onWidthChanged: terminalContainer.updateSources();
onHeightChanged: terminalContainer.updateSources();
function onWidthChanged() {
terminalContainer.updateSources()
}
function onHeightChanged() {
terminalContainer.updateSources()
}
}
Connections {
target: terminalWindow
function onActiveChanged() {
kterminal.forceActiveFocus()
}
}
function updateSources() {
kterminal.update();
kterminal.update()
}
QMLTermWidget {
@ -143,7 +169,7 @@ Item{
var args = Utils.tokenizeCommandLine(appSettings.customCommand);
ksession.setShellProgram(args[0]);
ksession.setArgs(args.slice(1));
} else if (!defaultCmd && Qt.platform.os === "osx") {
} else if (!defaultCmd && appSettings.isMacOS) {
// OSX Requires the following default parameters for auto login.
ksession.setArgs(["-i", "-l"]);
}
@ -173,7 +199,7 @@ Item{
Loader {
id: menuLoader
sourceComponent: (Qt.platform.os === "osx" || appSettings.showMenubar ? shortContextMenu : fullContextMenu)
sourceComponent: (appSettings.isMacOS || appSettings.showMenubar ? shortContextMenu : fullContextMenu)
}
property alias contextmenu: menuLoader.item

View File

@ -215,10 +215,12 @@ ColumnLayout {
}
Label {
text: qsTr("Opacity")
visible: !appSettings.isMacOS
}
SimpleSlider {
onValueChanged: appSettings.windowOpacity = value
value: appSettings.windowOpacity
visible: !appSettings.isMacOS
}
}
}

View File

@ -68,7 +68,10 @@ ColumnLayout {
}
Connections {
target: appSettings
onTerminalFontChanged: fontChanger.updateIndex()
function onTerminalFontChanged() {
fontChanger.updateIndex()
}
}
Component.onCompleted: updateIndex()
}

View File

@ -34,7 +34,7 @@ Window {
TabBar {
id: bar
width: parent.width
anchors { left: parent.left; right: parent.right; top: parent.top }
TabButton {
text: qsTr("General")
}

View File

@ -53,20 +53,30 @@ ApplicationWindow {
property bool fullscreen: appSettings.fullscreen
onFullscreenChanged: visibility = (fullscreen ? Window.FullScreen : Window.Windowed)
menuBar: WindowMenu {
id: mainMenu
visible: (Qt.platform.os === "osx" || appSettings.showMenubar)
menuBar: qtquickMenuLoader.item
Loader {
id: qtquickMenuLoader
active: !appSettings.isMacOS && appSettings.showMenubar
sourceComponent: WindowMenu { }
}
Loader {
id: globalMenuLoader
active: appSettings.isMacOS
sourceComponent: OSXMenu { }
}
property string wintitle: appSettings.wintitle
color: "#00000000"
title: terminalContainer.title || qsTr(appSettings.wintitle)
Action {
id: showMenubarAction
text: qsTr("Show Menubar")
enabled: Qt.platform.os !== "osx"
enabled: !appSettings.isMacOS
shortcut: "Ctrl+Shift+M"
checkable: true
checked: appSettings.showMenubar
@ -75,7 +85,7 @@ ApplicationWindow {
Action {
id: fullscreenAction
text: qsTr("Fullscreen")
enabled: Qt.platform.os !== "osx"
enabled: !appSettings.isMacOS
shortcut: "Alt+F11"
onTriggered: appSettings.fullscreen = !appSettings.fullscreen
checkable: true
@ -154,7 +164,7 @@ ApplicationWindow {
onClosing: {
// OSX Since we are currently supporting only one window
// quit the application when it is closed.
if (Qt.platform.os === "osx")
if (appSettings.isMacOS)
Qt.quit()
}
}

89
app/qml/menus/OSXMenu.qml Normal file
View File

@ -0,0 +1,89 @@
/*******************************************************************************
* 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.3
import Qt.labs.platform 1.1
MenuBar {
id: defaultMenuBar
Menu {
title: qsTr("File")
MenuItem {
text: quitAction.text
onTriggered: quitAction.trigger()
}
}
Menu {
title: qsTr("Edit")
MenuItem {
text: copyAction.text
shortcut: "Meta+C"
onTriggered: copyAction.trigger()
}
MenuItem {
text: pasteAction.text
shortcut: "Meta+V"
onTriggered: pasteAction.trigger()
}
MenuSeparator {}
MenuItem {
text: showsettingsAction.text
shortcut: showsettingsAction.shortcut
onTriggered: showsettingsAction.trigger()
}
}
Menu {
title: qsTr("View")
MenuItem {
text: zoomIn.text
shortcut: "Meta++"
onTriggered: zoomIn.trigger()
}
MenuItem {
text: zoomOut.text
shortcut: "Meta+-"
onTriggered: zoomOut.trigger()
}
}
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 {
text: showAboutAction.text
onTriggered: showAboutAction.trigger()
}
}
}

View File

@ -46,5 +46,6 @@
<file>menus/FullContextMenu.qml</file>
<file>menus/ShortContextMenu.qml</file>
<file>ShaderLibrary.qml</file>
<file>menus/OSXMenu.qml</file>
</qresource>
</RCC>

@ -1 +1 @@
Subproject commit 5c47d1f49455394226e0e595f79c148f0c098006
Subproject commit 997bdaa832609afc480e1153d458eff9692705e2