diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-12-24 17:16:23 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-12-24 17:16:23 +0100 |
commit | 426151664c6d81a1db0b95bb61a6e30feb2c9df3 (patch) | |
tree | d759d7dd0302d45bd0beb827e0e9d5a011ad246c /src/lib/navigation | |
parent | Request filter now properly takes hostlists (diff) | |
download | smolbote-426151664c6d81a1db0b95bb61a6e30feb2c9df3.tar.xz |
Address bar menu now reads entries from the bookmarks
Diffstat (limited to 'src/lib/navigation')
-rw-r--r-- | src/lib/navigation/urllineedit.cpp | 17 | ||||
-rw-r--r-- | src/lib/navigation/urllineedit.h | 4 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/lib/navigation/urllineedit.cpp b/src/lib/navigation/urllineedit.cpp index 5d20cef..03e0c0f 100644 --- a/src/lib/navigation/urllineedit.cpp +++ b/src/lib/navigation/urllineedit.cpp @@ -18,9 +18,15 @@ // ssl menu #include <QLabel> -UrlLineEdit::UrlLineEdit(QWidget *parent) : +#include "mainwindow.h" +#include "lib/bookmarks/bookmarkswidget.h" + +UrlLineEdit::UrlLineEdit(MainWindow *window, QWidget *parent) : QLineEdit(parent) { + Q_CHECK_PTR(window); + m_window = window; + setPlaceholderText(tr("Enter address")); // ssl menu @@ -58,8 +64,8 @@ UrlLineEdit::UrlLineEdit(QWidget *parent) : m_menu->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool); listWidget = new QListWidget(); - listWidget->addItem("start.duckduckgo.com"); - listWidget->addItem("neueland.iserlohn-fortress.net"); +// listWidget->addItem("start.duckduckgo.com"); +// listWidget->addItem("neueland.iserlohn-fortress.net"); connect(listWidget, &QListWidget::itemSelectionChanged, this, [&]() { setText(listWidget->currentItem()->text()); @@ -189,6 +195,9 @@ void UrlLineEdit::clearTextFormat() void UrlLineEdit::showCompleter(const QString &text) { m_menu->move(mapToGlobal(QPoint(0, height()))); - //listWidget->setCurrentRow(0, QItemSelectionModel::SelectCurrent); + listWidget->clear(); + for(const QString &url : m_window->m_bookmarksWidget->bookmarksFor(text)) { + listWidget->addItem(url); + } m_menu->exec(); } diff --git a/src/lib/navigation/urllineedit.h b/src/lib/navigation/urllineedit.h index cef0830..1eea1ef 100644 --- a/src/lib/navigation/urllineedit.h +++ b/src/lib/navigation/urllineedit.h @@ -16,11 +16,12 @@ class QMenu; class QLabel; +class MainWindow; class UrlLineEdit : public QLineEdit { Q_OBJECT public: - explicit UrlLineEdit(QWidget *parent = nullptr); + explicit UrlLineEdit(MainWindow *window, QWidget *parent = nullptr); QAction *sslAction(); QAction *pageAction(); @@ -47,6 +48,7 @@ private: QTextLayout::FormatRange m_hostFormat; + MainWindow *m_window; QAction *m_sslAction = nullptr; QAction *m_pageAction = nullptr; |