diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-06 23:38:05 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-06 23:38:05 +0200 |
| commit | 6887cd80266a8041f31b55b65c142a85239f15a1 (patch) | |
| tree | a3ceabb995fc31b6e77eb23cc2dad5d3bc4846fb /src/browsertab.cpp | |
| parent | 3aed883402dc8da829fc304434c5efd0570cbb97 (diff) | |
| download | kristall-6887cd80266a8041f31b55b65c142a85239f15a1.tar.gz | |
Adds rendering of about:blank and about:favourites.
Diffstat (limited to 'src/browsertab.cpp')
| -rw-r--r-- | src/browsertab.cpp | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp index 6a4bf69..5f58704 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -51,10 +51,11 @@ BrowserTab::~BrowserTab() void BrowserTab::navigateTo(const QUrl &url, PushToHistory mode) { // TODO: Implement about:// scheme! - if(url.scheme() != "gemini") { + if(url.scheme() != "gemini" and url.scheme() != "about") { QMessageBox::warning(this, "Kristall", "Unsupported uri scheme: " + url.scheme()); return; } + this->current_location = url; this->ui->url_bar->setText(url.toString()); @@ -63,11 +64,44 @@ void BrowserTab::navigateTo(const QUrl &url, PushToHistory mode) return; } - this->redirection_count = 0; - this->successfully_loaded = false; - this->push_to_history_after_load = (mode == PushAfterSuccess); + if(url.scheme() == "gemini") + { + this->redirection_count = 0; + this->successfully_loaded = false; + this->push_to_history_after_load = (mode == PushAfterSuccess); + gemini_client.startRequest(url); + } + else if(url.scheme() == "about") + { + this->redirection_count = 0; + this->push_to_history_after_load = false; + + if(mode == PushAfterSuccess) + mode = PushImmediate; + if(url.path() == "blank") + { + this->on_gemini_complete("", "text/gemini"); + } + else if(url.path() == "favourites") + { + QByteArray document; + + document.append("# Favourites\n"); + document.append("\n"); + + for(auto const & fav : this->mainWindow->favourites.getAll()) + { + document.append("=> " + fav.toString().toUtf8() + "\n"); + } + + this->on_gemini_complete(document, "text/gemini"); + } + else + { + QMessageBox::warning(this, "Kristall", "Unknown location: " + url.path()); + } + } - gemini_client.startRequest(url); switch(mode) { @@ -135,7 +169,6 @@ void BrowserTab::on_gemini_complete(const QByteArray &data, const QString &mime) { qDebug() << "Loaded" << data.length() << "bytes of type" << mime; - this->graphics_scene.clear(); this->ui->text_browser->setText(""); |
