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 m_view
= new DolphinView(url
, this);
124 connect(m_view
, &DolphinView::urlChanged
,
125 m_urlNavigator
, &KUrlNavigator::setLocationUrl
);
126 connect(m_view
, &DolphinView::urlChanged
,
127 m_messageWidget
, &KMessageWidget::hide
);
128 connect(m_view
, &DolphinView::writeStateChanged
,
129 this, &DolphinViewContainer::writeStateChanged
);
130 connect(m_view
, &DolphinView::requestItemInfo
,
131 this, &DolphinViewContainer::showItemInfo
);
132 connect(m_view
, &DolphinView::itemActivated
,
133 this, &DolphinViewContainer::slotItemActivated
);
134 connect(m_view
, &DolphinView::itemsActivated
,
135 this, &DolphinViewContainer::slotItemsActivated
);
136 connect(m_view
, &DolphinView::redirection
,
137 this, &DolphinViewContainer::redirect
);
138 connect(m_view
, &DolphinView::directoryLoadingStarted
,
139 this, &DolphinViewContainer::slotDirectoryLoadingStarted
);
140 connect(m_view
, &DolphinView::directoryLoadingCompleted
,
141 this, &DolphinViewContainer::slotDirectoryLoadingCompleted
);
142 connect(m_view
, &DolphinView::directoryLoadingCanceled
,
143 this, &DolphinViewContainer::slotDirectoryLoadingCanceled
);
144 connect(m_view
, &DolphinView::itemCountChanged
,
145 this, &DolphinViewContainer::delayedStatusBarUpdate
);
146 connect(m_view
, &DolphinView::directoryLoadingProgress
,
147 this, &DolphinViewContainer::updateDirectoryLoadingProgress
);
148 connect(m_view
, &DolphinView::directorySortingProgress
,
149 this, &DolphinViewContainer::updateDirectorySortingProgress
);
150 connect(m_view
, &DolphinView::selectionChanged
,
151 this, &DolphinViewContainer::delayedStatusBarUpdate
);
152 connect(m_view
, &DolphinView::errorMessage
,
153 this, &DolphinViewContainer::showErrorMessage
);
154 connect(m_view
, &DolphinView::urlIsFileError
,
155 this, &DolphinViewContainer::slotUrlIsFileError
);
156 connect(m_view
, &DolphinView::activated
,
157 this, &DolphinViewContainer::activate
);
159 connect(m_urlNavigator
, &KUrlNavigator::urlAboutToBeChanged
,
160 this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged
);
161 connect(m_urlNavigator
, &KUrlNavigator::urlChanged
,
162 this, &DolphinViewContainer::slotUrlNavigatorLocationChanged
);
163 connect(m_urlNavigator
, &KUrlNavigator::urlSelectionRequested
,
164 this, &DolphinViewContainer::slotUrlSelectionRequested
);
165 connect(m_urlNavigator
, &KUrlNavigator::returnPressed
,
166 this, &DolphinViewContainer::slotReturnPressed
);
167 connect(m_urlNavigator
, &KUrlNavigator::urlsDropped
, this, [=](const QUrl
&destination
, QDropEvent
*event
) {
168 m_view
->dropUrls(destination
, event
, m_urlNavigator
->dropWidget());
171 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, [this]() {
172 m_emptyTrashButton
->setVisible(m_view
->url().scheme() == QLatin1String("trash"));
175 // Initialize status bar
176 m_statusBar
= new DolphinStatusBar(this);
177 m_statusBar
->setUrl(m_view
->url());
178 m_statusBar
->setZoomLevel(m_view
->zoomLevel());
179 connect(m_view
, &DolphinView::urlChanged
,
180 m_statusBar
, &DolphinStatusBar::setUrl
);
181 connect(m_view
, &DolphinView::zoomLevelChanged
,
182 m_statusBar
, &DolphinStatusBar::setZoomLevel
);
183 connect(m_view
, &DolphinView::infoMessage
,
184 m_statusBar
, &DolphinStatusBar::setText
);
185 connect(m_view
, &DolphinView::operationCompletedMessage
,
186 m_statusBar
, &DolphinStatusBar::setText
);
187 connect(m_statusBar
, &DolphinStatusBar::stopPressed
,
188 this, &DolphinViewContainer::stopDirectoryLoading
);
189 connect(m_statusBar
, &DolphinStatusBar::zoomLevelChanged
,
190 this, &DolphinViewContainer::slotStatusBarZoomLevelChanged
);
192 m_statusBarTimer
= new QTimer(this);
193 m_statusBarTimer
->setSingleShot(true);
194 m_statusBarTimer
->setInterval(300);
195 connect(m_statusBarTimer
, &QTimer::timeout
, this, &DolphinViewContainer::updateStatusBar
);
197 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
198 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
199 this, &DolphinViewContainer::delayedStatusBarUpdate
);
201 // Initialize filter bar
202 m_filterBar
= new FilterBar(this);
203 m_filterBar
->setVisible(settings
->filterBar());
204 connect(m_filterBar
, &FilterBar::filterChanged
,
205 this, &DolphinViewContainer::setNameFilter
);
206 connect(m_filterBar
, &FilterBar::closeRequest
,
207 this, &DolphinViewContainer::closeFilterBar
);
208 connect(m_filterBar
, &FilterBar::focusViewRequest
,
209 this, &DolphinViewContainer::requestFocus
);
210 connect(m_view
, &DolphinView::urlChanged
,
211 m_filterBar
, &FilterBar::slotUrlChanged
);
213 navigatorLayout
->addWidget(m_urlNavigator
);
214 navigatorLayout
->addWidget(m_emptyTrashButton
);
216 m_topLayout
->addWidget(m_navigatorWidget
);
217 m_topLayout
->addWidget(m_searchBox
);
218 m_topLayout
->addWidget(m_messageWidget
);
219 m_topLayout
->addWidget(m_view
);
220 m_topLayout
->addWidget(m_filterBar
);
221 m_topLayout
->addWidget(m_statusBar
);
223 setSearchModeEnabled(isSearchUrl(url
));
225 // Initialize kactivities resource instance
227 #ifdef HAVE_KACTIVITIES
228 m_activityResourceInstance
= new KActivities::ResourceInstance(window()->winId(), url
);
229 m_activityResourceInstance
->setParent(this);
233 DolphinViewContainer::~DolphinViewContainer()
237 QUrl
DolphinViewContainer::url() const
239 return m_view
->url();
242 void DolphinViewContainer::setActive(bool active
)
244 m_searchBox
->setActive(active
);
245 m_urlNavigator
->setActive(active
);
246 m_view
->setActive(active
);
248 #ifdef HAVE_KACTIVITIES
250 m_activityResourceInstance
->notifyFocusedIn();
252 m_activityResourceInstance
->notifyFocusedOut();
257 bool DolphinViewContainer::isActive() const
259 Q_ASSERT(m_view
->isActive() == m_urlNavigator
->isActive());
260 return m_view
->isActive();
263 void DolphinViewContainer::setAutoGrabFocus(bool grab
)
265 m_autoGrabFocus
= grab
;
268 bool DolphinViewContainer::autoGrabFocus() const
270 return m_autoGrabFocus
;
273 QString
DolphinViewContainer::currentSearchText() const
275 return m_searchBox
->text();
278 const DolphinStatusBar
* DolphinViewContainer::statusBar() const
283 DolphinStatusBar
* DolphinViewContainer::statusBar()
288 const KUrlNavigator
* DolphinViewContainer::urlNavigator() const
290 return m_urlNavigator
;
293 KUrlNavigator
* DolphinViewContainer::urlNavigator()
295 return m_urlNavigator
;
298 const DolphinView
* DolphinViewContainer::view() const
303 DolphinView
* DolphinViewContainer::view()
308 void DolphinViewContainer::showMessage(const QString
& msg
, MessageType type
)
314 m_messageWidget
->setText(msg
);
316 // TODO: wrap at arbitrary character positions once QLabel can do this
317 // https://bugreports.qt.io/browse/QTBUG-1276
318 m_messageWidget
->setWordWrap(true);
321 case Information
: m_messageWidget
->setMessageType(KMessageWidget::Information
); break;
322 case Warning
: m_messageWidget
->setMessageType(KMessageWidget::Warning
); break;
323 case Error
: m_messageWidget
->setMessageType(KMessageWidget::Error
); break;
329 m_messageWidget
->setWordWrap(false);
330 const int unwrappedWidth
= m_messageWidget
->sizeHint().width();
331 m_messageWidget
->setWordWrap(unwrappedWidth
> size().width());
333 if (m_messageWidget
->isVisible()) {
334 m_messageWidget
->hide();
336 m_messageWidget
->animatedShow();
339 void DolphinViewContainer::readSettings()
341 if (GeneralSettings::modifiedStartupSettings()) {
342 // The startup settings should only get applied if they have been
343 // modified by the user. Otherwise keep the (possibly) different current
344 // settings of the URL navigator and the filterbar.
345 m_urlNavigator
->setUrlEditable(GeneralSettings::editableUrl());
346 m_urlNavigator
->setShowFullPath(GeneralSettings::showFullPath());
347 m_urlNavigator
->setHomeUrl(Dolphin::homeUrl());
348 setFilterBarVisible(GeneralSettings::filterBar());
351 m_view
->readSettings();
352 m_statusBar
->readSettings();
355 bool DolphinViewContainer::isFilterBarVisible() const
357 return m_filterBar
->isVisible();
360 void DolphinViewContainer::setSearchModeEnabled(bool enabled
)
362 if (enabled
== isSearchModeEnabled()) {
363 if (enabled
&& !m_searchBox
->hasFocus()) {
364 m_searchBox
->setFocus();
365 m_searchBox
->selectAll();
370 m_searchBox
->setVisible(enabled
);
371 m_navigatorWidget
->setVisible(!enabled
);
374 const QUrl
& locationUrl
= m_urlNavigator
->locationUrl();
375 m_searchBox
->fromSearchUrl(locationUrl
);
377 m_view
->setViewPropertiesContext(QString());
379 // Restore the URL for the URL navigator. If Dolphin has been
380 // started with a search-URL, the home URL is used as fallback.
381 QUrl url
= m_searchBox
->searchPath();
382 if (url
.isEmpty() || !url
.isValid() || isSearchUrl(url
)) {
383 url
= Dolphin::homeUrl();
385 m_urlNavigator
->setLocationUrl(url
);
388 m_searchModeEnabled
= enabled
;
391 bool DolphinViewContainer::isSearchModeEnabled() const
393 return m_searchModeEnabled
;
396 QString
DolphinViewContainer::placesText() const
400 if (isSearchModeEnabled()) {
401 text
= i18n("Search for %1 in %2", m_searchBox
->text(), m_searchBox
->searchPath().fileName());
403 text
= url().fileName();
404 if (text
.isEmpty()) {
407 if (text
.isEmpty()) {
408 text
= url().scheme();
415 void DolphinViewContainer::reload()
418 m_messageWidget
->hide();
421 QString
DolphinViewContainer::caption() const
423 if (GeneralSettings::showFullPathInTitlebar()) {
424 if (!url().isLocalFile()) {
425 return url().adjusted(QUrl::StripTrailingSlash
).toString();
427 return url().adjusted(QUrl::StripTrailingSlash
).path();
430 KFilePlacesModel
*placesModel
= DolphinPlacesModelSingleton::instance().placesModel();
431 const auto& matchedPlaces
= placesModel
->match(placesModel
->index(0,0), KFilePlacesModel::UrlRole
, url(), 1, Qt::MatchExactly
);
433 if (!matchedPlaces
.isEmpty()) {
434 return placesModel
->text(matchedPlaces
.first());
437 if (isSearchModeEnabled()) {
438 if (currentSearchText().isEmpty()){
439 return i18n("Search");
441 return i18n("Search for %1", currentSearchText());
445 if (!url().isLocalFile()) {
446 QUrl adjustedUrl
= url().adjusted(QUrl::StripTrailingSlash
);
448 if (!adjustedUrl
.fileName().isEmpty()) {
449 caption
= adjustedUrl
.fileName();
450 } else if (!adjustedUrl
.path().isEmpty() && adjustedUrl
.path() != "/") {
451 caption
= adjustedUrl
.path();
452 } else if (!adjustedUrl
.host().isEmpty()) {
453 caption
= adjustedUrl
.host();
455 caption
= adjustedUrl
.toString();
460 QString fileName
= url().adjusted(QUrl::StripTrailingSlash
).fileName();
461 if (fileName
.isEmpty()) {
468 void DolphinViewContainer::setUrl(const QUrl
& newUrl
)
470 if (newUrl
!= m_urlNavigator
->locationUrl()) {
471 m_urlNavigator
->setLocationUrl(newUrl
);
474 #ifdef HAVE_KACTIVITIES
475 m_activityResourceInstance
->setUri(newUrl
);
479 void DolphinViewContainer::setFilterBarVisible(bool visible
)
481 Q_ASSERT(m_filterBar
);
484 m_filterBar
->setFocus();
485 m_filterBar
->selectAll();
491 void DolphinViewContainer::delayedStatusBarUpdate()
493 if (m_statusBarTimer
->isActive() && (m_statusBarTimestamp
.elapsed() > 2000)) {
494 // No update of the statusbar has been done during the last 2 seconds,
495 // although an update has been requested. Trigger an immediate update.
496 m_statusBarTimer
->stop();
499 // Invoke updateStatusBar() with a small delay. This assures that
500 // when a lot of delayedStatusBarUpdates() are done in a short time,
501 // no bottleneck is given.
502 m_statusBarTimer
->start();
506 void DolphinViewContainer::updateStatusBar()
508 m_statusBarTimestamp
.start();
510 const QString text
= m_view
->statusBarText();
511 m_statusBar
->setDefaultText(text
);
512 m_statusBar
->resetToDefaultText();
515 void DolphinViewContainer::updateDirectoryLoadingProgress(int percent
)
517 if (m_statusBar
->progressText().isEmpty()) {
518 m_statusBar
->setProgressText(i18nc("@info:progress", "Loading folder..."));
520 m_statusBar
->setProgress(percent
);
523 void DolphinViewContainer::updateDirectorySortingProgress(int percent
)
525 if (m_statusBar
->progressText().isEmpty()) {
526 m_statusBar
->setProgressText(i18nc("@info:progress", "Sorting..."));
528 m_statusBar
->setProgress(percent
);
531 void DolphinViewContainer::slotDirectoryLoadingStarted()
533 if (isSearchUrl(url())) {
534 // Search KIO-slaves usually don't provide any progress information. Give
535 // a hint to the user that a searching is done:
537 m_statusBar
->setProgressText(i18nc("@info", "Searching..."));
538 m_statusBar
->setProgress(-1);
540 // Trigger an undetermined progress indication. The progress
541 // information in percent will be triggered by the percent() signal
542 // of the directory lister later.
543 updateDirectoryLoadingProgress(-1);
547 void DolphinViewContainer::slotDirectoryLoadingCompleted()
549 if (!m_statusBar
->progressText().isEmpty()) {
550 m_statusBar
->setProgressText(QString());
551 m_statusBar
->setProgress(100);
554 if (isSearchUrl(url()) && m_view
->itemsCount() == 0) {
555 // The dir lister has been completed on a Baloo-URI and no items have been found. Instead
556 // of showing the default status bar information ("0 items") a more helpful information is given:
557 m_statusBar
->setText(i18nc("@info:status", "No items found."));
563 void DolphinViewContainer::slotDirectoryLoadingCanceled()
565 if (!m_statusBar
->progressText().isEmpty()) {
566 m_statusBar
->setProgressText(QString());
567 m_statusBar
->setProgress(100);
570 m_statusBar
->setText(QString());
573 void DolphinViewContainer::slotUrlIsFileError(const QUrl
& url
)
575 const KFileItem
item(url
);
577 // Find out if the file can be opened in the view (for example, this is the
578 // case if the file is an archive). The mime type must be known for that.
579 item
.determineMimeType();
580 const QUrl
& folderUrl
= DolphinView::openItemAsFolderUrl(item
, true);
581 if (!folderUrl
.isEmpty()) {
584 slotItemActivated(item
);
588 void DolphinViewContainer::slotItemActivated(const KFileItem
& item
)
590 // It is possible to activate items on inactive views by
591 // drag & drop operations. Assure that activating an item always
592 // results in an active view.
593 m_view
->setActive(true);
595 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
, GeneralSettings::browseThroughArchives());
596 if (!url
.isEmpty()) {
601 KRun
*run
= new KRun(item
.targetUrl(), this);
602 run
->setShowScriptExecutionPrompt(true);
605 void DolphinViewContainer::slotItemsActivated(const KFileItemList
& items
)
607 Q_ASSERT(items
.count() >= 2);
609 KFileItemActions
fileItemActions(this);
610 fileItemActions
.runPreferredApplications(items
, QString());
613 void DolphinViewContainer::showItemInfo(const KFileItem
& item
)
616 m_statusBar
->resetToDefaultText();
618 m_statusBar
->setText(item
.getStatusBarInfo());
622 void DolphinViewContainer::closeFilterBar()
624 m_filterBar
->closeFilterBar();
626 emit
showFilterBarChanged(false);
629 void DolphinViewContainer::setNameFilter(const QString
& nameFilter
)
631 m_view
->setNameFilter(nameFilter
);
632 delayedStatusBarUpdate();
635 void DolphinViewContainer::activate()
640 void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const QUrl
&)
645 void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl
& url
)
649 if (KProtocolManager::supportsListing(url
)) {
650 setSearchModeEnabled(isSearchUrl(url
));
652 tryRestoreViewState();
654 if (m_autoGrabFocus
&& isActive() && !isSearchUrl(url
)) {
655 // When an URL has been entered, the view should get the focus.
656 // The focus must be requested asynchronously, as changing the URL might create
657 // a new view widget.
658 QTimer::singleShot(0, this, &DolphinViewContainer::requestFocus
);
660 } else if (KProtocolManager::isSourceProtocol(url
)) {
661 QString app
= QStringLiteral("konqueror");
662 if (url
.scheme().startsWith(QLatin1String("http"))) {
663 showMessage(i18nc("@info:status", // krazy:exclude=qmethods
664 "Dolphin does not support web pages, the web browser has been launched"),
667 const KConfigGroup
config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "General");
668 const QString browser
= config
.readEntry("BrowserApplication");
669 if (!browser
.isEmpty()) {
671 if (app
.startsWith('!')) {
672 // a literal command has been configured, remove the '!' prefix
677 showMessage(i18nc("@info:status",
678 "Protocol not supported by Dolphin, Konqueror has been launched"),
682 const QString secureUrl
= KShell::quoteArg(url
.toDisplayString(QUrl::PreferLocalFile
));
683 const QString command
= app
+ ' ' + secureUrl
;
684 KRun::runCommand(command
, app
, app
, this);
686 showMessage(i18nc("@info:status", "Invalid protocol"), Error
);
690 void DolphinViewContainer::slotUrlSelectionRequested(const QUrl
& url
)
692 m_view
->markUrlsAsSelected({url
});
693 m_view
->markUrlAsCurrent(url
); // makes the item scroll into view
696 void DolphinViewContainer::redirect(const QUrl
& oldUrl
, const QUrl
& newUrl
)
699 const bool block
= m_urlNavigator
->signalsBlocked();
700 m_urlNavigator
->blockSignals(true);
702 // Assure that the location state is reset for redirection URLs. This
703 // allows to skip redirection URLs when going back or forward in the
705 m_urlNavigator
->saveLocationState(QByteArray());
706 m_urlNavigator
->setLocationUrl(newUrl
);
707 setSearchModeEnabled(isSearchUrl(newUrl
));
709 m_urlNavigator
->blockSignals(block
);
712 void DolphinViewContainer::requestFocus()
717 void DolphinViewContainer::saveUrlCompletionMode(KCompletion::CompletionMode completion
)
719 GeneralSettings::setUrlCompletionMode(completion
);
722 void DolphinViewContainer::slotReturnPressed()
724 if (!GeneralSettings::editableUrl()) {
725 m_urlNavigator
->setUrlEditable(false);
729 void DolphinViewContainer::startSearching()
731 const QUrl url
= m_searchBox
->urlForSearching();
732 if (url
.isValid() && !url
.isEmpty()) {
733 m_view
->setViewPropertiesContext(QStringLiteral("search"));
734 m_urlNavigator
->setLocationUrl(url
);
738 void DolphinViewContainer::closeSearchBox()
740 setSearchModeEnabled(false);
743 void DolphinViewContainer::stopDirectoryLoading()
745 m_view
->stopLoading();
746 m_statusBar
->setProgress(100);
749 void DolphinViewContainer::slotStatusBarZoomLevelChanged(int zoomLevel
)
751 m_view
->setZoomLevel(zoomLevel
);
754 void DolphinViewContainer::showErrorMessage(const QString
& msg
)
756 showMessage(msg
, Error
);
759 bool DolphinViewContainer::isSearchUrl(const QUrl
& url
) const
761 return url
.scheme().contains(QStringLiteral("search"));
764 void DolphinViewContainer::saveViewState()
766 QByteArray locationState
;
767 QDataStream
stream(&locationState
, QIODevice::WriteOnly
);
768 m_view
->saveState(stream
);
769 m_urlNavigator
->saveLocationState(locationState
);
772 void DolphinViewContainer::tryRestoreViewState()
774 QByteArray locationState
= m_urlNavigator
->locationState();
775 if (!locationState
.isEmpty()) {
776 QDataStream
stream(&locationState
, QIODevice::ReadOnly
);
777 m_view
->restoreState(stream
);