Windows-specific improvments

This commit is contained in:
Alex Spataru 2021-11-14 19:52:41 -06:00
parent f3b8e6b409
commit 02ae0e0db1
9 changed files with 222 additions and 238 deletions

View File

@ -99,6 +99,7 @@ CONFIG += silent
# Unity build
#-----------------------------------------------------------------------------------------
CONFIG += unity_build
CONFIG(unity_build) {
CONFIG += ltcg # Enable linker optimization
DEFINES += UNITY_BUILD=1 # Enable unity build

View File

@ -51,6 +51,7 @@ Window {
property bool firstChange: true
property bool isMaximized: false
property bool isMinimized: false
property alias showIcon: _title.showIcon
property alias isFullscreen: _title.isFullscreen
readonly property int customFlags: Qt.Window |
Qt.CustomizeWindowHint |

View File

@ -42,6 +42,7 @@ Rectangle {
// Window controls
//
property Window window
property bool showIcon: false
property bool closeEnabled: true
property bool isFullscreen: false
property bool minimizeEnabled: true
@ -81,14 +82,11 @@ Rectangle {
// Calculations for Windows/Linux layout
else {
// Default spacer
margin = 10
// Add space for fullscreen button
if (fullscreenEnabled)
margin += 18
if (root.showIcon)
margin += 24
// Add extra spacer if icon is visible
if (margin > 10)
margin += 8
}
@ -305,16 +303,12 @@ Rectangle {
}
WindowButton {
width: 16
height: 16
rotation: 90
visible: root.showIcon
enabled: root.showIcon
textColor: root.textColor
visible: root.fullscreenEnabled
enabled: root.fullscreenEnabled
highlightColor: root.textColor
Layout.alignment: Qt.AlignVCenter
onClicked: root.toggleFullscreen()
highlightColor: Cpp_ThemeManager.highlight
name: root.isFullscreen ? "restore" : "fullscreen"
source: "qrc:/images/icon-window.svg"
}
Item {
@ -359,7 +353,6 @@ Rectangle {
window.close()
root.closed()
}
}
Item {

View File

@ -369,82 +369,10 @@ Item {
}
//
// RX/TX LEDs
// Vertical spacer
//
Item {
Layout.fillWidth: true
Layout.fillHeight: true
RowLayout {
spacing: app.spacing
anchors {
left: parent.left
right: parent.right
verticalCenter: parent.verticalCenter
}
Item {
Layout.fillWidth: true
}
Widgets.LED {
id: _rx
enabled: false
Layout.alignment: Qt.AlignVCenter
Connections {
target: Cpp_IO_Manager
function onRx() {
_rx.flash()
}
}
}
Label {
text: "RX"
font.bold: true
font.pixelSize: 18
font.family: app.monoFont
Layout.alignment: Qt.AlignVCenter
color: _rx.enabled ? Cpp_ThemeManager.ledEnabled : Cpp_ThemeManager.ledDisabled
}
Widgets.Icon {
width: 32
height: 32
source: "qrc:/icons/ethernet.svg"
Layout.alignment: Qt.AlignVCenter
color: Cpp_ThemeManager.ledDisabled
}
Label {
text: "TX"
font.bold: true
font.pixelSize: 18
font.family: app.monoFont
Layout.alignment: Qt.AlignVCenter
color: _tx.enabled ? Cpp_ThemeManager.ledEnabled : Cpp_ThemeManager.ledDisabled
}
Widgets.LED {
id: _tx
enabled: false
layoutDirection: Qt.RightToLeft
Layout.alignment: Qt.AlignVCenter
Connections {
target: Cpp_IO_Manager
function onTx() {
_tx.flash()
}
}
}
Item {
Layout.fillWidth: true
}
}
}
}
}

View File

@ -196,8 +196,8 @@ MenuBar {
DecentMenuItem {
sequence: "f11"
onTriggered: app.mainWindow.toggleFullscreen()
text: app.mainWindow.fullScreen ? qsTr("Exit full screen") :
qsTr("Enter full screen")
text: app.mainWindow.isFullscreen ? qsTr("Exit full screen") :
qsTr("Enter full screen")
}
}

View File

@ -62,8 +62,8 @@ RowLayout {
//
Rectangle {
id: _dot
width: 18
height: 18
width: 14
height: 14
radius: width / 2
Layout.alignment: Qt.AlignVCenter
color: root.enabled ? Cpp_ThemeManager.ledEnabled : Cpp_ThemeManager.ledDisabled

View File

@ -45,6 +45,7 @@ FramelessWindow.CustomWindow {
//
// Customize window border
//
showIcon: true
borderWidth: 1
fullscreenEnabled: true
borderColor: Qt.darker(Cpp_ThemeManager.toolbarGradient2, 1.5)
@ -167,12 +168,8 @@ FramelessWindow.CustomWindow {
// Startup code
//
Component.onCompleted: {
// Load welcome guide
terminal.showWelcomeGuide()
// Display the window & check for updates in 500 ms (we do this so that
// we wait for the window to read settings before showing it)
timer.start()
root.showMainWindow()
}
//
@ -223,15 +220,6 @@ FramelessWindow.CustomWindow {
property alias autoUpdater: root.automaticUpdates
}
//
// Startup timer
//
Timer {
id: timer
interval: 500
onTriggered: root.showMainWindow()
}
//
// macOS menubar loader
//
@ -247,11 +235,6 @@ FramelessWindow.CustomWindow {
RowLayout {
spacing: app.spacing
height: titlebar.height
opacity: enabled ? 1 : 0
enabled: !root.showMacControls || isFullscreen
visible: !root.showMacControls || isFullscreen
Behavior on opacity {NumberAnimation{}}
anchors {
top: parent.top
@ -262,17 +245,98 @@ FramelessWindow.CustomWindow {
topMargin: root.shadowMargin + (!root.showMacControls ? 1 : 0)
}
//
// Menubar
//
PlatformDependent.Menubar {
id: menubar
opacity: 0.8
opacity: enabled ? 0.8 : 0
Layout.alignment: Qt.AlignVCenter
enabled: !root.showMacControls || isFullscreen
visible: !root.showMacControls || isFullscreen
Behavior on opacity {NumberAnimation{}}
}
// Leaving this layout for future usage...
//
// Spacer
//
Item {
Layout.fillWidth: true
}
//
// RX LED
//
LED {
id: _rx
enabled: false
Layout.alignment: Qt.AlignVCenter
Connections {
target: Cpp_IO_Manager
function onRx() {
_rx.flash()
}
}
}
//
// RX label
//
Label {
text: "RX"
font.bold: true
font.family: app.monoFont
Layout.alignment: Qt.AlignVCenter
color: _rx.enabled ? Cpp_ThemeManager.ledEnabled : Cpp_ThemeManager.ledDisabled
}
//
// RX/TX middleman icon
//
Icon {
width: 24
height: 24
source: "qrc:/icons/ethernet.svg"
Layout.alignment: Qt.AlignVCenter
color: Cpp_ThemeManager.ledDisabled
}
//
// TX Label
//
Label {
text: "TX"
font.bold: true
font.family: app.monoFont
Layout.alignment: Qt.AlignVCenter
color: _tx.enabled ? Cpp_ThemeManager.ledEnabled : Cpp_ThemeManager.ledDisabled
}
//
// TX LED
//
LED {
id: _tx
enabled: false
layoutDirection: Qt.RightToLeft
Layout.alignment: Qt.AlignVCenter
Connections {
target: Cpp_IO_Manager
function onTx() {
_tx.flash()
}
}
}
//
// Spacer
//
Item {
width: app.spacing
}
}
//

View File

@ -34,8 +34,8 @@
"alternativeHighlight":"#53ab27",
"setupPanelBackground":"#e8e8e8",
"paneWindowBackground":"#f1f1f1",
"ledEnabled":"#0072C3",
"ledDisabled":"#686868",
"ledEnabled":"#fe696e",
"ledDisabled":"#0072C3",
"csvCheckbox":"#2e895c",
"connectButtonChecked":"#fe696e",
"connectButtonUnchecked":"#26cd40",

View File

@ -118,15 +118,15 @@ int Client::mqttVersion() const
{
switch (m_client.version())
{
case QMQTT::V3_1_0:
return 0;
break;
case QMQTT::V3_1_1:
return 1;
break;
default:
return -1;
break;
case QMQTT::V3_1_0:
return 0;
break;
case QMQTT::V3_1_1:
return 1;
break;
default:
return -1;
break;
}
}
@ -206,8 +206,8 @@ StringList Client::qosLevels() const
// clang-format off
return StringList {
tr("0: At most once"),
tr("1: At least once"),
tr("2: Exactly once")
tr("1: At least once"),
tr("2: Exactly once")
};
// clang-format on
}
@ -235,12 +235,12 @@ StringList Client::sslProtocols() const
{
return StringList {
tr("System default"),
"TLS v1.0",
"TLS v1.1",
"TLS v1.2",
"DTLS v1.0",
"DTLS v1.2",
"DTLS v1.3"
"TLS v1.0",
"TLS v1.1",
"TLS v1.2",
"DTLS v1.0",
"DTLS v1.2",
"DTLS v1.3"
};
}
@ -277,11 +277,8 @@ void Client::disconnectFromHost()
*/
void Client::setQos(const quint8 qos)
{
if (qos >= 0 && qos <= 2)
{
m_client.setWillQos(qos);
emit qosChanged();
}
m_client.setWillQos(qos);
emit qosChanged();
}
/**
@ -378,14 +375,14 @@ void Client::setMqttVersion(const int versionIndex)
{
switch (versionIndex)
{
case 0:
m_client.setVersion(QMQTT::V3_1_0);
break;
case 1:
m_client.setVersion(QMQTT::V3_1_1);
break;
default:
break;
case 0:
m_client.setVersion(QMQTT::V3_1_0);
break;
case 1:
m_client.setVersion(QMQTT::V3_1_1);
break;
default:
break;
}
emit mqttVersionChanged();
@ -467,99 +464,99 @@ void Client::onError(const QMQTT::ClientError error)
switch (error)
{
case QMQTT::UnknownError:
str = tr("Unknown error");
break;
case QMQTT::SocketConnectionRefusedError:
str = tr("Connection refused");
break;
case QMQTT::SocketRemoteHostClosedError:
str = tr("Remote host closed the connection");
break;
case QMQTT::SocketHostNotFoundError:
str = tr("Host not found");
break;
case QMQTT::SocketAccessError:
str = tr("Socket access error");
break;
case QMQTT::SocketResourceError:
str = tr("Socket resource error");
break;
case QMQTT::SocketTimeoutError:
str = tr("Socket timeout");
break;
case QMQTT::SocketDatagramTooLargeError:
str = tr("Socket datagram too large");
break;
case QMQTT::SocketNetworkError:
str = tr("Network error");
break;
case QMQTT::SocketAddressInUseError:
str = tr("Address in use");
break;
case QMQTT::SocketAddressNotAvailableError:
str = tr("Address not available");
break;
case QMQTT::SocketUnsupportedSocketOperationError:
str = tr("Unsupported socket operation");
break;
case QMQTT::SocketUnfinishedSocketOperationError:
str = tr("Unfinished socket operation");
break;
case QMQTT::SocketProxyAuthenticationRequiredError:
str = tr("Proxy authentication required");
break;
case QMQTT::SocketSslHandshakeFailedError:
str = tr("SSL handshake failed");
break;
case QMQTT::SocketProxyConnectionRefusedError:
str = tr("Proxy connection refused");
break;
case QMQTT::SocketProxyConnectionClosedError:
str = tr("Proxy connection closed");
break;
case QMQTT::SocketProxyConnectionTimeoutError:
str = tr("Proxy connection timeout");
break;
case QMQTT::SocketProxyNotFoundError:
str = tr("Proxy not found");
break;
case QMQTT::SocketProxyProtocolError:
str = tr("Proxy protocol error");
break;
case QMQTT::SocketOperationError:
str = tr("Operation error");
break;
case QMQTT::SocketSslInternalError:
str = tr("SSL internal error");
break;
case QMQTT::SocketSslInvalidUserDataError:
str = tr("Invalid SSL user data");
break;
case QMQTT::SocketTemporaryError:
str = tr("Socket temprary error");
break;
case QMQTT::MqttUnacceptableProtocolVersionError:
str = tr("Unacceptable MQTT protocol");
break;
case QMQTT::MqttIdentifierRejectedError:
str = tr("MQTT identifier rejected");
break;
case QMQTT::MqttServerUnavailableError:
str = tr("MQTT server unavailable");
break;
case QMQTT::MqttBadUserNameOrPasswordError:
str = tr("Bad MQTT username or password");
break;
case QMQTT::MqttNotAuthorizedError:
str = tr("MQTT authorization error");
break;
case QMQTT::MqttNoPingResponse:
str = tr("MQTT no ping response");
break;
default:
str = "";
break;
case QMQTT::UnknownError:
str = tr("Unknown error");
break;
case QMQTT::SocketConnectionRefusedError:
str = tr("Connection refused");
break;
case QMQTT::SocketRemoteHostClosedError:
str = tr("Remote host closed the connection");
break;
case QMQTT::SocketHostNotFoundError:
str = tr("Host not found");
break;
case QMQTT::SocketAccessError:
str = tr("Socket access error");
break;
case QMQTT::SocketResourceError:
str = tr("Socket resource error");
break;
case QMQTT::SocketTimeoutError:
str = tr("Socket timeout");
break;
case QMQTT::SocketDatagramTooLargeError:
str = tr("Socket datagram too large");
break;
case QMQTT::SocketNetworkError:
str = tr("Network error");
break;
case QMQTT::SocketAddressInUseError:
str = tr("Address in use");
break;
case QMQTT::SocketAddressNotAvailableError:
str = tr("Address not available");
break;
case QMQTT::SocketUnsupportedSocketOperationError:
str = tr("Unsupported socket operation");
break;
case QMQTT::SocketUnfinishedSocketOperationError:
str = tr("Unfinished socket operation");
break;
case QMQTT::SocketProxyAuthenticationRequiredError:
str = tr("Proxy authentication required");
break;
case QMQTT::SocketSslHandshakeFailedError:
str = tr("SSL handshake failed");
break;
case QMQTT::SocketProxyConnectionRefusedError:
str = tr("Proxy connection refused");
break;
case QMQTT::SocketProxyConnectionClosedError:
str = tr("Proxy connection closed");
break;
case QMQTT::SocketProxyConnectionTimeoutError:
str = tr("Proxy connection timeout");
break;
case QMQTT::SocketProxyNotFoundError:
str = tr("Proxy not found");
break;
case QMQTT::SocketProxyProtocolError:
str = tr("Proxy protocol error");
break;
case QMQTT::SocketOperationError:
str = tr("Operation error");
break;
case QMQTT::SocketSslInternalError:
str = tr("SSL internal error");
break;
case QMQTT::SocketSslInvalidUserDataError:
str = tr("Invalid SSL user data");
break;
case QMQTT::SocketTemporaryError:
str = tr("Socket temprary error");
break;
case QMQTT::MqttUnacceptableProtocolVersionError:
str = tr("Unacceptable MQTT protocol");
break;
case QMQTT::MqttIdentifierRejectedError:
str = tr("MQTT identifier rejected");
break;
case QMQTT::MqttServerUnavailableError:
str = tr("MQTT server unavailable");
break;
case QMQTT::MqttBadUserNameOrPasswordError:
str = tr("Bad MQTT username or password");
break;
case QMQTT::MqttNotAuthorizedError:
str = tr("MQTT authorization error");
break;
case QMQTT::MqttNoPingResponse:
str = tr("MQTT no ping response");
break;
default:
str = "";
break;
}
if (!str.isEmpty())