mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-06-17 03:50:03 +02:00
gui/SearchWindow: adding "Dictionary file" widget.
This commit is contained in:
parent
50a2805c3f
commit
769e56af2f
2 changed files with 54 additions and 25 deletions
|
|
@ -22,6 +22,7 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QGridLayout>
|
||||
|
|
@ -39,6 +40,7 @@ QWidget (parent, flags),
|
|||
m_status ("status"),
|
||||
m_leet_cb ("L33t"),
|
||||
m_dict_lang ("Dictionary Language"),
|
||||
m_dict_file ("Dictionary File", true),
|
||||
m_btn_exec ("Search"),
|
||||
m_btn_clear ("Clear")
|
||||
{
|
||||
|
|
@ -55,29 +57,30 @@ m_btn_clear ("Clear")
|
|||
// ------------------------
|
||||
setLayout(&m_layout);
|
||||
m_layout.setColumnStretch(0, 10);
|
||||
m_layout.setColumnStretch(1, 10);
|
||||
|
||||
// First row.
|
||||
m_dict_lang.addItems(get_files(CONFIG_DICT_FULL_PATH));
|
||||
m_layout.addWidget(&m_dict_lang, 0, 0);
|
||||
m_layout.addWidget(&m_dict_file, 0, 1);
|
||||
|
||||
m_layout.addWidget(&m_leet_cb, 0, 1);
|
||||
m_layout.addWidget(&m_leet_cb, 0, 2);
|
||||
|
||||
m_num_threads.setValue((int) eoskeygen::KeySearch::max_threads());
|
||||
m_num_threads.setRange(1, (int) eoskeygen::KeySearch::max_threads());
|
||||
m_num_threads.setSuffix(" Threads");
|
||||
m_layout.addWidget(&m_num_threads, 0, 2);
|
||||
m_layout.addWidget(&m_num_threads, 0, 3);
|
||||
|
||||
m_num_results.setValue(10);
|
||||
m_num_results.setRange(1, 99);
|
||||
m_num_results.setSuffix(" Results");
|
||||
m_layout.addWidget(&m_num_results, 0, 3);
|
||||
m_layout.addWidget(&m_num_results, 0, 4);
|
||||
|
||||
// Second row.
|
||||
m_layout.addWidget(&m_status, 1, 0, 1, 2);
|
||||
m_layout.addWidget(&m_txt_search, 1, 0, 1, 2);
|
||||
m_layout.addWidget(&m_btn_exec, 1, 2);
|
||||
m_layout.addWidget(&m_btn_clear, 1, 3);
|
||||
|
||||
m_layout.addWidget(&m_status, 1, 0, 1, 3);
|
||||
m_layout.addWidget(&m_txt_search, 1, 0, 1, 3);
|
||||
m_layout.addWidget(&m_btn_exec, 1, 3);
|
||||
m_layout.addWidget(&m_btn_clear, 1, 4);
|
||||
|
||||
// Third row.
|
||||
m_layout.addWidget(&m_output, 2, 0, 1, 0);
|
||||
|
|
@ -105,7 +108,35 @@ void SearchWindow::initSignals()
|
|||
|
||||
connect(this, SIGNAL(addOutput(QString)), this, SLOT(output(QString)));
|
||||
|
||||
connect(&m_dict_lang, SIGNAL(selectionChanged(QStringList)), this, SLOT(langSelected(QStringList)));
|
||||
connect(&m_dict_file, SIGNAL(addNewItem()), this, SLOT(langFileAdd()));
|
||||
}
|
||||
|
||||
void SearchWindow::loadDictionaries()
|
||||
{
|
||||
QStringList list;
|
||||
eoskeygen::Dictionary tmpDict;
|
||||
std::string base_path(CONFIG_DICT_FULL_PATH);
|
||||
|
||||
// Clear dictionary first.
|
||||
m_dict.clear();
|
||||
|
||||
// Go through all selected languages.
|
||||
list = m_dict_lang.getSelectedItems();
|
||||
for(QStringList::const_iterator it = list.cbegin(); it != list.cend(); it++) {
|
||||
|
||||
// Load and add them to dictionary.
|
||||
tmpDict.loadFromFile(base_path + "/" + it->toStdString());
|
||||
m_dict.add(tmpDict);
|
||||
}
|
||||
|
||||
// Go through all selected files.
|
||||
list = m_dict_file.getSelectedItems();
|
||||
for(QStringList::const_iterator it = list.cbegin(); it != list.cend(); it++) {
|
||||
|
||||
// Load and add them to dictionary.
|
||||
tmpDict.loadFromFile(it->toStdString());
|
||||
m_dict.add(tmpDict);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchWindow::onResult(const struct libeosio::ec_keypair* key, const struct eoskeygen::KeySearch::result& result)
|
||||
|
|
@ -173,6 +204,8 @@ void SearchWindow::search()
|
|||
return;
|
||||
}
|
||||
|
||||
loadDictionaries();
|
||||
|
||||
m_ksearch.clear();
|
||||
m_ksearch.addList(list);
|
||||
m_ksearch.setThreadCount(m_num_threads.value());
|
||||
|
|
@ -200,22 +233,12 @@ void SearchWindow::output(const QString& html)
|
|||
m_output.verticalScrollBar()->setValue(m_output.verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
void SearchWindow::langSelected(QStringList selected)
|
||||
void SearchWindow::langFileAdd()
|
||||
{
|
||||
std::string base_path(CONFIG_DICT_FULL_PATH);
|
||||
QStringList files = QFileDialog::getOpenFileNames(this,
|
||||
"Select one or more language files");
|
||||
|
||||
// Clear dictionary first.
|
||||
m_dict.clear();
|
||||
|
||||
// Go through all selected languages.
|
||||
for(QStringList::const_iterator it = selected.cbegin(); it != selected.cend(); it++) {
|
||||
|
||||
// Load and add them to dictionary.
|
||||
eoskeygen::Dictionary dict;
|
||||
dict.loadFromFile(base_path + "/" + it->toStdString());
|
||||
|
||||
m_dict.add(dict);
|
||||
}
|
||||
m_dict_file.addItems(files, true);
|
||||
}
|
||||
|
||||
void SearchWindow::searchStarted()
|
||||
|
|
@ -223,6 +246,7 @@ void SearchWindow::searchStarted()
|
|||
m_txt_search.setEnabled(false);
|
||||
m_txt_search.setHidden(true);
|
||||
m_dict_lang.setEnabled(false);
|
||||
m_dict_file.setEnabled(false);
|
||||
m_leet_cb.setEnabled(false);
|
||||
m_btn_exec.setEnabled(false);
|
||||
m_btn_clear.setEnabled(false);
|
||||
|
|
@ -235,6 +259,7 @@ void SearchWindow::searchFinished()
|
|||
m_txt_search.setEnabled(true);
|
||||
m_txt_search.setHidden(false);
|
||||
m_dict_lang.setEnabled(true);
|
||||
m_dict_file.setEnabled(true);
|
||||
m_leet_cb.setEnabled(true);
|
||||
m_btn_exec.setEnabled(true);
|
||||
m_btn_clear.setEnabled(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue