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