feat: make word-list size configurable from ui

This commit is contained in:
Michael Mandl 2024-03-20 18:38:44 +01:00
parent 48283d0d76
commit 291d8d198e
Signed by: mandlm
GPG key ID: 4AA25D647AA54CC7
3 changed files with 40 additions and 10 deletions

View file

@ -33,7 +33,7 @@ void MainWindow::setupAlgorithmSelector() {
void MainWindow::generateWordList() {
Timer timer;
word_list_ = WordListGenerator::generate();
word_list_ = WordListGenerator::generate(ui->wordListSizeSelector->value());
timer.stop();
std::stringstream status_message;
@ -91,10 +91,22 @@ void MainWindow::showResults(
}
void MainWindow::on_searchInput_textChanged(const QString &search_term) {
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
search(search_term);
QGuiApplication::restoreOverrideCursor();
}
void MainWindow::on_searchAlgorithmSelector_currentIndexChanged(int) {
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
createSelectedFinder();
search(ui->searchInput->displayText());
QGuiApplication::restoreOverrideCursor();
}
void MainWindow::on_wordListSizeSelector_valueChanged(int) {
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
generateWordList();
createSelectedFinder();
search(ui->searchInput->displayText());
QGuiApplication::restoreOverrideCursor();
}

View file

@ -35,6 +35,7 @@ private:
private slots:
void on_searchInput_textChanged(const QString &search_term);
void on_searchAlgorithmSelector_currentIndexChanged(int);
void on_wordListSizeSelector_valueChanged(int new_value);
private:
Ui::MainWindow *ui;

View file

@ -35,6 +35,16 @@
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="searchInput">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@ -42,6 +52,9 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="searchAlgorithmSelector"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
@ -55,16 +68,20 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="searchAlgorithmSelector"/>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select word-list size&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="searchInput">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="2" column="1">
<widget class="QSpinBox" name="wordListSizeSelector">
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>