pragma ComponentBehavior: Bound import QtQuick import QtQuick.Controls import QtQuick.Layouts import BiLauncher Dialog { id: picker required property LauncherUpdates updates property string channel: "release" property string selectedVersion: "" readonly property string state: updates.states[channel] ?? "" readonly property var entries: updates.catalogs[channel] ?? [] function selectChannel(value) { channel = value selectedVersion = "" if (state !== "ready") updates.refresh(channel) } modal: true anchors.centerIn: parent width: Math.min(720, parent.width - 24) height: Math.min(480, parent.height - 24) padding: 0 closePolicy: updates.installing ? Popup.NoAutoClose : Popup.CloseOnEscape | Popup.CloseOnPressOutside onAboutToShow: selectChannel(updates.channel === "rc" ? "rc" : "release") background: Rectangle { color: "#1e1e1e" radius: 10 border.color: "#91B315" } header: Item { implicitHeight: 52 Text { anchors.centerIn: parent text: Loc.t.app.label.launcherVersions color: "#ffffff" font.pixelSize: 17 font.bold: true } Rectangle { anchors.bottom: parent.bottom width: parent.width height: 1 color: "#333333" } } contentItem: RowLayout { spacing: 0 Column { Layout.preferredWidth: 160 Layout.fillHeight: true padding: 8 spacing: 4 enabled: !picker.updates.installing Repeater { model: [{ key: "release", title: "Release" }, { key: "rc", title: "Release Candidate" }] delegate: ItemDelegate { id: channelButton required property var modelData width: 144 height: 34 text: modelData.title contentItem: Text { text: channelButton.text color: "#ffffff" font.pixelSize: 13 verticalAlignment: Text.AlignVCenter } background: Rectangle { radius: 5 color: picker.channel === channelButton.modelData.key ? "#91B315" : channelButton.hovered || channelButton.activeFocus ? "#2d2d2d" : "transparent" } onClicked: picker.selectChannel(modelData.key) } } } Rectangle { Layout.preferredWidth: 1 Layout.fillHeight: true color: "#333333" } ColumnLayout { Layout.fillWidth: true Layout.fillHeight: true Layout.margins: 8 spacing: 6 RowLayout { Layout.fillWidth: true Layout.leftMargin: 10 Layout.rightMargin: 10 Label { Layout.fillWidth: true text: Loc.t.app.label.versionName color: "#aaaaaa" } Label { Layout.preferredWidth: 110 text: Loc.t.app.label.releaseDate color: "#aaaaaa" } Label { Layout.preferredWidth: 100 text: Loc.t.app.label.changes horizontalAlignment: Text.AlignHCenter color: "#aaaaaa" } } ListView { id: versionList Layout.fillWidth: true Layout.fillHeight: true clip: true spacing: 1 model: picker.entries enabled: !picker.updates.installing ScrollBar.vertical: ScrollBar {} delegate: ItemDelegate { id: versionRow required property var modelData readonly property bool isLatest: picker.channel === picker.updates.channel && modelData.version === picker.updates.latest width: versionList.width height: 36 horizontalPadding: 10 verticalPadding: 0 hoverEnabled: true onClicked: picker.selectedVersion = modelData.version background: Rectangle { radius: 5 color: picker.selectedVersion === versionRow.modelData.version ? "#364514" : versionRow.hovered || versionRow.activeFocus ? "#2d2d2d" : "#232323" } contentItem: RowLayout { Text { Layout.fillWidth: true text: versionRow.modelData.version color: versionRow.modelData.download ? "#ffffff" : "#aaaaaa" font.pixelSize: 13 elide: Text.ElideRight } Text { visible: versionRow.isLatest text: Loc.t.app.status.newVersion color: "#b9d84f" font.pixelSize: 11 } Text { Layout.preferredWidth: 110 text: Qt.formatDate(versionRow.modelData.date, Qt.locale().dateFormat(Locale.ShortFormat)) color: "#aaaaaa" font.pixelSize: 12 } Item { Layout.preferredWidth: 100 Layout.preferredHeight: 28 Button { id: changelogButton anchors.centerIn: parent width: 28 height: 28 padding: 0 hoverEnabled: true flat: true display: AbstractButton.IconOnly icon.source: "images/ExternalLink.svg" icon.width: 16 icon.height: 16 icon.color: "#b9d84f" Accessible.name: Loc.t.app.hint.openChanges ToolTip.text: Accessible.name ToolTip.visible: hovered onClicked: Qt.openUrlExternally(versionRow.modelData.changelog) } } } } Label { anchors.centerIn: parent visible: picker.state !== "ready" || versionList.count === 0 text: picker.state === "loading" ? Loc.t.app.status.loadingVersions : picker.state === "error" ? Loc.t.app.error.versionCatalog : Loc.t.app.status.noVersions color: "#aaaaaa" } } } } footer: Item { implicitHeight: 60 Rectangle { width: parent.width height: 1 color: "#333333" } Row { anchors.centerIn: parent spacing: 12 Button { id: closeButton width: 130 height: 36 text: Loc.t.common.button.close enabled: !picker.updates.installing contentItem: Text { text: closeButton.text color: "#ffffff" horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } background: Rectangle { color: closeButton.hovered || closeButton.activeFocus ? "#444444" : "#333333" radius: 6 } onClicked: picker.close() } Button { id: installButton width: 170 height: 36 text: picker.updates.installing ? Loc.t.app.status.downloadingInstaller : Loc.t.common.button.install enabled: !picker.updates.installing && picker.state === "ready" && picker.entries.some(entry => entry.version === picker.selectedVersion && entry.download) opacity: enabled || picker.updates.installing ? 1 : 0.45 contentItem: Text { text: installButton.text color: "#ffffff" horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } background: Rectangle { color: installButton.hovered || installButton.activeFocus ? "#a0c51a" : "#91B315" radius: 6 } onClicked: picker.updates.install(picker.channel, picker.selectedVersion) } } } }