Skip to content

Commit b44586a

Browse files
authored
Create main.qml
1 parent f5ed76f commit b44586a

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed

main.qml

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import QtQuick 2.15
2+
import QtQuick.Controls 2.15
3+
4+
ApplicationWindow {
5+
id: window
6+
visible: true
7+
width: 400
8+
height: 400
9+
title: "Fibonacci Sequence Generator"
10+
color: themeToggle.checked ? "#ffffff" : "#2b2b2b"
11+
12+
Rectangle {
13+
anchors.fill: parent
14+
color: themeToggle.checked ? "#ffffff" : "#2b2b2b"
15+
16+
// Exit button at top left
17+
Button {
18+
text: "Exit"
19+
width: 80
20+
height: 40
21+
anchors.left: parent.left
22+
anchors.top: parent.top
23+
anchors.margins: 10
24+
onClicked: Qt.quit()
25+
font.pixelSize: 16
26+
background: Rectangle {
27+
color: themeToggle.checked ? "#e74c3c" : "#c0392b"
28+
radius: 5
29+
}
30+
}
31+
32+
// Theme toggle button at top right
33+
CheckBox {
34+
id: themeToggle
35+
text: "Light Theme"
36+
37+
anchors.right: parent.right
38+
anchors.top: parent.top
39+
anchors.margins: 10
40+
font.pixelSize: 16
41+
onCheckedChanged: {
42+
if (checked) {
43+
themeToggle.text = "Dark Theme"
44+
} else {
45+
themeToggle.text = "Light Theme"
46+
}
47+
}
48+
}
49+
50+
Column {
51+
anchors.centerIn: parent
52+
spacing: 10
53+
54+
Text {
55+
text: "Fibonacci Sequence Generator"
56+
font.pixelSize: 24
57+
color: themeToggle.checked ? "#000000" : "#61dafb"
58+
anchors.horizontalCenter: parent.horizontalCenter
59+
}
60+
61+
TextField {
62+
id: inputField
63+
width: 300
64+
placeholderText: "Enter the number of terms"
65+
anchors.horizontalCenter: parent.horizontalCenter
66+
font.pixelSize: 18
67+
inputMethodHints: Qt.ImhDigitsOnly
68+
color: themeToggle.checked ? "#000000" : "#ffffff"
69+
background: Rectangle {
70+
color: themeToggle.checked ? "#dddddd" : "#444444"
71+
radius: 5
72+
}
73+
}
74+
75+
Button {
76+
text: "Generate"
77+
width: 150
78+
height: 40
79+
anchors.horizontalCenter: parent.horizontalCenter
80+
onClicked: {
81+
if (inputField.text) {
82+
app.generateFibonacci(parseInt(inputField.text))
83+
} else {
84+
inputField.placeholderText = "Please enter a number"
85+
}
86+
}
87+
font.pixelSize: 18
88+
background: Rectangle {
89+
color: themeToggle.checked ? "#3498db" : "#2980b9"
90+
radius: 5
91+
}
92+
}
93+
94+
ListView {
95+
id: fibonacciList
96+
width: 300
97+
height: 100
98+
model: fibonacciModel
99+
delegate: Item {
100+
width: 300
101+
height: 30
102+
103+
Text {
104+
text: modelData
105+
font.pixelSize: 16
106+
color: themeToggle.checked ? "#000000" : "white"
107+
}
108+
}
109+
anchors.horizontalCenter: parent.horizontalCenter
110+
clip: true
111+
}
112+
113+
TextArea {
114+
id: outputArea
115+
width: 300
116+
height: 100
117+
readOnly: true
118+
font.pixelSize: 16
119+
color: themeToggle.checked ? "#000000" : "white"
120+
121+
wrapMode: TextEdit.Wrap
122+
text: app.fibonacciOutput
123+
anchors.horizontalCenter: parent.horizontalCenter
124+
}
125+
}
126+
}
127+
}

0 commit comments

Comments
 (0)