From 2984d71971fb49e47ff1485ad918e9d520404e4b Mon Sep 17 00:00:00 2001 From: trilene Date: Wed, 30 Dec 2020 15:03:07 -0500 Subject: [PATCH] Fix Qml control colors --- resources/qml/MessageInput.qml | 5 +- resources/qml/voip/ActiveCallBar.qml | 18 ++----- resources/qml/voip/CallDevices.qml | 75 ++++++++++++++-------------- resources/qml/voip/CallInviteBar.qml | 69 +++++++++++++------------ resources/qml/voip/DeviceError.qml | 31 ++++++++++++ resources/qml/voip/PlaceCall.qml | 59 ++++++++++++++-------- resources/res.qrc | 1 + src/UserSettingsPage.cpp | 4 +- 8 files changed, 153 insertions(+), 109 deletions(-) create mode 100644 resources/qml/voip/DeviceError.qml diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index ecacedba..71c61697 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -1,9 +1,9 @@ +import "./voip" import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.2 import QtQuick.Window 2.2 import im.nheko 1.0 -import "./voip" Rectangle { color: colors.window @@ -26,6 +26,7 @@ Rectangle { ImageButton { visible: CallManager.callsSupported + opacity: CallManager.haveCallInvite ? 0.3 : 1.0 Layout.alignment: Qt.AlignBottom hoverEnabled: true width: 22 @@ -46,7 +47,7 @@ Rectangle { } else { var dialog = placeCallDialog.createObject(timelineRoot); - dialog.show(); + dialog.open(); } } } diff --git a/resources/qml/voip/ActiveCallBar.qml b/resources/qml/voip/ActiveCallBar.qml index 86fe37f6..0e932e13 100644 --- a/resources/qml/voip/ActiveCallBar.qml +++ b/resources/qml/voip/ActiveCallBar.qml @@ -1,8 +1,8 @@ +import "../" import QtQuick 2.9 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.2 import im.nheko 1.0 -import "../" Rectangle { @@ -38,7 +38,7 @@ Rectangle { Layout.leftMargin: 8 font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.callParty - color: colors.windowText + color: "#000000" } Image { @@ -52,7 +52,7 @@ Rectangle { id: callStateLabel font.pointSize: fontMetrics.font.pointSize * 1.1 - color: colors.windowText + color: "#000000" } Item { @@ -163,11 +163,9 @@ Rectangle { onClicked: CallManager.toggleCameraView() } - Item { - implicitWidth: 8 - } - ImageButton { + Layout.leftMargin: 8 + Layout.rightMargin: 16 width: 24 height: 24 buttonTextColor: "#000000" @@ -177,11 +175,5 @@ Rectangle { ToolTip.text: CallManager.isMicMuted ? qsTr("Unmute Mic") : qsTr("Mute Mic") onClicked: CallManager.toggleMicMute() } - - Item { - implicitWidth: 16 - } - } - } diff --git a/resources/qml/voip/CallDevices.qml b/resources/qml/voip/CallDevices.qml index ee3503ca..b07412c7 100644 --- a/resources/qml/voip/CallDevices.qml +++ b/resources/qml/voip/CallDevices.qml @@ -1,31 +1,44 @@ -import QtQuick 2.3 +import QtQuick 2.9 import QtQuick.Controls 2.3 -import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.2 import im.nheko 1.0 -import "../" -ApplicationWindow { +Popup { - flags: Qt.Dialog - modality: Qt.ApplicationModal - palette: colors - width: columnLayout.implicitWidth - height: columnLayout.implicitHeight + modal: true + anchors.centerIn: parent + background: Rectangle { + color: colors.window + border.color: colors.windowText + } + + // palette: colors + // colorize controls correctly + palette.base: colors.base + palette.brightText: colors.brightText + palette.button: colors.button + palette.buttonText: colors.buttonText + palette.dark: colors.dark + palette.highlight: colors.highlight + palette.highlightedText: colors.highlightedText + palette.light: colors.light + palette.mid: colors.mid + palette.text: colors.text + palette.window: colors.window + palette.windowText: colors.windowText ColumnLayout { - id: columnLayout spacing: 16 ColumnLayout { spacing: 8 - RowLayout { + Layout.topMargin: 8 + Layout.leftMargin: 8 + Layout.rightMargin: 8 - Layout.topMargin: 8 - Layout.leftMargin: 8 - Layout.rightMargin: 8 + RowLayout { Image { Layout.preferredWidth: 22 @@ -42,9 +55,7 @@ ApplicationWindow { RowLayout { - visible: CallManager.cameras.length > 0 - Layout.leftMargin: 8 - Layout.rightMargin: 8 + visible: CallManager.isVideo && CallManager.cameras.length > 0 Image { Layout.preferredWidth: 22 @@ -60,31 +71,21 @@ ApplicationWindow { } } - RowLayout { + DialogButtonBox { - Layout.rightMargin: 8 - Layout.bottomMargin: 8 - - Item { - implicitWidth: 128 - } + Layout.leftMargin: 128 + standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel - Button { - text: qsTr("Ok") - onClicked: { - Settings.microphone = micCombo.currentText - if (cameraCombo.visible) { - Settings.camera = cameraCombo.currentText - } - close(); + onAccepted: { + Settings.microphone = micCombo.currentText + if (cameraCombo.visible) { + Settings.camera = cameraCombo.currentText } + close(); } - Button { - text: qsTr("Cancel") - onClicked: { - close(); - } + onRejected: { + close(); } } } diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index 93ff1042..8c3a8f6a 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -1,9 +1,8 @@ +import "../" import QtQuick 2.9 import QtQuick.Controls 2.3 -import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.2 import im.nheko 1.0 -import "../" Rectangle { @@ -11,18 +10,18 @@ Rectangle { color: "#2ECC71" implicitHeight: visible ? rowLayout.height + 8 : 0 - MessageDialog { - id: warningDialog - icon: StandardIcon.Warning - } - Component { id: devicesDialog - CallDevices { } } + Component { + id: deviceError + DeviceError { + } + } + RowLayout { id: rowLayout @@ -42,7 +41,7 @@ Rectangle { Layout.leftMargin: 8 font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.callParty - color: colors.windowText + color: "#000000" } Image { @@ -55,7 +54,7 @@ Rectangle { Label { font.pointSize: fontMetrics.font.pointSize * 1.1 text: CallManager.isVideo ? qsTr("Video Call") : qsTr("Voice Call") - color: colors.windowText + color: "#000000" } Item { @@ -63,8 +62,9 @@ Rectangle { } ImageButton { - width: 24 - height: 24 + Layout.rightMargin: 16 + width: 20 + height: 20 buttonTextColor: "#000000" image: ":/icons/icons/ui/settings.png" hoverEnabled: true @@ -72,53 +72,56 @@ Rectangle { ToolTip.text: qsTr("Devices") onClicked: { var dialog = devicesDialog.createObject(timelineRoot); - dialog.show(); + dialog.open(); } } - Item { - implicitWidth: 8 - } - Button { + Layout.rightMargin: 4 icon.source: CallManager.isVideo ? "qrc:/icons/icons/ui/video-call.png" : "qrc:/icons/icons/ui/place-call.png" - palette: colors text: qsTr("Accept") + palette.button: colors.button + palette.buttonText: colors.buttonText + onClicked: { if (CallManager.mics.length == 0) { - warningDialog.text = qsTr("No microphone found."); - warningDialog.open(); + var dialog = deviceError.createObject(timelineRoot, { + "errorString": qsTr("No microphone found."), + "iconSource": "qrc:/icons/icons/ui/place-call.png" + }); + dialog.open(); return; } else if (!CallManager.mics.includes(Settings.microphone)) { - warningDialog.text = qsTr("Unknown microphone: ") + Settings.microphone; - warningDialog.open(); + var dialog = deviceError.createObject(timelineRoot, { + "errorString": qsTr("Unknown microphone: ") + Settings.microphone, + "iconSource": "qrc:/icons/icons/ui/place-call.png" + }); + dialog.open(); return; } if (CallManager.isVideo && CallManager.cameras.length > 0 && !CallManager.cameras.includes(Settings.camera)) { - warningDialog.text = qsTr("Unknown camera: ") + Settings.camera; - warningDialog.open(); + var dialog = deviceError.createObject(timelineRoot, { + "errorString": qsTr("Unknown camera: ") + Settings.camera, + "iconSource": "qrc:/icons/icons/ui/video-call.png" + }); + dialog.open(); return; } CallManager.acceptInvite(); } } - Item { - implicitWidth: 4 - } - Button { + Layout.rightMargin: 16 icon.source: "qrc:/icons/icons/ui/end-call.png" - palette: colors text: qsTr("Decline") + palette.button: colors.button + palette.buttonText: colors.buttonText + onClicked: { CallManager.hangUp(); } } - - Item { - implicitWidth: 16 - } } } diff --git a/resources/qml/voip/DeviceError.qml b/resources/qml/voip/DeviceError.qml new file mode 100644 index 00000000..c88c7faa --- /dev/null +++ b/resources/qml/voip/DeviceError.qml @@ -0,0 +1,31 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.2 +import im.nheko 1.0 + +Popup { + + property string errorString + property var iconSource + + modal: true + anchors.centerIn: parent + background: Rectangle { + color: colors.window + border.color: colors.windowText + } + + RowLayout { + + Image { + Layout.preferredWidth: 16 + Layout.preferredHeight: 16 + source: iconSource + } + + Label { + text: errorString + color: colors.windowText + } + } +} diff --git a/resources/qml/voip/PlaceCall.qml b/resources/qml/voip/PlaceCall.qml index 4e29c1ae..8dc7d781 100644 --- a/resources/qml/voip/PlaceCall.qml +++ b/resources/qml/voip/PlaceCall.qml @@ -1,23 +1,39 @@ -import QtQuick 2.3 +import "../" +import QtQuick 2.9 import QtQuick.Controls 2.3 -import QtQuick.Dialogs 1.3 import QtQuick.Layouts 1.2 import im.nheko 1.0 -import "../" -ApplicationWindow { +Popup { - flags: Qt.Dialog - modality: Qt.ApplicationModal - palette: colors - width: columnLayout.implicitWidth - height: columnLayout.implicitHeight + modal: true + anchors.centerIn: parent + background: Rectangle { + color: colors.window + border.color: colors.windowText + } - MessageDialog { - id: warningDialog - icon: StandardIcon.Warning + Component { + id: deviceError + DeviceError { + } } + // palette: colors + // colorize controls correctly + palette.base: colors.base + palette.brightText: colors.brightText + palette.button: colors.button + palette.buttonText: colors.buttonText + palette.dark: colors.dark + palette.highlight: colors.highlight + palette.highlightedText: colors.highlightedText + palette.light: colors.light + palette.mid: colors.mid + palette.text: colors.text + palette.window: colors.window + palette.windowText: colors.windowText + ColumnLayout { id: columnLayout @@ -25,11 +41,10 @@ ApplicationWindow { RowLayout { - Layout.topMargin: 16 + Layout.topMargin: 8 Layout.leftMargin: 8 Label { - font.pointSize: fontMetrics.font.pointSize * 1.1 text: qsTr("Place a call to ") + TimelineManager.timeline.roomName + "?" color: colors.windowText } @@ -47,24 +62,24 @@ ApplicationWindow { function validateMic() { if (CallManager.mics.length == 0) { - warningDialog.text = qsTr("No microphone found."); - warningDialog.open(); + var dialog = deviceError.createObject(timelineRoot, { + "errorString": qsTr("No microphone found."), + "iconSource": "qrc:/icons/icons/ui/place-call.png" + }); + dialog.open(); return false; } return true; } Avatar { + Layout.rightMargin: cameraCombo.visible ? 16 : 64 width: avatarSize height: avatarSize url: TimelineManager.timeline.roomAvatarUrl.replace("mxc://", "image://MxcImage/") displayName: TimelineManager.timeline.roomName } - Item { - implicitWidth: cameraCombo.visible ? 16 : 64 - } - Button { text: qsTr("Voice") icon.source: "qrc:/icons/icons/ui/place-call.png" @@ -106,7 +121,7 @@ ApplicationWindow { Layout.leftMargin: 8 Layout.rightMargin: 8 - Layout.bottomMargin: cameraCombo.visible ? 0 : 16 + Layout.bottomMargin: cameraCombo.visible ? 0 : 8 Image { Layout.preferredWidth: 22 @@ -126,7 +141,7 @@ ApplicationWindow { visible: CallManager.cameras.length > 0 Layout.leftMargin: 8 Layout.rightMargin: 8 - Layout.bottomMargin: 16 + Layout.bottomMargin: 8 Image { Layout.preferredWidth: 22 diff --git a/resources/res.qrc b/resources/res.qrc index ca333978..bceeb298 100644 --- a/resources/res.qrc +++ b/resources/res.qrc @@ -160,6 +160,7 @@ qml/voip/ActiveCallBar.qml qml/voip/CallDevices.qml qml/voip/CallInviteBar.qml + qml/voip/DeviceError.qml qml/voip/PlaceCall.qml qml/voip/VideoCall.qml diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 7c7ef9ab..f133c87d 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -464,7 +464,7 @@ UserSettings::applyTheme() stylefile.setFileName(":/styles/styles/nheko.qss"); QPalette lightActive( /*windowText*/ QColor("#333"), - /*button*/ QColor("#333"), + /*button*/ QColor("white"), /*light*/ QColor(0xef, 0xef, 0xef), /*dark*/ QColor(110, 110, 110), /*mid*/ QColor(220, 220, 220), @@ -477,7 +477,7 @@ UserSettings::applyTheme() lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color()); lightActive.setColor(QPalette::ToolTipText, lightActive.text().color()); lightActive.setColor(QPalette::Link, QColor("#0077b5")); - lightActive.setColor(QPalette::ButtonText, QColor("#495057")); + lightActive.setColor(QPalette::ButtonText, QColor("#333")); QApplication::setPalette(lightActive); } else if (this->theme() == "dark") { stylefile.setFileName(":/styles/styles/nheko-dark.qss");