Skip to content

Commit 276b791

Browse files
committed
Removal of 'SwiftNav' Qt Quick Control style
Because QTBUG-108518 will not be resolved in time for 6.5, we must remove the use of custom Qt Quick Control Styles that require fallback to another style, as the fallback style's theme does not properly initialize. (See bug). This removes the SwiftNav style Qt Quick Controls. Some additional things done here: * Remove use of SwiftButton where the customization done in SwiftButton was not used, and Material button is more appropriate to use with the same look and feel. * Remove use of SwiftComboBox where the customization done in SwiftComboBox was not used, and Material ComboBox is more appropriate to use with the same look and feel. * Remove access to change orientation of TabBar, as this was never used. It was originally added, as the original implementation of the SideNavBar was originally implemented with an altered Vertical TabBar, however when I refactored it, I found that TabBar was not the right tool for the job, and abandoned the TabBar based SideNavBar implementation. This was a vestige of that logic. * Use swiftWhite constant instead of literal "white". * Tweaks to the SwiftTabButtons on the TabInfoBar to make it display correctly.
1 parent 3972a69 commit 276b791

File tree

10 files changed

+76
-129
lines changed

10 files changed

+76
-129
lines changed

resources/styles/SwiftNav/TabBar.qml renamed to resources/BaseComponents/SwiftTabBar.qml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,23 @@
3636
** $QT_END_LICENSE$
3737
**
3838
****************************************************************************/
39+
import "../Constants"
3940
import QtQuick
41+
import QtQuick.Templates as T
4042
import QtQuick.Controls.Material
4143
import QtQuick.Controls.Material.impl
42-
import QtQuick.Templates as T
4344

4445
T.TabBar {
4546
id: control
4647

47-
property var orientation: ListView.Horizontal
48-
4948
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, contentWidth + leftPadding + rightPadding)
5049
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, contentHeight + topPadding + bottomPadding)
5150

