1 /***************************************************************************
2 * Copyright (C) 2007 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "dolphinviewcontainer.h"
22 #include "dolphin_generalsettings.h"
23 #include "dolphinplacesmodelsingleton.h"
24 #include "dolphindebug.h"
25 #include "filterbar/filterbar.h"
27 #include "search/dolphinsearchbox.h"
28 #include "statusbar/dolphinstatusbar.h"
29 #include "trash/dolphintrash.h"
30 #include "views/viewmodecontroller.h"
31 #include "views/viewproperties.h"
33 #ifdef HAVE_KACTIVITIES
34 #include <KActivities/ResourceInstance>
36 #include <KFileItemActions>
37 #include <KFilePlacesModel>
38 #include <KIO/PreviewJob>
39 #include <KLocalizedString>
40 #include <KMessageWidget>
41 #include <KProtocolManager>
44 #include <KUrlComboBox>
45 #include <KUrlNavigator>
48 #include <QLoggingCategory>
52 #include <QVBoxLayout>
54 DolphinViewContainer::DolphinViewContainer(const QUrl
& url
, QWidget
* parent
) :
57 m_navigatorWidget(nullptr),
58 m_urlNavigator(nullptr),
59 m_emptyTrashButton(nullptr),
61 m_searchModeEnabled(false),
62 m_messageWidget(nullptr),
66 m_statusBarTimer(nullptr),
67 m_statusBarTimestamp(),
69 #ifdef HAVE_KACTIVITIES
70 , m_activityResourceInstance(nullptr)
75 m_topLayout
= new QVBoxLayout(this);
76 m_topLayout
->setSpacing(0);
77 m_topLayout
->setContentsMargins(0, 0, 0, 0);
79 m_navigatorWidget
= new QWidget(this);
80 QHBoxLayout
* navigatorLayout
= new QHBoxLayout(m_navigatorWidget
);
81 navigatorLayout
->setSpacing(0);
82 navigatorLayout
->setContentsMargins(0, 0, 0, 0);
84 m_urlNavigator
= new KUrlNavigator(DolphinPlacesModelSingleton::instance().placesModel(), url
, this);
85 connect(m_urlNavigator
, &KUrlNavigator::activated
,
86 this, &DolphinViewContainer::activate
);
87 connect(m_urlNavigator
->editor(), &KUrlComboBox::completionModeChanged
,
88 this, &DolphinViewContainer::saveUrlCompletionMode
);
90 const GeneralSettings
* settings
= GeneralSettings::self();
91 m_urlNavigator
->setUrlEditable(settings
->editableUrl());
92 m_urlNavigator
->setShowFullPath(settings
->showFullPath());
93 m_urlNavigator
->setHomeUrl(Dolphin::homeUrl());
94 KUrlComboBox
* editor
= m_urlNavigator
->editor();
95 editor
->setCompletionMode(KCompletion::CompletionMode(settings
->urlCompletionMode()));
97 m_emptyTrashButton
= new QPushButton(QIcon::fromTheme(QStringLiteral("user-trash")), i18nc("@action:button", "Empty Trash"), this);
98 m_emptyTrashButton
->setFlat(true);
99 connect(m_emptyTrashButton
, &QPushButton::clicked
, this, [this]() { Trash::empty(this); });
100 connect(&Trash::instance(), &Trash::emptinessChanged
, m_emptyTrashButton
, &QPushButton::setDisabled
);
101 m_emptyTrashButton
->setDisabled(Trash::isEmpty());
102 m_emptyTrashButton
->hide();
104 m_searchBox
= new DolphinSearchBox(this);
106 connect(m_searchBox
, &DolphinSearchBox::activated
, this, &DolphinViewContainer::activate
);
107 connect(m_searchBox
, &DolphinSearchBox::closeRequest
, this, &DolphinViewContainer::closeSearchBox
);
108 connect(m_searchBox
, &DolphinSearchBox::searchRequest
, this, &DolphinViewContainer::startSearching
);
109 connect(m_searchBox
, &DolphinSearchBox::returnPressed
, this, &DolphinViewContainer::requestFocus
);
111 m_messageWidget
= new KMessageWidget(this);
112 m_messageWidget
->setCloseButtonVisible(true);
113 m_messageWidget
->hide();
118 // We must be logged in as the root user; show a big scary warning
119 showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), Warning
);
123 // Initialize filter bar
124 m_filterBar
= new FilterBar(this);
125 m_filterBar
->setVisible(settings
->filterBar());
127 connect(m_filterBar
, &FilterBar::filterChanged
,
128 this, &DolphinViewContainer::setNameFilter
);
129 connect(m_filterBar
, &FilterBar::closeRequest
,
130 this, &DolphinViewContainer::closeFilterBar
);
131 connect(m_filterBar
, &FilterBar::focusViewRequest
,
132 this, &DolphinViewContainer::requestFocus
);
134 // Initialize the main view
135 m_view
= new DolphinView(url
, this);
136 connect(m_view
, &DolphinView::urlChanged
,
137 m_filterBar
, &FilterBar::slotUrlChanged
);
138 connect(m_view
, &DolphinView::urlChanged
,
139 m_urlNavigator
, &KUrlNavigator::setLocationUrl
);
140 connect(m_view
, &DolphinView::urlChanged
,
141 m_messageWidget
, &KMessageWidget::hide
);
142 connect(m_view
, &DolphinView::writeStateChanged
,
143 this, &DolphinViewContainer::writeStateChanged
);
144 connect(m_view
, &DolphinView::requestItemInfo
,
145 this, &DolphinViewContainer::showItemInfo
);
146 connect(m_view
, &DolphinView::itemActivated
,
147 this, &DolphinViewContainer::slotItemActivated
);
148 connect(m_view
, &DolphinView::itemsActivated
,
149 this, &DolphinViewContainer::slotItemsActivated
);
150 connect(m_view
, &DolphinView::redirection
,
151 this, &DolphinViewContainer::redirect
);
152 connect(m_view
, &DolphinView::directoryLoadingStarted
,
153 this, &DolphinViewContainer::slotDirectoryLoadingStarted
);
154 connect(m_view
, &DolphinView::directoryLoadingCompleted
,
155 this, &DolphinViewContainer::slotDirectoryLoadingCompleted
);
156 connect(m_view
, &DolphinView::directoryLoadingCanceled
,
157 this, &DolphinViewContainer::slotDirectoryLoadingCanceled
);
158 connect(m_view
, &DolphinView::itemCountChanged
,
159 this, &DolphinViewContainer::delayedStatusBarUpdate
);
160 connect(m_view
, &DolphinView::directoryLoadingProgress
,
161 this, &DolphinViewContainer::updateDirectoryLoadingProgress
);
162 connect(m_view
, &DolphinView::directorySortingProgress
,
163 this, &DolphinViewContainer::updateDirectorySortingProgress
);
164 connect(m_view
, &DolphinView::selectionChanged
,
165 this, &DolphinViewContainer::delayedStatusBarUpdate
);
166 connect(m_view
, &DolphinView::errorMessage
,
167 this, &DolphinViewContainer::showErrorMessage
);
168 connect(m_view
, &DolphinView::urlIsFileError
,
169 this, &DolphinViewContainer::slotUrlIsFileError
);
170 connect(m_view
, &DolphinView::activated
,
171 this, &DolphinViewContainer::activate
);
173 connect(m_urlNavigator
, &KUrlNavigator::urlAboutToBeChanged
,
174 this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged
);
175 connect(m_urlNavigator
, &KUrlNavigator::urlChanged
,
176 this, &DolphinViewContainer::slotUrlNavigatorLocationChanged
);
177 connect(m_urlNavigator
, &KUrlNavigator::urlSelectionRequested
,
178 this, &DolphinViewContainer::slotUrlSelectionRequested
);
179 connect(m_urlNavigator
, &KUrlNavigator::returnPressed
,
180 this, &DolphinViewContainer::slotReturnPressed
);
181 connect(m_urlNavigator
, &KUrlNavigator::urlsDropped
, this, [=](const QUrl
&destination
, QDropEvent
*event
) {
182 m_view
->dropUrls(destination
, event
, m_urlNavigator
->dropWidget());
185 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, [this]() {
186 m_emptyTrashButton
->setVisible(m_view
->url().scheme() == QLatin1String("trash"));
189 // Initialize status bar
190 m_statusBar
= new DolphinStatusBar(this);
191 m_statusBar
->setUrl(m_view
->url());
192 m_statusBar
->setZoomLevel(m_view
->zoomLevel());
193 connect(m_view
, &DolphinView::urlChanged
,
194 m_statusBar
, &DolphinStatusBar::setUrl
);
195 connect(m_view
, &DolphinView::zoomLevelChanged
,
196 m_statusBar
, &DolphinStatusBar::setZoomLevel
);
197 connect(m_view
, &DolphinView::infoMessage
,
198 m_statusBar
, &DolphinStatusBar::setText
);
199 connect(m_view
, &DolphinView::operationCompletedMessage
,
200 m_statusBar
, &DolphinStatusBar::setText
);
201 connect(m_statusBar
, &DolphinStatusBar::stopPressed
,
202 this, &DolphinViewContainer::stopDirectoryLoading
);
203 connect(m_statusBar
, &DolphinStatusBar::zoomLevelChanged
,
204 this, &DolphinViewContainer::slotStatusBarZoomLevelChanged
);
206 m_statusBarTimer
= new QTimer(this);
207 m_statusBarTimer
->setSingleShot(true);
208 m_statusBarTimer
->setInterval(300);
209 connect(m_statusBarTimer
, &QTimer::timeout
, this, &DolphinViewContainer::updateStatusBar
);
211 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
212 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
213 this, &DolphinViewContainer::delayedStatusBarUpdate
);
215 navigatorLayout
->addWidget(m_urlNavigator
);
216 navigatorLayout
->addWidget(m_emptyTrashButton
);
218 m_topLayout
->addWidget(m_navigatorWidget
);
219 m_topLayout
->addWidget(m_searchBox
);
220 m_topLayout
->addWidget(m_messageWidget
);
221 m_topLayout
->addWidget(m_view
);
222 m_topLayout
->addWidget(m_filterBar
);
223 m_topLayout
->addWidget(m_statusBar
);
225 setSearchModeEnabled(isSearchUrl(url
));
227 // Initialize kactivities resource instance
229 #ifdef HAVE_KACTIVITIES
230 m_activityResourceInstance
= new KActivities::ResourceInstance(window()->winId(), url
);
231 m_activityResourceInstance
->setParent(this);
235 DolphinViewContainer::~DolphinViewContainer()
239 QUrl
DolphinViewContainer::url() const
241 return m_view
->url();
244 void DolphinViewContainer::setActive(bool active
)
246 m_searchBox
->setActive(active
);
247 m_urlNavigator
->setActive(active
);
248 m_view
->setActive(active
);
250 #ifdef HAVE_KACTIVITIES
252 m_activityResourceInstance
->notifyFocusedIn();
254 m_activityResourceInstance
->notifyFocusedOut();
259 bool DolphinViewContainer::isActive() const
261 Q_ASSERT(m_view
->isActive() == m_urlNavigator
->isActive());
262 return m_view
->isActive();
265 void DolphinViewContainer::setAutoGrabFocus(bool grab
)
267 m_autoGrabFocus
= grab
;
270 bool DolphinViewContainer::autoGrabFocus() const
272 return m_autoGrabFocus
;
275 QString
DolphinViewContainer::currentSearchText() const
277 return m_searchBox
->text();
280 const DolphinStatusBar
* DolphinViewContainer::statusBar() const
285 DolphinStatusBar
* DolphinViewContainer::statusBar()
290 const KUrlNavigator
* DolphinViewContainer::urlNavigator() const
292 return m_urlNavigator
;
295 KUrlNavigator
* DolphinViewContainer::urlNavigator()
297 return m_urlNavigator
;
300 const DolphinView
* DolphinViewContainer::view() const
305 DolphinView
* DolphinViewContainer::view()
310 void DolphinViewContainer::showMessage(const QString
& msg
, MessageType type
)
316 m_messageWidget
->setText(msg
);
318 // TODO: wrap at arbitrary character positions once QLabel can do this
319 // https://bugreports.qt.io/browse/QTBUG-1276
320 m_messageWidget
->setWordWrap(true);
323 case Information
: m_messageWidget
->setMessageType(KMessageWidget::Information
); break;
324 case Warning
: m_messageWidget
->setMessageType(KMessageWidget::Warning
); break;
325 case Error
: m_messageWidget
->setMessageType(KMessageWidget::Error
); break;
331 m_messageWidget
->setWordWrap(false);
332 const int unwrappedWidth
= m_messageWidget
->sizeHint().width();
333 m_messageWidget
->setWordWrap(unwrappedWidth
> size().width());
335 if (m_messageWidget
->isVisible()) {
336 m_messageWidget
->hide();
338 m_messageWidget
->animatedShow();
341 void DolphinViewContainer::readSettings()
343 if (GeneralSettings::modifiedStartupSettings()) {
344 // The startup settings should only get applied if they have been
345 // modified by the user. Otherwise keep the (possibly) different current
346 // settings of the URL navigator and the filterbar.
347 m_urlNavigator
->setUrlEditable(GeneralSettings::editableUrl());
348 m_urlNavigator
->setShowFullPath(GeneralSettings::showFullPath());
349 m_urlNavigator
->setHomeUrl(Dolphin::homeUrl());
350 setFilterBarVisible(GeneralSettings::filterBar());
353 m_view
->readSettings();
354 m_statusBar
->readSettings();
357 bool DolphinViewContainer::isFilterBarVisible() const
359 return m_filterBar
->isVisible();
362 void DolphinViewContainer::setSearchModeEnabled(bool enabled
)
364 if (enabled
== isSearchModeEnabled()) {
365 if (enabled
&& !m_searchBox
->hasFocus()) {
366 m_searchBox
->setFocus();
367 m_searchBox
->selectAll();
372 m_searchBox
->setVisible(enabled
);
373 m_navigatorWidget
->setVisible(!enabled
);
376 const QUrl
& locationUrl
= m_urlNavigator
->locationUrl();
377 m_searchBox
->fromSearchUrl(locationUrl
);
379 m_view
->setViewPropertiesContext(QString());
381 // Restore the URL for the URL navigator. If Dolphin has been
382 // started with a search-URL, the home URL is used as fallback.
383 QUrl url
= m_searchBox
->searchPath();
384 if (url
.isEmpty() || !url
.isValid() || isSearchUrl(url
)) {
385 url
= Dolphin::homeUrl();
387 m_urlNavigator
->setLocationUrl(url
);
390 m_searchModeEnabled
= enabled
;
393 bool DolphinViewContainer::isSearchModeEnabled() const
395 return m_searchModeEnabled
;
398 QString
DolphinViewContainer::placesText() const
402 if (isSearchModeEnabled()) {
403 text
= i18n("Search for %1 in %2", m_searchBox
->text(), m_searchBox
->searchPath().fileName());
405 text
= url().fileName();
406 if (text
.isEmpty()) {
409 if (text
.isEmpty()) {
410 text
= url().scheme();
417 void DolphinViewContainer::reload()
420 m_messageWidget
->hide();
423 QString
DolphinViewContainer::caption() const
425 if (GeneralSettings::showFullPathInTitlebar()) {
426 if (!url().isLocalFile()) {
427 return url().adjusted(QUrl::StripTrailingSlash
).toString();
429 return url().adjusted(QUrl::StripTrailingSlash
).path();
432 KFilePlacesModel
*placesModel
= DolphinPlacesModelSingleton::instance().placesModel();
433 const auto& matchedPlaces
= placesModel
->match(placesModel
->index(0,0), KFilePlacesModel::UrlRole
, url(), 1, Qt::MatchExactly
);
435 if (!matchedPlaces
.isEmpty()) {
436 return placesModel
->text(matchedPlaces
.first());
439 if (isSearchModeEnabled()) {
440 if (currentSearchText().isEmpty()){
441 return i18n("Search");
443 return i18n("Search for %1", currentSearchText());
447 if (!url().isLocalFile()) {
448 QUrl adjustedUrl
= url().adjusted(QUrl::StripTrailingSlash
);
450 if (!adjustedUrl
.fileName().isEmpty()) {
451 caption
= adjustedUrl
.fileName();
452 } else if (!adjustedUrl
.path().isEmpty() && adjustedUrl
.path() != "/") {
453 caption
= adjustedUrl
.path();
454 } else if (!adjustedUrl
.host().isEmpty()) {
455 caption
= adjustedUrl
.host();
457 caption
= adjustedUrl
.toString();
462 QString fileName
= url().adjusted(QUrl::StripTrailingSlash
).fileName();
463 if (fileName
.isEmpty()) {
470 void DolphinViewContainer::setUrl(const QUrl
& newUrl
)
472 if (newUrl
!= m_urlNavigator
->locationUrl()) {
473 m_urlNavigator
->setLocationUrl(newUrl
);
476 #ifdef HAVE_KACTIVITIES
477 m_activityResourceInstance
->setUri(newUrl
);
481 void DolphinViewContainer::setFilterBarVisible(bool visible
)
483 Q_ASSERT(m_filterBar
);
486 m_filterBar
->setFocus();
487 m_filterBar
->selectAll();
493 void DolphinViewContainer::delayedStatusBarUpdate()
495 if (m_statusBarTimer
->isActive() && (m_statusBarTimestamp
.elapsed() > 2000)) {
496 // No update of the statusbar has been done during the last 2 seconds,
497 // although an update has been requested. Trigger an immediate update.
498 m_statusBarTimer
->stop();
501 // Invoke updateStatusBar() with a small delay. This assures that
502 // when a lot of delayedStatusBarUpdates() are done in a short time,
503 // no bottleneck is given.
504 m_statusBarTimer
->start();
508 void DolphinViewContainer::updateStatusBar()
510 m_statusBarTimestamp
.start();
512 const QString text
= m_view
->statusBarText();
513 m_statusBar
->setDefaultText(text
);
514 m_statusBar
->resetToDefaultText();
517 void DolphinViewContainer::updateDirectoryLoadingProgress(int percent
)
519 if (m_statusBar
->progressText().isEmpty()) {
520 m_statusBar
->setProgressText(i18nc("@info:progress", "Loading folder..."));
522 m_statusBar
->setProgress(percent
);
525 void DolphinViewContainer::updateDirectorySortingProgress(int percent
)
527 if (m_statusBar
->progressText().isEmpty()) {
528 m_statusBar
->setProgressText(i18nc("@info:progress", "Sorting..."));
530 m_statusBar
->setProgress(percent
);
533 void DolphinViewContainer::slotDirectoryLoadingStarted()
535 if (isSearchUrl(url())) {
536 // Search KIO-slaves usually don't provide any progress information. Give
537 // a hint to the user that a searching is done:
539 m_statusBar
->setProgressText(i18nc("@info", "Searching..."));
540 m_statusBar
->setProgress(-1);
542 // Trigger an undetermined progress indication. The progress
543 // information in percent will be triggered by the percent() signal
544 // of the directory lister later.
545 updateDirectoryLoadingProgress(-1);
549 void DolphinViewContainer::slotDirectoryLoadingCompleted()
551 if (!m_statusBar
->progressText().isEmpty()) {
552 m_statusBar
->setProgressText(QString());
553 m_statusBar
->setProgress(100);
556 if (isSearchUrl(url()) && m_view
->itemsCount() == 0) {
557 // The dir lister has been completed on a Baloo-URI and no items have been found. Instead
558 // of showing the default status bar information ("0 items") a more helpful information is given:
559 m_statusBar
->setText(i18nc("@info:status", "No items found."));
565 void DolphinViewContainer::slotDirectoryLoadingCanceled()
567 if (!m_statusBar
->progressText().isEmpty()) {
568 m_statusBar
->setProgressText(QString());
569 m_statusBar
->setProgress(100);
572 m_statusBar
->setText(QString());
575 void DolphinViewContainer::slotUrlIsFileError(const QUrl
& url
)
577 const KFileItem
item(url
);
579 // Find out if the file can be opened in the view (for example, this is the
580 // case if the file is an archive). The mime type must be known for that.
581 item
.determineMimeType();
582 const QUrl
& folderUrl
= DolphinView::openItemAsFolderUrl(item
, true);
583 if (!folderUrl
.isEmpty()) {
586 slotItemActivated(item
);
590 void DolphinViewContainer::slotItemActivated(const KFileItem
& item
)
592 // It is possible to activate items on inactive views by
593 // drag & drop operations. Assure that activating an item always
594 // results in an active view.
595 m_view
->setActive(true);
597 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
, GeneralSettings::browseThroughArchives());
598 if (!url
.isEmpty()) {
603 KRun
*run
= new KRun(item
.targetUrl(), this);
604 run
->setShowScriptExecutionPrompt(true);
607 void DolphinViewContainer::slotItemsActivated(const KFileItemList
& items
)
609 Q_ASSERT(items
.count() >= 2);
611 KFileItemActions
fileItemActions(this);
612 fileItemActions
.runPreferredApplications(items
, QString());
615 void DolphinViewContainer::showItemInfo(const KFileItem
& item
)
618 m_statusBar
->resetToDefaultText();
620 m_statusBar
->setText(item
.getStatusBarInfo());
624 void DolphinViewContainer::closeFilterBar()
626 m_filterBar
->closeFilterBar();
628 emit
showFilterBarChanged(false);
631 void DolphinViewContainer::setNameFilter(const QString
& nameFilter
)
633 m_view
->setNameFilter(nameFilter
);
634 delayedStatusBarUpdate();
637 void DolphinViewContainer::activate()
642 void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const QUrl
&)
647 void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl
& url
)
651 if (KProtocolManager::supportsListing(url
)) {
652 setSearchModeEnabled(isSearchUrl(url
));
654 tryRestoreViewState();
656 if (m_autoGrabFocus
&& isActive() && !isSearchUrl(url
)) {
657 // When an URL has been entered, the view should get the focus.
658 // The focus must be requested asynchronously, as changing the URL might create
659 // a new view widget.
660 QTimer::singleShot(0, this, &DolphinViewContainer::requestFocus
);
662 } else if (KProtocolManager::isSourceProtocol(url
)) {
663 QString app
= QStringLiteral("konqueror");
664 if (url
.scheme().startsWith(QLatin1String("http"))) {
665 showMessage(i18nc("@info:status", // krazy:exclude=qmethods
666 "Dolphin does not support web pages, the web browser has been launched"),
669 const KConfigGroup
config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "General");
670 const QString browser
= config
.readEntry("BrowserApplication");
671 if (!browser
.isEmpty()) {
673 if (app
.startsWith('!')) {
674 // a literal command has been configured, remove the '!' prefix
679 showMessage(i18nc("@info:status",
680 "Protocol not supported by Dolphin, Konqueror has been launched"),
684 const QString secureUrl
= KShell::quoteArg(url
.toDisplayString(QUrl::PreferLocalFile
));
685 const QString command
= app
+ ' ' + secureUrl
;
686 KRun::runCommand(command
, app
, app
, this);
688 showMessage(i18nc("@info:status", "Invalid protocol"), Error
);
692 void DolphinViewContainer::slotUrlSelectionRequested(const QUrl
& url
)
694 m_view
->markUrlsAsSelected({url
});
695 m_view
->markUrlAsCurrent(url
); // makes the item scroll into view
698 void DolphinViewContainer::redirect(const QUrl
& oldUrl
, const QUrl
& newUrl
)
701 const bool block
= m_urlNavigator
->signalsBlocked();
702 m_urlNavigator
->blockSignals(true);
704 // Assure that the location state is reset for redirection URLs. This
705 // allows to skip redirection URLs when going back or forward in the
707 m_urlNavigator
->saveLocationState(QByteArray());
708 m_urlNavigator
->setLocationUrl(newUrl
);
709 setSearchModeEnabled(isSearchUrl(newUrl
));
711 m_urlNavigator
->blockSignals(block
);
714 void DolphinViewContainer::requestFocus()
719 void DolphinViewContainer::saveUrlCompletionMode(KCompletion::CompletionMode completion
)
721 GeneralSettings::setUrlCompletionMode(completion
);
724 void DolphinViewContainer::slotReturnPressed()
726 if (!GeneralSettings::editableUrl()) {
727 m_urlNavigator
->setUrlEditable(false);
731 void DolphinViewContainer::startSearching()
733 const QUrl url
= m_searchBox
->urlForSearching();
734 if (url
.isValid() && !url
.isEmpty()) {
735 m_view
->setViewPropertiesContext(QStringLiteral("search"));
736 m_urlNavigator
->setLocationUrl(url
);
740 void DolphinViewContainer::closeSearchBox()
742 setSearchModeEnabled(false);
745 void DolphinViewContainer::stopDirectoryLoading()
747 m_view
->stopLoading();
748 m_statusBar
->setProgress(100);
751 void DolphinViewContainer::slotStatusBarZoomLevelChanged(int zoomLevel
)
753 m_view
->setZoomLevel(zoomLevel
);
756 void DolphinViewContainer::showErrorMessage(const QString
& msg
)
758 showMessage(msg
, Error
);
761 bool DolphinViewContainer::isSearchUrl(const QUrl
& url
) const
763 return url
.scheme().contains(QStringLiteral("search"));
766 void DolphinViewContainer::saveViewState()
768 QByteArray locationState
;
769 QDataStream
stream(&locationState
, QIODevice::WriteOnly
);
770 m_view
->saveState(stream
);
771 m_urlNavigator
->saveLocationState(locationState
);
774 void DolphinViewContainer::tryRestoreViewState()
776 QByteArray locationState
= m_urlNavigator
->locationState();
777 if (!locationState
.isEmpty()) {
778 QDataStream
stream(&locationState
, QIODevice::ReadOnly
);
779 m_view
->restoreState(stream
);