LogarithmPlotter/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/Popup/Changelog.qml

107 lines
3.3 KiB
QML
Raw Normal View History

2022-01-27 21:59:02 +00:00
/**
* LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions.
2024-01-10 23:11:09 +00:00
* Copyright (C) 2021-2024 Ad5001
2022-01-27 21:59:02 +00:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2023-05-21 22:15:09 +00:00
import QtQuick
import QtQuick.Controls
2022-01-27 21:59:02 +00:00
/*!
\qmltype Changelog
\inqmlmodule eu.ad5001.LogarithmPlotter.Popup
\brief Overlay used to display the current changelog to the user.
\note The changelog is either fetched from https://api.ad5001.eu/changelog/logarithmplotter/ or taken locally when a file named CHANGELOG.md exists within the main source code.
\sa LogarithmPlotter, GreetScreen
*/
2022-01-27 21:59:02 +00:00
Popup {
id: changelogPopup
x: (parent.width-width)/2
y: Math.max(20, (parent.height-height)/2)
2023-10-08 16:34:09 +00:00
width: 800
2022-01-27 21:59:02 +00:00
height: Math.min(parent.height-40, 500)
modal: true
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
/*!
\qmlproperty string Changelog::changelogNeedsFetching
true when the changelog has yet to be loaded, set to false the moment it's loaded.
*/
2022-01-27 21:59:02 +00:00
property bool changelogNeedsFetching: true
2023-10-08 16:34:09 +00:00
onAboutToShow: if(changelogNeedsFetching) {
Helper.fetchChangelog()
}
2022-01-27 21:59:02 +00:00
Connections {
target: Helper
function onChangelogFetched(chl) {
changelogNeedsFetching = false;
changelog.text = chl
2023-10-08 16:34:09 +00:00
changelogView.contentItem.implicitHeight = changelog.height
// console.log(changelog.height, changelogView.contentItem.implicitHeight)
2022-01-27 21:59:02 +00:00
}
}
ScrollView {
2023-10-08 16:34:09 +00:00
id: changelogView
2022-01-27 21:59:02 +00:00
anchors.top: parent.top
anchors.topMargin: 10
anchors.left: parent.left
anchors.leftMargin: 10
2023-10-08 16:34:09 +00:00
anchors.right: parent.right
anchors.rightMargin: 10
2022-01-27 21:59:02 +00:00
anchors.bottom: doneBtn.top
anchors.bottomMargin: 10
clip: true
2023-10-08 16:34:09 +00:00
2022-01-27 21:59:02 +00:00
Label {
id: changelog
color: sysPalette.windowText
2023-10-08 16:34:09 +00:00
width: 760
wrapMode: Text.WordWrap
2022-01-27 21:59:02 +00:00
textFormat: TextEdit.MarkdownText
text: qsTr("Fetching changelog...")
onLinkActivated: Qt.openUrlExternally(link)
2022-01-27 21:59:02 +00:00
}
}
2023-05-22 07:31:43 +00:00
Rectangle {
id: bottomSeparator
opacity: 0.3
color: sysPalette.windowText
width: parent.width * 2 / 3
height: 1
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: doneBtn.top
anchors.bottomMargin: 7
}
2022-01-27 21:59:02 +00:00
Button {
id: doneBtn
text: qsTr("Done")
font.pixelSize: 18
anchors.bottom: parent.bottom
2023-05-22 07:31:43 +00:00
anchors.bottomMargin: 7
2022-01-27 21:59:02 +00:00
anchors.horizontalCenter: parent.horizontalCenter
onClicked: changelogPopup.close()
}
}