5251
contentItem: ListView {
5352
model: control.contentModel
5453
currentIndex: control.currentIndex
5554
spacing: control.spacing
56-
orientation: control.orientation
55+
orientation: ListView.Horizontal
5756
boundsBehavior: Flickable.StopAtBounds
5857
flickableDirection: Flickable.AutoFlickIfNeeded
5958
snapMode: ListView.SnapToItem
@@ -79,7 +78,7 @@ T.TabBar {
7978
background: Item {
8079
Rectangle {
8180
anchors.fill: parent
82-
color: "white"
81+
color: Constants.swiftWhite
8382
layer.enabled: control.Material.elevation > 0
8483

8584
layer.effect: ElevationEffect {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import "../Constants"
2+
import QtQuick
3+
import QtQuick.Controls.Material
4+
import QtQuick.Controls.Material.impl
5+
import QtQuick.Controls.impl
6+
import QtQuick.Templates as T
7+
8+
T.TabButton {
9+
id: control
10+
11+
property color labelColor: !control.enabled ? control.Material.hintTextColor : control.down || control.checked ? Constants.swiftWhite : Constants.tabButtonUnselectedTextColor
12+
property color gradientStartColor: down || checked ? Qt.lighter(Constants.swiftGrey, 1.7) : hovered ? Qt.lighter(Constants.swiftControlBackground, 1.1) : Constants.swiftWhite
13+
property color backgroundColor: down || checked ? Constants.swiftGrey : hovered ? Qt.darker(Constants.swiftControlBackground, 1.1) : Constants.swiftControlBackground
14+
property bool border: true
15+
16+
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, implicitContentWidth + leftPadding + rightPadding)
17+
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, implicitContentHeight + topPadding + bottomPadding)
18+
padding: 12
19+
spacing: 6
20+
icon.width: 24
21+
icon.height: 24
22+
icon.color: !enabled ? Material.hintTextColor : down || checked ? Constants.swiftWhite : Constants.tabButtonUnselectedTextColor
23+
24+
font {
25+
family: "Roboto"
26+
pixelSize: Constants.largePixelSize
27+
bold: true
28+
capitalization: Font.MixedCase
29+
}
30+
31+
contentItem: IconLabel {
32+
spacing: control.spacing
33+
mirrored: control.mirrored
34+
display: control.display
35+
icon: control.icon
36+
text: control.text
37+
font: control.font
38+
color: control.labelColor
39+
}
40+
41+
background: Rectangle {
42+
border.width: control.border ? 1 : 0
43+
border.color: Constants.spacerColor
44+
implicitHeight: control.Material.touchTarget
45+
clip: true
46+
color: backgroundColor
47+
48+
gradient: Gradient {
49+
GradientStop {
50+
position: 0
51+
color: gradientStartColor
52+
}
53+
54+
GradientStop {
55+
position: 1
56+
color: backgroundColor
57+
}
58+
}
59+
}
60+
}

resources/LogoPopup.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Item {
2121
ColumnLayout {
2222
anchors.fill: parent
2323

24-
TabBar {
24+
SwiftTabBar {
2525
id: logoPopupBar
2626

2727
z: Constants.commonChart.zAboveCharts
@@ -31,7 +31,7 @@ Item {
3131
Repeater {
3232
model: ["About", "Licenses"]
3333

34-
TabButton {
34+
SwiftTabButton {
3535
text: modelData
3636
width: implicitWidth
3737
}

resources/TabInfoBar.qml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ Rectangle {
6868
anchors.bottom: parent.bottom
6969
height: 1
7070
color: Constants.spacerColor
71-
z: 2
7271
}
7372

7473
RowLayout {
@@ -89,7 +88,7 @@ Rectangle {
8988
font: Constants.tabInfoBar.tabLabelFont
9089
}
9190

92-
TabBar {
91+
SwiftTabBar {
9392
id: tabBar
9493

9594
visible: tabBarRepeater.count > 0
@@ -108,11 +107,12 @@ Rectangle {
108107
}
109108
model: subTabNames
110109

111-
TabButton {
110+
SwiftTabButton {
112111
width: implicitWidth
113-
topPadding: 16
114-
bottomPadding: 16
115-
rightInset: -0.5
112+
topPadding: 17.5
113+
bottomPadding: 17.5
114+
rightInset: -1
115+
leftInset: -1
116116
text: modelData
117117
}
118118
}

resources/console_resources.qrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@
128128
<file>BaseComponents/SwiftImage.qml</file>
129129
<file>BaseComponents/SwiftComboBox.qml</file>
130130
<file>BaseComponents/SwiftRoundButton.qml</file>
131+
<file>BaseComponents/SwiftTabBar.qml</file>
132+
<file>BaseComponents/SwiftTabButton.qml</file>
131133
<file>ChartLegend.qml</file>
132-
<file>styles/SwiftNav/qmldir</file>
133-
<file>styles/SwiftNav/TabBar.qml</file>
134-
<file>styles/SwiftNav/TabButton.qml</file>
135134
<file>MainTab.qml</file>
136135
<file>TabInfoBar.qml</file>
137136
<file>PositionLoopAnimation.qml</file>

resources/qtquickcontrols2.conf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
[Controls]
22
Style=Material
3-
FallbackStyle=Material
4-
5-
[SwiftNav\Font]
6-
Family=Roboto Condensed
7-
PixelSize=9
83

94
[Material]
105
Variant=Dense

resources/styles/SwiftNav/TabButton.qml

Lines changed: 0 additions & 98 deletions
This file was deleted.

resources/styles/SwiftNav/qmldir

Lines changed: 0 additions & 5 deletions
This file was deleted.

swift-toolbox.pyproject

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
"resources/BaseComponents/SwiftValueAxis.qml",
8383
"resources/BaseComponents/SwiftComboBox.qml",
8484
"resources/BaseComponents/SwiftRoundButton.qml",
85+
"resources/BaseComponents/SwiftTabBar.qml",
86+
"resources/BaseComponents/SwiftTabButton.qml",
8587

8688
"resources/BaselineTabComponents/BaselinePlot.qml",
8789
"resources/BaselineTabComponents/BaselineTable.qml",
@@ -184,10 +186,6 @@
184186
"resources/SolutionTabComponents/SolutionTable.qml",
185187
"resources/SolutionTabComponents/SolutionVelocityTab.qml",
186188

187-
"resources/styles/SwiftNav/qmldir",
188-
"resources/styles/SwiftNav/TabBar.qml",
189-
"resources/styles/SwiftNav/TabButton.qml",
190-
191189
"resources/TableComponents/SortableColumnHeading.qml",
192190
"resources/TableComponents/SwiftTableView.qml",
193191
"resources/TableComponents/TableCellDelegate.qml",

swiftnav_console/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ def main(passed_args: Optional[Tuple[str, ...]] = None) -> int:
739739
QFontDatabase.addApplicationFont(":/fonts/Roboto-Bold.ttf")
740740
QFontDatabase.addApplicationFont(":/fonts/RobotoCondensed-Regular.ttf")
741741
QQuickStyle.setStyle("Material")
742-
QQuickStyle.setFallbackStyle("Material")
743742
# We specifically *don't* want the RobotoCondensed-Bold.ttf font so we get the right look when bolded.
744743

745744
qmlRegisterType(ConnectionData, "SwiftConsole", 1, 0, "ConnectionData") # type: ignore

0 commit comments

Comments
 (0)