LogarithmPlotter/LogarithmPlotter/qml/eu/ad5001/LogarithmPlotter/History/HistoryBrowser.qml

168 lines
5.6 KiB
QML
Raw Normal View History

2021-04-07 12:51:48 +00:00
/**
* LogarithmPlotter - 2D plotter software to make BODE plots, sequences and distribution functions.
* Copyright (C) 2022 Ad5001
2021-04-07 12:51:48 +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/>.
*/
2021-04-07 12:51:48 +00:00
import QtQuick.Controls 2.12
import QtQuick 2.12
2022-02-01 08:59:31 +00:00
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
2022-01-30 00:22:33 +00:00
import "../js/utils.js" as Utils
2021-04-07 12:51:48 +00:00
/*!
\qmltype HistoryBrowser
2022-01-30 00:22:33 +00:00
\inqmlmodule eu.ad5001.LogarithmPlotter.History
\brief Tab of the drawer that allows to navigate through the undo and redo history.
Creates a scrollable view containing a list of history actions based on the redo stack, then a "Now" indicator
followed by the entirety of the saved undo stack. Each action can be click to restore a state of the graph at
some point of the history.
\sa LogarithmPlotter, Settings, ObjectLists
*/
2022-02-01 08:59:31 +00:00
Item {
2021-04-07 12:51:48 +00:00
id: historyBrowser
/*!
\qmlproperty int HistoryBrowser::actionWidth
Width of the actions.
*/
2021-04-07 12:51:48 +00:00
property int actionWidth: width-20
2022-01-30 02:16:47 +00:00
/*!
\qmlproperty int HistoryBrowser::darkTheme
true when the system is running with a dark theme, false otherwise.
*/
property bool darkTheme: isDarkTheme()
2022-02-01 08:59:31 +00:00
Setting.TextSetting {
id: filterInput
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
placeholderText: qsTr("Filter...")
2022-02-01 08:59:31 +00:00
}
ScrollView {
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.top: filterInput.bottom
ScrollBar.horizontal.visible: false
clip: true
2021-04-07 12:51:48 +00:00
2022-02-01 08:59:31 +00:00
Flickable {
width: parent.width
height: parent.height
contentHeight: redoColumn.height + nowRect.height + undoColumn.height
contentWidth: parent.width
2021-04-07 12:51:48 +00:00
2022-02-01 08:59:31 +00:00
Column {
id: redoColumn
anchors.right: parent.right
anchors.top: parent.top
width: actionWidth
Repeater {
model: history.redoCount
HistoryItem {
id: redoButton
width: actionWidth
//height: actionHeight
isRedo: true
idx: index
darkTheme: historyBrowser.darkTheme
hidden: !(filterInput.value == "" || content.includes(filterInput.value))
}
2021-04-07 12:51:48 +00:00
}
}
2022-02-01 08:59:31 +00:00
2021-04-07 12:51:48 +00:00
Text {
anchors.left: parent.left
2022-02-01 08:59:31 +00:00
anchors.bottom: nowRect.top
text: qsTr("Redo >")
color: sysPaletteIn.windowText
transform: Rotation { origin.x: 30; origin.y: 30; angle: 270}
height: 70
width: 20
visible: history.redoCount > 0
2021-04-07 12:51:48 +00:00
}
2022-02-01 08:59:31 +00:00
Rectangle {
id: nowRect
anchors.right: parent.right
anchors.top: redoColumn.bottom
width: actionWidth
height: 40
color: sysPalette.highlight
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 5
text: qsTr("> Now")
color: sysPalette.windowText
}
}
2021-04-07 12:51:48 +00:00
2022-02-01 08:59:31 +00:00
Column {
id: undoColumn
anchors.right: parent.right
anchors.top: nowRect.bottom
width: actionWidth
Repeater {
model: history.undoCount
2022-01-30 00:22:33 +00:00
2022-02-01 08:59:31 +00:00
HistoryItem {
id: undoButton
width: actionWidth
//height: actionHeight
isRedo: false
idx: index
darkTheme: historyBrowser.darkTheme
hidden: !(filterInput.value == "" || content.includes(filterInput.value))
}
2021-04-07 12:51:48 +00:00
}
}
2022-02-01 08:59:31 +00:00
Text {
anchors.left: parent.left
anchors.top: undoColumn.top
text: qsTr("< Undo")
color: sysPaletteIn.windowText
transform: Rotation { origin.x: 30; origin.y: 30; angle: 270}
height: 60
width: 20
visible: history.undoCount > 0
}
2021-04-07 12:51:48 +00:00
}
}
2022-01-30 02:16:47 +00:00
/*!
\qmlmethod bool HistoryBrowser::isDarkTheme()
Checks whether the system is running with a light or dark theme.
*/
function isDarkTheme() {
let hex = sysPalette.windowText.toString()
// We only check the first parameter, as on all normal OSes, text color is grayscale.
return parseInt(hex.substr(1,2), 16) > 128
}
2021-04-07 12:51:48 +00:00
}