Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ qt_add_qml_module(${APP_TARGET}
QML_FILES
qml/main.qml
qml/dialogs/AboutDialog.qml
qml/dialogs/ProjectSettingsDialog.qml
)

set(QML_IMPORT_PATH "${QML_IMPORT_PATH};${CMAKE_CURRENT_LIST_DIR}"
Expand Down
6 changes: 6 additions & 0 deletions src/app/appmenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ AppMenuBar::AppMenuBar(QObject *parent) :
m_editMenu->addItem(m_fps60ModeItem);
connect(m_fps60ModeItem, &MenuItemModel::checkedChanged, this, &AppMenuBar::fps60ModeChanged);

// Edit -> Project settings
m_projectSettingsItem = new MenuItemModel(m_editMenu);
m_projectSettingsItem->setText(tr("Project settings..."));
m_editMenu->addItem(m_projectSettingsItem);
connect(m_projectSettingsItem, &MenuItemModel::clicked, this, &AppMenuBar::projectSettingsTriggered);

// Help menu
m_helpMenu = new MenuModel(m_model);
m_helpMenu->setTitle(tr("&Help"));
Expand Down
2 changes: 2 additions & 0 deletions src/app/appmenubar.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class AppMenuBar : public QObject
void fileOpened(const QString &fileName);
void turboModeChanged();
void fps60ModeChanged();
void projectSettingsTriggered();
void aboutAppTriggered();

private:
Expand All @@ -64,6 +65,7 @@ class AppMenuBar : public QObject
uicomponents::MenuModel *m_editMenu = nullptr;
uicomponents::MenuItemModel *m_turboModeItem = nullptr;
uicomponents::MenuItemModel *m_fps60ModeItem = nullptr;
uicomponents::MenuItemModel *m_projectSettingsItem = nullptr;

uicomponents::MenuModel *m_helpMenu = nullptr;
uicomponents::MenuItemModel *m_aboutAppItem = nullptr;
Expand Down
96 changes: 96 additions & 0 deletions src/app/qml/dialogs/ProjectSettingsDialog.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// SPDX-License-Identifier: GPL-3.0-or-later

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import ScratchCPP
import ScratchCPP.UiComponents
import ScratchCPP.Render

CustomDialog {
property ProjectPlayer projectPlayer: null
title: qsTr("Project settings")
standardButtons: Dialog.Close

contentItem: ColumnLayout {
// General
Label {
text: qsTr("General")
font.pointSize: 14
font.bold: true
}

RowLayout {
Label {
text: qsTr("FPS (frames per second)")
}

SpinBox {
editable: true
from: 1
to: 250
stepSize: 10
value: projectPlayer.fps
onValueChanged: {
projectPlayer.fps = value;
AppMenuBar.fps60Mode = (value === 60);
}
}
}

// Remove limits
Label {
text: qsTr("Remove limits")
font.pointSize: 14
font.bold: true
}

CheckBox {
text: qsTr("Infinite clones")
checked: projectPlayer.cloneLimit === -1
onCheckedChanged: projectPlayer.cloneLimit = checked ? -1 : 300
}

CheckBox {
text: qsTr("Remove sprite fencing")
checked: !projectPlayer.spriteFencing
onCheckedChanged: projectPlayer.spriteFencing = !checked
}

// Experimental
Label {
text: qsTr("Experimental")
font.pointSize: 14
font.bold: true
}

RowLayout {
Label {
text: qsTr("Custom stage size")
}

SpinBox {
editable: true
from: 20
to: 1920
stepSize: 20
value: projectPlayer.stageWidth
onValueChanged: projectPlayer.stageWidth = value
}

Label {
text: "×"
font.pointSize: 16
}

SpinBox {
editable: true
from: 20
to: 1080
stepSize: 20
value: projectPlayer.stageHeight
onValueChanged: projectPlayer.stageHeight = value
}
}
}
}
19 changes: 17 additions & 2 deletions src/app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ApplicationWindow {
id: root
minimumWidth: layout.implicitWidth + layout.anchors.margins * 2
minimumHeight: menuBar.height + layout.implicitHeight + layout.anchors.margins * 2
visible: true
visible: true
title: Qt.application.displayName
color: Material.background
Material.accent: "orange"
Expand All @@ -33,6 +33,17 @@ ApplicationWindow {
player.fileName = fileName;
}

function onFps60ModeChanged() {
if(AppMenuBar.fps60Mode)
player.fps = 60;
else if(player.fps === 60)
player.fps = 30;
}

function onProjectSettingsTriggered() {
projectSettingsDialog.open();
}

function onAboutAppTriggered() {
aboutDialog.open();
}
Expand All @@ -41,6 +52,11 @@ ApplicationWindow {

AboutDialog { id: aboutDialog }

ProjectSettingsDialog {
id: projectSettingsDialog
projectPlayer: player
}

ColumnLayout {
id: layout
anchors.fill: parent
Expand Down Expand Up @@ -125,7 +141,6 @@ ApplicationWindow {
activeFocusOnTab: true
focus: true
turboMode: AppMenuBar.turboMode
fps: AppMenuBar.fps60Mode ? 60 : 30
}
}
}