1
0
Fork 0

Tweak addons catalog styling

Refactor into a separate delegate component to make things cleaner
This commit is contained in:
James Turner 2018-07-04 09:54:17 +01:00
parent 81f4ce5ea8
commit 728a5b13db
3 changed files with 124 additions and 106 deletions

View file

@ -10,106 +10,6 @@ Item {
flickableDirection: Flickable.VerticalFlick
contentHeight: contents.childrenRect.height
Component {
id: catalogDelegate
Rectangle {
id: delegateRoot
// don't show the delegate for newly added catalogs, until the
// adding process is complete
visible: !model.isNewlyAdded
height: catalogTextColumn.childrenRect.height + Style.margin * 2
border.width: 1
border.color: Style.themeColor
width: catalogsColumn.width
Column {
id: catalogTextColumn
y: Style.margin
anchors.left: parent.left
anchors.leftMargin: Style.margin
anchors.right: catalogDeleteButton.left
anchors.rightMargin: Style.margin
spacing: Style.margin
StyledText {
font.pixelSize: Style.subHeadingFontPixelSize
font.bold: true
width: parent.width
text: model.name
}
StyledText {
visible: model.status === CatalogListModel.Ok
width: parent.width
text: model.description
wrapMode: Text.WordWrap
}
ClickableText {
visible: model.status !== CatalogListModel.Ok
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("This hangar is currently disabled due to a problem. " +
"Click here to try updating the hangar information from the server. "
+ "(An Internet connection is required for this)");
onClicked: {
_addOns.catalogs.refreshCatalog(model.index)
}
}
StyledText {
width: parent.width
text: model.url
}
}
DeleteButton {
id: catalogDeleteButton
anchors.right: parent.right
anchors.rightMargin: Style.margin
anchors.verticalCenter: parent.verticalCenter
visible: delegateHover.containsMouse
onClicked: {
confirmDeleteHangar.visible = true;
}
}
MouseArea {
id: delegateHover
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
}
YesNoPanel {
id: confirmDeleteHangar
visible: false
anchors.fill: parent
yesText: qsTr("Remove")
noText: qsTr("Cancel")
yesIsDestructive: true
promptText: qsTr("Remove this hangar? (Downloaded aircraft will be deleted from your computer)");
onAccepted: {
_addOns.catalogs.removeCatalog(model.index);
}
onRejected: {
confirmDeleteHangar.visible = false
}
}
}
}
Column {
id: contents
width: parent.width - (Style.margin * 2)
@ -135,20 +35,20 @@ Item {
Column {
id: catalogsColumn
width: parent.width - Style.margin * 2
x: Style.margin
y: Style.margin
width: parent.width
spacing: Style.margin
Repeater {
id: catalogsRepeater
model: _addOns.catalogs
delegate: catalogDelegate
delegate: CatalogDelegate {
width: catalogsColumn.width
}
}
ClickableText {
visible: !_addOns.isOfficialHangarRegistered && !addCatalogPanel.isActive
width: parent.width
anchors { left: parent.left; right: parent.right; margins: Style.margin }
text : qsTr("The official FlightGear aircraft hangar is not set up. To add it, click here.");
onClicked: {
_addOns.catalogs.installDefaultCatalog()
@ -157,7 +57,7 @@ Item {
AddCatalogPanel {
id: addCatalogPanel
width: parent.width
anchors { left: parent.left; right: parent.right; margins: Style.margin }
}
}
}

View file

@ -0,0 +1,117 @@
import QtQuick 2.4
import FlightGear.Launcher 1.0
import "."
Item {
id: delegateRoot
// don't show the delegate for newly added catalogs, until the
// adding process is complete
visible: !model.isNewlyAdded
implicitWidth: 300
height: childrenRect.height
Item {
id: divider
visible: model.index > 0 // divider before each item except the first
height: Style.margin
width: parent.width
Rectangle {
color: Style.frameColor
height: 1
width: parent.width - Style.strutSize
anchors.centerIn: parent
}
}
Item
{
anchors.top: divider.bottom
height: catalogTextColumn.childrenRect.height + Style.margin * 2
width: parent.width
Column {
id: catalogTextColumn
y: Style.margin
anchors.left: parent.left
anchors.leftMargin: Style.margin
anchors.right: catalogDeleteButton.left
anchors.rightMargin: Style.margin
spacing: Style.margin
StyledText {
font.pixelSize: Style.subHeadingFontPixelSize
font.bold: true
width: parent.width
text: model.name
}
StyledText {
visible: model.status === CatalogListModel.Ok
width: parent.width
text: model.description
wrapMode: Text.WordWrap
}
ClickableText {
visible: model.status !== CatalogListModel.Ok
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("This hangar is currently disabled due to a problem. " +
"Click here to try updating the hangar information from the server. "
+ "(An Internet connection is required for this)");
onClicked: {
_addOns.catalogs.refreshCatalog(model.index)
}
}
StyledText {
width: parent.width
text: model.url
}
}
DeleteButton {
id: catalogDeleteButton
anchors.right: parent.right
anchors.rightMargin: Style.margin
anchors.verticalCenter: parent.verticalCenter
visible: delegateHover.containsMouse
onClicked: {
confirmDeleteHangar.visible = true;
}
}
MouseArea {
id: delegateHover
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton
}
YesNoPanel {
id: confirmDeleteHangar
visible: false
anchors.fill: parent
anchors.margins: 1 // don't cover the border
yesText: qsTr("Remove")
noText: qsTr("Cancel")
yesIsDestructive: true
promptText: qsTr("Remove this hangar? (Downloaded aircraft will be deleted from your computer)");
onAccepted: {
_addOns.catalogs.removeCatalog(model.index);
}
onRejected: {
confirmDeleteHangar.visible = false
}
}
}
}

View file

@ -107,6 +107,7 @@
<file>qml/MenuDivider.qml</file>
<file>qml/ToggleBox.qml</file>
<file>qml/LocationAltitudeRow.qml</file>
<file>qml/CatalogDelegate.qml</file>
</qresource>
<qresource prefix="/preview">
<file alias="close-icon">preview-close.png</file>