Skip to content

Commit

Permalink
Increased contrast for better visibility of ui elements
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilInTheGaps committed Nov 13, 2023
1 parent d4dcb4b commit 72cf9d9
Show file tree
Hide file tree
Showing 32 changed files with 201 additions and 258 deletions.
2 changes: 1 addition & 1 deletion app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void setPalette()
palette.setColor(QPalette::ColorRole::AlternateBase, "#343a43"_L1);
palette.setColor(QPalette::ColorRole::Window, "#2e2e2e"_L1);
palette.setColor(QPalette::ColorRole::WindowText, "#f6f7f8"_L1);
palette.setColor(QPalette::ColorRole::Button, "#3f4957"_L1);
palette.setColor(QPalette::ColorRole::Button, "#8f9aa9"_L1); // 3f4957
palette.setColor(QPalette::ColorRole::ButtonText, "#f6f7f8"_L1);
palette.setColor(QPalette::ColorRole::Light, "#ebedef"_L1);
palette.setColor(QPalette::ColorRole::Midlight, "#d5dade"_L1);
Expand Down
2 changes: 1 addition & 1 deletion app/ui/Colors.qml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pragma Singleton

import QtQuick

QtObject {
readonly property color border: "#3f4957"
readonly property color borderFocus: "#586679"
readonly property color menuSeparator: "#A0f1f2f4"
readonly property color buttonPressed: "#737e8c"
}
3 changes: 2 additions & 1 deletion app/ui/CustomComponents/CCColors.qml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pragma Singleton

import QtQuick

