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 #include <KFileItemActions>
34 #include <KFilePlacesModel>
35 #include <KIO/PreviewJob>
36 #include <KLocalizedString>
37 #include <KMessageWidget>
38 #include <KProtocolManager>
41 #include <KUrlComboBox>
42 #include <KUrlNavigator>
43 #include <kio_version.h>
46 #include <QLoggingCategory>
50 #include <QVBoxLayout>
52 DolphinViewContainer::DolphinViewContainer(const QUrl
& url
, QWidget
* parent
) :
55 m_navigatorWidget(nullptr),
56 m_urlNavigator(nullptr),
57 m_emptyTrashButton(nullptr),
59 m_searchModeEnabled(false),
60 m_messageWidget(nullptr),
64 m_statusBarTimer(nullptr),
65 m_statusBarTimestamp(),
67 #ifdef KActivities_FOUND
68 , m_activityResourceInstance(0)
73 m_topLayout
= new QVBoxLayout(this);
74 m_topLayout
->setSpacing(0);
75 m_topLayout
->setMargin(0);
77 m_navigatorWidget
= new QWidget(this);
78 QHBoxLayout
* navigatorLayout
= new QHBoxLayout(m_navigatorWidget
);
79 navigatorLayout
->setSpacing(0);
80 navigatorLayout
->setMargin(0);
82 m_urlNavigator
= new KUrlNavigator(DolphinPlacesModelSingleton::instance().placesModel(), url
, this);
83 connect(m_urlNavigator
, &KUrlNavigator::activated
,
84 this, &DolphinViewContainer::activate
);
85 connect(m_urlNavigator
->editor(), &KUrlComboBox::completionModeChanged
,
86 this, &DolphinViewContainer::saveUrlCompletionMode
);
88 const GeneralSettings
* settings
= GeneralSettings::self();
89 m_urlNavigator
->setUrlEditable(settings
->editableUrl());
90 m_urlNavigator
->setShowFullPath(settings
->showFullPath());
91 m_urlNavigator
->setHomeUrl(Dolphin::homeUrl());
92 KUrlComboBox
* editor
= m_urlNavigator
->editor();
93 editor
->setCompletionMode(KCompletion::CompletionMode(settings
->urlCompletionMode()));
95 m_emptyTrashButton
= new QPushButton(QIcon::fromTheme(QStringLiteral("user-trash")), i18nc("@action:button", "Empty Trash"), this);
96 m_emptyTrashButton
->setFlat(true);
97 connect(m_emptyTrashButton
, &QPushButton::clicked
, this, [this]() { Trash::empty(this); });
98 connect(&Trash::instance(), &Trash::emptinessChanged
, m_emptyTrashButton
, &QPushButton::setDisabled
);
99 m_emptyTrashButton
->setDisabled(Trash::isEmpty());
100 m_emptyTrashButton
->hide();
102 m_searchBox
= new DolphinSearchBox(this);
104 connect(m_searchBox
, &DolphinSearchBox::activated
, this, &DolphinViewContainer::activate
);
105 connect(m_searchBox
, &DolphinSearchBox::closeRequest
, this, &DolphinViewContainer::closeSearchBox
);
106 connect(m_searchBox
, &DolphinSearchBox::searchRequest
, this, &DolphinViewContainer::startSearching
);
107 connect(m_searchBox
, &DolphinSearchBox::returnPressed
, this, &DolphinViewContainer::requestFocus
);
109 m_messageWidget
= new KMessageWidget(this);
110 m_messageWidget
->setCloseButtonVisible(true);
111 m_messageWidget
->hide();
116 // We must be logged in as the root user; show a big scary warning
117 showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), Warning
);
121 m_view
= new DolphinView(url
, this);
122 connect(m_view
, &DolphinView::urlChanged
,
123 m_urlNavigator
, &KUrlNavigator::setLocationUrl
);
124 connect(m_view
, &DolphinView::urlChanged
,
125 m_messageWidget
, &KMessageWidget::hide
);
126 connect(m_view
, &DolphinView::writeStateChanged
,
127 this, &DolphinViewContainer::writeStateChanged
);
128 connect(m_view
, &DolphinView::requestItemInfo
,
129 this, &DolphinViewContainer::showItemInfo
);
130 connect(m_view
, &DolphinView::itemActivated
,
131 this, &DolphinViewContainer::slotItemActivated
);
132 connect(m_view
, &DolphinView::itemsActivated
,
133 this, &DolphinViewContainer::slotItemsActivated
);
134 connect(m_view
, &DolphinView::redirection
,
135 this, &DolphinViewContainer::redirect
);
136 connect(m_view
, &DolphinView::directoryLoadingStarted
,
137 this, &DolphinViewContainer::slotDirectoryLoadingStarted
);
138 connect(m_view
, &DolphinView::directoryLoadingCompleted
,
139 this, &DolphinViewContainer::slotDirectoryLoadingCompleted
);
140 connect(m_view
, &DolphinView::directoryLoadingCanceled
,
141 this, &DolphinViewContainer::slotDirectoryLoadingCanceled
);
142 connect(m_view
, &DolphinView::itemCountChanged
,
143 this, &DolphinViewContainer::delayedStatusBarUpdate
);
144 connect(m_view
, &DolphinView::directoryLoadingProgress
,
145 this, &DolphinViewContainer::updateDirectoryLoadingProgress
);
146 connect(m_view
, &DolphinView::directorySortingProgress
,
147 this, &DolphinViewContainer::updateDirectorySortingProgress
);
148 connect(m_view
, &DolphinView::selectionChanged
,
149 this, &DolphinViewContainer::delayedStatusBarUpdate
);
150 connect(m_view
, &DolphinView::errorMessage
,
151 this, &DolphinViewContainer::showErrorMessage
);
152 connect(m_view
, &DolphinView::urlIsFileError
,
153 this, &DolphinViewContainer::slotUrlIsFileError
);
154 connect(m_view
, &DolphinView::activated
,
155 this, &DolphinViewContainer::activate
);
157 connect(m_urlNavigator
, &KUrlNavigator::urlAboutToBeChanged
,
158 this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged
);
159 connect(m_urlNavigator
, &KUrlNavigator::urlChanged
,
160 this, &DolphinViewContainer::slotUrlNavigatorLocationChanged
);
161 connect(m_urlNavigator
, &KUrlNavigator::urlSelectionRequested
,
162 this, &DolphinViewContainer::slotUrlSelectionRequested
);
163 connect(m_urlNavigator
, &KUrlNavigator::returnPressed
,
164 this, &DolphinViewContainer::slotReturnPressed
);
165 connect(m_urlNavigator
, &KUrlNavigator::urlsDropped
, this, [=](const QUrl
&destination
, QDropEvent
*event
) {
166 m_view
->dropUrls(destination
, event
, m_urlNavigator
->dropWidget());
169 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, [this]() {
170 m_emptyTrashButton
->setVisible(m_view
->url().scheme() == QLatin1String("trash"));
173 // Initialize status bar
174 m_statusBar
= new DolphinStatusBar(this);
175 m_statusBar
->setUrl(m_view
->url());
176 m_statusBar
->setZoomLevel(m_view
->zoomLevel());
177 connect(m_view
, &DolphinView::urlChanged
,
178 m_statusBar
, &DolphinStatusBar::setUrl
);
179 connect(m_view
, &DolphinView::zoomLevelChanged
,
180 m_statusBar
, &DolphinStatusBar::setZoomLevel
);
181 connect(m_view
, &DolphinView::infoMessage
,
182 m_statusBar
, &DolphinStatusBar::setText
);
183 connect(m_view
, &DolphinView::operationCompletedMessage
,
184 m_statusBar
, &DolphinStatusBar::setText
);
185 connect(m_statusBar
, &DolphinStatusBar::stopPressed
,
186 this, &DolphinViewContainer::stopDirectoryLoading
);
187 connect(m_statusBar
, &DolphinStatusBar::zoomLevelChanged
,
188 this, &DolphinViewContainer::slotStatusBarZoomLevelChanged
);
190 m_statusBarTimer
= new QTimer(this);
191 m_statusBarTimer
->setSingleShot(true);
192 m_statusBarTimer
->setInterval(300);
193 connect(m_statusBarTimer
, &QTimer::timeout
, this, &DolphinViewContainer::updateStatusBar
);
195 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
196 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
197 this, &DolphinViewContainer::delayedStatusBarUpdate
);
199 // Initialize filter bar
200 m_filterBar
= new FilterBar(this);
201 m_filterBar
->setVisible(settings
->filterBar());
202 connect(m_filterBar
, &FilterBar::filterChanged
,
203 this, &DolphinViewContainer::setNameFilter
);
204 connect(m_filterBar
, &FilterBar::closeRequest
,
205 this, &DolphinViewContainer::closeFilterBar
);
206 connect(m_filterBar
, &FilterBar::focusViewRequest
,
207 this, &DolphinViewContainer::requestFocus
);
208 connect(m_view
, &DolphinView::urlChanged
,
209 m_filterBar
, &FilterBar::slotUrlChanged
);
211 navigatorLayout
->addWidget(m_urlNavigator
);
212 navigatorLayout
->addWidget(m_emptyTrashButton
);
214 m_topLayout
->addWidget(m_navigatorWidget
);
215 m_topLayout
->addWidget(m_searchBox
);
216 m_topLayout
->addWidget(m_messageWidget
);
217 m_topLayout
->addWidget(m_view
);
218 m_topLayout
->addWidget(m_filterBar
);
219 m_topLayout
->addWidget(m_statusBar
);
221 setSearchModeEnabled(isSearchUrl(url
));
223 // Initialize kactivities resource instance
225 #ifdef KActivities_FOUND
226 m_activityResourceInstance
= new KActivities::ResourceInstance(
227 window()->winId(), url
);
228 m_activityResourceInstance
->setParent(this);
232 DolphinViewContainer::~DolphinViewContainer()
236 QUrl
DolphinViewContainer::url() const
238 return m_view
->url();
241 void DolphinViewContainer::setActive(bool active
)
243 m_searchBox
->setActive(active
);
244 m_urlNavigator
->setActive(active
);
245 m_view
->setActive(active
);
247 #ifdef KActivities_FOUND
249 m_activityResourceInstance
->notifyFocusedIn();
251 m_activityResourceInstance
->notifyFocusedOut();
256 bool DolphinViewContainer::isActive() const
258 Q_ASSERT(m_view
->isActive() == m_urlNavigator
->isActive());
259 return m_view
->isActive();
262 void DolphinViewContainer::setAutoGrabFocus(bool grab
)
264 m_autoGrabFocus
= grab
;
267 bool DolphinViewContainer::autoGrabFocus() const
269 return m_autoGrabFocus
;
272 QString
DolphinViewContainer::currentSearchText() const
274 return m_searchBox
->text();
277 const DolphinStatusBar
* DolphinViewContainer::statusBar() const
282 DolphinStatusBar
* DolphinViewContainer::statusBar()
287 const KUrlNavigator
* DolphinViewContainer::urlNavigator() const
289 return m_urlNavigator
;
292 KUrlNavigator
* DolphinViewContainer::urlNavigator()
294 return m_urlNavigator
;
297 const DolphinView
* DolphinViewContainer::view() const
302 DolphinView
* DolphinViewContainer::view()
307 void DolphinViewContainer::showMessage(const QString
& msg
, MessageType type
)
313 m_messageWidget
->setText(msg
);
316 case Information
: m_messageWidget
->setMessageType(KMessageWidget::Information
); break;
317 case Warning
: m_messageWidget
->setMessageType(KMessageWidget::Warning
); break;
318 case Error
: m_messageWidget
->setMessageType(KMessageWidget::Error
); break;
324 m_messageWidget
->setWordWrap(false);
325 const int unwrappedWidth
= m_messageWidget
->sizeHint().width();
326 m_messageWidget
->setWordWrap(unwrappedWidth
> size().width());
328 if (m_messageWidget
->isVisible()) {
329 m_messageWidget
->hide();
331 m_messageWidget
->animatedShow();
334 void DolphinViewContainer::readSettings()
336 if (GeneralSettings::modifiedStartupSettings()) {
337 // The startup settings should only get applied if they have been
338 // modified by the user. Otherwise keep the (possibly) different current
339 // settings of the URL navigator and the filterbar.
340 m_urlNavigator
->setUrlEditable(GeneralSettings::editableUrl());
341 m_urlNavigator
->setShowFullPath(GeneralSettings::showFullPath());
342 m_urlNavigator
->setHomeUrl(Dolphin::homeUrl());
343 setFilterBarVisible(GeneralSettings::filterBar());
346 m_view
->readSettings();
347 m_statusBar
->readSettings();
350 bool DolphinViewContainer::isFilterBarVisible() const
352 return m_filterBar
->isVisible();
355 void DolphinViewContainer::setSearchModeEnabled(bool enabled
)
357 if (enabled
== isSearchModeEnabled()) {
358 if (enabled
&& !m_searchBox
->hasFocus()) {
359 m_searchBox
->setFocus();
360 m_searchBox
->selectAll();
365 m_searchBox
->setVisible(enabled
);
366 m_navigatorWidget
->setVisible(!enabled
);
369 const QUrl
& locationUrl
= m_urlNavigator
->locationUrl();
370 m_searchBox
->fromSearchUrl(locationUrl
);
372 m_view
->setViewPropertiesContext(QString());
374 // Restore the URL for the URL navigator. If Dolphin has been
375 // started with a search-URL, the home URL is used as fallback.
376 QUrl url
= m_searchBox
->searchPath();
377 if (url
.isEmpty() || !url
.isValid() || isSearchUrl(url
)) {
378 url
= Dolphin::homeUrl();
380 m_urlNavigator
->setLocationUrl(url
);
383 m_searchModeEnabled
= enabled
;
386 bool DolphinViewContainer::isSearchModeEnabled() const
388 return m_searchModeEnabled
;
391 QString
DolphinViewContainer::placesText() const
395 if (isSearchModeEnabled()) {
396 text
= i18n("Search for %1 in %2", m_searchBox
->text(), m_searchBox
->searchPath().fileName());
398 text
= url().fileName();
399 if (text
.isEmpty()) {
402 if (text
.isEmpty()) {
403 text
= url().scheme();
410 void DolphinViewContainer::reload()
413 m_messageWidget
->hide();
416 QString
DolphinViewContainer::caption() const
418 if (GeneralSettings::showFullPathInTitlebar()) {
419 if (!url().isLocalFile()) {
420 return url().adjusted(QUrl::StripTrailingSlash
).toString();
422 return url().adjusted(QUrl::StripTrailingSlash
).path();
425 KFilePlacesModel
*placesModel
= DolphinPlacesModelSingleton::instance().placesModel();
426 const auto& matchedPlaces
= placesModel
->match(placesModel
->index(0,0), KFilePlacesModel::UrlRole
, url(), 1, Qt::MatchExactly
);
428 if (!matchedPlaces
.isEmpty()) {
429 return placesModel
->text(matchedPlaces
.first());
432 if (isSearchModeEnabled()) {
433 if (currentSearchText().isEmpty()){
434 return i18n("Search");
436 return i18n("Search for %1", currentSearchText());
440 if (!url().isLocalFile()) {
441 QUrl adjustedUrl
= url().adjusted(QUrl::StripTrailingSlash
);
443 if (!adjustedUrl
.fileName().isEmpty()) {
444 caption
= adjustedUrl
.fileName();
445 } else if (!adjustedUrl
.path().isEmpty() && adjustedUrl
.path() != "/") {
446 caption
= adjustedUrl
.path();
447 } else if (!adjustedUrl
.host().isEmpty()) {
448 caption
= adjustedUrl
.host();
450 caption
= adjustedUrl
.toString();
455 QString fileName
= url().adjusted(QUrl::StripTrailingSlash
).fileName();
456 if (fileName
.isEmpty()) {
463 void DolphinViewContainer::setUrl(const QUrl
& newUrl
)
465 if (newUrl
!= m_urlNavigator
->locationUrl()) {
466 m_urlNavigator
->setLocationUrl(newUrl
);
469 #ifdef KActivities_FOUND
470 m_activityResourceInstance
->setUri(newUrl
);
474 void DolphinViewContainer::setFilterBarVisible(bool visible
)
476 Q_ASSERT(m_filterBar
);
479 m_filterBar
->setFocus();
480 m_filterBar
->selectAll();
486 void DolphinViewContainer::delayedStatusBarUpdate()
488 if (m_statusBarTimer
->isActive() && (m_statusBarTimestamp
.elapsed() > 2000)) {
489 // No update of the statusbar has been done during the last 2 seconds,
490 // although an update has been requested. Trigger an immediate update.
491 m_statusBarTimer
->stop();
494 // Invoke updateStatusBar() with a small delay. This assures that
495 // when a lot of delayedStatusBarUpdates() are done in a short time,
496 // no bottleneck is given.
497 m_statusBarTimer
->start();
501 void DolphinViewContainer::updateStatusBar()
503 m_statusBarTimestamp
.start();
505 const QString text
= m_view
->statusBarText();
506 m_statusBar
->setDefaultText(text
);
507 m_statusBar
->resetToDefaultText();
510 void DolphinViewContainer::updateDirectoryLoadingProgress(int percent
)
512 if (m_statusBar
->progressText().isEmpty()) {
513 m_statusBar
->setProgressText(i18nc("@info:progress", "Loading folder..."));
515 m_statusBar
->setProgress(percent
);
518 void DolphinViewContainer::updateDirectorySortingProgress(int percent
)
520 if (m_statusBar
->progressText().isEmpty()) {
521 m_statusBar
->setProgressText(i18nc("@info:progress", "Sorting..."));
523 m_statusBar
->setProgress(percent
);
526 void DolphinViewContainer::slotDirectoryLoadingStarted()
528 if (isSearchUrl(url())) {
529 // Search KIO-slaves usually don't provide any progress information. Give
530 // a hint to the user that a searching is done:
532 m_statusBar
->setProgressText(i18nc("@info", "Searching..."));
533 m_statusBar
->setProgress(-1);
535 // Trigger an undetermined progress indication. The progress
536 // information in percent will be triggered by the percent() signal
537 // of the directory lister later.
538 updateDirectoryLoadingProgress(-1);
542 void DolphinViewContainer::slotDirectoryLoadingCompleted()
544 if (!m_statusBar
->progressText().isEmpty()) {
545 m_statusBar
->setProgressText(QString());
546 m_statusBar
->setProgress(100);
549 if (isSearchUrl(url()) && m_view
->itemsCount() == 0) {
550 // The dir lister has been completed on a Baloo-URI and no items have been found. Instead
551 // of showing the default status bar information ("0 items") a more helpful information is given:
552 m_statusBar
->setText(i18nc("@info:status", "No items found."));
558 void DolphinViewContainer::slotDirectoryLoadingCanceled()
560 if (!m_statusBar
->progressText().isEmpty()) {
561 m_statusBar
->setProgressText(QString());
562 m_statusBar
->setProgress(100);
565 m_statusBar
->setText(QString());
568 void DolphinViewContainer::slotUrlIsFileError(const QUrl
& url
)
570 const KFileItem
item(url
);
572 // Find out if the file can be opened in the view (for example, this is the
573 // case if the file is an archive). The mime type must be known for that.
574 item
.determineMimeType();
575 const QUrl
& folderUrl
= DolphinView::openItemAsFolderUrl(item
, true);
576 if (!folderUrl
.isEmpty()) {
579 slotItemActivated(item
);
583 void DolphinViewContainer::slotItemActivated(const KFileItem
& item
)
585 // It is possible to activate items on inactive views by
586 // drag & drop operations. Assure that activating an item always
587 // results in an active view.
588 m_view
->setActive(true);
590 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
, GeneralSettings::browseThroughArchives());
591 if (!url
.isEmpty()) {
596 KRun
*run
= new KRun(item
.targetUrl(), this);
597 run
->setShowScriptExecutionPrompt(true);
600 void DolphinViewContainer::slotItemsActivated(const KFileItemList
& items
)
602 Q_ASSERT(items
.count() >= 2);
604 KFileItemActions
fileItemActions(this);
605 fileItemActions
.runPreferredApplications(items
, QString());
608 void DolphinViewContainer::showItemInfo(const KFileItem
& item
)
611 m_statusBar
->resetToDefaultText();
613 m_statusBar
->setText(item
.getStatusBarInfo());
617 void DolphinViewContainer::closeFilterBar()
619 m_filterBar
->closeFilterBar();
621 emit
showFilterBarChanged(false);
624 void DolphinViewContainer::setNameFilter(const QString
& nameFilter
)
626 m_view
->setNameFilter(nameFilter
);
627 delayedStatusBarUpdate();
630 void DolphinViewContainer::activate()
635 void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const QUrl
&)
640 void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl
& url
)
644 if (KProtocolManager::supportsListing(url
)) {
645 setSearchModeEnabled(isSearchUrl(url
));
647 tryRestoreViewState();
649 if (m_autoGrabFocus
&& isActive() && !isSearchUrl(url
)) {
650 // When an URL has been entered, the view should get the focus.
651 // The focus must be requested asynchronously, as changing the URL might create
652 // a new view widget.
653 QTimer::singleShot(0, this, &DolphinViewContainer::requestFocus
);
655 } else if (KProtocolManager::isSourceProtocol(url
)) {
656 QString app
= QStringLiteral("konqueror");
657 if (url
.scheme().startsWith(QLatin1String("http"))) {
658 showMessage(i18nc("@info:status", // krazy:exclude=qmethods
659 "Dolphin does not support web pages, the web browser has been launched"),
662 const KConfigGroup
config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "General");
663 const QString browser
= config
.readEntry("BrowserApplication");
664 if (!browser
.isEmpty()) {
666 if (app
.startsWith('!')) {
667 // a literal command has been configured, remove the '!' prefix
672 showMessage(i18nc("@info:status",
673 "Protocol not supported by Dolphin, Konqueror has been launched"),
677 const QString secureUrl
= KShell::quoteArg(url
.toDisplayString(QUrl::PreferLocalFile
));
678 const QString command
= app
+ ' ' + secureUrl
;
679 KRun::runCommand(command
, app
, app
, this);
681 showMessage(i18nc("@info:status", "Invalid protocol"), Error
);
685 void DolphinViewContainer::slotUrlSelectionRequested(const QUrl
& url
)
687 m_view
->markUrlsAsSelected({url
});
688 m_view
->markUrlAsCurrent(url
); // makes the item scroll into view
691 void DolphinViewContainer::redirect(const QUrl
& oldUrl
, const QUrl
& newUrl
)
694 const bool block
= m_urlNavigator
->signalsBlocked();
695 m_urlNavigator
->blockSignals(true);
697 // Assure that the location state is reset for redirection URLs. This
698 // allows to skip redirection URLs when going back or forward in the
700 m_urlNavigator
->saveLocationState(QByteArray());
701 m_urlNavigator
->setLocationUrl(newUrl
);
702 setSearchModeEnabled(isSearchUrl(newUrl
));
704 m_urlNavigator
->blockSignals(block
);
707 void DolphinViewContainer::requestFocus()
712 void DolphinViewContainer::saveUrlCompletionMode(KCompletion::CompletionMode completion
)
714 GeneralSettings::setUrlCompletionMode(completion
);
717 void DolphinViewContainer::slotReturnPressed()
719 if (!GeneralSettings::editableUrl()) {
720 m_urlNavigator
->setUrlEditable(false);
724 void DolphinViewContainer::startSearching()
726 const QUrl url
= m_searchBox
->urlForSearching();
727 if (url
.isValid() && !url
.isEmpty()) {
728 m_view
->setViewPropertiesContext(QStringLiteral("search"));
729 m_urlNavigator
->setLocationUrl(url
);
733 void DolphinViewContainer::closeSearchBox()
735 setSearchModeEnabled(false);
738 void DolphinViewContainer::stopDirectoryLoading()
740 m_view
->stopLoading();
741 m_statusBar
->setProgress(100);
744 void DolphinViewContainer::slotStatusBarZoomLevelChanged(int zoomLevel
)
746 m_view
->setZoomLevel(zoomLevel
);
749 void DolphinViewContainer::showErrorMessage(const QString
& msg
)
751 showMessage(msg
, Error
);
754 bool DolphinViewContainer::isSearchUrl(const QUrl
& url
) const
756 return url
.scheme().contains(QStringLiteral("search"));
759 void DolphinViewContainer::saveViewState()
761 QByteArray locationState
;
762 QDataStream
stream(&locationState
, QIODevice::WriteOnly
);
763 m_view
->saveState(stream
);
764 m_urlNavigator
->saveLocationState(locationState
);
767 void DolphinViewContainer::tryRestoreViewState()
769 QByteArray locationState
= m_urlNavigator
->locationState();
770 if (!locationState
.isEmpty()) {
771 QDataStream
stream(&locationState
, QIODevice::ReadOnly
);
772 m_view
->restoreState(stream
);