Skip to content

Commit 4df27a6

Browse files
authored
Merge pull request #45 from scratchcpp/project_settings
Add project settings
2 parents 6f2fc21 + 3d21e88 commit 4df27a6

File tree

5 files changed

+122
-2
lines changed

5 files changed

+122
-2
lines changed

src/app/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ qt_add_qml_module(${APP_TARGET}
1616
QML_FILES
1717
qml/main.qml
1818
qml/dialogs/AboutDialog.qml
19+
qml/dialogs/ProjectSettingsDialog.qml
1920
)
2021

2122
set(QML_IMPORT_PATH "${QML_IMPORT_PATH};${CMAKE_CURRENT_LIST_DIR}"

src/app/appmenubar.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ AppMenuBar::AppMenuBar(QObject *parent) :
5555
m_editMenu->addItem(m_fps60ModeItem);
5656
connect(m_fps60ModeItem, &MenuItemModel::checkedChanged, this, &AppMenuBar::fps60ModeChanged);
5757

58+
// Edit -> Project settings
59+
m_projectSettingsItem = new MenuItemModel(m_editMenu);
60+
m_projectSettingsItem->setText(tr("Project settings..."));
61+
m_editMenu->addItem(m_projectSettingsItem);
62+
connect(m_projectSettingsItem, &MenuItemModel::clicked, this, &AppMenuBar::projectSettingsTriggered);
63+
5864
// Help menu
5965
m_helpMenu = new MenuModel(m_model);
6066
m_helpMenu->setTitle(tr("&Help"));

src/app/appmenubar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class AppMenuBar : public QObject
4646
void fileOpened(const QString &fileName);
4747
void turboModeChanged();
4848
void fps60ModeChanged();
49+
void projectSettingsTriggered();
4950
void aboutAppTriggered();
5051

5152
private:
@@ -64,6 +65,7 @@ class AppMenuBar : public QObject
6465
uicomponents::MenuModel *m_editMenu = nullptr;
6566
uicomponents::MenuItemModel *m_turboModeItem = nullptr;
6667
uicomponents::MenuItemModel *m_fps60ModeItem = nullptr;
68+
uicomponents::MenuItemModel *m_projectSettingsItem = nullptr;
6769

6870
uicomponents::MenuModel *m_helpMenu = nullptr;
6971
uicomponents::MenuItemModel *m_aboutAppItem = nullptr;
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
3+
import QtQuick
4+
import QtQuick.Controls
5+
import QtQuick.Layouts
6+
import ScratchCPP
7+
import ScratchCPP.UiComponents
8+
import ScratchCPP.Render
9+
10+
CustomDialog {
11+
property ProjectPlayer projectPlayer: null
12+
title: qsTr("Project settings")
13+
standardButtons: Dialog.Close
14+
15+
contentItem: ColumnLayout {
16+
// General
17+
Label {
18+
text: qsTr("General")
19+
font.pointSize: 14
20+
font.bold: true
21+
}
22+
23+
RowLayout {
24+
Label {
25+
text: qsTr("FPS (frames per second)")
26+
}
27+
28+
SpinBox {
29+
editable: true
30+
from: 1
31+
to: 250
32+
stepSize: 10
33+
value: projectPlayer.fps
34+
onValueChanged: {
35+
projectPlayer.fps = value;
36+
AppMenuBar.fps60Mode = (value === 60);
37+
}
38+
}
39+
}
40+
41+
// Remove limits
42+
Label {
43+
text: qsTr("Remove limits")
44+
font.pointSize: 14
45+
font.bold: true
46+
}
47+
48+
CheckBox {
49+
text: qsTr("Infinite clones")
50+
checked: projectPlayer.cloneLimit === -1
51+
onCheckedChanged: projectPlayer.cloneLimit = checked ? -1 : 300
52+
}
53+
54+
CheckBox {
55+
text: qsTr("Remove sprite fencing")
56+
checked: !projectPlayer.spriteFencing
57+
onCheckedChanged: projectPlayer.spriteFencing = !checked
58+
}
59+
60+
// Experimental
61+
Label {
62+
text: qsTr("Experimental")
63+
font.pointSize: 14
64+
font.bold: true
65+
}
66+
67+
RowLayout {
68+
Label {
69+
text: qsTr("Custom stage size")
70+
}
71+
72+
SpinBox {
73+
editable: true
74+
from: 20
75+
to: 1920
76+
stepSize: 20
77+
value: projectPlayer.stageWidth
78+
onValueChanged: projectPlayer.stageWidth = value
79+
}
80+
81+
Label {
82+
text: "×"
83+
font.pointSize: 16
84+
}
85+
86+
SpinBox {
87+
editable: true
88+
from: 20
89+
to: 1080
90+
stepSize: 20
91+
value: projectPlayer.stageHeight
92+
onValueChanged: projectPlayer.stageHeight = value
93+
}
94+
}
95+
}
96+
}

src/app/qml/main.qml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ApplicationWindow {
1414
id: root
1515
minimumWidth: layout.implicitWidth + layout.anchors.margins * 2
1616
minimumHeight: menuBar.height + layout.implicitHeight + layout.anchors.margins * 2
17-
visible: true
17+
visible: true
1818
title: Qt.application.displayName
1919
color: Material.background
2020
Material.accent: "orange"
@@ -33,6 +33,17 @@ ApplicationWindow {
3333
player.fileName = fileName;
3434
}
3535

36+
function onFps60ModeChanged() {
37+
if(AppMenuBar.fps60Mode)
38+
player.fps = 60;
39+
else if(player.fps === 60)
40+
player.fps = 30;
41+
}
42+
43+
function onProjectSettingsTriggered() {
44+
projectSettingsDialog.open();
45+
}
46+
3647
function onAboutAppTriggered() {
3748
aboutDialog.open();
3849
}
@@ -41,6 +52,11 @@ ApplicationWindow {
4152

4253
AboutDialog { id: aboutDialog }
4354

55+
ProjectSettingsDialog {
56+
id: projectSettingsDialog
57+
projectPlayer: player
58+
}
59+
4460
ColumnLayout {
4561
id: layout
4662
anchors.fill: parent
@@ -125,7 +141,6 @@ ApplicationWindow {
125141
activeFocusOnTab: true
126142
focus: true
127143
turboMode: AppMenuBar.turboMode
128-
fps: AppMenuBar.fps60Mode ? 60 : 30
129144
}
130145
}
131146
}

0 commit comments

Comments
 (0)