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_messageWidget(nullptr),
63 m_statusBarTimer(nullptr),
64 m_statusBarTimestamp(),
66 #ifdef KActivities_FOUND
67 , m_activityResourceInstance(0)
72 m_topLayout
= new QVBoxLayout(this);
73 m_topLayout
->setSpacing(0);
74 m_topLayout
->setMargin(0);
76 m_navigatorWidget
= new QWidget(this);
77 QHBoxLayout
* navigatorLayout
= new QHBoxLayout(m_navigatorWidget
);
78 navigatorLayout
->setSpacing(0);
79 navigatorLayout
->setMargin(0);
81 m_urlNavigator
= new KUrlNavigator(DolphinPlacesModelSingleton::instance().placesModel(), url
, this);
82 connect(m_urlNavigator
, &KUrlNavigator::activated
,
83 this, &DolphinViewContainer::activate
);
84 connect(m_urlNavigator
->editor(), &KUrlComboBox::completionModeChanged
,
85 this, &DolphinViewContainer::saveUrlCompletionMode
);
87 const GeneralSettings
* settings
= GeneralSettings::self();
88 m_urlNavigator
->setUrlEditable(settings
->editableUrl());
89 m_urlNavigator
->setShowFullPath(settings
->showFullPath());
90 m_urlNavigator
->setHomeUrl(Dolphin::homeUrl());
91 KUrlComboBox
* editor
= m_urlNavigator
->editor();
92 editor
->setCompletionMode(KCompletion::CompletionMode(settings
->urlCompletionMode()));
94 m_emptyTrashButton
= new QPushButton(QIcon::fromTheme(QStringLiteral("user-trash")), i18nc("@action:button", "Empty Trash"), this);
95 m_emptyTrashButton
->setFlat(true);
96 connect(m_emptyTrashButton
, &QPushButton::clicked
, this, [this]() { Trash::empty(this); });
97 connect(&Trash::instance(), &Trash::emptinessChanged
, m_emptyTrashButton
, &QPushButton::setDisabled
);
98 m_emptyTrashButton
->setDisabled(Trash::isEmpty());
99 m_emptyTrashButton
->hide();
101 m_searchBox
= new DolphinSearchBox(this);
103 connect(m_searchBox
, &DolphinSearchBox::activated
, this, &DolphinViewContainer::activate
);
104 connect(m_searchBox
, &DolphinSearchBox::closeRequest
, this, &DolphinViewContainer::closeSearchBox
);
105 connect(m_searchBox
, &DolphinSearchBox::searchRequest
, this, &DolphinViewContainer::startSearching
);
106 connect(m_searchBox
, &DolphinSearchBox::returnPressed
, this, &DolphinViewContainer::requestFocus
);
108 m_messageWidget
= new KMessageWidget(this);
109 m_messageWidget
->setCloseButtonVisible(true);
110 m_messageWidget
->hide();
115 // We must be logged in as the root user; show a big scary warning
116 showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), Warning
);
120 m_view
= new DolphinView(url
, this);
121 connect(m_view
, &DolphinView::urlChanged
,
122 m_urlNavigator
, &KUrlNavigator::setLocationUrl
);
123 connect(m_view
, &DolphinView::urlChanged
,
124 m_messageWidget
, &KMessageWidget::hide
);
125 connect(m_view
, &DolphinView::writeStateChanged
,
126 this, &DolphinViewContainer::writeStateChanged
);
127 connect(m_view
, &DolphinView::requestItemInfo
,
128 this, &DolphinViewContainer::showItemInfo
);
129 connect(m_view
, &DolphinView::itemActivated
,
130 this, &DolphinViewContainer::slotItemActivated
);
131 connect(m_view
, &DolphinView::itemsActivated
,
132 this, &DolphinViewContainer::slotItemsActivated
);
133 connect(m_view
, &DolphinView::redirection
,
134 this, &DolphinViewContainer::redirect
);
135 connect(m_view
, &DolphinView::directoryLoadingStarted
,
136 this, &DolphinViewContainer::slotDirectoryLoadingStarted
);
137 connect(m_view
, &DolphinView::directoryLoadingCompleted
,
138 this, &DolphinViewContainer::slotDirectoryLoadingCompleted
);
139 connect(m_view
, &DolphinView::directoryLoadingCanceled
,
140 this, &DolphinViewContainer::slotDirectoryLoadingCanceled
);
141 connect(m_view
, &DolphinView::itemCountChanged
,
142 this, &DolphinViewContainer::delayedStatusBarUpdate
);
143 connect(m_view
, &DolphinView::directoryLoadingProgress
,
144 this, &DolphinViewContainer::updateDirectoryLoadingProgress
);
145 connect(m_view
, &DolphinView::directorySortingProgress
,
146 this, &DolphinViewContainer::updateDirectorySortingProgress
);
147 connect(m_view
, &DolphinView::selectionChanged
,
148 this, &DolphinViewContainer::delayedStatusBarUpdate
);
149 connect(m_view
, &DolphinView::errorMessage
,
150 this, &DolphinViewContainer::showErrorMessage
);
151 connect(m_view
, &DolphinView::urlIsFileError
,
152 this, &DolphinViewContainer::slotUrlIsFileError
);
153 connect(m_view
, &DolphinView::activated
,
154 this, &DolphinViewContainer::activate
);
156 connect(m_urlNavigator
, &KUrlNavigator::urlAboutToBeChanged
,
157 this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged
);
158 connect(m_urlNavigator
, &KUrlNavigator::urlChanged
,
159 this, &DolphinViewContainer::slotUrlNavigatorLocationChanged
);
160 connect(m_urlNavigator
, &KUrlNavigator::urlSelectionRequested
,
161 this, &DolphinViewContainer::slotUrlSelectionRequested
);
162 connect(m_urlNavigator
, &KUrlNavigator::returnPressed
,
163 this, &DolphinViewContainer::slotReturnPressed
);
164 connect(m_urlNavigator
, &KUrlNavigator::urlsDropped
, this, [=](const QUrl
&destination
, QDropEvent
*event
) {
165 m_view
->dropUrls(destination
, event
, m_urlNavigator
->dropWidget());
168 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, [this]() {
169 m_emptyTrashButton
->setVisible(m_view
->url().scheme() == QLatin1String("trash"));
172 // Initialize status bar
173 m_statusBar
= new DolphinStatusBar(this);
174 m_statusBar
->setUrl(m_view
->url());
175 m_statusBar
->setZoomLevel(m_view
->zoomLevel());
176 connect(m_view
, &DolphinView::urlChanged
,
177 m_statusBar
, &DolphinStatusBar::setUrl
);
178 connect(m_view
, &DolphinView::zoomLevelChanged
,
179 m_statusBar
, &DolphinStatusBar::setZoomLevel
);
180 connect(m_view
, &DolphinView::infoMessage
,
181 m_statusBar
, &DolphinStatusBar::setText
);
182 connect(m_view
, &DolphinView::operationCompletedMessage
,
183 m_statusBar
, &DolphinStatusBar::setText
);
184 connect(m_statusBar
, &DolphinStatusBar::stopPressed
,
185 this, &DolphinViewContainer::stopDirectoryLoading
);
186 connect(m_statusBar
, &DolphinStatusBar::zoomLevelChanged
,
187 this, &DolphinViewContainer::slotStatusBarZoomLevelChanged
);
189 m_statusBarTimer
= new QTimer(this);
190 m_statusBarTimer
->setSingleShot(true);
191 m_statusBarTimer
->setInterval(300);
192 connect(m_statusBarTimer
, &QTimer::timeout
, this, &DolphinViewContainer::updateStatusBar
);
194 KIO::FileUndoManager
* undoManager
= KIO::FileUndoManager::self();
195 connect(undoManager
, &KIO::FileUndoManager::jobRecordingFinished
,
196 this, &DolphinViewContainer::delayedStatusBarUpdate
);
198 // Initialize filter bar
199 m_filterBar
= new FilterBar(this);
200 m_filterBar
->setVisible(settings
->filterBar());
201 connect(m_filterBar
, &FilterBar::filterChanged
,
202 this, &DolphinViewContainer::setNameFilter
);
203 connect(m_filterBar
, &FilterBar::closeRequest
,
204 this, &DolphinViewContainer::closeFilterBar
);
205 connect(m_filterBar
, &FilterBar::focusViewRequest
,
206 this, &DolphinViewContainer::requestFocus
);
207 connect(m_view
, &DolphinView::urlChanged
,
208 m_filterBar
, &FilterBar::slotUrlChanged
);
210 navigatorLayout
->addWidget(m_urlNavigator
);
211 navigatorLayout
->addWidget(m_emptyTrashButton
);
213 m_topLayout
->addWidget(m_navigatorWidget
);
214 m_topLayout
->addWidget(m_searchBox
);
215 m_topLayout
->addWidget(m_messageWidget
);
216 m_topLayout
->addWidget(m_view
);
217 m_topLayout
->addWidget(m_filterBar
);
218 m_topLayout
->addWidget(m_statusBar
);
220 setSearchModeEnabled(isSearchUrl(url
));
222 // Initialize kactivities resource instance
224 #ifdef KActivities_FOUND
225 m_activityResourceInstance
= new KActivities::ResourceInstance(
226 window()->winId(), url
);
227 m_activityResourceInstance
->setParent(this);
231 DolphinViewContainer::~DolphinViewContainer()
235 QUrl
DolphinViewContainer::url() const
237 return m_view
->url();
240 void DolphinViewContainer::setActive(bool active
)
242 m_searchBox
->setActive(active
);
243 m_urlNavigator
->setActive(active
);
244 m_view
->setActive(active
);
246 #ifdef KActivities_FOUND
248 m_activityResourceInstance
->notifyFocusedIn();
250 m_activityResourceInstance
->notifyFocusedOut();
255 bool DolphinViewContainer::isActive() const
257 Q_ASSERT(m_view
->isActive() == m_urlNavigator
->isActive());
258 return m_view
->isActive();
261 void DolphinViewContainer::setAutoGrabFocus(bool grab
)
263 m_autoGrabFocus
= grab
;
266 bool DolphinViewContainer::autoGrabFocus() const
268 return m_autoGrabFocus
;
271 QString
DolphinViewContainer::currentSearchText() const
273 return m_searchBox
->text();
276 const DolphinStatusBar
* DolphinViewContainer::statusBar() const
281 DolphinStatusBar
* DolphinViewContainer::statusBar()
286 const KUrlNavigator
* DolphinViewContainer::urlNavigator() const
288 return m_urlNavigator
;
291 KUrlNavigator
* DolphinViewContainer::urlNavigator()
293 return m_urlNavigator
;
296 const DolphinView
* DolphinViewContainer::view() const
301 DolphinView
* DolphinViewContainer::view()
306 void DolphinViewContainer::showMessage(const QString
& msg
, MessageType type
)
312 m_messageWidget
->setText(msg
);
315 case Information
: m_messageWidget
->setMessageType(KMessageWidget::Information
); break;
316 case Warning
: m_messageWidget
->setMessageType(KMessageWidget::Warning
); break;
317 case Error
: m_messageWidget
->setMessageType(KMessageWidget::Error
); break;
323 m_messageWidget
->setWordWrap(false);
324 const int unwrappedWidth
= m_messageWidget
->sizeHint().width();
325 m_messageWidget
->setWordWrap(unwrappedWidth
> size().width());
327 if (m_messageWidget
->isVisible()) {
328 m_messageWidget
->hide();
330 m_messageWidget
->animatedShow();
333 void DolphinViewContainer::readSettings()
335 if (GeneralSettings::modifiedStartupSettings()) {
336 // The startup settings should only get applied if they have been
337 // modified by the user. Otherwise keep the (possibly) different current
338 // settings of the URL navigator and the filterbar.
339 m_urlNavigator
->setUrlEditable(GeneralSettings::editableUrl());
340 m_urlNavigator
->setShowFullPath(GeneralSettings::showFullPath());
341 m_urlNavigator
->setHomeUrl(Dolphin::homeUrl());
342 setFilterBarVisible(GeneralSettings::filterBar());
345 m_view
->readSettings();
346 m_statusBar
->readSettings();
349 bool DolphinViewContainer::isFilterBarVisible() const
351 return m_filterBar
->isVisible();
354 void DolphinViewContainer::setSearchModeEnabled(bool enabled
)
356 if (enabled
== isSearchModeEnabled()) {
357 if (enabled
&& !m_searchBox
->hasFocus()) {
358 m_searchBox
->setFocus();
359 m_searchBox
->selectAll();
364 m_searchBox
->setVisible(enabled
);
365 m_navigatorWidget
->setVisible(!enabled
);
368 const QUrl
& locationUrl
= m_urlNavigator
->locationUrl();
369 m_searchBox
->fromSearchUrl(locationUrl
);
371 m_view
->setViewPropertiesContext(QString());
373 // Restore the URL for the URL navigator. If Dolphin has been
374 // started with a search-URL, the home URL is used as fallback.
375 QUrl url
= m_searchBox
->searchPath();
376 if (url
.isEmpty() || !url
.isValid() || isSearchUrl(url
)) {
377 url
= Dolphin::homeUrl();
379 m_urlNavigator
->setLocationUrl(url
);
383 bool DolphinViewContainer::isSearchModeEnabled() const
385 return m_searchBox
->isVisible();
388 QString
DolphinViewContainer::placesText() const
392 if (isSearchModeEnabled()) {
393 text
= i18n("Search for %1 in %2", m_searchBox
->text(), m_searchBox
->searchPath().fileName());
395 text
= url().fileName();
396 if (text
.isEmpty()) {
399 if (text
.isEmpty()) {
400 text
= url().scheme();
407 void DolphinViewContainer::reload()
410 m_messageWidget
->hide();
413 QString
DolphinViewContainer::caption() const
415 if (GeneralSettings::showFullPathInTitlebar()) {
416 if (!url().isLocalFile()) {
417 return url().adjusted(QUrl::StripTrailingSlash
).toString();
419 return url().adjusted(QUrl::StripTrailingSlash
).path();
422 KFilePlacesModel
*placesModel
= DolphinPlacesModelSingleton::instance().placesModel();
423 const auto& matchedPlaces
= placesModel
->match(placesModel
->index(0,0), KFilePlacesModel::UrlRole
, url(), 1, Qt::MatchExactly
);
425 if (!matchedPlaces
.isEmpty()) {
426 return placesModel
->text(matchedPlaces
.first());
429 if (isSearchModeEnabled()) {
430 if (currentSearchText().isEmpty()){
431 return i18n("Search");
433 return i18n("Search for %1", currentSearchText());
437 if (!url().isLocalFile()) {
438 QUrl adjustedUrl
= url().adjusted(QUrl::StripTrailingSlash
);
440 if (!adjustedUrl
.fileName().isEmpty()) {
441 caption
= adjustedUrl
.fileName();
442 } else if (!adjustedUrl
.path().isEmpty() && adjustedUrl
.path() != "/") {
443 caption
= adjustedUrl
.path();
444 } else if (!adjustedUrl
.host().isEmpty()) {
445 caption
= adjustedUrl
.host();
447 caption
= adjustedUrl
.toString();
452 QString fileName
= url().adjusted(QUrl::StripTrailingSlash
).fileName();
453 if (fileName
.isEmpty()) {
460 void DolphinViewContainer::setUrl(const QUrl
& newUrl
)
462 if (newUrl
!= m_urlNavigator
->locationUrl()) {
463 m_urlNavigator
->setLocationUrl(newUrl
);
466 #ifdef KActivities_FOUND
467 m_activityResourceInstance
->setUri(newUrl
);
471 void DolphinViewContainer::setFilterBarVisible(bool visible
)
473 Q_ASSERT(m_filterBar
);
476 m_filterBar
->setFocus();
477 m_filterBar
->selectAll();
483 void DolphinViewContainer::delayedStatusBarUpdate()
485 if (m_statusBarTimer
->isActive() && (m_statusBarTimestamp
.elapsed() > 2000)) {
486 // No update of the statusbar has been done during the last 2 seconds,
487 // although an update has been requested. Trigger an immediate update.
488 m_statusBarTimer
->stop();
491 // Invoke updateStatusBar() with a small delay. This assures that
492 // when a lot of delayedStatusBarUpdates() are done in a short time,
493 // no bottleneck is given.
494 m_statusBarTimer
->start();
498 void DolphinViewContainer::updateStatusBar()
500 m_statusBarTimestamp
.start();
502 const QString text
= m_view
->statusBarText();
503 m_statusBar
->setDefaultText(text
);
504 m_statusBar
->resetToDefaultText();
507 void DolphinViewContainer::updateDirectoryLoadingProgress(int percent
)
509 if (m_statusBar
->progressText().isEmpty()) {
510 m_statusBar
->setProgressText(i18nc("@info:progress", "Loading folder..."));
512 m_statusBar
->setProgress(percent
);
515 void DolphinViewContainer::updateDirectorySortingProgress(int percent
)
517 if (m_statusBar
->progressText().isEmpty()) {
518 m_statusBar
->setProgressText(i18nc("@info:progress", "Sorting..."));
520 m_statusBar
->setProgress(percent
);
523 void DolphinViewContainer::slotDirectoryLoadingStarted()
525 if (isSearchUrl(url())) {
526 // Search KIO-slaves usually don't provide any progress information. Give
527 // a hint to the user that a searching is done:
529 m_statusBar
->setProgressText(i18nc("@info", "Searching..."));
530 m_statusBar
->setProgress(-1);
532 // Trigger an undetermined progress indication. The progress
533 // information in percent will be triggered by the percent() signal
534 // of the directory lister later.
535 updateDirectoryLoadingProgress(-1);
539 void DolphinViewContainer::slotDirectoryLoadingCompleted()
541 if (!m_statusBar
->progressText().isEmpty()) {
542 m_statusBar
->setProgressText(QString());
543 m_statusBar
->setProgress(100);
546 if (isSearchUrl(url()) && m_view
->itemsCount() == 0) {
547 // The dir lister has been completed on a Baloo-URI and no items have been found. Instead
548 // of showing the default status bar information ("0 items") a more helpful information is given:
549 m_statusBar
->setText(i18nc("@info:status", "No items found."));
555 void DolphinViewContainer::slotDirectoryLoadingCanceled()
557 if (!m_statusBar
->progressText().isEmpty()) {
558 m_statusBar
->setProgressText(QString());
559 m_statusBar
->setProgress(100);
562 m_statusBar
->setText(QString());
565 void DolphinViewContainer::slotUrlIsFileError(const QUrl
& url
)
567 const KFileItem
item(url
);
569 // Find out if the file can be opened in the view (for example, this is the
570 // case if the file is an archive). The mime type must be known for that.
571 item
.determineMimeType();
572 const QUrl
& folderUrl
= DolphinView::openItemAsFolderUrl(item
, true);
573 if (!folderUrl
.isEmpty()) {
576 slotItemActivated(item
);
580 void DolphinViewContainer::slotItemActivated(const KFileItem
& item
)
582 // It is possible to activate items on inactive views by
583 // drag & drop operations. Assure that activating an item always
584 // results in an active view.
585 m_view
->setActive(true);
587 const QUrl
& url
= DolphinView::openItemAsFolderUrl(item
, GeneralSettings::browseThroughArchives());
588 if (!url
.isEmpty()) {
593 KRun
*run
= new KRun(item
.targetUrl(), this);
594 run
->setShowScriptExecutionPrompt(true);
597 void DolphinViewContainer::slotItemsActivated(const KFileItemList
& items
)
599 Q_ASSERT(items
.count() >= 2);
601 KFileItemActions
fileItemActions(this);
602 fileItemActions
.runPreferredApplications(items
, QString());
605 void DolphinViewContainer::showItemInfo(const KFileItem
& item
)
608 m_statusBar
->resetToDefaultText();
610 m_statusBar
->setText(item
.getStatusBarInfo());
614 void DolphinViewContainer::closeFilterBar()
616 m_filterBar
->closeFilterBar();
618 emit
showFilterBarChanged(false);
621 void DolphinViewContainer::setNameFilter(const QString
& nameFilter
)
623 m_view
->setNameFilter(nameFilter
);
624 delayedStatusBarUpdate();
627 void DolphinViewContainer::activate()
632 void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const QUrl
&)
637 void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl
& url
)
641 if (KProtocolManager::supportsListing(url
)) {
642 setSearchModeEnabled(isSearchUrl(url
));
644 tryRestoreViewState();
646 if (m_autoGrabFocus
&& isActive() && !isSearchUrl(url
)) {
647 // When an URL has been entered, the view should get the focus.
648 // The focus must be requested asynchronously, as changing the URL might create
649 // a new view widget.
650 QTimer::singleShot(0, this, &DolphinViewContainer::requestFocus
);
652 } else if (KProtocolManager::isSourceProtocol(url
)) {
653 QString app
= QStringLiteral("konqueror");
654 if (url
.scheme().startsWith(QLatin1String("http"))) {
655 showMessage(i18nc("@info:status", // krazy:exclude=qmethods
656 "Dolphin does not support web pages, the web browser has been launched"),
659 const KConfigGroup
config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "General");
660 const QString browser
= config
.readEntry("BrowserApplication");
661 if (!browser
.isEmpty()) {
663 if (app
.startsWith('!')) {
664 // a literal command has been configured, remove the '!' prefix
669 showMessage(i18nc("@info:status",
670 "Protocol not supported by Dolphin, Konqueror has been launched"),
674 const QString secureUrl
= KShell::quoteArg(url
.toDisplayString(QUrl::PreferLocalFile
));
675 const QString command
= app
+ ' ' + secureUrl
;
676 KRun::runCommand(command
, app
, app
, this);
678 showMessage(i18nc("@info:status", "Invalid protocol"), Error
);
682 void DolphinViewContainer::slotUrlSelectionRequested(const QUrl
& url
)
684 qCDebug(DolphinDebug
) << "slotUrlSelectionRequested: " << url
;
685 m_view
->markUrlsAsSelected({url
});
686 m_view
->markUrlAsCurrent(url
); // makes the item scroll into view
689 void DolphinViewContainer::redirect(const QUrl
& oldUrl
, const QUrl
& newUrl
)
692 const bool block
= m_urlNavigator
->signalsBlocked();
693 m_urlNavigator
->blockSignals(true);
695 // Assure that the location state is reset for redirection URLs. This
696 // allows to skip redirection URLs when going back or forward in the
698 m_urlNavigator
->saveLocationState(QByteArray());
699 m_urlNavigator
->setLocationUrl(newUrl
);
700 setSearchModeEnabled(isSearchUrl(newUrl
));
702 m_urlNavigator
->blockSignals(block
);
705 void DolphinViewContainer::requestFocus()
710 void DolphinViewContainer::saveUrlCompletionMode(KCompletion::CompletionMode completion
)
712 GeneralSettings::setUrlCompletionMode(completion
);
715 void DolphinViewContainer::slotReturnPressed()
717 if (!GeneralSettings::editableUrl()) {
718 m_urlNavigator
->setUrlEditable(false);
722 void DolphinViewContainer::startSearching()
724 const QUrl url
= m_searchBox
->urlForSearching();
725 if (url
.isValid() && !url
.isEmpty()) {
726 m_view
->setViewPropertiesContext(QStringLiteral("search"));
727 m_urlNavigator
->setLocationUrl(url
);
731 void DolphinViewContainer::closeSearchBox()
733 setSearchModeEnabled(false);
736 void DolphinViewContainer::stopDirectoryLoading()
738 m_view
->stopLoading();
739 m_statusBar
->setProgress(100);
742 void DolphinViewContainer::slotStatusBarZoomLevelChanged(int zoomLevel
)
744 m_view
->setZoomLevel(zoomLevel
);
747 void DolphinViewContainer::showErrorMessage(const QString
& msg
)
749 showMessage(msg
, Error
);
752 bool DolphinViewContainer::isSearchUrl(const QUrl
& url
) const
754 return url
.scheme().contains(QStringLiteral("search"));
757 void DolphinViewContainer::saveViewState()
759 QByteArray locationState
;
760 QDataStream
stream(&locationState
, QIODevice::WriteOnly
);
761 m_view
->saveState(stream
);
762 m_urlNavigator
->saveLocationState(locationState
);
765 void DolphinViewContainer::tryRestoreViewState()
767 QByteArray locationState
= m_urlNavigator
->locationState();
768 if (!locationState
.isEmpty()) {
769 QDataStream
stream(&locationState
, QIODevice::ReadOnly
);
770 m_view
->restoreState(stream
);