Commit a26950bd authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Christoph Cullmann
Browse files

Make sure url bar works after hide => show

parent 893cccb7
......@@ -149,47 +149,59 @@ KateUrlBar::KateUrlBar(KateViewSpace *parent)
m_layout->setSpacing(0);
auto *vm = parent->viewManger();
connect(vm, &KateViewManager::viewChanged, this, [this, vm](KTextEditor::View *v) {
if (vm && !vm->showUrlNavBar()) {
return;
}
m_paths.clear();
connect(vm, &KateViewManager::viewChanged, this, &KateUrlBar::onViewChanged);
QLayoutItem *l;
while ((l = m_layout->takeAt(0)) != nullptr) {
delete l->widget();
delete l;
connect(vm, &KateViewManager::showUrlNavBarChanged, this, [this, vm](bool show) {
setHidden(!show);
if (show) {
onViewChanged(vm->activeView());
}
});
const auto url = v->document()->url();
if (url.isEmpty()) {
hide();
return;
}
setHidden(!vm->showUrlNavBar());
}
auto res = splittedUrl(url);
const auto &file = res.first;
const auto &dirs = res.second;
if (dirs.isEmpty() || file.isEmpty()) {
hide();
return;
}
void KateUrlBar::onViewChanged(KTextEditor::View *v)
{
if (!v) {
hide();
return;
}
for (const auto &dir : dirs) {
m_layout->addWidget(dirButton(dir.name, dir.path));
m_layout->addWidget(separatorLabel());
}
m_layout->addWidget(fileLabel(file));
m_layout->addStretch();
if (isHidden())
show();
});
auto *vm = static_cast<KateViewSpace *>(parentWidget())->viewManger();
if (vm && !vm->showUrlNavBar()) {
return;
}
m_paths.clear();
connect(vm, &KateViewManager::showUrlNavBarChanged, this, [this](bool show) {
setHidden(!show);
});
QLayoutItem *l;
while ((l = m_layout->takeAt(0)) != nullptr) {
delete l->widget();
delete l;
}
setHidden(!vm->showUrlNavBar());
const auto url = v->document()->url();
if (url.isEmpty()) {
hide();
return;
}
auto res = splittedUrl(url);
const auto &file = res.first;
const auto &dirs = res.second;
if (dirs.isEmpty() || file.isEmpty()) {
hide();
return;
}
for (const auto &dir : dirs) {
m_layout->addWidget(dirButton(dir.name, dir.path));
m_layout->addWidget(separatorLabel());
}
m_layout->addWidget(fileLabel(file));
m_layout->addStretch();
if (isHidden())
show();
}
std::pair<QString, QVector<KateUrlBar::DirNamePath>> KateUrlBar::splittedUrl(const QUrl &u)
......
......@@ -24,6 +24,7 @@ private:
QString path;
};
void onViewChanged(KTextEditor::View *v);
std::pair<QString, QVector<DirNamePath>> splittedUrl(const QUrl &u);
class QLabel *separatorLabel();
class QToolButton *dirButton(const QString &dirName, const QString &path);
......
Markdown is supported
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