96 lines
2.8 KiB
QML
96 lines
2.8 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Window
|
|
import FigmaQmlInterface
|
|
|
|
ApplicationWindow {
|
|
id: rootWindow
|
|
width: 1600
|
|
height: 900
|
|
visible: true
|
|
minimumWidth: width // Фиксированная ширина
|
|
maximumWidth: width
|
|
minimumHeight: height
|
|
maximumHeight: height
|
|
flags: Qt.Window | Qt.WindowTitleHint | Qt.WindowCloseButtonHint | Qt.WindowMinimizeButtonHint
|
|
color: "transparent" // Прозрачный фон (если нужно)
|
|
title: "Заголовок" // Пустой заголовок
|
|
|
|
// Чёрная рамка 1px по краям
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
anchors.margins: -1 // Выступает за границы родителя
|
|
color: "transparent"
|
|
border.color: "#000000"
|
|
border.width: 1
|
|
}
|
|
|
|
// Верхняя панель управления
|
|
Rectangle {
|
|
id: titleBar
|
|
width: parent.width
|
|
height: 30
|
|
|
|
// Текст заголовка
|
|
Text {
|
|
anchors.centerIn: parent
|
|
text: "Custom Window"
|
|
color: "white"
|
|
font.pixelSize: 12
|
|
}
|
|
|
|
// Обработчик перемещения окна
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
|
|
property point clickPos: "0,0"
|
|
|
|
onPressed: {
|
|
if (mouse.button === Qt.LeftButton) {
|
|
clickPos = Qt.point(mouse.x, mouse.y)
|
|
} else if (mouse.button === Qt.RightButton) {
|
|
contextMenu.popup()
|
|
}
|
|
}
|
|
|
|
onPositionChanged: {
|
|
if (pressedButtons === Qt.LeftButton) {
|
|
var delta = Qt.point(mouse.x - clickPos.x,
|
|
mouse.y - clickPos.y)
|
|
rootWindow.x += delta.x
|
|
rootWindow.y += delta.y
|
|
}
|
|
}
|
|
}
|
|
|
|
// Контекстное меню
|
|
Menu {
|
|
id: contextMenu
|
|
|
|
MenuItem {
|
|
text: "Скрыть"
|
|
onTriggered: rootWindow.visibility = Window.Minimized
|
|
}
|
|
|
|
MenuItem {
|
|
text: "Закрыть"
|
|
onTriggered: Qt.quit()
|
|
}
|
|
}
|
|
}
|
|
|
|
FigmaQmlUi {
|
|
anchors.fill: parent
|
|
}
|
|
|
|
// Обработчик события
|
|
// FigmaQmlSingleton.onEventReceived: {
|
|
// if (event === 'click_event' && element === 'temp_unit') {
|
|
// currentUnitCelcius = !currentUnitCelcius; // Переключаем значение
|
|
// console.log("Текущая единица измерения:", currentUnitCelcius ? "Цельсий" : "Фаренгейт");
|
|
// }
|
|
// }
|
|
|
|
}
|