aboutsummaryrefslogtreecommitdiff
path: root/src/addressbar
diff options
context:
space:
mode:
Diffstat (limited to 'src/addressbar')
-rw-r--r--src/addressbar/completer.h4
-rw-r--r--src/addressbar/urllineedit.cpp18
-rw-r--r--src/addressbar/urllineedit.h7
3 files changed, 15 insertions, 14 deletions
diff --git a/src/addressbar/completer.h b/src/addressbar/completer.h
index ce19f07..daef67c 100644
--- a/src/addressbar/completer.h
+++ b/src/addressbar/completer.h
@@ -21,14 +21,12 @@ class Completer : public QListView
public:
explicit Completer(QWidget *parent = nullptr);
- bool updateItems(const QList<QTreeWidgetItem*> &list);
+ bool updateItems(const QList<QTreeWidgetItem *> &list);
bool keyPressed(QKeyEvent *event);
private:
QStringListModel *completionModel;
-
};
-
#endif //SMOLBOTE_COMPLETER_H
diff --git a/src/addressbar/urllineedit.cpp b/src/addressbar/urllineedit.cpp
index cf2c08b..8aa03c7 100644
--- a/src/addressbar/urllineedit.cpp
+++ b/src/addressbar/urllineedit.cpp
@@ -7,6 +7,7 @@
*/
#include "urllineedit.h"
+#include "webengine/webview.h"
#include <QLabel>
#include <QMenu>
#include <QShortcut>
@@ -18,19 +19,13 @@ UrlLineEdit::UrlLineEdit(const QHash<QString, QString> &config, QWidget *parent)
: QLineEdit(parent)
, m_listView(new Completer(this))
{
- auto *focusShortcut = new QShortcut(QKeySequence(config.value("addressbar.shortcuts.focus")), parent);
- connect(focusShortcut, &QShortcut::activated, this, [this]() {
- setFocus();
- selectAll();
- });
-
setPlaceholderText(tr("Enter address"));
m_listView->setVisible(false);
connect(this, &UrlLineEdit::textEdited, this, &UrlLineEdit::updateCompleter);
m_pageMenuAction = addAction(style()->standardIcon(QStyle::SP_DriveNetIcon), QLineEdit::LeadingPosition);
- m_pageMenuAction->setShortcut(QKeySequence(config.value("addressbar.shortcuts.pageMenu")));
+ m_pageMenuAction->setShortcut(QKeySequence("F2"));
m_pageMenuAction->setToolTip(tr("Page Actions (%1)").arg(m_pageMenuAction->shortcut().toString()));
connect(m_pageMenuAction, &QAction::triggered, m_pageMenuAction, [&]() {
if(m_pageMenuAction->menu()) {
@@ -39,7 +34,7 @@ UrlLineEdit::UrlLineEdit(const QHash<QString, QString> &config, QWidget *parent)
});
m_toolsMenuAction = addAction(style()->standardIcon(QStyle::SP_FileIcon), QLineEdit::TrailingPosition);
- m_toolsMenuAction->setShortcut(QKeySequence(config.value("addressbar.shortcuts.toolsMenu")));
+ m_toolsMenuAction->setShortcut(QKeySequence("F10"));
m_toolsMenuAction->setToolTip(tr("Tools (%1)").arg(m_toolsMenuAction->shortcut().toString()));
connect(m_toolsMenuAction, &QAction::triggered, m_toolsMenuAction, [&]() {
if(m_toolsMenuAction->menu()) {
@@ -56,7 +51,11 @@ UrlLineEdit::UrlLineEdit(const QHash<QString, QString> &config, QWidget *parent)
if(this->text().startsWith('#')) {
emit searchTermEntered(this->text().mid(1));
} else {
- emit addressEntered(QUrl::fromUserInput(this->text()));
+ if(m_view) {
+ m_view->load(QUrl::fromUserInput(this->text()));
+ } else {
+ this->clear();
+ }
}
this->clearFocus();
});
@@ -71,6 +70,7 @@ void UrlLineEdit::setCompleterModel(BookmarksView *model)
void UrlLineEdit::connectWebView(WebView *view)
{
Q_CHECK_PTR(view);
+ m_view = view;
disconnect(urlChangedConnection);
diff --git a/src/addressbar/urllineedit.h b/src/addressbar/urllineedit.h
index 17465bc..24ad403 100644
--- a/src/addressbar/urllineedit.h
+++ b/src/addressbar/urllineedit.h
@@ -9,15 +9,16 @@
#ifndef SMOLBOTE_URLLINEEDIT_H
#define SMOLBOTE_URLLINEEDIT_H
+#include "completer.h"
+#include "webengine/webview.h"
#include <QAction>
#include <QLineEdit>
#include <QTextLayout>
-#include "webengine/webview.h"
-#include "completer.h"
class BookmarksView;
class QMenu;
class QLabel;
+class WebView;
class UrlLineEdit : public QLineEdit
{
Q_OBJECT
@@ -45,6 +46,8 @@ private:
void setTextFormat(const QTextLayout::FormatRange &format);
void clearTextFormat();
+ WebView *m_view = nullptr;
+
QTextLayout::FormatRange m_hostFormat;
// pageMenu action: zoom, print