Compare commits

..

6 commits

6 changed files with 141 additions and 12 deletions

View file

@ -18,8 +18,8 @@
import QtQuick 2.12
import QtQuick.Dialogs 1.3
import QtQuick.Controls 2.15
//import eu.ad5001.MixedMenu 1.1
//import QtQuick.Controls 2.15
import eu.ad5001.MixedMenu 1.1
import "js/objects.js" as Objects
import "js/historylib.js" as HistoryLib
@ -156,7 +156,7 @@ MenuBar {
Action {
text: qsTr("&User manual")
icon.name: 'documentation'
onTriggered: Qt.openUrlExternally("https://git.ad5001.eu/Ad5001/LogarithmPlotter/wiki")
onTriggered: Qt.openUrlExternally("https://git.ad5001.eu/Ad5001/LogarithmPlotter/wiki/User-Manual")
}
Action {
text: qsTr("&Changelog")

View file

@ -47,7 +47,7 @@ ApplicationWindow {
SystemPalette { id: sysPalette; colorGroup: SystemPalette.Active }
SystemPalette { id: sysPaletteIn; colorGroup: SystemPalette.Disabled }
menuBar: appMenu//.trueItem
menuBar: appMenu.trueItem
AppMenuBar {id: appMenu}
@ -66,15 +66,16 @@ ApplicationWindow {
z: 3
}
Drawer {
Item {
id: sidebar
width: 300
height: parent.height
y: root.menuBar.height
//y: root.menuBar.height
readonly property bool inPortrait: root.width < root.height
modal: inPortrait
/*modal: true// inPortrait
interactive: inPortrait
position: inPortrait ? 0 : 1
*/
visible: !inPortrait
@ -109,7 +110,7 @@ ApplicationWindow {
anchors.topMargin: 5
anchors.leftMargin: 5
anchors.bottom: parent.bottom
anchors.bottomMargin: sidebarSelector.height
//anchors.bottomMargin: sidebarSelector.height
width: parent.width - 5
currentIndex: sidebarSelector.currentIndex
z: -1
@ -137,8 +138,8 @@ ApplicationWindow {
anchors.top: parent.top
anchors.left: sidebar.inPortrait ? parent.left : sidebar.right
height: parent.height
width: sidebar.inPortrait ? parent.width : parent.width - sidebar.position*sidebar.width
x: sidebar.position*sidebar.width
width: sidebar.inPortrait ? parent.width : parent.width - sidebar.width//*sidebar.position
x: sidebar.width//*sidebar.position
xmin: settings.xmin
ymax: settings.ymax

View file

@ -112,6 +112,9 @@ Item {
verticalAlignment: TextInput.AlignVCenter
horizontalAlignment: control.label == "" ? TextInput.AlignLeft : TextInput.AlignHCenter
color: sysPalette.windowText
validator: RegExpValidator {
regExp: control.isInt ? /-?[0-9]+/ : control.isDouble ? /-?[0-9]+(\.[0-9]+)?/ : /.+/
}
focus: true
text: control.defValue
selectByMouse: true

View file

@ -84,8 +84,8 @@ class EditedProperty extends C.Action {
this.next = this.propertyType.translatedValues[this.propertyType.values.indexOf(this.newValue)]
break;
case "ObjectType":
this.prev = this.previousValue.name
this.next = this.newValue.name
this.prev = this.previousValue == null ? "null" : this.previousValue.name
this.next = this.newValue == null ? "null" : this.newValue.name
break;
case "List":
this.prev = this.previousValue.join(",")

View file

@ -146,9 +146,15 @@ class XCursor extends Common.DrawableObject {
switch(this.labelPosition) {
case 'left':
case 'above-left':
case 'below-left':
case 'below':
case 'above':
canvas.drawVisibleText(ctx, text, xpos-textSize.width-5, textSize.height+5)
break;
case 'right':
case 'above-right':
case 'below-right':
canvas.drawVisibleText(ctx, text, xpos+5, textSize.height+5)
break;
}
@ -159,11 +165,25 @@ class XCursor extends Common.DrawableObject {
var ypox = canvas.y2px(this.targetElement.execute(this.x.execute()))
switch(this.labelPosition) {
case 'left':
case 'below':
case 'above':
canvas.drawVisibleText(ctx, text, xpos-textSize.width-5, ypox+textSize.height)
break;
case 'above-left':
canvas.drawVisibleText(ctx, text, xpos-textSize.width-5, ypox+textSize.height+12)
break;
case 'below-left':
canvas.drawVisibleText(ctx, text, xpos-textSize.width-5, ypox+textSize.height-12)
break;
case 'right':
canvas.drawVisibleText(ctx, text, xpos+5, ypox+textSize.height)
break;
case 'above-right':
canvas.drawVisibleText(ctx, text, xpos+5, ypox+textSize.height+12)
break;
case 'below-right':
canvas.drawVisibleText(ctx, text, xpos+5, ypox+textSize.height-12)
break;
}
}
}

View file

@ -0,0 +1,105 @@
<?php
#
# LogarithmPlotter - 2D plotter software to make BODE plots, sequences and repartition functions.
# Copyright (C) 2022 Ad5001 <mail@ad5001.eu>
#
# 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/>.
#
# This PHP script generates manuals for LogarithmPlotter in Markdown, HTML and PDF.
declare(strict_types=1);
error_reporting(E_ALL);
function generate_html(string $title, string $body) : string {
$h = "<!DOCTYPE html>
<html>
<head>
<title>$title</title>
<meta charset=\"utf-8\">
<style>* {
font-family: sans-serif
}</style>
</head>
<body>$body</body>
</html>";
return $h;
}
function fetch_page(string $man) : string {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://git.ad5001.eu/api/v1/repos/Ad5001/LogarithmPlotter/wiki/page/{$man}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = json_decode(curl_exec($ch));
return base64_decode($data->content_base64);
}
function extract_markdown_links(string $content) : array {
preg_match_all(
"/\[[\w\d+:',é -]*\]\(([\w\d'+%-]+)\)/i",
$content,
$matches
);
return $matches[1];
}
function do_replacements(string $man_name, string $content) : string {
$cnt = preg_replace("/# /", "## ", $content);
if(str_contains($cnt, $man_name))
$cnt = preg_replace("/$man_name/", "#$man_name", $cnt);
return $cnt;
}
function remove_navigation(string $content) : string {
$lines = explode("\n", $content);
return implode("\n", array_slice($lines, 2, count($lines)-3));
}
function fetch_full_manual(string $man_page) : string {
$intro = fetch_page($man_page);
$pages = extract_markdown_links($intro);
# Extract content from first page
$lines = explode("\n", $intro);
$content = implode("\n", array_slice($lines, 0, count($lines)-count($pages)));
$content .= "\n\n[Online version](https://git.ad5001.eu/Ad5001/LogarithmPlotter/wiki/$man_page)\n";
# Extract pages
foreach($pages as $page) {
$content .= "\n<span id=\"$page\"></span>\n";
$content .= do_replacements($man_page, remove_navigation(fetch_page($page)));
}
return $content;
}
function convert_to_html(string $md_content) : string {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://git.ad5001.eu/api/v1/markdown/raw");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/plain', 'Accept: text/html'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $md_content);
return curl_exec($ch);
}
function save_manuals(string $man_page) {
$md = fetch_full_manual($man_page);
$html = generate_html("$man_page", convert_to_html($md));
file_put_contents("$man_page.md", $md);
file_put_contents("$man_page.html", $html);
system("wkhtmltopdf \"$man_page.html\" \"$man_page.pdf\"");
}
save_manuals("User-Manual");
save_manuals("Manuel-d'utilisation");