feat(openWithDialog): new UI
This commit is contained in:
parent
5a16f0ee53
commit
54d2f054f2
1 changed files with 36 additions and 13 deletions
|
@ -28,7 +28,7 @@ Item {
|
||||||
|
|
||||||
property string url: main.url
|
property string url: main.url
|
||||||
|
|
||||||
width: 320 + FishUI.Units.largeSpacing * 2
|
width: 400 + FishUI.Units.largeSpacing * 2
|
||||||
height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 2
|
height: _mainLayout.implicitHeight + FishUI.Units.largeSpacing * 2
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -63,17 +63,26 @@ Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
ListView {
|
GridView {
|
||||||
id: listView
|
id: listView
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 250
|
Layout.preferredHeight: 250
|
||||||
model: ListModel {}
|
model: ListModel {}
|
||||||
spacing: FishUI.Units.smallSpacing * 1.5
|
|
||||||
ScrollBar.vertical: ScrollBar {}
|
|
||||||
clip: true
|
clip: true
|
||||||
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
|
||||||
leftMargin: FishUI.Units.largeSpacing
|
leftMargin: FishUI.Units.smallSpacing
|
||||||
rightMargin: FishUI.Units.largeSpacing
|
rightMargin: FishUI.Units.smallSpacing
|
||||||
|
|
||||||
|
cellHeight: {
|
||||||
|
var extraHeight = calcExtraSpacing(80, listView.Layout.preferredHeight - topMargin - bottomMargin)
|
||||||
|
return 80 + extraHeight
|
||||||
|
}
|
||||||
|
|
||||||
|
cellWidth: {
|
||||||
|
var extraWidth = calcExtraSpacing(120, listView.width - leftMargin - rightMargin)
|
||||||
|
return 120 + extraWidth
|
||||||
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
@ -83,8 +92,8 @@ Item {
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: item
|
id: item
|
||||||
width: ListView.view.width - listView.leftMargin - listView.rightMargin
|
width: GridView.view.cellWidth
|
||||||
height: 30 + FishUI.Units.largeSpacing
|
height: GridView.view.cellHeight
|
||||||
scale: mouseArea.pressed ? 0.95 : 1.0
|
scale: mouseArea.pressed ? 0.95 : 1.0
|
||||||
|
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
|
@ -106,7 +115,8 @@ Item {
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
radius: FishUI.Theme.bigRadius
|
anchors.margins: FishUI.Units.smallSpacing
|
||||||
|
radius: FishUI.Theme.mediumRadius
|
||||||
color: isSelected ? FishUI.Theme.highlightColor
|
color: isSelected ? FishUI.Theme.highlightColor
|
||||||
: mouseArea.containsMouse ? Qt.rgba(FishUI.Theme.textColor.r,
|
: mouseArea.containsMouse ? Qt.rgba(FishUI.Theme.textColor.r,
|
||||||
FishUI.Theme.textColor.g,
|
FishUI.Theme.textColor.g,
|
||||||
|
@ -115,23 +125,25 @@ Item {
|
||||||
smooth: true
|
smooth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: FishUI.Units.smallSpacing
|
anchors.margins: FishUI.Units.smallSpacing
|
||||||
spacing: FishUI.Units.smallSpacing
|
spacing: FishUI.Units.smallSpacing
|
||||||
|
|
||||||
FishUI.IconItem {
|
FishUI.IconItem {
|
||||||
id: icon
|
id: icon
|
||||||
Layout.fillHeight: true
|
Layout.preferredHeight: 36
|
||||||
Layout.preferredWidth: height
|
Layout.preferredWidth: height
|
||||||
source: model.icon
|
source: model.icon
|
||||||
Layout.alignment: Qt.AlignLeft
|
Layout.alignment: Qt.AlignHCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
text: model.name
|
text: model.name
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.alignment: Qt.AlignLeft
|
elide: Text.ElideMiddle
|
||||||
|
Layout.alignment: Qt.AlignHCenter
|
||||||
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
color: isSelected ? FishUI.Theme.highlightedTextColor : FishUI.Theme.textColor
|
color: isSelected ? FishUI.Theme.highlightedTextColor : FishUI.Theme.textColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,4 +185,15 @@ Item {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function calcExtraSpacing(cellSize, containerSize) {
|
||||||
|
var availableColumns = Math.floor(containerSize / cellSize)
|
||||||
|
var extraSpacing = 0
|
||||||
|
if (availableColumns > 0) {
|
||||||
|
var allColumnSize = availableColumns * cellSize
|
||||||
|
var extraSpace = Math.max(containerSize - allColumnSize, 0)
|
||||||
|
extraSpacing = extraSpace / availableColumns
|
||||||
|
}
|
||||||
|
return Math.floor(extraSpacing)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue