10#include "kurlnavigator.h"
11#include "kcoreurlnavigator.h"
13#include "../utils_p.h"
14#include "kurlnavigatorbutton_p.h"
15#include "kurlnavigatordropdownbutton_p.h"
16#include "kurlnavigatorpathselectoreventfilter_p.h"
17#include "kurlnavigatorplacesselector_p.h"
18#include "kurlnavigatorschemecombo_p.h"
19#include "kurlnavigatortogglebutton_p.h"
22#include <KLocalizedString>
24#include <kfileplacesmodel.h>
25#include <kprotocolinfo.h>
26#include <kurifilter.h>
27#include <kurlcombobox.h>
28#include <kurlcompletion.h>
30#include <QActionGroup>
31#include <QApplication>
40#include <QMimeDatabase>
50using namespace KDEPrivate;
52struct KUrlNavigatorData {
55Q_DECLARE_METATYPE(KUrlNavigatorData)
57class KUrlNavigatorPrivate
60 KUrlNavigatorPrivate(
const QUrl &url, KUrlNavigator *qq, KFilePlacesModel *placesModel);
62 ~KUrlNavigatorPrivate()
64 m_dropDownButton->removeEventFilter(q);
65 m_pathBox->removeEventFilter(q);
66 m_toggleEditableMode->removeEventFilter(q);
68 for (KUrlNavigatorButton *button : std::as_const(m_navButtons)) {
69 button->removeEventFilter(q);
73 enum class ApplyUrlMethod {
81 void applyUncommittedUrl(ApplyUrlMethod method);
82 void slotApplyUrl(QUrl url);
86 std::optional<QUrl> checkFilters(
const QString &text);
88 void slotReturnPressed();
89 void slotSchemeChanged(
const QString &);
90 void openPathSelectorMenu();
97 void appendWidget(QWidget *widget,
int stretch = 0);
103 void slotToggleEditableButtonPressed();
112 void dropUrls(
const QUrl &destination, QDropEvent *event, KUrlNavigatorButton *dropButton);
125 void openContextMenu(
const QPoint &p);
127 void slotPathBoxChanged(
const QString &text);
129 void updateContent();
139 void updateButtons(
int startIndex);
146 void updateButtonVisibility();
154 void updateTabOrder();
159 QString firstButtonText()
const;
164 QUrl buttonUrl(
int index)
const;
166 void switchToBreadcrumbMode();
172 void deleteButtons();
181 QUrl retrievePlaceUrl()
const;
183 KUrlNavigator *
const q;
185 QHBoxLayout *m_layout =
new QHBoxLayout(q);
186 KCoreUrlNavigator *m_coreUrlNavigator =
nullptr;
187 QList<KUrlNavigatorButton *> m_navButtons;
188 QStringList m_supportedSchemes;
190 KUrlNavigatorPlacesSelector *m_placesSelector =
nullptr;
191 KUrlComboBox *m_pathBox =
nullptr;
192 KUrlNavigatorSchemeCombo *m_schemes =
nullptr;
193 KUrlNavigatorDropDownButton *m_dropDownButton =
nullptr;
194 KUrlNavigatorButtonBase *m_toggleEditableMode =
nullptr;
195 QWidget *m_dropWidget =
nullptr;
196 QWidget *m_badgeWidgetContainer =
nullptr;
198 bool m_editable =
false;
199 bool m_active =
true;
200 bool m_showPlacesSelector =
false;
201 bool m_showFullPath =
false;
202 bool m_backgroundEnabled =
true;
207 bool showHidden =
false;
208 bool sortHiddenLast =
false;
209 } m_subfolderOptions;
215 , m_showPlacesSelector(placesModel != nullptr)
217 m_layout->setSpacing(0);
218 m_layout->setContentsMargins(0, 0, 0, 0);
222 q->connect(m_coreUrlNavigator, &KCoreUrlNavigator::currentLocationUrlChanged, q, [
this]() {
223 Q_EMIT q->urlChanged(m_coreUrlNavigator->currentLocationUrl());
226 Q_EMIT q->urlAboutToBeChanged(url);
228 q->connect(m_coreUrlNavigator, &KCoreUrlNavigator::historySizeChanged, q, [
this]() {
229 Q_EMIT q->historyChanged();
231 q->connect(m_coreUrlNavigator, &KCoreUrlNavigator::historyIndexChanged, q, [
this]() {
232 Q_EMIT q->historyChanged();
235 Q_EMIT q->historyChanged();
238 Q_EMIT q->urlSelectionRequested(url);
242 q->setAutoFillBackground(
false);
244 if (placesModel !=
nullptr) {
245 m_placesSelector =
new KUrlNavigatorPlacesSelector(q, placesModel);
249 auto updateContentFunc = [
this]() {
258 m_schemes =
new KUrlNavigatorSchemeCombo(
QString(), q);
259 q->connect(m_schemes, &KUrlNavigatorSchemeCombo::activated, q, [
this](
const QString &schene) {
260 slotSchemeChanged(schene);
264 m_dropDownButton =
new KUrlNavigatorDropDownButton(q);
266 m_dropDownButton->installEventFilter(q);
267 q->connect(m_dropDownButton, &KUrlNavigatorDropDownButton::clicked, q, [
this]() {
268 openPathSelectorMenu();
272 m_pathBox =
new KUrlComboBox(KUrlComboBox::Directories,
true, q);
274 m_pathBox->installEventFilter(q);
275 m_pathBox->setAutoFillBackground(
false);
277 m_pathBox->setFrame(
false);
280 m_pathBox->setCompletionObject(kurlCompletion);
281 m_pathBox->setAutoDeleteCompletionObject(
true);
289 slotPathBoxChanged(text);
292 m_badgeWidgetContainer =
new QWidget(q);
293 auto badgeLayout =
new QHBoxLayout(m_badgeWidgetContainer);
294 badgeLayout->setContentsMargins(0, 0, 0, 0);
298 m_toggleEditableMode =
new KUrlNavigatorToggleButton(q);
299 m_toggleEditableMode->installEventFilter(q);
300 m_toggleEditableMode->setMinimumWidth(20);
301 q->connect(m_toggleEditableMode, &KUrlNavigatorToggleButton::clicked, q, [
this]() {
302 slotToggleEditableButtonPressed();
305 if (m_placesSelector !=
nullptr) {
306 m_layout->addWidget(m_placesSelector);
308 m_layout->addWidget(m_schemes);
309 m_layout->addWidget(m_dropDownButton);
310 m_layout->addWidget(m_pathBox, 1);
311 m_layout->addWidget(m_badgeWidgetContainer);
313 m_layout->addWidget(m_toggleEditableMode);
323 q->rect().adjust(0, -1, 0, 1);
324 q->setContentsMargins(paddingLeft, 1, paddingRight, 1);
325 m_pathBox->setContentsMargins(paddingLeft, 0, paddingRight, 0);
328void KUrlNavigatorPrivate::appendWidget(
QWidget *widget,
int stretch)
331 m_layout->insertWidget(m_layout->count() - 2, widget, stretch);
334void KUrlNavigatorPrivate::slotApplyUrl(
QUrl url)
344 url.
setPath(QStringLiteral(
"/"));
348 QStringList urls = m_pathBox->urls();
351 m_pathBox->setUrls(urls, KUrlComboBox::RemoveBottom);
353 q->setLocationUrl(url);
356 m_pathBox->setUrl(q->locationUrl());
359std::optional<QUrl> KUrlNavigatorPrivate::checkFilters(
const QString &text)
361 KUriFilterData filteredData(text);
362 filteredData.setCheckForExecutables(
false);
364 const auto filtersList = QStringList{QStringLiteral(
"kshorturifilter")};
367 return filteredData.uri();
372void KUrlNavigatorPrivate::applyUncommittedUrl(ApplyUrlMethod method)
374 const QString text = m_pathBox->currentText().
trimmed();
375 QUrl url = q->locationUrl();
377 auto applyUrl = [
this, method](
const QUrl &url) {
379 case ApplyUrlMethod::Apply:
382 case ApplyUrlMethod::Tab:
383 Q_EMIT q->tabRequested(url);
385 case ApplyUrlMethod::ActiveTab:
386 Q_EMIT q->activeTabRequested(url);
388 case ApplyUrlMethod::NewWindow:
389 Q_EMIT q->newWindowRequested(url);
399 if (
const auto filteredUrl = checkFilters(text); filteredUrl) {
400 applyUrl(*filteredUrl);
416 q->connect(job, &
KJob::result, q, [
this, job, text, applyUrl]() {
420 if (!job->error() && job->statResult().isDir()) {
421 applyUrl(job->url());
426 if (
const auto filteredUrl = checkFilters(text); filteredUrl) {
427 applyUrl(*filteredUrl);
436void KUrlNavigatorPrivate::slotReturnPressed()
442 applyUncommittedUrl(ApplyUrlMethod::Tab);
444 applyUncommittedUrl(ApplyUrlMethod::ActiveTab);
447 applyUncommittedUrl(ApplyUrlMethod::NewWindow);
449 applyUncommittedUrl(ApplyUrlMethod::Apply);
451 Q_EMIT q->returnPressed();
458 auto switchModeFunc = [
this]() {
459 switchToBreadcrumbMode();
465void KUrlNavigatorPrivate::slotSchemeChanged(
const QString &scheme)
467 Q_ASSERT(m_editable);
475 url.
setPath(QStringLiteral(
"/"));
482 m_pathBox->setEditUrl(url);
485void KUrlNavigatorPrivate::openPathSelectorMenu()
487 if (m_navButtons.count() <= 0) {
491 const QUrl firstVisibleUrl = m_navButtons.constFirst()->url();
494 QPointer<QMenu> popup =
new QMenu(q);
496 auto *popupFilter =
new KUrlNavigatorPathSelectorEventFilter(popup.
data());
498 popup->installEventFilter(popupFilter);
500 const QUrl placeUrl = retrievePlaceUrl();
501 int idx = placeUrl.
path().
count(QLatin1Char(
'/'));
504 const QString
path = m_coreUrlNavigator->locationUrl(m_coreUrlNavigator->historyIndex()).path();
505 QString dirName =
path.
section(QLatin1Char(
'/'), idx, idx);
508 dirName = QStringLiteral(
"/");
514 const QString text = spacer + dirName;
516 QAction *action =
new QAction(text, popup);
517 const QUrl currentUrl = buttonUrl(idx);
518 if (currentUrl == firstVisibleUrl) {
519 popup->addSeparator();
522 popup->addAction(action);
525 spacer.
append(QLatin1String(
" "));
526 dirName =
path.
section(QLatin1Char(
'/'), idx, idx);
527 }
while (!dirName.isEmpty());
529 const QPoint pos = q->mapToGlobal(m_dropDownButton->geometry().bottomRight());
530 const QAction *activatedAction = popup->exec(pos);
531 if (activatedAction !=
nullptr) {
533 q->setLocationUrl(url);
538 popup->deleteLater();
542void KUrlNavigatorPrivate::slotToggleEditableButtonPressed()
545 applyUncommittedUrl(ApplyUrlMethod::Apply);
551void KUrlNavigatorPrivate::switchView()
553 m_toggleEditableMode->setFocus();
554 m_editable = !m_editable;
555 m_toggleEditableMode->setChecked(m_editable);
557 if (q->isUrlEditable()) {
558 m_pathBox->setFixedHeight(m_badgeWidgetContainer->height());
559 m_pathBox->setFocus();
562 q->requestActivation();
563 Q_EMIT q->editableStateChanged(m_editable);
568void KUrlNavigatorPrivate::dropUrls(
const QUrl &destination,
QDropEvent *event, KUrlNavigatorButton *dropButton)
570 if (
event->mimeData()->hasUrls()) {
571 m_dropWidget = qobject_cast<QWidget *>(dropButton);
572 Q_EMIT q->urlsDropped(destination, event);
579 Q_EMIT q->activeTabRequested(url);
581 Q_EMIT q->tabRequested(url);
583 Q_EMIT q->newWindowRequested(url);
585 q->setLocationUrl(url);
589void KUrlNavigatorPrivate::openContextMenu(
const QPoint &p)
593 QPointer<QMenu> popup =
new QMenu(q);
597 QAction *copyAction = popup->addAction(
QIcon::fromTheme(QStringLiteral(
"edit-copy")),
i18n(
"Copy"));
601 QAction *pasteAction = popup->addAction(
QIcon::fromTheme(QStringLiteral(
"edit-paste")),
i18n(
"Paste"));
605 popup->addSeparator();
611 if (isTabSignal || isWindowSignal) {
612 auto it = std::find_if(m_navButtons.cbegin(), m_navButtons.cend(), [&p](
const KUrlNavigatorButton *button) {
613 return button->geometry().contains(p);
615 if (it != m_navButtons.cend()) {
616 const auto *button = *it;
617 const QUrl url = button->
url();
618 const QString text = button->text();
621 QAction *openInTab = popup->addAction(
QIcon::fromTheme(QStringLiteral(
"tab-new")),
i18nc(
"@item:inmenu",
"Open \"%1\" in New Tab", text));
623 Q_EMIT q->tabRequested(url);
627 if (isWindowSignal) {
628 QAction *openInWindow =
629 popup->addAction(
QIcon::fromTheme(QStringLiteral(
"window-new")),
i18nc(
"@item:inmenu",
"Open \"%1\" in New Window", text));
631 Q_EMIT q->newWindowRequested(url);
638 QAction *editAction = popup->addAction(
i18n(
"Edit"));
641 QAction *navigateAction = popup->addAction(
i18n(
"Navigate"));
644 QActionGroup *modeGroup =
new QActionGroup(popup);
647 if (q->isUrlEditable()) {
653 popup->addSeparator();
656 QAction *showFullPathAction = popup->addAction(
i18n(
"Show Full Path"));
658 showFullPathAction->
setChecked(q->showFullPath());
661 if (activatedAction == copyAction) {
662 QMimeData *mimeData =
new QMimeData();
665 }
else if (activatedAction == pasteAction) {
667 }
else if (activatedAction == editAction) {
668 q->setUrlEditable(
true);
669 }
else if (activatedAction == navigateAction) {
670 q->setUrlEditable(
false);
671 }
else if (activatedAction == showFullPathAction) {
672 q->setShowFullPath(showFullPathAction->
isChecked());
677 popup->deleteLater();
681void KUrlNavigatorPrivate::slotPathBoxChanged(
const QString &text)
684 const QString scheme = q->locationUrl().scheme();
685 m_schemes->setScheme(scheme);
686 if (m_supportedSchemes.count() != 1) {
696void KUrlNavigatorPrivate::updateContent()
698 const QUrl currentUrl = q->locationUrl();
699 if (m_placesSelector !=
nullptr) {
700 m_placesSelector->updateSelection(currentUrl);
705 m_dropDownButton->hide();
706 m_badgeWidgetContainer->hide();
713 m_pathBox->setUrl(currentUrl);
715 q->setTabOrder(m_pathBox, m_toggleEditableMode);
719 m_badgeWidgetContainer->show();
729 if ((m_placesSelector !=
nullptr) && !m_showFullPath) {
730 placeUrl = m_placesSelector->selectedPlaceUrl();
734 placeUrl = retrievePlaceUrl();
736 QString placePath = Utils::trailingSlashRemoved(placeUrl.
path());
738 const int startIndex = placePath.
count(QLatin1Char(
'/'));
739 updateButtons(startIndex);
743void KUrlNavigatorPrivate::updateButtons(
int startIndex)
745 QUrl currentUrl = q->locationUrl();
750 const QString
path = currentUrl.
path();
752 const int oldButtonCount = m_navButtons.
count();
754 int idx = startIndex;
757 const bool createButton = (idx - startIndex) >= oldButtonCount;
758 const bool isFirstButton = (idx == startIndex);
759 const QString dirName =
path.
section(QLatin1Char(
'/'), idx, idx);
760 hasNext = isFirstButton || !dirName.
isEmpty();
762 KUrlNavigatorButton *button =
nullptr;
764 button =
new KUrlNavigatorButton(buttonUrl(idx), q);
765 button->installEventFilter(q);
767 q->connect(button, &KUrlNavigatorButton::urlsDroppedOnNavButton, q, [
this, button](
const QUrl &destination, QDropEvent *event) {
768 dropUrls(destination, event, button);
772 slotNavigatorButtonClicked(url, btn, modifiers);
774 q->connect(button, &KUrlNavigatorButton::navigatorButtonActivated, q, activatedFunc);
776 q->connect(button, &KUrlNavigatorButton::finishedTextResolving, q, [
this]() {
777 updateButtonVisibility();
780 appendWidget(button);
782 button = m_navButtons[idx - startIndex];
783 button->setUrl(buttonUrl(idx));
787 button->setText(firstButtonText());
789 button->setActive(q->isActive());
792 if (!isFirstButton) {
793 q->setTabOrder(m_navButtons.constLast(), button);
795 m_navButtons.append(button);
799 button->setActiveSubDirectory(
path.
section(QLatin1Char(
'/'), idx, idx));
804 const int newButtonCount = idx - startIndex;
805 if (newButtonCount < oldButtonCount) {
806 const auto itBegin = m_navButtons.begin() + newButtonCount;
807 const auto itEnd = m_navButtons.end();
808 for (
auto it = itBegin; it != itEnd; ++it) {
811 navBtn->deleteLater();
813 m_navButtons.erase(itBegin, itEnd);
816 m_dropDownButton->setToolTip(
xi18nc(
"@info:tooltip for button. 1 is path",
817 "Go to any location on the path <filename>%1</filename>",
819 .
replace(QStringLiteral(
"///"), QStringLiteral(
"/")));
820 updateButtonVisibility();
823void KUrlNavigatorPrivate::updateButtonVisibility()
829 const int buttonsCount = m_navButtons.count();
830 if (buttonsCount == 0) {
831 m_dropDownButton->hide();
837 int availableWidth = q->width() - m_toggleEditableMode->minimumWidth();
839 availableWidth -= m_badgeWidgetContainer->width();
841 if ((m_placesSelector !=
nullptr) && m_placesSelector->isVisible()) {
842 availableWidth -= m_placesSelector->width();
845 if ((m_schemes !=
nullptr) && m_schemes->isVisible()) {
846 availableWidth -= m_schemes->width();
849 availableWidth -= m_dropDownButton->width();
852 availableWidth -= m_padding * 4;
855 bool isLastButton =
true;
856 bool hasHiddenButtons =
false;
857 QList<KUrlNavigatorButton *> buttonsToShow;
858 for (
auto it = m_navButtons.crbegin(); it != m_navButtons.crend(); ++it) {
859 KUrlNavigatorButton *button = *it;
860 availableWidth -= button->minimumWidth();
861 if ((availableWidth <= 0) && !isLastButton) {
863 hasHiddenButtons =
true;
870 buttonsToShow.
append(button);
872 isLastButton =
false;
877 for (KUrlNavigatorButton *button : std::as_const(buttonsToShow)) {
881 if (hasHiddenButtons) {
882 m_dropDownButton->show();
885 QUrl url(m_navButtons.front()->url());
887 && url.
scheme() != QLatin1String(
"baloosearch")
888 && url.
scheme() != QLatin1String(
"filenamesearch");
889 m_dropDownButton->setVisible(visible);
892 auto lastButton = m_navButtons.last();
893 for (
const auto &button : m_navButtons) {
894 if (button != lastButton) {
895 button->setDrawSeparator(
true);
897 button->setDrawSeparator(
false);
904void KUrlNavigatorPrivate::updateTabOrder()
906 QMultiMap<int, QWidget *> visibleChildrenSortedByX;
907 const auto childWidgets = q->findChildren<KUrlNavigatorButtonBase *>();
908 for (
auto childWidget : childWidgets) {
909 if (childWidget->isVisible()) {
911 visibleChildrenSortedByX.
insert(childWidget->x(), childWidget);
913 visibleChildrenSortedByX.
insert(-childWidget->x(), childWidget);
918 if (visibleChildrenSortedByX.
isEmpty()) {
921 q->setFocusProxy(visibleChildrenSortedByX.
first());
922 auto it = visibleChildrenSortedByX.
begin();
923 auto nextIt = ++visibleChildrenSortedByX.
begin();
924 while (nextIt != visibleChildrenSortedByX.
end()) {
925 q->setTabOrder(*it, *nextIt);
929 Q_EMIT q->layoutChanged();
932QString KUrlNavigatorPrivate::firstButtonText()
const
938 if ((m_placesSelector !=
nullptr) && !m_showFullPath) {
939 text = m_placesSelector->selectedPlaceText();
942 const QUrl currentUrl = q->locationUrl();
949 text = QStringLiteral(
"/");
955 if (currentUrl.
path().
isEmpty() || currentUrl.
path() == QLatin1Char(
'/')) {
956 QUrlQuery
query(currentUrl);
962 text = currentUrl.
scheme() + QLatin1Char(
':');
964 text += QLatin1Char(
' ') + currentUrl.
host();
971QUrl KUrlNavigatorPrivate::buttonUrl(
int index)
const
979 QUrl url = q->locationUrl();
989 path = QStringLiteral(
"/");
1000void KUrlNavigatorPrivate::switchToBreadcrumbMode()
1002 q->setUrlEditable(
false);
1005void KUrlNavigatorPrivate::deleteButtons()
1007 for (KUrlNavigatorButton *button : std::as_const(m_navButtons)) {
1009 button->deleteLater();
1011 m_navButtons.
clear();
1014QUrl KUrlNavigatorPrivate::retrievePlaceUrl()
const
1016 QUrl currentUrl = q->locationUrl();
1017 currentUrl.
setPath(QString());
1030 , d(new KUrlNavigatorPrivate(url, this, placesModel))
1032 const int minHeight = d->m_pathBox->sizeHint().
height();
1039 d->updateTabOrder();
1042KUrlNavigator::~KUrlNavigator()
1044 d->m_dropDownButton->removeEventFilter(
this);
1045 d->m_pathBox->removeEventFilter(
this);
1046 for (
auto *button : std::as_const(d->m_navButtons)) {
1047 button->removeEventFilter(
this);
1054 return d->m_coreUrlNavigator->locationUrl(
historyIndex);
1059 auto current = d->m_coreUrlNavigator->locationState().value<KUrlNavigatorData>();
1060 current.state = state;
1066 return d->m_coreUrlNavigator->locationState(
historyIndex).value<KUrlNavigatorData>().state;
1071 return d->m_coreUrlNavigator->goBack();
1076 return d->m_coreUrlNavigator->goForward();
1081 return d->m_coreUrlNavigator->goUp();
1086 if (d->m_homeUrl.isEmpty() || !d->m_homeUrl.isValid()) {
1098QUrl KUrlNavigator::homeUrl()
const
1100 return d->m_homeUrl;
1105 if (d->m_editable != editable) {
1112 return d->m_editable;
1117 if (d->m_showFullPath !=
show) {
1118 d->m_showFullPath =
show;
1125 return d->m_showFullPath;
1130 if (active != d->m_active) {
1131 d->m_active = active;
1133 d->m_dropDownButton->setActive(active);
1134 for (KUrlNavigatorButton *button : std::as_const(d->m_navButtons)) {
1135 button->setActive(active);
1152 if (
visible == d->m_showPlacesSelector) {
1156 if (
visible && (d->m_placesSelector ==
nullptr)) {
1162 d->m_showPlacesSelector =
visible;
1164 if (d->m_placesSelector) {
1165 d->m_placesSelector->setVisible(
visible);
1166 d->updateTabOrder();
1172 return d->m_showPlacesSelector;
1177 KUriFilterData filteredData(d->m_pathBox->currentText().trimmed());
1180 return filteredData.
uri();
1188 d->m_coreUrlNavigator->setCurrentLocationUrl(newUrl);
1203 d->m_pathBox->setFocus();
1234 const QRect bounds = d->m_toggleEditableMode->geometry();
1240 const QMimeData *mimeData = clipboard->
mimeData(QClipboard::Mode::Selection);
1241 if (mimeData && mimeData->
hasText()) {
1242 const QString text = mimeData->
text();
1243 const auto currentUrl = d->m_coreUrlNavigator->currentLocationUrl();
1244 QString workindDirectory;
1261 d->updateButtonVisibility();
1274 d->updateTabOrder();
1280 switch (
event->type()) {
1282 if (watched == d->m_pathBox) {
1286 for (KUrlNavigatorButton *button : std::as_const(d->m_navButtons)) {
1287 button->setShowMnemonic(
true);
1293 for (KUrlNavigatorButton *button : std::as_const(d->m_navButtons)) {
1294 button->setShowMnemonic(
false);
1310#if KIO_VERSION < QT_VERSION_CHECK(7, 0, 0)
1318 if (watched ==
this) {
1319 auto *pEvent =
static_cast<QPaintEvent *
>(
event);
1338 return d->m_coreUrlNavigator->historySize();
1343 return d->m_coreUrlNavigator->historyIndex();
1348 return d->m_pathBox;
1353 d->m_supportedSchemes = schemes;
1354 d->m_schemes->setSupportedSchemes(d->m_supportedSchemes);
1359 return d->m_supportedSchemes;
1364 return d->m_dropWidget;
1374 return d->m_subfolderOptions.showHidden;
1384 return d->m_subfolderOptions.sortHiddenLast;
1391 if (widget == oldWidget) {
1394 d->m_badgeWidgetContainer->layout()->replaceWidget(oldWidget, widget);
1397 d->m_badgeWidgetContainer->layout()->addWidget(widget);
1413 d->m_backgroundEnabled =
enabled;
1418 return d->m_backgroundEnabled;
1433 if (d->m_backgroundEnabled) {
1435 if (!d->m_editable) {
1441 if (d->m_editable) {
1447#include "moc_kurlnavigator.cpp"
void returnPressed(const QString &text)
Object that helps with keeping track of URLs in file-manager like interfaces.
Q_SIGNAL void urlSelectionRequested(const QUrl &url)
When the URL is changed and the new URL (e.g. /home/user1/) is a parent of the previous URL (e....
Q_SIGNAL void currentUrlAboutToChange(const QUrl &newUrl)
Is emitted, before the location URL is going to be changed to newUrl.
Q_SIGNAL void historyChanged()
Is emitted, if the history has been changed.
This class is a list view model.
static QString protocolClass(const QString &protocol)
Returns the protocol class for the specified protocol.
This class is a basic messaging class used to exchange filtering information between the filter plugi...
QUrl uri() const
Returns the filtered or the original URL.
QString typedString() const
The string as typed by the user, before any URL processing is done.
void setCheckForExecutables(bool check)
Check whether the provided uri is executable or not.
static KUriFilter * self()
Returns an instance of KUriFilter.
bool filterUri(KUriFilterData &data, const QStringList &filters=QStringList())
Filters data using the specified filters.
This combobox shows a number of recent URLs/directories, as well as some default directories.
void urlActivated(const QUrl &url)
Emitted when an item was clicked at.
This class does completion of URLs including user directories (~user) and environment variables.
Widget that allows to navigate through the paths of an URL.
void newWindowRequested(const QUrl &url)
Is emitted if the URL url should be opened in a new window because the user left-clicked on a breadcr...
void setShowFullPath(bool show)
Shows the full path of the URL even if a place represents a part of the URL.
void setBadgeWidget(QWidget *widget)
Puts widget to the right of the breadcrumb.
void setSortHiddenFoldersLast(bool sortHiddenFoldersLast)
Sets whether to sort hidden folders in the subdirectories popup last.
void setPlacesSelectorVisible(bool visible)
Sets the places selector visible, if visible is true.
void setLocationUrl(const QUrl &url)
Sets the location to url.
bool goUp()
Goes up one step of the URL path and remembers the old path in the history.
bool showHiddenFolders() const
Returns whether to show hidden folders in the subdirectories popup.
QUrl uncommittedUrl() const
KUrlComboBox * editor() const
QStringList supportedSchemes() const
Returns the URL schemes that the navigator should allow navigating to.
KUrlNavigator(QWidget *parent=nullptr)
bool sortHiddenFoldersLast() const
Returns whether to sort hidden folders in the subdirectories popup last.
void tabRequested(const QUrl &url)
Is emitted if the URL url should be opened in a new inactive tab because the user clicked on a breadc...
void saveLocationState(const QByteArray &state)
Saves the location state described by state for the current location.
void goHome()
Goes to the home URL and remembers the old URL in the history.
void setHomeUrl(const QUrl &url)
Sets the home URL used by KUrlNavigator::goHome().
QWidget * badgeWidget() const
Returns the badge widget set by setBadgeWidget().
bool goBack()
Goes back one step in the URL history.
QUrl locationUrl(int historyIndex=-1) const
void setBackgroundEnabled(bool enabled)
Sets the background painting enabled or disabled for the buttons layout.
void requestActivation()
Activates the URL navigator (KUrlNavigator::isActive() will return true) and emits the signal KUrlNav...
bool isBackgroundEnabled() const
Returns true if the background of the buttons layout is being painted.
void setUrlEditable(bool editable)
Allows to edit the URL of the navigation bar if editable is true, and sets the focus accordingly.
bool isPlacesSelectorVisible() const
bool showFullPath() const
bool goForward()
Goes forward one step in the URL history.
void setShowHiddenFolders(bool showHiddenFolders)
Sets whether to show hidden folders in the subdirectories popup.
void setActive(bool active)
Set the URL navigator to the active mode, if active is true.
QWidget * dropWidget() const
The child widget that received the QDropEvent when dropping on the URL navigator.
void activated()
Is emitted, if the URL navigator has been activated by an user interaction.
QByteArray locationState(int historyIndex=-1) const
bool isUrlEditable() const
void setSupportedSchemes(const QStringList &schemes)
Set the URL schemes that the navigator should allow navigating to.
QString xi18nc(const char *context, const char *text, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
KSERVICE_EXPORT KService::List query(FilterFunc filterFunc)
KIOCORE_EXPORT StatJob * stat(const QUrl &url, JobFlags flags=DefaultFlags)
Find all details for one file or directory.
KIOCORE_EXPORT QUrl upUrl(const QUrl &url)
This function is useful to implement the "Up" button in a file manager for example.
@ HideProgressInfo
Hide progress information dialog, i.e. don't show a GUI.
@ StatBasic
Filename, access, type, size, linkdest.
@ StatResolveSymlink
Resolve symlinks.
QString path(const QString &relativePath)
const QList< QKeySequence > & openContextMenu()
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles)
void rowsInserted(const QModelIndex &parent, int first, int last)
void rowsRemoved(const QModelIndex &parent, int first, int last)
QVariant data() const const
void setData(const QVariant &data)
void triggered(bool checked)
QAction * addAction(QAction *action)
const QMimeData * mimeData(Mode mode) const const
void setMimeData(QMimeData *src, Mode mode)
QString text(Mode mode) const const
AdjustToContentsOnFirstShow
void editTextChanged(const QString &text)
Qt::KeyboardModifiers keyboardModifiers()
QIcon fromTheme(const QString &name)
virtual QLayoutItem * itemAt(int index) const const=0
virtual QLayout * layout()
void append(QList< T > &&value)
void prepend(parameter_type value)
qsizetype removeAll(const AT &t)
bool hasText() const const
void setText(const QString &text)
QString text() const const
iterator insert(const Key &key, const T &value)
bool isEmpty() const const
virtual bool event(QEvent *e)
virtual bool eventFilter(QObject *watched, QEvent *event)
void installEventFilter(QObject *filterObj)
QObject * parent() const const
void removeEventFilter(QObject *obj)
bool contains(const QPoint &point, bool proper) const const
qsizetype count() const const
QString & append(QChar ch)
bool isEmpty() const const
QString left(qsizetype n) const const
qsizetype length() const const
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString section(QChar sep, qsizetype start, qsizetype end, SectionFlags flags) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString trimmed() const const
PM_LayoutHorizontalSpacing
virtual void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const const=0
void initFrom(const QWidget *widget)
typedef KeyboardModifiers
void keyEvent(KeyAction action, QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier, int delay)
QUrl fromLocalFile(const QString &localFile)
QString host(ComponentFormattingOptions options) const const
bool isEmpty() const const
bool isLocalFile() const const
bool isValid() const const
bool matches(const QUrl &url, FormattingOptions options) const const
QString path(ComponentFormattingOptions options) const const
QString scheme() const const
void setAuthority(const QString &authority, ParsingMode mode)
void setPath(const QString &path, ParsingMode mode)
void setScheme(const QString &scheme)
QString toDisplayString(FormattingOptions options) const const
QString toLocalFile() const const
QString toString(FormattingOptions options) const const
QString url(FormattingOptions options) const const
QVariant fromValue(T &&value)
QString toString() const const