cool-retro-term/app/qml/main.qml

161 lines
4.7 KiB
QML
Raw Normal View History

2013-12-28 14:52:10 +01:00
/*******************************************************************************
* Copyright (c) 2013 "Filippo Scognamiglio"
* https://github.com/Swordfish90/cool-retro-term
2013-12-28 14:52:10 +01:00
*
* This file is part of cool-retro-term.
2013-12-28 14:52:10 +01:00
*
* cool-retro-term is free software: you can redistribute it and/or modify
2013-12-28 14:52:10 +01:00
* 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 <http://www.gnu.org/licenses/>.
*******************************************************************************/
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 1.1
2016-08-06 08:34:11 +02:00
import Qt.labs.settings 1.0
import QtGraphicalEffects 1.0
ApplicationWindow{
id: terminalWindow
2014-07-12 01:51:53 +02:00
width: 1024
height: 768
2014-07-07 01:42:17 +02:00
minimumWidth: 320
minimumHeight: 240
visible: true
property bool fullscreen: appSettings.fullscreen
2014-07-12 01:51:53 +02:00
onFullscreenChanged: visibility = (fullscreen ? Window.FullScreen : Window.Windowed)
2016-08-06 08:34:11 +02:00
// Save window size automatically
Settings {
category: "MainWindow"
2016-08-06 09:04:35 +02:00
property alias x: terminalWindow.x
property alias y: terminalWindow.y
2016-08-06 08:34:11 +02:00
property alias width: terminalWindow.width
property alias height: terminalWindow.height
}
//Workaround: Without __contentItem a ugly thin border is visible.
menuBar: CRTMainMenuBar{
id: mainMenu
visible: (Qt.platform.os === "osx" || appSettings.showMenubar)
__contentItem.visible: mainMenu.visible
}
2014-09-18 10:33:40 +02:00
2014-07-14 02:23:22 +02:00
color: "#00000000"
title: terminalContainer.title || qsTr("cool-retro-term")
2014-08-01 00:07:54 +02:00
Action {
id: showMenubarAction
text: qsTr("Show Menubar")
2014-10-10 15:12:28 +02:00
enabled: Qt.platform.os !== "osx"
shortcut: "Ctrl+Shift+M"
2014-08-01 00:07:54 +02:00
checkable: true
checked: appSettings.showMenubar
onTriggered: appSettings.showMenubar = !appSettings.showMenubar
2014-08-01 00:07:54 +02:00
}
Action {
id: fullscreenAction
text: qsTr("Fullscreen")
2014-10-10 15:12:28 +02:00
enabled: Qt.platform.os !== "osx"
shortcut: "Alt+F11"
onTriggered: appSettings.fullscreen = !appSettings.fullscreen;
checkable: true
checked: appSettings.fullscreen
}
Action {
id: quitAction
text: qsTr("Quit")
2014-08-07 00:30:08 +02:00
shortcut: "Ctrl+Shift+Q"
onTriggered: Qt.quit();
}
Action{
id: showsettingsAction
text: qsTr("Settings")
onTriggered: {
settingswindow.show();
settingswindow.requestActivate();
settingswindow.raise();
}
}
2014-04-16 19:30:11 +02:00
Action{
id: copyAction
text: qsTr("Copy")
2014-12-26 17:36:03 +01:00
shortcut: Qt.platform.os === "osx" ? StandardKey.Copy : "Ctrl+Shift+C"
2014-04-16 19:30:11 +02:00
}
Action{
id: pasteAction
text: qsTr("Paste")
2014-12-26 17:36:03 +01:00
shortcut: Qt.platform.os === "osx" ? StandardKey.Paste : "Ctrl+Shift+V"
2014-04-16 19:30:11 +02:00
}
Action{
id: zoomIn
text: qsTr("Zoom In")
shortcut: "Ctrl++"
onTriggered: appSettings.incrementScaling();
}
Action{
id: zoomOut
text: qsTr("Zoom Out")
shortcut: "Ctrl+-"
onTriggered: appSettings.decrementScaling();
}
2014-07-27 18:00:18 +02:00
Action{
id: showAboutAction
text: qsTr("About")
onTriggered: {
aboutDialog.show();
aboutDialog.requestActivate();
aboutDialog.raise();
2014-07-27 18:00:18 +02:00
}
}
2014-06-27 23:54:17 +02:00
ApplicationSettings{
id: appSettings
2014-06-07 02:19:37 +02:00
}
TerminalContainer{
id: terminalContainer
y: appSettings.showMenubar ? 0 : -2 // Workaroud to hide the margin in the menubar.
width: parent.width * appSettings.windowScaling
height: (parent.height + Math.abs(y)) * appSettings.windowScaling
2014-12-11 01:48:30 +01:00
transform: Scale {
xScale: 1 / appSettings.windowScaling
yScale: 1 / appSettings.windowScaling
2014-12-11 01:48:30 +01:00
}
2013-11-25 16:46:10 +01:00
}
SettingsWindow{
id: settingswindow
visible: false
}
2014-07-27 18:00:18 +02:00
AboutDialog{
id: aboutDialog
visible: false
}
2014-12-11 01:48:30 +01:00
Loader{
anchors.centerIn: parent
active: appSettings.showTerminalSize
2014-12-11 01:48:30 +01:00
sourceComponent: SizeOverlay{
z: 3
terminalSize: terminalContainer.terminalSize
}
}
Component.onCompleted: appSettings.handleFontChanged();
onClosing: {
// OSX Since we are currently supporting only one window
// quit the application when it is closed.
if (Qt.platform.os === "osx")
Qt.quit()
}
}