diff --git a/MenuToolbar.qml b/MenuToolbar.qml new file mode 100644 index 0000000..06d5410 --- /dev/null +++ b/MenuToolbar.qml @@ -0,0 +1,68 @@ +import QtQuick 2.0 +import QtQuick.Window 2.12 + +Item { + Rectangle { + id: menu + width: mainWindow.width + height: 32 + + Image { + source: "Resources/menu-background.png" + fillMode: Image.Tile + anchors.fill: parent + + } + + + MouseArea { + anchors.fill: parent; + property variant clickPos: "1,1" + + onPressed: { + clickPos = Qt.point(mouse.x,mouse.y) + } + + onPositionChanged: { + var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y) + var new_x = mainWindow.x + delta.x + var new_y = mainWindow.y + delta.y + if (new_y <= 0) + mainWindow.visibility = Window.Maximized + else + { + if (mainWindow.visibility === Window.Maximized) + mainWindow.visibility = Window.Windowed + mainWindow.x = new_x + mainWindow.y = new_y + } + } + + MenuButton { + id: buttonExit + caption: "X" + onClicked: Qt.quit(); + + } + + MenuButton { + id: buttonMinimize + anchors.left: buttonExit.right + caption: "_" + onClicked: mainWindow.hide() + + } + + Text { + id: appTitle + anchors.left: buttonMinimize.right + text: qsTr("TangraPlay") + font.family: mainfont.name + font.pixelSize: 20 + font.bold: true + color: "#f9c620" + } + } + } +} + diff --git a/main.qml b/main.qml index 435e78c..8cc42a7 100644 --- a/main.qml +++ b/main.qml @@ -67,69 +67,12 @@ Window { fillMode: Image.Tile source: "Resources/dark_leather.png" - Rectangle { - id: menu - width: mainWindow.width - height: 32 + MenuToolbar {} - Image { - source: "Resources/menu-background.png" - fillMode: Image.Tile - anchors.fill: parent - - } - - - MouseArea { - anchors.fill: parent; - property variant clickPos: "1,1" - - onPressed: { - clickPos = Qt.point(mouse.x,mouse.y) - } - - onPositionChanged: { - var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y) - var new_x = mainWindow.x + delta.x - var new_y = mainWindow.y + delta.y - if (new_y <= 0) - mainWindow.visibility = Window.Maximized - else - { - if (mainWindow.visibility === Window.Maximized) - mainWindow.visibility = Window.Windowed - mainWindow.x = new_x - mainWindow.y = new_y - } - } - - MenuButton { - id: buttonExit - caption: "X" - onClicked: Qt.quit() - - } - - MenuButton { - id: buttonMinimize - anchors.left: buttonExit.right - caption: "_" - onClicked: mainWindow.hide() - - } - - Text { - id: appTitle - anchors.left: buttonMinimize.right - text: qsTr("TangraPlay") - font.family: mainfont.name - font.pixelSize: 20 - font.bold: true - color: "#f9c620" - } - } + PgLive { + id: pgLive1 } - } - PgLive {} + } } + diff --git a/qml.qrc b/qml.qrc index 34e9eac..40fcbd6 100644 --- a/qml.qrc +++ b/qml.qrc @@ -15,5 +15,6 @@ Resources/tangra.ico Resources/KellySlab-Regular.ttf PgLive.qml + MenuToolbar.qml