Skip to content

Commit

Permalink
Code cleanup. Increased font size of track browser.
Browse files Browse the repository at this point in the history
  • Loading branch information
kokernutz committed Dec 22, 2017
1 parent 0c34d91 commit 2d93bb5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
52 changes: 38 additions & 14 deletions Screens/Views/Browser/ListDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ Item {
property color textColor : ListView.isCurrentItem ? deckColor : colors.colorFontsListBrowser
property bool isCurrentItem : ListView.isCurrentItem
property string prepIconColorPostfix: (screenFocus < 2 && ListView.isCurrentItem) ? "Blue" : ((screenFocus > 1 && ListView.isCurrentItem) ? "White" : "Grey")
readonly property int textTopMargin: 5 // centers text vertically
readonly property int textTopMargin: 1 // centers text vertically
readonly property bool isLoaded: (model.dataType == BrowserDataType.Track) ? model.loadedInDeck.length > 0 : false
// visible: !ListView.isCurrentItem
readonly property variant keyText: ["8B", "3B", "10B", "5B", "12B", "7B", "2B", "9B", "4B", "11B", "6B", "1B",
"5A", "12A", "7A", "2A", "9A", "4A", "11A", "6A", "1A", "8A", "3A", "10A"]

property int browserFontSize: fonts.scale(14)

height: 25
anchors.left: parent.left
anchors.right: parent.right
Expand All @@ -34,17 +36,23 @@ Item {
Rectangle {
// when changing colors here please remember to change it in the GridView in Templates/Browser.qml
color: (index%2 == 0) ? colors.colorGrey08 : "transparent"

anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom

anchors.leftMargin: 3
anchors.rightMargin: 3
height: parent.height

// track name, toggles with folder name
Rectangle {
color: (index%2 == 0) ? colors.colorGrey08 : "transparent"
id: firstFieldTrack
anchors.left: parent.left //listImage.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: contactDelegate.textTopMargin
anchors.leftMargin: 33
width: 190
Expand All @@ -54,18 +62,21 @@ Item {
Text {
id: textLengthDummy
visible: false
font.pixelSize: fonts.smallFontSize
font.pixelSize: browserFontSize
text: (model.dataType == BrowserDataType.Track) ? model.trackName : ( (model.dataType == BrowserDataType.Folder) ? model.nodeName : "")
}

Text {
id: firstFieldText
width: (textLengthDummy.width) > 175 ? 175 : textLengthDummy.width
anchors.top: parent.top
anchors.bottom: parent.bottom
width: (textLengthDummy.width) > 190 ? 190 : textLengthDummy.width
// visible: false
elide: Text.ElideRight
text: textLengthDummy.text
font.pixelSize: fonts.smallFontSize
font.pixelSize: browserFontSize
color: textColor
verticalAlignment: Text.AlignVCenter
}

Image {
Expand All @@ -76,6 +87,7 @@ Item {
height: sourceSize.height
anchors.left: firstFieldText.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: 0
anchors.leftMargin: 5
}
Expand All @@ -86,30 +98,35 @@ Item {
id: firstFieldFolder
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: contactDelegate.textTopMargin
anchors.leftMargin: 33
color: textColor
clip: true
text: (model.dataType == BrowserDataType.Folder) ? model.nodeName : ""
font.pixelSize: fonts.smallFontSize
font.pixelSize: browserFontSize
elide: Text.ElideRight
visible: (model.dataType != BrowserDataType.Track)
width: 190
verticalAlignment: Text.AlignVCenter
}


// artist name
Text {
id: trackTitleField
anchors.leftMargin: 9
anchors.leftMargin: 5
anchors.left: (model.dataType == BrowserDataType.Track) ? firstFieldTrack.right : firstFieldFolder.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: contactDelegate.textTopMargin
width: 130
verticalAlignment: Text.AlignVCenter

width: 145
color: textColor
clip: true
text: (model.dataType == BrowserDataType.Track) ? model.artistName: ""
font.pixelSize: fonts.smallFontSize
font.pixelSize: browserFontSize
elide: Text.ElideRight
}

Expand All @@ -118,13 +135,15 @@ Item {
id: bpmField
anchors.left: trackTitleField.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: contactDelegate.textTopMargin
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignRight
width: 36
width: 24
color: textColor
clip: true
text: (model.dataType == BrowserDataType.Track) ? model.bpm.toFixed(0) : ""
font.pixelSize: fonts.smallFontSize
font.pixelSize: browserFontSize
}

function colorForKey(keyIndex) {
Expand All @@ -136,14 +155,16 @@ Item {
id: keyField
anchors.left: bpmField.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: contactDelegate.textTopMargin
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignRight

color: (model.dataType == BrowserDataType.Track) ? (((model.key == "none") || (model.key == "None")) ? textColor : (qmlBrowser.sortingId == 28 ? parent.colorForKey(model.keyIndex) : textColor)) : textColor
width: 27
width: 30
clip: true
text: (model.dataType == BrowserDataType.Track) ? (((model.key == "none") || (model.key == "None")) ? "n.a." : keyText[model.keyIndex]) : ""
font.pixelSize: fonts.smallFontSize
font.pixelSize: browserFontSize
}

// keyMatch
Expand All @@ -152,16 +173,19 @@ Item {
anchors.left: keyField.right
anchors.right: ratingField.left
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: contactDelegate.textTopMargin
anchors.rightMargin: 8
verticalAlignment: Text.AlignVCenter

anchors.rightMargin: 5
horizontalAlignment: Text.AlignRight

color: getListItemKeyTextColor() // (model.dataType == BrowserDataType.Track) ? (((model.key == "none") || (model.key == "None")) ? textColor : parent.colorForKey(model.keyIndex)) : textColor
// width: 20
clip: true

text: (model.dataType == BrowserDataType.Track) ? (((model.key == "none") || (model.key == "None")) ? "n.a." : utils.getMasterKeyOffset(qmlBrowser.getMasterKey(), model.key)) : ""
font.pixelSize: fonts.smallFontSize
font.pixelSize: browserFontSize
}

// track rating
Expand Down
2 changes: 1 addition & 1 deletion Screens/Views/Deck/TrackDeck.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Item {
isInEditMode: trackDeck.isInEditMode
stemStyle: trackDeck.stemStyle

// anchors.topMargin: -2
anchors.topMargin: 3

// the height of the waveform is defined as the remaining space of deckHeight - stripe.height - spacerWaveStripe.height
height: waveformHeight
Expand Down
27 changes: 0 additions & 27 deletions Screens/Views/Definitions/Utils.qml
Original file line number Diff line number Diff line change
Expand Up @@ -111,31 +111,4 @@ QtObject {
return "ERR";
}

function getListItemKeyTextColor() {
if (model.dataType != BrowserDataType.Track) {
return textColor;
}

var keyOffset = utils.getMasterKeyOffset(qmlBrowser.getMasterKey(), model.key);

switch (keyOffset) {
case -7:
case -2:
return colors.colorOrange;
case -1:
case 0:
case 1:
return colors.color11MusicalKey;
case 2:
case 7:
return colors.color07MusicalKey; // Green
}

if (keyOffset == 3 || keyOffset == -3) {
return colors.colorRed;
}

return textColor;
}

}

0 comments on commit 2d93bb5

Please sign in to comment.