import QtQuick import QtQuick.Controls import QtQuick.Layouts import PrimeNumbers ApplicationWindow { visible: true 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 } } }