QtObject {
readonly property color focus: "#f6f7f8"
readonly property color borderFocus: "#586679"
readonly property color buttonPressed: "#737e8c"
}
15 changes: 7 additions & 8 deletions app/ui/CustomComponents/CustomButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Control {
property color backgroundColor: palette.dark
property bool transparentBackground: false
property int borderWidth: 1
property bool forceBorderVisible: false

// Layout
property bool usesFixedWidth: true
Expand All @@ -42,10 +43,8 @@ Control {
id: main_row
spacing: 10

property int spacingCount: icon_item.visible
&& text_item.visible ? 1 : 0
property int contentWidth: (icon_item.visible ? icon_item.width : 0)
+ (text_item.visible ? text_item.width : 0) + spacingCount
property int spacingCount: icon_item.visible && text_item.visible ? 1 : 0
property int contentWidth: (icon_item.visible ? icon_item.width : 0) + (text_item.visible ? text_item.width : 0) + spacingCount

padding: root.centering ? (width - contentWidth) / 2 : 0

Expand Down Expand Up @@ -90,8 +89,8 @@ Control {
background: Rectangle {
visible: !root.transparentBackground
color: root.backgroundColor
border.color: palette.button
border.width: mouse_area.containsMouse ? root.borderWidth : 0
border.color: root.pressed ? CCColors.buttonPressed : palette.button
border.width: mouse_area.containsMouse || root.forceBorderVisible ? root.borderWidth : 0
}

ToolTip.text: root.toolTipText
Expand All @@ -107,9 +106,9 @@ Control {

onClicked: function (mouse) {
if (mouse.button === Qt.LeftButton) {
root.clicked(root.buttonText)
root.clicked(root.buttonText);
} else if (mouse.button === Qt.RightButton) {
root.rightClicked(root.buttonText)
root.rightClicked(root.buttonText);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/ui/CustomComponents/CustomTextEdit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Rectangle {
signal linkClicked(string link)

color: palette.dark
border.color: root.enabled ? palette.button : palette.dark
border.color: root.enabled ? (area.activeFocus ? CCColors.borderFocus : palette.button) : palette.dark
border.width: root.enabled && area.activeFocus ? 2 : 1

ScrollView {
Expand Down
21 changes: 7 additions & 14 deletions app/ui/Style/Button.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@ import QtQuick.Templates as T
T.Button {
id: control

implicitWidth: Math.max(
background ? background.implicitWidth : 0,
contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(
background ? background.implicitHeight : 0,
contentItem.implicitHeight + topPadding + bottomPadding)
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)
baselineOffset: contentItem.y + contentItem.baselineOffset

padding: 6
leftPadding: padding + 2
rightPadding: padding + 2
hoverEnabled: true

font.bold: control.hovered
font.bold: control.enabled && control.hovered

contentItem: Text {
text: control.text
font: control.font
opacity: enabled || control.highlighted || control.checked ? 1 : 0.3
color: control.checked
|| control.highlighted ? StyleColors.focus : (control.visualFocus ? StyleColors.focus : (control.down ? StyleColors.textDisabled : palette.text))
color: control.enabled ? (control.checked || control.highlighted ? StyleColors.focus : (control.visualFocus ? StyleColors.focus : (control.down ? StyleColors.textDisabled : palette.text))) : StyleColors.textDisabled
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
Expand All @@ -33,10 +27,9 @@ T.Button {
background: Rectangle {
implicitWidth: 100
implicitHeight: 40
visible: !control.flat || control.down || control.checked
|| control.highlighted
visible: !control.flat || control.down || control.checked || control.highlighted
color: palette.dark
border.color: palette.button
border.width: control.visualFocus || control.hovered ? 1 : 0
border.color: control.down ? StyleColors.buttonPressed : palette.button
border.width: control.enabled && (control.visualFocus || control.hovered) ? 1 : 0
}
}
1 change: 1 addition & 0 deletions app/ui/Style/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ qt_add_qml_module(gm-companion-ui-style
RadioIndicator.qml
ScrollBar.qml
ScrollIndicator.qml
ScrollView.qml
Slider.qml
SpinBox.qml
SplitView.qml
Expand Down
5 changes: 2 additions & 3 deletions app/ui/Style/CheckIndicator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ Label {
required property int checkState

font.pixelSize: control.height > 26 ? 26 : control.height
x: root.control.text ? (root.control.mirrored ? root.control.width - width - root.control.rightPadding : root.control.leftPadding) : root.control.leftPadding
+ (root.control.availableWidth - width) / 2
x: root.control.text ? (root.control.mirrored ? root.control.width - width - root.control.rightPadding : root.control.leftPadding) : root.control.leftPadding + (root.control.availableWidth - width) / 2
y: parent.height / 2 - height / 2
color: StyleColors.border
color: root.control.down ? StyleColors.buttonPressed : palette.button

text: FontAwesome.square
font.family: FontAwesome.fontRegular.family
Expand Down
10 changes: 5 additions & 5 deletions app/ui/Style/ComboBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ T.ComboBox {
validator: control.validator

font: control.font
color: !control.editable && control.visualFocus ? StyleColors.focus : palette.text
selectionColor: StyleColors.focus
color: !control.editable && control.visualFocus ? palette.button : palette.text
selectionColor: palette.button
selectedTextColor: palette.highlightedText
verticalAlignment: Text.AlignVCenter
opacity: control.enabled ? 1 : 0.3

background: Rectangle {
visible: control.editable && !control.flat
border.width: parent && parent.activeFocus ? 2 : 1
border.color: parent && parent.activeFocus ? StyleColors.focus : StyleColors.border
border.color: palette.button
implicitHeight: 40
}
}
Expand All @@ -75,7 +75,7 @@ T.ComboBox {
implicitHeight: StyleSizes.comboBoxHeight

color: palette.dark
border.color: StyleColors.border
border.color: control.down ? StyleColors.buttonPressed : palette.button
border.width: 1
}

Expand Down Expand Up @@ -138,7 +138,7 @@ T.ComboBox {
width: parent.width
height: parent.height
color: "transparent"
border.color: StyleColors.border
border.color: palette.button
}

T.ScrollIndicator.vertical: ScrollIndicator {
Expand Down
17 changes: 5 additions & 12 deletions app/ui/Style/ItemDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import QtQuick.Templates as T
T.ItemDelegate {
id: control

implicitWidth: Math.max(
background ? background.implicitWidth : 0,
contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(
background ? background.implicitHeight : 0, Math.max(
contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, Math.max(contentItem.implicitHeight, indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
baselineOffset: contentItem.y + contentItem.baselineOffset

padding: 12
Expand All @@ -21,10 +16,8 @@ T.ItemDelegate {
font.pointSize: 12

contentItem: Label {
leftPadding: control.mirrored ? (control.indicator ? control.indicator.width : 0)
+ control.spacing : 0
rightPadding: !control.mirrored ? (control.indicator ? control.indicator.width : 0)
+ control.spacing : 0
leftPadding: control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0
rightPadding: !control.mirrored ? (control.indicator ? control.indicator.width : 0) + control.spacing : 0

text: control.text
font: control.font
Expand All @@ -39,7 +32,7 @@ T.ItemDelegate {
implicitHeight: StyleSizes.delegateHeight
visible: control.down || control.highlighted || control.visualFocus
color: palette.dark
border.color: StyleColors.border
border.color: control.down ? StyleColors.buttonPressed : palette.button
border.width: control.hovered ? 1 : 0
}
}
14 changes: 5 additions & 9 deletions app/ui/Style/Menu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import QtQuick.Templates as T
T.Menu {
id: control

implicitWidth: Math.max(
background ? background.implicitWidth : 0,
contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0)
implicitHeight: Math.max(
background ? background.implicitHeight : 0,
contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding

margins: 0
transformOrigin: Item.Top
Expand Down Expand Up @@ -55,13 +51,13 @@ T.Menu {
implicitHeight: contentHeight
model: control.contentModel

interactive: ApplicationWindow.window ? contentHeight
> ApplicationWindow.window.height : false
interactive: ApplicationWindow.window ? contentHeight > ApplicationWindow.window.height : false
clip: true
keyNavigationWraps: false
currentIndex: -1

ScrollIndicator.vertical: ScrollIndicator {}
ScrollIndicator.vertical: ScrollIndicator {
}
}

background: Rectangle {
Expand Down
17 changes: 5 additions & 12 deletions app/ui/Style/MenuItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,16 @@ import QtQuick.Templates as T
T.MenuItem {
id: control

implicitWidth: Math.max(
background ? background.implicitWidth : 0,
contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(
background ? background.implicitHeight : 0, Math.max(
contentItem.implicitHeight,
indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, Math.max(contentItem.implicitHeight, indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)
baselineOffset: contentItem.y + contentItem.baselineOffset

padding: 6
hoverEnabled: true

contentItem: Label {
leftPadding: control.checkable
&& !control.mirrored ? control.indicator.width + control.spacing : 0
rightPadding: control.checkable
&& control.mirrored ? control.indicator.width + control.spacing : 0
leftPadding: control.checkable && !control.mirrored ? control.indicator.width + control.spacing : 0
rightPadding: control.checkable && control.mirrored ? control.indicator.width + control.spacing : 0

text: control.text
font: control.font
Expand All @@ -39,7 +32,7 @@ T.MenuItem {
height: parent.height - 2
color: "transparent"
opacity: enabled ? 1 : 0.3
border.color: StyleColors.border
border.color: control.down ? StyleColors.buttonPressed : palette.button
border.width: control.hovered ? 1 : 0
}
}
10 changes: 3 additions & 7 deletions app/ui/Style/ProgressBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ import QtQuick.Templates as T
T.ProgressBar {
id: control

implicitWidth: Math.max(
background ? background.implicitWidth : 0,
contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(
background ? background.implicitHeight : 0,
contentItem.implicitHeight + topPadding + bottomPadding)
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)

contentItem: Item {
implicitHeight: StyleSizes.progressBarHeight
Expand All @@ -35,7 +31,7 @@ T.ProgressBar {
height: StyleSizes.progressBarHeight

color: palette.window
border.color: StyleColors.border
border.color: palette.button
border.width: 1
}
}
5 changes: 2 additions & 3 deletions app/ui/Style/RadioIndicator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ Label {
property T.RadioButton control

font.pixelSize: 26
x: control.text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding
+ (control.availableWidth - width) / 2
x: control.text ? (control.mirrored ? control.width - width - control.rightPadding : control.leftPadding) : control.leftPadding + (control.availableWidth - width) / 2
y: parent.height / 2 - height / 2
color: StyleColors.border
color: control.down ? StyleColors.buttonPressed : palette.button

text: FontAwesome.circle
font.family: FontAwesome.fontRegular.family
Expand Down
15 changes: 4 additions & 11 deletions app/ui/Style/ScrollBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@ import QtQuick.Templates as T
T.ScrollBar {
id: control

implicitWidth: Math.max(
background ? background.implicitWidth : 0,
contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(
background ? background.implicitHeight : 0,
contentItem.implicitHeight + topPadding + bottomPadding)
implicitWidth: Math.max(background ? background.implicitWidth : 0, contentItem.implicitWidth + leftPadding + rightPadding)
implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding)

padding: 2
visible: policy !== T.ScrollBar.AlwaysOff
Expand All @@ -19,15 +15,12 @@ T.ScrollBar {
implicitHeight: control.interactive ? 6 : 2

radius: width / 2
color: control.pressed ? palette.dark : palette.button
border.color: StyleColors.border
border.width: control.pressed ? 1 : 0
color: control.pressed ? StyleColors.buttonPressed : palette.button
opacity: control.size < 1.0 ? 0.5 : 0.0

states: State {
name: "active"
when: control.policy === T.ScrollBar.AlwaysOn
|| (control.active && control.size < 1.0)
when: control.policy === T.ScrollBar.AlwaysOn || (control.active && control.size < 1.0)

PropertyChanges {
control.contentItem.opacity: 0.75
Expand Down
24 changes: 24 additions & 0 deletions app/ui/Style/ScrollView.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import QtQuick.Templates as T

T.ScrollView {
id: control

implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, contentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, contentHeight + topPadding + bottomPadding)

ScrollBar.vertical: ScrollBar {
parent: control
x: control.mirrored ? 0 : control.width - width
y: control.topPadding
height: control.availableHeight
active: control.ScrollBar.horizontal.active
}

ScrollBar.horizontal: ScrollBar {
parent: control
x: control.leftPadding
y: control.height - height
width: control.availableWidth
active: control.ScrollBar.vertical.active
}
}
Loading

0 comments on commit 72cf9d9

Please sign in to comment.