diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-08 00:30:32 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-08 00:30:32 +0200 |
| commit | f02ccb928fd4ed591d2efe118a571e154f5df68a (patch) | |
| tree | 2fc7c4037423d074c410f4c53714ddc842d33351 /src/browsertab.cpp | |
| parent | 425f9d41cd337133d5677744eef937a8a2a61212 (diff) | |
| download | kristall-f02ccb928fd4ed591d2efe118a571e154f5df68a.tar.gz | |
Starts to implement gopher protocol and gophermap support. Heavily WIP, but you can already surf on gopherspace!
Diffstat (limited to 'src/browsertab.cpp')
| -rw-r--r-- | src/browsertab.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp index 2a24815..2e02433 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -3,6 +3,7 @@ #include "mainwindow.hpp" #include "geminirenderer.hpp" #include "settingsdialog.hpp" +#include "gophermaprenderer.hpp" #include <QTabWidget> #include <QMenu> @@ -38,6 +39,10 @@ BrowserTab::BrowserTab(MainWindow * mainWindow) : connect(&gemini_client, &GeminiClient::authorisedCertificateRequested, this, &BrowserTab::on_authorisedCertificateRequested); connect(&gemini_client, &GeminiClient::certificateRejected, this, &BrowserTab::on_certificateRejected); + connect(&gopher_client, &GopherClient::requestComplete, this, &BrowserTab::on_requestComplete); + connect(&gopher_client, &GopherClient::requestFailed, this, &BrowserTab::on_requestFailed); + + this->updateUI(); this->ui->graphics_browser->setVisible(false); @@ -72,6 +77,11 @@ void BrowserTab::navigateTo(const QUrl &url, PushToHistory mode) return; } + if(not gopher_client.cancelRequest()) { + QMessageBox::warning(this, "Kristall", "Failed to cancel running gopher request!"); + return; + } + this->redirection_count = 0; this->successfully_loaded = false; this->push_to_history_after_load = (mode == PushAfterSuccess); @@ -84,6 +94,10 @@ void BrowserTab::navigateTo(const QUrl &url, PushToHistory mode) { web_client.startRequest(url); } + else if(url.scheme() == "gopher") + { + gopher_client.startRequest(url); + } else if(url.scheme() == "about") { this->redirection_count = 0; @@ -204,14 +218,17 @@ void BrowserTab::on_requestComplete(const QByteArray &data, const QString &mime) this->ui->text_browser->setStyleSheet(QString("QTextBrowser { background-color: %1; }").arg(doc_style.background_color.name())); if(mime.startsWith("text/gemini")) { - - auto doc= GeminiRenderer::render( + document = GeminiRenderer::render( data, this->current_location, doc_style, this->outline); - - document = std::move(doc); + } + else if(mime.startsWith("text/gophermap")) { + document = GophermapRenderer::render( + data, + this->current_location, + doc_style); } else if(mime.startsWith("text/html")) { document = std::make_unique<QTextDocument>(); @@ -442,6 +459,8 @@ void BrowserTab::on_text_browser_highlighted(const QUrl &url) void BrowserTab::on_stop_button_clicked() { gemini_client.cancelRequest(); + web_client.cancelRequest(); + gopher_client.cancelRequest(); } void BrowserTab::on_back_button_clicked() |
