Quarts/Main.qml
Станислав Хозяенок 471fe59b72 Init project finished
2025-05-18 19:23:54 +07:00

93 lines
2.7 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Window
import FigmaQmlInterface
Window {
id: rootWindow
width: 1600
height: 900
visible: true
// flags: Qt.Window | Qt.FramelessWindowHint // Убираем рамку и заголовок
//flags: Qt.Window | Qt.MSWindowsFixedSizeDialogHint
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 ? "Цельсий" : "Фаренгейт");
// }
// }
}