aboutsummaryrefslogtreecommitdiff
path: root/lib/addressbar/addressbar.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2019-11-03 00:18:10 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2019-11-03 00:20:41 +0200
commitf3a4607d6a722a862af0eb9747a15dcdf624b6fb (patch)
tree9885709cdff55a865be6c03c591a9757680b0396 /lib/addressbar/addressbar.cpp
parentChange spdlog from makedepends to depends (diff)
downloadsmolbote-f3a4607d6a722a862af0eb9747a15dcdf624b6fb.tar.xz
Drop boost dependency
- wrote not-invented-here config file parser and conf class - spent obscene amount of time plugging in said conf class
Diffstat (limited to 'lib/addressbar/addressbar.cpp')
-rw-r--r--lib/addressbar/addressbar.cpp61
1 files changed, 0 insertions, 61 deletions
diff --git a/lib/addressbar/addressbar.cpp b/lib/addressbar/addressbar.cpp
deleted file mode 100644
index 2ea6d5e..0000000
--- a/lib/addressbar/addressbar.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "addressbar.h"
-#include "ui_addressbar.h"
-#include <QShortcut>
-
-AddressBar::AddressBar(const QHash<QString, QString> &config, QWidget *parent)
- : QWidget(parent)
- , ui(new Ui::AddressBar)
-{
- ui->setupUi(this);
-
- ui->urlBar->menuAction->setShortcut(QKeySequence(config.value("addressbar.shortcuts.menu")));
-
- auto *focusShortcut = new QShortcut(QKeySequence(config.value("addressbar.shortcuts.focus")), parent);
- connect(focusShortcut, &QShortcut::activated, ui->urlBar, [=]() {
- ui->urlBar->setFocus();
- ui->urlBar->selectAll();
- });
-
- connect(ui->urlBar, &UrlLineEdit::textEdited, [=](const QString &text) {
- std::function<void(QStringList &)> callback = std::bind(&UrlLineEdit::updateCompleter, ui->urlBar, std::placeholders::_1);
- emit complete(text, callback);
- });
-
- connect(ui->urlBar, &UrlLineEdit::returnPressed, [=]() {
- const QUrl url = QUrl::fromUserInput(ui->urlBar->text());
-
- // check if url contains \w+:// (matches protocol://) or contains a '.' (matches site.domain)
- // this is because single words are valid URLs for QUrl (searchterm becomes http://searchterm)
- // check for protocol://site because \. wouldn't match it (localhost is a search term; http://localhost is an address)
- if(ui->urlBar->text().contains(QRegularExpression("\\w+://|\\.")) && url.isValid()) {
- emit load(url);
- } else {
- emit search(ui->urlBar->text());
- }
- });
-}
-
-AddressBar::~AddressBar()
-{
- disconnect(this);
-}
-
-void AddressBar::setUrl(const QUrl &url)
-{
- if(url.isEmpty())
- ui->urlBar->clear();
- else
- ui->urlBar->setUrl(url);
-}
-
-void AddressBar::setProgress(int value) {
- ui->loadingBar->setValue(std::min(value, 100));
-}