Commit b08003ff authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

update url bar on url modifications

this properly tracks e.g. saveAs or
the "we switch to new file in the current one"
parent f2e0bdf5
Pipeline #137370 passed with stage
in 5 minutes and 19 seconds
......@@ -439,22 +439,40 @@ KateUrlBar::KateUrlBar(KateViewSpace *parent)
void KateUrlBar::onViewChanged(KTextEditor::View *v)
{
if (!v) {
updateForDocument(nullptr);
hide();
return;
}
updateForDocument(v->document());
}
void KateUrlBar::updateForDocument(KTextEditor::Document *doc)
{
// always disconnect and perhaps set nullptr doc
if (m_currentDoc) {
disconnect(m_currentDoc, &KTextEditor::Document::documentUrlChanged, this, &KateUrlBar::updateForDocument);
}
m_currentDoc = doc;
if (!doc) {
return;
}
// we want to watch for url changed
connect(m_currentDoc, &KTextEditor::Document::documentUrlChanged, this, &KateUrlBar::updateForDocument);
auto *vm = static_cast<KateViewSpace *>(parentWidget())->viewManger();
if (vm && !vm->showUrlNavBar()) {
return;
}
const auto url = v->document()->url();
const auto url = doc->url();
if (url.isEmpty() || !url.isLocalFile()) {
hide();
return;
}
m_breadCrumbView->setUrl(v->document()->url());
m_breadCrumbView->setUrl(url);
if (isHidden())
show();
......
......@@ -6,7 +6,9 @@
#define KATE_URL_BAR_H
#include "kateviewspace.h"
#include <QFrame>
#include <QPointer>
class KateUrlBar : public QWidget
{
......@@ -19,7 +21,12 @@ Q_SIGNALS:
private:
void onViewChanged(KTextEditor::View *v);
void updateForDocument(KTextEditor::Document *doc);
class BreadCrumbView *m_breadCrumbView;
// document for which the url bar is currently active
// might be nullptr
QPointer<KTextEditor::Document> m_currentDoc;
};
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment