Basic implementation

This commit is contained in:
ItsDrike 2025-02-25 18:59:49 +01:00
parent 54332b6384
commit e0178e27d2
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
4 changed files with 417 additions and 12 deletions

View file

@ -1,8 +1,107 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import PrimeNumbers
Window {
width: 640
height: 480
ApplicationWindow {
visible: true
title: qsTr("Hello World")
width: 400
height: 500
title: "Factorization"
FactorizationController {
id: factorizationController
}
ColumnLayout {
anchors.fill: parent
spacing: 10
Text {
text: "Enter a number to factorize:"
font.pixelSize: 16
Layout.alignment: Qt.AlignHCenter
}
TextField {
id: numberInput
placeholderText: "Enter number"
// NOTE: We can't use the IntValidator here, since it doesn't support 64-bit values (long long)
Layout.fillWidth: true
onTextChanged: {
// If the number changes, reset
factorizationController.reset();
}
}
RowLayout {
Layout.fillWidth: true
spacing: 10
Button {
text: {
if (factorizationController.isPaused) {
return "Resume";
} else if (factorizationController.isRunning) {
return "...";
} else {
return "Start";
}
}
Layout.fillWidth: true
enabled: !factorizationController.isRunning
onClicked: {
if (factorizationController.isPaused) {
factorizationController.resume();
} else {
factorizationController.start(parseInt(numberInput.text, 10));
}
}
}
Button {
text: "Pause"
Layout.fillWidth: true
enabled: factorizationController.isRunning
onClicked: factorizationController.stop()
}
}
ProgressBar {
Layout.fillWidth: true
from: 0
to: 100
value: factorizationController.progress
}
Text {
text: "Current Factor: " + factorizationController.currentFactor
font.pixelSize: 14
Layout.alignment: Qt.AlignHCenter
}
Text {
text: "Factors Found:"
font.pixelSize: 14
Layout.alignment: Qt.AlignHCenter
}
ListView {
Layout.fillWidth: true
Layout.fillHeight: true
model: factorizationController.factors
delegate: Text {
text: modelData
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
width: parent.width
}
}
Text {
text: "Warning: This only shows factors below sqrt(num)"
font.pixelSize: 12
Layout.alignment: Qt.AlignHCenter
}
}
}