feat: make word-list size configurable from ui

main
mandlm 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() { void MainWindow::generateWordList() {
Timer timer; Timer timer;
word_list_ = WordListGenerator::generate(); word_list_ = WordListGenerator::generate(ui->wordListSizeSelector->value());
timer.stop(); timer.stop();
std::stringstream status_message; std::stringstream status_message;
@ -91,10 +91,22 @@ void MainWindow::showResults(
} }
void MainWindow::on_searchInput_textChanged(const QString &search_term) { void MainWindow::on_searchInput_textChanged(const QString &search_term) {
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
search(search_term); search(search_term);
QGuiApplication::restoreOverrideCursor();
} }
void MainWindow::on_searchAlgorithmSelector_currentIndexChanged(int) { void MainWindow::on_searchAlgorithmSelector_currentIndexChanged(int) {
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
createSelectedFinder(); createSelectedFinder();
search(ui->searchInput->displayText()); 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: private slots:
void on_searchInput_textChanged(const QString &search_term); void on_searchInput_textChanged(const QString &search_term);
void on_searchAlgorithmSelector_currentIndexChanged(int); void on_searchAlgorithmSelector_currentIndexChanged(int);
void on_wordListSizeSelector_valueChanged(int new_value);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;

View File

@ -35,6 +35,16 @@
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum> <enum>QLayout::SetDefaultConstraint</enum>
</property> </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"> <item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@ -42,6 +52,9 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QComboBox" name="searchAlgorithmSelector"/>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="sizePolicy"> <property name="sizePolicy">
@ -55,16 +68,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="0">
<widget class="QComboBox" name="searchAlgorithmSelector"/> <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>
<item row="0" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="searchInput"> <widget class="QSpinBox" name="wordListSizeSelector">
<property name="sizePolicy"> <property name="maximum">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <number>100</number>
<horstretch>0</horstretch> </property>
<verstretch>0</verstretch> <property name="value">
</sizepolicy> <number>1</number>
</property> </property>
</widget> </widget>
</item> </item>