2026-08-17 12:34:03 +03:00
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import QtQuick.Layouts
|
2026-09-01 19:25:07 +03:00
|
|
|
import Flora
|
2026-08-17 12:34:03 +03:00
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: toolbar
|
|
|
|
|
|
2026-09-01 19:25:07 +03:00
|
|
|
property var targetPane: null
|
|
|
|
|
readonly property bool usable: targetPane !== null
|
2026-08-17 12:34:03 +03:00
|
|
|
|
|
|
|
|
signal tableRequested()
|
|
|
|
|
|
2026-09-01 19:25:07 +03:00
|
|
|
implicitHeight: 38
|
2026-08-17 12:34:03 +03:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
2026-09-01 19:25:07 +03:00
|
|
|
color: Theme.toolbarBg
|
|
|
|
|
border.color: Theme.divider
|
2026-08-17 12:34:03 +03:00
|
|
|
|
2026-09-01 19:25:07 +03:00
|
|
|
ScrollView {
|
2026-08-17 12:34:03 +03:00
|
|
|
anchors.fill: parent
|
2026-09-01 19:25:07 +03:00
|
|
|
anchors.leftMargin: 6
|
|
|
|
|
anchors.rightMargin: 6
|
|
|
|
|
clip: true
|
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AsNeeded
|
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
height: parent.height
|
|
|
|
|
spacing: 2
|
|
|
|
|
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "B"; tip: qsTr("Жирный (Ctrl+B)"); onTapped: targetPane.applyInline("**", "**") }
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "I"; tip: qsTr("Курсив (Ctrl+I)"); onTapped: targetPane.applyInline("*", "*") }
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "U"; tip: qsTr("Подчёркнутый"); onTapped: targetPane.applyInline("<u>", "</u>") }
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "S"; tip: qsTr("Зачёркнутый"); onTapped: targetPane.applyInline("~~", "~~") }
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "=="; tip: qsTr("Выделение"); onTapped: targetPane.applyInline("==", "==") }
|
|
|
|
|
|
|
|
|
|
TbButton {
|
|
|
|
|
enabled: usable; opacity: enabled?1:0.4
|
|
|
|
|
text: "A"; tip: qsTr("Цвет текста"); bold: true
|
|
|
|
|
onTapped: { colorPopup.highlightMode = false; colorPopup.openAt(this) }
|
|
|
|
|
}
|
|
|
|
|
TbButton {
|
|
|
|
|
enabled: usable; opacity: enabled?1:0.4
|
|
|
|
|
text: "A"; tip: qsTr("Цвет выделения"); accent: true
|
|
|
|
|
onTapped: { colorPopup.highlightMode = true; colorPopup.openAt(this) }
|
|
|
|
|
}
|
2026-08-17 12:34:03 +03:00
|
|
|
|
2026-09-01 19:25:07 +03:00
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "x²"; tip: qsTr("Верхний индекс"); onTapped: targetPane.applySubSup("sup") }
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "x₂"; tip: qsTr("Нижний индекс"); onTapped: targetPane.applySubSup("sub") }
|
2026-08-17 12:34:03 +03:00
|
|
|
|
2026-09-01 19:25:07 +03:00
|
|
|
Item { width: 8 }
|
|
|
|
|
Rectangle { width: 1; height: 20; color: Theme.divider }
|
|
|
|
|
Item { width: 8 }
|
2026-08-17 12:34:03 +03:00
|
|
|
|
2026-09-01 19:25:07 +03:00
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "H#"; tip: qsTr("Заголовок"); onTapped: headingMenu.popup(this) }
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "☰"; tip: qsTr("Списки"); onTapped: listMenu.popup(this) }
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "❝"; tip: qsTr("Цитата"); onTapped: targetPane.applyLinePrefix("> ") }
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "⚠"; tip: qsTr("Выноска"); onTapped: calloutMenu.popup(this) }
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "▦"; tip: qsTr("Таблица"); onTapped: toolbar.tableRequested() }
|
|
|
|
|
TbButton { enabled: usable; opacity: enabled?1:0.4; text: "⊡"; tip: qsTr("Обтекание"); onTapped: targetPane.applyFloatWrap() }
|
|
|
|
|
}
|
2026-08-17 12:34:03 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
|
id: headingMenu
|
|
|
|
|
title: qsTr("Заголовок")
|
|
|
|
|
Repeater {
|
|
|
|
|
model: [1, 2, 3, 4, 5, 6]
|
|
|
|
|
MenuItem {
|
|
|
|
|
text: "H" + modelData + " — " + "######".slice(0, modelData)
|
2026-09-01 19:25:07 +03:00
|
|
|
onTriggered: targetPane.applyHeading(modelData)
|
2026-08-17 12:34:03 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
|
id: listMenu
|
|
|
|
|
title: qsTr("Список")
|
2026-09-01 19:25:07 +03:00
|
|
|
MenuItem { text: qsTr("Маркированный"); onTriggered: targetPane.applyLinePrefix("- ") }
|
|
|
|
|
MenuItem { text: qsTr("Нумерованный"); onTriggered: targetPane.applyLinePrefix("1. ") }
|
|
|
|
|
MenuItem { text: qsTr("Задачи (- [ ])"); onTriggered: targetPane.applyTaskToggle() }
|
2026-08-17 12:34:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Menu {
|
|
|
|
|
id: calloutMenu
|
|
|
|
|
title: qsTr("Выноска")
|
|
|
|
|
Repeater {
|
|
|
|
|
model: ["NOTE", "INFO", "WARN", "ERROR"]
|
2026-09-01 19:25:07 +03:00
|
|
|
MenuItem { text: modelData; onTriggered: targetPane.applyCallout(modelData) }
|
2026-08-17 12:34:03 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
property var colorList: [
|
|
|
|
|
"#000000", "#ffffff", "#9e9e9e", "#795548", "#607d8b",
|
|
|
|
|
"#f44336", "#ff9800", "#ffeb3b", "#4caf50", "#00bcd4",
|
|
|
|
|
"#2196f3", "#3f51b5", "#9c27b0", "#e91e63"
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
Popup {
|
|
|
|
|
id: colorPopup
|
|
|
|
|
property bool highlightMode: false
|
2026-09-01 19:25:07 +03:00
|
|
|
function openAt(btn) { x = btn.mapToItem(toolbar, 0, 0).x; y = btn.mapToItem(toolbar, 0, 0).y + btn.height + 4; open() }
|
|
|
|
|
width: grid.width + 16
|
|
|
|
|
height: grid.height + 16
|
|
|
|
|
background: Rectangle { color: Theme.surface; border.color: Theme.borderStrong; radius: 8 }
|
2026-08-17 12:34:03 +03:00
|
|
|
Grid {
|
|
|
|
|
id: grid
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
columns: 7
|
2026-09-01 19:25:07 +03:00
|
|
|
spacing: 4
|
2026-08-17 12:34:03 +03:00
|
|
|
Repeater {
|
|
|
|
|
model: toolbar.colorList
|
|
|
|
|
delegate: Rectangle {
|
2026-09-01 19:25:07 +03:00
|
|
|
width: 24; height: 24; radius: 6
|
2026-08-17 12:34:03 +03:00
|
|
|
color: modelData
|
2026-09-01 19:25:07 +03:00
|
|
|
border.color: modelData === "#ffffff" ? Theme.borderStrong : "transparent"
|
|
|
|
|
border.width: 1
|
2026-08-17 12:34:03 +03:00
|
|
|
MouseArea {
|
|
|
|
|
anchors.fill: parent
|
2026-09-01 19:25:07 +03:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
onClicked: { toolbar.targetPane.applyColor(modelData, colorPopup.highlightMode); colorPopup.close() }
|
2026-08-17 12:34:03 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-09-01 19:25:07 +03:00
|
|
|
}
|