aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Skec <skec@protonmail.ch>2021-01-03 11:06:13 +1100
committerFelix Queißner <felix@ib-queissner.de>2021-01-04 11:06:26 +0100
commitf93bc413e9325750c8d41a465090058386518cfc (patch)
tree51fc2647c171df9ad9b8039a6c454c1cd70e2035 /src
parent7fe5c148ff4083c3938f145a53f00f643985659b (diff)
downloadkristall-f93bc413e9325750c8d41a465090058386518cfc.tar.gz
Added 'busy' cursor while current tab is loading
Diffstat (limited to 'src')
-rw-r--r--src/browsertab.cpp12
-rw-r--r--src/browsertab.hpp2
-rw-r--r--src/widgets/kristalltextbrowser.cpp20
-rw-r--r--src/widgets/kristalltextbrowser.hpp5
4 files changed, 39 insertions, 0 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp
index 687dcd8..e8b8443 100644
--- a/src/browsertab.cpp
+++ b/src/browsertab.cpp
@@ -485,6 +485,8 @@ void BrowserTab::on_requestComplete(const QByteArray &ref_data, const QString &m
this->current_stats.mime_type = mime;
this->current_stats.loading_time = this->timer.elapsed();
emit this->fileLoaded(this->current_stats);
+
+ this->updateMouseCursor(false);
}
void BrowserTab::renderPage(const QByteArray &data, const MimeType &mime)
@@ -1263,6 +1265,8 @@ void BrowserTab::addProtocolHandler(std::unique_ptr<ProtocolHandler> &&handler)
bool BrowserTab::startRequest(const QUrl &url, ProtocolHandler::RequestOptions options)
{
+ this->updateMouseCursor(true);
+
this->current_server_certificate = QSslCertificate { };
this->current_handler = nullptr;
@@ -1359,6 +1363,14 @@ bool BrowserTab::startRequest(const QUrl &url, ProtocolHandler::RequestOptions o
return this->current_handler->startRequest(url.adjusted(QUrl::RemoveFragment), options);
}
+void BrowserTab::updateMouseCursor(bool waiting)
+{
+ if (waiting)
+ this->ui->text_browser->setDefaultCursor(Qt::BusyCursor);
+ else
+ this->ui->text_browser->setDefaultCursor(Qt::ArrowCursor);
+}
+
bool BrowserTab::enableClientCertificate(const CryptoIdentity &ident)
{
if (not ident.isValid())
diff --git a/src/browsertab.hpp b/src/browsertab.hpp
index 2b3854e..52340d9 100644
--- a/src/browsertab.hpp
+++ b/src/browsertab.hpp
@@ -166,6 +166,8 @@ private:
bool startRequest(QUrl const & url, ProtocolHandler::RequestOptions options);
+ void updateMouseCursor(bool waiting);
+
bool enableClientCertificate(CryptoIdentity const & ident);
void disableClientCertificate();
public:
diff --git a/src/widgets/kristalltextbrowser.cpp b/src/widgets/kristalltextbrowser.cpp
index c813b05..f94485e 100644
--- a/src/widgets/kristalltextbrowser.cpp
+++ b/src/widgets/kristalltextbrowser.cpp
@@ -28,7 +28,27 @@ void KristallTextBrowser::mouseReleaseEvent(QMouseEvent *event)
}
}
+void KristallTextBrowser::mouseMoveEvent(QMouseEvent *event)
+{
+ QTextBrowser::mouseMoveEvent(event);
+
+ // This slight hack allows us to set the "default" cursor,
+ // (i.e when not hovering over links) We need to do this
+ // because QTextBrowser for some reason resets viewport cursor
+ // to ArrowCursor after we hover over links
+ const QCursor& cur = this->viewport()->cursor();
+ if (cur != this->wanted_cursor && cur != Qt::PointingHandCursor)
+ {
+ this->viewport()->setCursor(wanted_cursor);
+ }
+}
+
void KristallTextBrowser::on_anchorClicked(const QUrl &url)
{
emit this->anchorClicked(url, this->signal_new_tab);
}
+
+void KristallTextBrowser::setDefaultCursor(const QCursor &cur)
+{
+ this->wanted_cursor = cur;
+}
diff --git a/src/widgets/kristalltextbrowser.hpp b/src/widgets/kristalltextbrowser.hpp
index def130a..cf0101a 100644
--- a/src/widgets/kristalltextbrowser.hpp
+++ b/src/widgets/kristalltextbrowser.hpp
@@ -12,6 +12,10 @@ public:
void mouseReleaseEvent(QMouseEvent * event) override;
+ void mouseMoveEvent(QMouseEvent * event) override;
+
+ void setDefaultCursor(QCursor const & shape);
+
signals:
void anchorClicked(QUrl const &, bool open_in_new_tab);
@@ -20,6 +24,7 @@ private: // slots
private:
bool signal_new_tab = false;
+ QCursor wanted_cursor;
};
#endif // KRISTALLTEXTBROWSER_HPP