From 62fefb3183135c18d929d44ecac32f45217353ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Fri, 27 Jan 2017 15:57:21 +0000 Subject: [PATCH] url as combobox with completion --- src/testgui.hxx | 24 ++++++++++++++++++---- src/testgui.ui | 53 +++++++++++++++++++++++++++---------------------- 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/src/testgui.hxx b/src/testgui.hxx index 498d075..399973c 100644 --- a/src/testgui.hxx +++ b/src/testgui.hxx @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -49,8 +50,11 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { QSettings settings("mrw", "webtester"); restoreGeometry(settings.value("geometry").toByteArray()); restoreState(settings.value("windowstate").toByteArray()); + _url->completer()->setFilterMode(Qt::MatchContains); + _url->completer()->setCaseSensitivity(Qt::CaseInsensitive); + _url->completer()->setCompletionMode(QCompleter::PopupCompletion); if (!url.isEmpty()) { - _url->setText(url); + storeUrl(url); } TestWebPage* page(new TestWebPage(_web)); _web->setPage(page); @@ -70,8 +74,10 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { void on__load_clicked() { enterText(true); if (_record->isChecked()) - appendCommand("load "+map(_url->text())); - _web->load(_url->text()); + appendCommand("load "+map(_url->currentText())); + storeUrl(_url->currentText()); + _webprogress->setFormat(_url->currentText()); + _web->load(_url->currentText()); } void on__abort_clicked() { enterText(true); @@ -156,6 +162,9 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { _status->setCurrentIndex(STATUS_SUCCESS); } catch (std::exception &x) { _status->setCurrentIndex(STATUS_ERROR); + QMessageBox::critical(this, tr("Test Failed"), tr("Error [%1]: %2") + .arg(demangle(typeid(x).name())) + .arg(x.what())); } _run->setEnabled(true); _record->setEnabled(true); @@ -202,7 +211,8 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { //std::cout<<"titleChanged: "<setText(url.url()); + _webprogress->setFormat(url.url()); + storeUrl(url); enterText(true); if (_record->isChecked()) appendCommand("expect "+map("urlChanged "+url.url())); @@ -415,6 +425,12 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI { return false; } private: + void storeUrl(QUrl u) { + if (!_url->findText(u.url())) { + _url->addItem(u.url()); + _url->setCurrentText(u.url()); + } + } void loadFile(QString name) { QFile file(name); try { diff --git a/src/testgui.ui b/src/testgui.ui index f7321a4..b46b30c 100644 --- a/src/testgui.ui +++ b/src/testgui.ui @@ -33,15 +33,21 @@ URL: - - _url - - - - https:// + + + + 0 + 0 + + + + true + + + QComboBox::InsertAtTop @@ -752,7 +758,7 @@ this.dispatchEvent(evObj); Revert to saved - Ctrl+R + Ctrl+Shift+R @@ -774,28 +780,11 @@ this.dispatchEvent(evObj); - _url _load _web - - _url - returnPressed() - _load - click() - - - 493 - 343 - - - 580 - 344 - - - _selector returnPressed() @@ -1084,5 +1073,21 @@ this.dispatchEvent(evObj); + + _url + activated(int) + _load + click() + + + 277 + 315 + + + 549 + 315 + + +