]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewcontainer.cpp
dolphinui: Set view_mode action to low priority
[dolphin.git] / src / dolphinviewcontainer.cpp
1 /*
2 * SPDX-FileCopyrightText: 2007 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include "dolphinviewcontainer.h"
8
9 #include "admin/bar.h"
10 #include "admin/workerintegration.h"
11 #include "dolphin_compactmodesettings.h"
12 #include "dolphin_contentdisplaysettings.h"
13 #include "dolphin_detailsmodesettings.h"
14 #include "dolphin_generalsettings.h"
15 #include "dolphin_iconsmodesettings.h"
16 #include "dolphindebug.h"
17 #include "dolphinplacesmodelsingleton.h"
18 #include "filterbar/filterbar.h"
19 #include "global.h"
20 #include "kitemviews/kitemlistcontainer.h"
21 #include "search/dolphinsearchbox.h"
22 #include "selectionmode/topbar.h"
23 #include "statusbar/dolphinstatusbar.h"
24
25 #include <KActionCollection>
26 #include <KApplicationTrader>
27 #include <KFileItemActions>
28 #include <KFilePlacesModel>
29 #include <KIO/JobUiDelegateFactory>
30 #include <KIO/OpenUrlJob>
31 #include <KLocalizedString>
32 #include <KMessageWidget>
33 #include <KProtocolManager>
34 #include <KShell>
35 #include <kio_version.h>
36
37 #ifndef QT_NO_ACCESSIBILITY
38 #include <QAccessible>
39 #endif
40 #include <QApplication>
41 #include <QDesktopServices>
42 #include <QDropEvent>
43 #include <QGridLayout>
44 #include <QGuiApplication>
45 #include <QRegularExpression>
46 #include <QScrollBar>
47 #include <QStyle>
48 #include <QTimer>
49 #include <QUrl>
50 #include <QUrlQuery>
51
52 // An overview of the widgets contained by this ViewContainer
53 struct LayoutStructure {
54 int searchBox = 0;
55 int adminBar = 1;
56 int messageWidget = 2;
57 int selectionModeTopBar = 3;
58 int view = 4;
59 int selectionModeBottomBar = 5;
60 int filterBar = 6;
61 int statusBar = 7;
62 };
63 constexpr LayoutStructure positionFor;
64
65 DolphinViewContainer::DolphinViewContainer(const QUrl &url, QWidget *parent)
66 : QWidget(parent)
67 , m_topLayout(nullptr)
68 , m_urlNavigator{new DolphinUrlNavigator(url)}
69 , m_urlNavigatorConnected{nullptr}
70 , m_searchBox(nullptr)
71 , m_searchModeEnabled(false)
72 , m_adminBar{nullptr}
73 , m_authorizeToEnterFolderAction{nullptr}
74 , m_messageWidget(nullptr)
75 , m_selectionModeTopBar{nullptr}
76 , m_view(nullptr)
77 , m_filterBar(nullptr)
78 , m_selectionModeBottomBar{nullptr}
79 , m_statusBar(nullptr)
80 , m_statusBarTimer(nullptr)
81 , m_statusBarTimestamp()
82 , m_autoGrabFocus(true)
83 {
84 hide();
85
86 m_topLayout = new QGridLayout(this);
87 m_topLayout->setSpacing(0);
88 m_topLayout->setContentsMargins(0, 0, 0, 0);
89
90 m_searchBox = new DolphinSearchBox(this);
91 m_searchBox->setVisible(false, WithoutAnimation);
92 connect(m_searchBox, &DolphinSearchBox::activated, this, &DolphinViewContainer::activate);
93 connect(m_searchBox, &DolphinSearchBox::openRequest, this, &DolphinViewContainer::openSearchBox);
94 connect(m_searchBox, &DolphinSearchBox::closeRequest, this, &DolphinViewContainer::closeSearchBox);
95 connect(m_searchBox, &DolphinSearchBox::searchRequest, this, &DolphinViewContainer::startSearching);
96 connect(m_searchBox, &DolphinSearchBox::focusViewRequest, this, &DolphinViewContainer::requestFocus);
97 m_searchBox->setWhatsThis(xi18nc("@info:whatsthis findbar",
98 "<para>This helps you find files and folders. Enter a <emphasis>"
99 "search term</emphasis> and specify search settings with the "
100 "buttons at the bottom:<list><item>Filename/Content: "
101 "Does the item you are looking for contain the search terms "
102 "within its filename or its contents?<nl/>The contents of images, "
103 "audio files and videos will not be searched.</item><item>"
104 "From Here/Everywhere: Do you want to search in this "
105 "folder and its sub-folders or everywhere?</item><item>"
106 "More Options: Click this to search by media type, access "
107 "time or rating.</item><item>More Search Tools: Install other "
108 "means to find an item.</item></list></para>"));
109
110 m_messageWidget = new KMessageWidget(this);
111 m_messageWidget->setCloseButtonVisible(true);
112 m_messageWidget->setPosition(KMessageWidget::Header);
113 m_messageWidget->hide();
114
115 #if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU)
116 if (getuid() == 0) {
117 // We must be logged in as the root user; show a big scary warning
118 showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), KMessageWidget::Warning);
119 }
120 #endif
121
122 // Initialize filter bar
123 m_filterBar = new FilterBar(this);
124 m_filterBar->setVisible(GeneralSettings::filterBar(), WithoutAnimation);
125
126 connect(m_filterBar, &FilterBar::filterChanged, this, &DolphinViewContainer::setNameFilter);
127 connect(m_filterBar, &FilterBar::closeRequest, this, &DolphinViewContainer::closeFilterBar);
128 connect(m_filterBar, &FilterBar::focusViewRequest, this, &DolphinViewContainer::requestFocus);
129
130 // Initialize the main view
131 m_view = new DolphinView(url, this);
132 connect(m_view, &DolphinView::urlChanged, m_filterBar, &FilterBar::clearIfUnlocked);
133 connect(m_view, &DolphinView::urlChanged, m_messageWidget, &KMessageWidget::hide);
134 // m_urlNavigator stays in sync with m_view's location changes and
135 // keeps track of them so going back and forth in the history works.
136 connect(m_view, &DolphinView::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
137 connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlChanged, this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
138 connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlAboutToBeChanged, this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
139 connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested);
140 connect(m_view, &DolphinView::writeStateChanged, this, &DolphinViewContainer::writeStateChanged);
141 connect(m_view, &DolphinView::requestItemInfo, this, &DolphinViewContainer::showItemInfo);
142 connect(m_view, &DolphinView::itemActivated, this, &DolphinViewContainer::slotItemActivated);
143 connect(m_view, &DolphinView::fileMiddleClickActivated, this, &DolphinViewContainer::slotfileMiddleClickActivated);
144 connect(m_view, &DolphinView::itemsActivated, this, &DolphinViewContainer::slotItemsActivated);
145 connect(m_view, &DolphinView::redirection, this, &DolphinViewContainer::redirect);
146 connect(m_view, &DolphinView::directoryLoadingStarted, this, &DolphinViewContainer::slotDirectoryLoadingStarted);
147 connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
148 connect(m_view, &DolphinView::directoryLoadingCanceled, this, &DolphinViewContainer::slotDirectoryLoadingCanceled);
149 connect(m_view, &DolphinView::itemCountChanged, this, &DolphinViewContainer::delayedStatusBarUpdate);
150 connect(m_view, &DolphinView::selectionChanged, this, &DolphinViewContainer::delayedStatusBarUpdate);
151 connect(m_view, &DolphinView::errorMessage, this, &DolphinViewContainer::slotErrorMessageFromView);
152 connect(m_view, &DolphinView::urlIsFileError, this, &DolphinViewContainer::slotUrlIsFileError);
153 connect(m_view, &DolphinView::activated, this, &DolphinViewContainer::activate);
154 connect(m_view, &DolphinView::hiddenFilesShownChanged, this, &DolphinViewContainer::slotHiddenFilesShownChanged);
155 connect(m_view, &DolphinView::sortHiddenLastChanged, this, &DolphinViewContainer::slotSortHiddenLastChanged);
156 connect(m_view, &DolphinView::currentDirectoryRemoved, this, &DolphinViewContainer::slotCurrentDirectoryRemoved);
157
158 // Initialize status bar
159 m_statusBar = new DolphinStatusBar(this);
160 m_statusBar->setUrl(m_view->url());
161 m_statusBar->setZoomLevel(m_view->zoomLevel());
162 connect(m_view, &DolphinView::urlChanged, m_statusBar, &DolphinStatusBar::setUrl);
163 connect(m_view, &DolphinView::zoomLevelChanged, m_statusBar, &DolphinStatusBar::setZoomLevel);
164 connect(m_view, &DolphinView::infoMessage, m_statusBar, &DolphinStatusBar::setText);
165 connect(m_view, &DolphinView::operationCompletedMessage, m_statusBar, &DolphinStatusBar::setText);
166 connect(m_view, &DolphinView::statusBarTextChanged, m_statusBar, &DolphinStatusBar::setDefaultText);
167 connect(m_view, &DolphinView::statusBarTextChanged, m_statusBar, &DolphinStatusBar::resetToDefaultText);
168 connect(m_view, &DolphinView::directoryLoadingProgress, m_statusBar, [this](int percent) {
169 m_statusBar->showProgress(i18nc("@info:progress", "Loading folder…"), percent);
170 });
171 connect(m_view, &DolphinView::directorySortingProgress, m_statusBar, [this](int percent) {
172 m_statusBar->showProgress(i18nc("@info:progress", "Sorting…"), percent);
173 });
174 connect(m_statusBar, &DolphinStatusBar::stopPressed, this, &DolphinViewContainer::stopDirectoryLoading);
175 connect(m_statusBar, &DolphinStatusBar::zoomLevelChanged, this, &DolphinViewContainer::slotStatusBarZoomLevelChanged);
176 connect(m_statusBar, &DolphinStatusBar::showMessage, this, [this](const QString &message, KMessageWidget::MessageType messageType) {
177 showMessage(message, messageType);
178 });
179 connect(m_statusBar, &DolphinStatusBar::widthUpdated, this, &DolphinViewContainer::updateStatusBarGeometry);
180 connect(m_statusBar, &DolphinStatusBar::urlChanged, this, &DolphinViewContainer::updateStatusBar);
181 connect(this, &DolphinViewContainer::showFilterBarChanged, this, &DolphinViewContainer::updateStatusBar);
182
183 m_statusBarTimer = new QTimer(this);
184 m_statusBarTimer->setSingleShot(true);
185 m_statusBarTimer->setInterval(300);
186 connect(m_statusBarTimer, &QTimer::timeout, this, &DolphinViewContainer::updateStatusBar);
187
188 KIO::FileUndoManager *undoManager = KIO::FileUndoManager::self();
189 connect(undoManager, &KIO::FileUndoManager::jobRecordingFinished, this, &DolphinViewContainer::delayedStatusBarUpdate);
190
191 m_topLayout->addWidget(m_searchBox, positionFor.searchBox, 0);
192 m_topLayout->addWidget(m_messageWidget, positionFor.messageWidget, 0);
193 m_topLayout->addWidget(m_view, positionFor.view, 0);
194 m_topLayout->addWidget(m_filterBar, positionFor.filterBar, 0);
195 if (GeneralSettings::showStatusBar() == GeneralSettings::EnumShowStatusBar::FullWidth) {
196 m_topLayout->addWidget(m_statusBar, positionFor.statusBar, 0);
197 }
198 connect(m_statusBar, &DolphinStatusBar::modeUpdated, this, [this]() {
199 const bool statusBarInLayout = m_topLayout->itemAtPosition(positionFor.statusBar, 0);
200 if (GeneralSettings::showStatusBar() == GeneralSettings::EnumShowStatusBar::FullWidth) {
201 if (!statusBarInLayout) {
202 m_topLayout->addWidget(m_statusBar, positionFor.statusBar, 0);
203 m_statusBar->setUrl(m_view->url());
204 }
205 } else {
206 if (statusBarInLayout) {
207 m_topLayout->removeWidget(m_statusBar);
208 }
209 }
210 updateStatusBarGeometry();
211 });
212 m_statusBar->setHidden(false);
213
214 setSearchModeEnabled(isSearchUrl(url));
215
216 // Update view as the ContentDisplaySettings change
217 // this happens here and not in DolphinView as DolphinviewContainer and DolphinView are not in the same build target ATM
218 connect(ContentDisplaySettings::self(), &KCoreConfigSkeleton::configChanged, m_view, &DolphinView::reload);
219
220 KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
221 connect(placesModel, &KFilePlacesModel::dataChanged, this, &DolphinViewContainer::slotPlacesModelChanged);
222 connect(placesModel, &KFilePlacesModel::rowsInserted, this, &DolphinViewContainer::slotPlacesModelChanged);
223 connect(placesModel, &KFilePlacesModel::rowsRemoved, this, &DolphinViewContainer::slotPlacesModelChanged);
224
225 connect(this, &DolphinViewContainer::searchModeEnabledChanged, this, &DolphinViewContainer::captionChanged);
226
227 QApplication::instance()->installEventFilter(this);
228 }
229
230 DolphinViewContainer::~DolphinViewContainer()
231 {
232 }
233
234 QUrl DolphinViewContainer::url() const
235 {
236 return m_view->url();
237 }
238
239 KFileItem DolphinViewContainer::rootItem() const
240 {
241 return m_view->rootItem();
242 }
243
244 void DolphinViewContainer::setActive(bool active)
245 {
246 m_searchBox->setActive(active);
247 if (m_urlNavigatorConnected) {
248 m_urlNavigatorConnected->setActive(active);
249 }
250 m_view->setActive(active);
251 }
252
253 bool DolphinViewContainer::isActive() const
254 {
255 return m_view->isActive();
256 }
257
258 void DolphinViewContainer::setAutoGrabFocus(bool grab)
259 {
260 m_autoGrabFocus = grab;
261 }
262
263 bool DolphinViewContainer::autoGrabFocus() const
264 {
265 return m_autoGrabFocus;
266 }
267
268 QString DolphinViewContainer::currentSearchText() const
269 {
270 return m_searchBox->text();
271 }
272
273 const DolphinStatusBar *DolphinViewContainer::statusBar() const
274 {
275 return m_statusBar;
276 }
277
278 DolphinStatusBar *DolphinViewContainer::statusBar()
279 {
280 return m_statusBar;
281 }
282
283 const DolphinUrlNavigator *DolphinViewContainer::urlNavigator() const
284 {
285 return m_urlNavigatorConnected;
286 }
287
288 DolphinUrlNavigator *DolphinViewContainer::urlNavigator()
289 {
290 return m_urlNavigatorConnected;
291 }
292
293 const DolphinUrlNavigator *DolphinViewContainer::urlNavigatorInternalWithHistory() const
294 {
295 return m_urlNavigator.get();
296 }
297
298 DolphinUrlNavigator *DolphinViewContainer::urlNavigatorInternalWithHistory()
299 {
300 return m_urlNavigator.get();
301 }
302
303 const DolphinView *DolphinViewContainer::view() const
304 {
305 return m_view;
306 }
307
308 DolphinView *DolphinViewContainer::view()
309 {
310 return m_view;
311 }
312
313 void DolphinViewContainer::connectUrlNavigator(DolphinUrlNavigator *urlNavigator)
314 {
315 Q_CHECK_PTR(urlNavigator);
316 Q_ASSERT(!m_urlNavigatorConnected);
317 Q_ASSERT(m_urlNavigator.get() != urlNavigator);
318 Q_CHECK_PTR(m_view);
319
320 urlNavigator->setLocationUrl(m_view->url());
321 urlNavigator->setShowHiddenFolders(m_view->hiddenFilesShown());
322 urlNavigator->setSortHiddenFoldersLast(m_view->sortHiddenLast());
323 if (m_urlNavigatorVisualState) {
324 urlNavigator->setVisualState(*m_urlNavigatorVisualState.get());
325 m_urlNavigatorVisualState.reset();
326 }
327 urlNavigator->setActive(isActive());
328
329 // Url changes are still done via m_urlNavigator.
330 connect(urlNavigator, &DolphinUrlNavigator::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
331 connect(urlNavigator, &DolphinUrlNavigator::urlsDropped, this, [=, this](const QUrl &destination, QDropEvent *event) {
332 m_view->dropUrls(destination, event, urlNavigator->dropWidget());
333 });
334 // Aside from these, only visual things need to be connected.
335 connect(m_view, &DolphinView::urlChanged, urlNavigator, &DolphinUrlNavigator::setLocationUrl);
336 connect(urlNavigator, &DolphinUrlNavigator::activated, this, &DolphinViewContainer::activate);
337 connect(urlNavigator, &DolphinUrlNavigator::requestToLoseFocus, m_view, [this]() {
338 m_view->setFocus();
339 });
340
341 urlNavigator->setReadOnlyBadgeVisible(rootItem().isLocalFile() && !rootItem().isWritable());
342
343 m_urlNavigatorConnected = urlNavigator;
344 }
345
346 void DolphinViewContainer::disconnectUrlNavigator()
347 {
348 if (!m_urlNavigatorConnected) {
349 return;
350 }
351
352 disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
353 disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlsDropped, this, nullptr);
354 disconnect(m_view, &DolphinView::urlChanged, m_urlNavigatorConnected, &DolphinUrlNavigator::setLocationUrl);
355 disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::activated, this, &DolphinViewContainer::activate);
356 disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::requestToLoseFocus, m_view, nullptr);
357
358 m_urlNavigatorVisualState = m_urlNavigatorConnected->visualState();
359 m_urlNavigatorConnected = nullptr;
360 }
361
362 void DolphinViewContainer::setSelectionModeEnabled(bool enabled, KActionCollection *actionCollection, SelectionMode::BottomBar::Contents bottomBarContents)
363 {
364 const bool wasEnabled = m_view->selectionMode();
365 m_view->setSelectionModeEnabled(enabled);
366
367 if (!enabled) {
368 if (!wasEnabled) {
369 return; // nothing to do here
370 }
371 Q_CHECK_PTR(m_selectionModeTopBar); // there is no point in disabling selectionMode when it wasn't even enabled once.
372 Q_CHECK_PTR(m_selectionModeBottomBar);
373 m_selectionModeTopBar->setVisible(false, WithAnimation);
374 m_selectionModeBottomBar->setVisible(false, WithAnimation);
375 Q_EMIT selectionModeChanged(false);
376
377 if (!QApplication::focusWidget() || m_selectionModeTopBar->isAncestorOf(QApplication::focusWidget())
378 || m_selectionModeBottomBar->isAncestorOf(QApplication::focusWidget())) {
379 m_view->setFocus();
380 }
381 return;
382 }
383
384 if (!m_selectionModeTopBar) {
385 // Changing the location will disable selection mode.
386 connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlChanged, this, [this]() {
387 setSelectionModeEnabled(false);
388 });
389
390 m_selectionModeTopBar = new SelectionMode::TopBar(this); // will be created hidden
391 connect(m_selectionModeTopBar, &SelectionMode::TopBar::selectionModeLeavingRequested, this, [this]() {
392 setSelectionModeEnabled(false);
393 });
394 m_topLayout->addWidget(m_selectionModeTopBar, positionFor.selectionModeTopBar, 0);
395 }
396
397 if (!m_selectionModeBottomBar) {
398 m_selectionModeBottomBar = new SelectionMode::BottomBar(actionCollection, this);
399 connect(m_view, &DolphinView::selectionChanged, this, [this](const KFileItemList &selection) {
400 m_selectionModeBottomBar->slotSelectionChanged(selection, m_view->url());
401 });
402 connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::error, this, &DolphinViewContainer::showErrorMessage);
403 connect(m_selectionModeBottomBar, &SelectionMode::BottomBar::selectionModeLeavingRequested, this, [this]() {
404 setSelectionModeEnabled(false);
405 });
406 m_topLayout->addWidget(m_selectionModeBottomBar, positionFor.selectionModeBottomBar, 0);
407 }
408 m_selectionModeBottomBar->resetContents(bottomBarContents);
409 if (bottomBarContents == SelectionMode::BottomBar::GeneralContents) {
410 m_selectionModeBottomBar->slotSelectionChanged(m_view->selectedItems(), m_view->url());
411 }
412
413 if (!wasEnabled) {
414 m_selectionModeTopBar->setVisible(true, WithAnimation);
415 m_selectionModeBottomBar->setVisible(true, WithAnimation);
416 Q_EMIT selectionModeChanged(true);
417 }
418 }
419
420 bool DolphinViewContainer::isSelectionModeEnabled() const
421 {
422 const bool isEnabled = m_view->selectionMode();
423 Q_ASSERT((!isEnabled
424 // We can't assert that the bars are invisible only because the selection mode is disabled because the hide animation might still be playing.
425 && (!m_selectionModeBottomBar || !m_selectionModeBottomBar->isEnabled() || !m_selectionModeBottomBar->isVisible()
426 || m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::PasteContents))
427 || (isEnabled && m_selectionModeTopBar
428 && m_selectionModeTopBar->isVisible()
429 // The bottom bar is either visible or was hidden because it has nothing to show in GeneralContents mode e.g. because no items are selected.
430 && m_selectionModeBottomBar
431 && (m_selectionModeBottomBar->isVisible() || m_selectionModeBottomBar->contents() == SelectionMode::BottomBar::GeneralContents)));
432 return isEnabled;
433 }
434
435 void DolphinViewContainer::slotSplitTabDisabled()
436 {
437 if (m_selectionModeBottomBar) {
438 m_selectionModeBottomBar->slotSplitTabDisabled();
439 }
440 }
441
442 void DolphinViewContainer::showMessage(const QString &message, KMessageWidget::MessageType messageType, std::initializer_list<QAction *> buttonActions)
443 {
444 if (message.isEmpty()) {
445 return;
446 }
447
448 m_messageWidget->setText(message);
449
450 // TODO: wrap at arbitrary character positions once QLabel can do this
451 // https://bugreports.qt.io/browse/QTBUG-1276
452 m_messageWidget->setWordWrap(true);
453 m_messageWidget->setMessageType(messageType);
454
455 const QList<QAction *> previousMessageWidgetActions = m_messageWidget->actions();
456 for (auto action : previousMessageWidgetActions) {
457 m_messageWidget->removeAction(action);
458 }
459 for (QAction *action : buttonActions) {
460 m_messageWidget->addAction(action);
461 }
462
463 m_messageWidget->setWordWrap(false);
464 const int unwrappedWidth = m_messageWidget->sizeHint().width();
465 m_messageWidget->setWordWrap(unwrappedWidth > size().width());
466
467 if (m_messageWidget->isVisible()) {
468 m_messageWidget->hide();
469 }
470 m_messageWidget->animatedShow();
471
472 #ifndef QT_NO_ACCESSIBILITY
473 if (QAccessible::isActive() && isActive()) {
474 // To announce the new message keyboard focus must be moved to the message label. However, we do not have direct access to the label that is internal
475 // to the KMessageWidget. Instead we setFocus() on the KMessageWidget and trust that it has set correct focus handling.
476 m_messageWidget->setFocus();
477 }
478 #endif
479 }
480
481 void DolphinViewContainer::readSettings()
482 {
483 // The startup settings should (only) get applied if they have been
484 // modified by the user. Otherwise keep the (possibly) different current
485 // setting of the filterbar.
486 if (GeneralSettings::modifiedStartupSettings()) {
487 setFilterBarVisible(GeneralSettings::filterBar());
488 }
489
490 m_view->readSettings();
491 m_statusBar->readSettings();
492 }
493
494 bool DolphinViewContainer::isFilterBarVisible() const
495 {
496 return m_filterBar->isEnabled(); // Gets disabled in AnimatedHeightWidget while animating towards a hidden state.
497 }
498
499 void DolphinViewContainer::setSearchModeEnabled(bool enabled)
500 {
501 m_searchBox->setVisible(enabled, WithAnimation);
502
503 if (enabled) {
504 const QUrl &locationUrl = m_urlNavigator->locationUrl();
505 m_searchBox->fromSearchUrl(locationUrl);
506 }
507
508 if (enabled == isSearchModeEnabled()) {
509 if (enabled && !m_searchBox->hasFocus()) {
510 m_searchBox->setFocus();
511 m_searchBox->selectAll();
512 }
513 return;
514 }
515
516 if (!enabled) {
517 m_view->setViewPropertiesContext(QString());
518
519 // Restore the URL for the URL navigator. If Dolphin has been
520 // started with a search-URL, the home URL is used as fallback.
521 QUrl url = m_searchBox->searchPath();
522 if (url.isEmpty() || !url.isValid() || isSearchUrl(url)) {
523 url = Dolphin::homeUrl();
524 }
525 if (m_urlNavigatorConnected) {
526 m_urlNavigatorConnected->setLocationUrl(url);
527 }
528 }
529
530 m_searchModeEnabled = enabled;
531
532 Q_EMIT searchModeEnabledChanged(enabled);
533 }
534
535 bool DolphinViewContainer::isSearchModeEnabled() const
536 {
537 return m_searchModeEnabled;
538 }
539
540 QString DolphinViewContainer::placesText() const
541 {
542 QString text;
543
544 if (isSearchModeEnabled()) {
545 text = i18n("Search for %1 in %2", m_searchBox->text(), m_searchBox->searchPath().fileName());
546 } else {
547 text = url().adjusted(QUrl::StripTrailingSlash).fileName();
548 if (text.isEmpty()) {
549 text = url().host();
550 }
551 if (text.isEmpty()) {
552 text = url().scheme();
553 }
554 }
555
556 return text;
557 }
558
559 void DolphinViewContainer::reload()
560 {
561 view()->reload();
562 m_messageWidget->hide();
563 }
564
565 QString DolphinViewContainer::captionWindowTitle() const
566 {
567 if (GeneralSettings::showFullPathInTitlebar() && !isSearchModeEnabled()) {
568 if (!url().isLocalFile()) {
569 return url().adjusted(QUrl::StripTrailingSlash).toString();
570 }
571 return url().adjusted(QUrl::StripTrailingSlash).path();
572 } else {
573 return DolphinViewContainer::caption();
574 }
575 }
576
577 QString DolphinViewContainer::caption() const
578 {
579 // see KUrlNavigatorPrivate::firstButtonText().
580 if (url().path().isEmpty() || url().path() == QLatin1Char('/')) {
581 QUrlQuery query(url());
582 const QString title = query.queryItemValue(QStringLiteral("title"));
583 if (!title.isEmpty()) {
584 return title;
585 }
586 }
587
588 if (isSearchModeEnabled()) {
589 if (currentSearchText().isEmpty()) {
590 return i18n("Search");
591 } else {
592 return i18n("Search for %1", currentSearchText());
593 }
594 }
595
596 KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
597
598 QModelIndex url_index = placesModel->closestItem(url());
599
600 if (url_index.isValid() && placesModel->url(url_index).matches(url(), QUrl::StripTrailingSlash)) {
601 return placesModel->text(url_index);
602 }
603
604 if (!url().isLocalFile()) {
605 QUrl adjustedUrl = url().adjusted(QUrl::StripTrailingSlash);
606 QString caption;
607 if (!adjustedUrl.fileName().isEmpty()) {
608 caption = adjustedUrl.fileName();
609 } else if (!adjustedUrl.path().isEmpty() && adjustedUrl.path() != "/") {
610 caption = adjustedUrl.path();
611 } else if (!adjustedUrl.host().isEmpty()) {
612 caption = adjustedUrl.host();
613 } else {
614 caption = adjustedUrl.toString();
615 }
616 return caption;
617 }
618
619 QString fileName = url().adjusted(QUrl::StripTrailingSlash).fileName();
620 if (fileName.isEmpty()) {
621 fileName = '/';
622 }
623
624 return fileName;
625 }
626
627 void DolphinViewContainer::setUrl(const QUrl &newUrl)
628 {
629 if (newUrl != m_urlNavigator->locationUrl()) {
630 m_urlNavigator->setLocationUrl(newUrl);
631 }
632 }
633
634 void DolphinViewContainer::setFilterBarVisible(bool visible)
635 {
636 Q_ASSERT(m_filterBar);
637 if (visible) {
638 m_view->hideToolTip(ToolTipManager::HideBehavior::Instantly);
639 m_filterBar->setVisible(true, WithAnimation);
640 m_filterBar->setFocus();
641 m_filterBar->selectAll();
642 Q_EMIT showFilterBarChanged(true);
643 } else {
644 closeFilterBar();
645 }
646 }
647
648 void DolphinViewContainer::delayedStatusBarUpdate()
649 {
650 if (m_statusBarTimer->isActive() && (m_statusBarTimestamp.elapsed() > 2000)) {
651 // No update of the statusbar has been done during the last 2 seconds,
652 // although an update has been requested. Trigger an immediate update.
653 m_statusBarTimer->stop();
654 updateStatusBar();
655 } else {
656 // Invoke updateStatusBar() with a small delay. This assures that
657 // when a lot of delayedStatusBarUpdates() are done in a short time,
658 // no bottleneck is given.
659 m_statusBarTimer->start();
660 }
661 }
662
663 void DolphinViewContainer::updateStatusBar()
664 {
665 m_statusBarTimestamp.start();
666 m_view->requestStatusBarText();
667 updateStatusBarGeometry();
668 }
669
670 void DolphinViewContainer::slotDirectoryLoadingStarted()
671 {
672 if (isSearchUrl(url())) {
673 // Search KIO-slaves usually don't provide any progress information. Give
674 // a hint to the user that a searching is done:
675 updateStatusBar();
676 m_statusBar->showProgress(i18nc("@info", "Searching…"), -1);
677 } else {
678 // Trigger an undetermined progress indication. The progress
679 // information in percent will be triggered by the percent() signal
680 // of the directory lister later.
681 m_statusBar->showProgress(QString(), -1);
682 }
683
684 if (m_urlNavigatorConnected) {
685 m_urlNavigatorConnected->setReadOnlyBadgeVisible(false);
686 }
687 }
688
689 void DolphinViewContainer::slotDirectoryLoadingCompleted()
690 {
691 m_statusBar->showProgress(QString(), 100);
692
693 if (isSearchUrl(url()) && m_view->itemsCount() == 0) {
694 // The dir lister has been completed on a Baloo-URI and no items have been found. Instead
695 // of showing the default status bar information ("0 items") a more helpful information is given:
696 m_statusBar->setText(i18nc("@info:status", "No items found."));
697 } else {
698 updateStatusBar();
699 }
700
701 if (m_urlNavigatorConnected) {
702 m_urlNavigatorConnected->setReadOnlyBadgeVisible(rootItem().isLocalFile() && !rootItem().isWritable());
703 }
704
705 // Update admin bar visibility
706 if (m_view->url().scheme() == QStringLiteral("admin")) {
707 if (!m_adminBar) {
708 m_adminBar = new Admin::Bar(this);
709 m_topLayout->addWidget(m_adminBar, positionFor.adminBar, 0);
710 }
711 m_adminBar->setVisible(true, WithAnimation);
712 } else if (m_adminBar) {
713 m_adminBar->setVisible(false, WithAnimation);
714 }
715 }
716
717 void DolphinViewContainer::slotDirectoryLoadingCanceled()
718 {
719 m_statusBar->showProgress(QString(), 100);
720 m_statusBar->setText(QString());
721 }
722
723 void DolphinViewContainer::slotUrlIsFileError(const QUrl &url)
724 {
725 const KFileItem item(url);
726
727 // Find out if the file can be opened in the view (for example, this is the
728 // case if the file is an archive). The mime type must be known for that.
729 item.determineMimeType();
730 const QUrl &folderUrl = DolphinView::openItemAsFolderUrl(item, true);
731 if (!folderUrl.isEmpty()) {
732 setUrl(folderUrl);
733 } else {
734 slotItemActivated(item);
735 }
736 }
737
738 void DolphinViewContainer::slotItemActivated(const KFileItem &item)
739 {
740 // It is possible to activate items on inactive views by
741 // drag & drop operations. Assure that activating an item always
742 // results in an active view.
743 m_view->setActive(true);
744
745 const QUrl &url = DolphinView::openItemAsFolderUrl(item, GeneralSettings::browseThroughArchives());
746 if (!url.isEmpty()) {
747 const auto modifiers = QGuiApplication::keyboardModifiers();
748 // keep in sync with KUrlNavigator::slotNavigatorButtonClicked
749 if (modifiers & Qt::ControlModifier && modifiers & Qt::ShiftModifier) {
750 Q_EMIT activeTabRequested(url);
751 } else if (modifiers & Qt::ControlModifier) {
752 Q_EMIT tabRequested(url);
753 } else if (modifiers & Qt::ShiftModifier) {
754 Dolphin::openNewWindow({KFilePlacesModel::convertedUrl(url)}, this);
755 } else {
756 setUrl(url);
757 }
758 return;
759 }
760
761 KIO::OpenUrlJob *job = new KIO::OpenUrlJob(item.targetUrl(), item.mimetype());
762 // Auto*Warning*Handling, errors are put in a KMessageWidget by us in slotOpenUrlFinished.
763 job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoWarningHandlingEnabled, this));
764 job->setShowOpenOrExecuteDialog(true);
765 connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished);
766 job->start();
767 }
768
769 void DolphinViewContainer::slotfileMiddleClickActivated(const KFileItem &item)
770 {
771 KService::List services = KApplicationTrader::queryByMimeType(item.mimetype());
772
773 int indexOfAppToOpenFileWith = 1;
774
775 // executable scripts
776 auto mimeType = item.currentMimeType();
777 if (item.isLocalFile() && mimeType.inherits(QStringLiteral("application/x-executable")) && mimeType.inherits(QStringLiteral("text/plain"))
778 && QFileInfo(item.localPath()).isExecutable()) {
779 KConfigGroup cfgGroup(KSharedConfig::openConfig(QStringLiteral("kiorc")), QStringLiteral("Executable scripts"));
780 const QString value = cfgGroup.readEntry("behaviourOnLaunch", "alwaysAsk");
781
782 // in case KIO::WidgetsOpenOrExecuteFileHandler::promptUserOpenOrExecute would not open the file
783 if (value != QLatin1String("open")) {
784 indexOfAppToOpenFileWith = 0;
785 }
786 }
787
788 if (services.length() >= indexOfAppToOpenFileWith + 1) {
789 auto service = services.at(indexOfAppToOpenFileWith);
790
791 KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(service, this);
792 job->setUrls({item.url()});
793
794 job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
795 connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished);
796 job->start();
797 } else {
798 // If no 2nd service available, try to open archives in new tabs, regardless of the "Open archives as folder" setting.
799 const QUrl &url = DolphinView::openItemAsFolderUrl(item);
800 const auto modifiers = QGuiApplication::keyboardModifiers();
801 if (!url.isEmpty()) {
802 // keep in sync with KUrlNavigator::slotNavigatorButtonClicked
803 if (modifiers & Qt::ShiftModifier) {
804 Q_EMIT activeTabRequested(url);
805 } else {
806 Q_EMIT tabRequested(url);
807 }
808 }
809 }
810 }
811
812 void DolphinViewContainer::slotItemsActivated(const KFileItemList &items)
813 {
814 Q_ASSERT(items.count() >= 2);
815
816 KFileItemActions fileItemActions(this);
817 fileItemActions.runPreferredApplications(items);
818 }
819
820 void DolphinViewContainer::showItemInfo(const KFileItem &item)
821 {
822 if (item.isNull()) {
823 m_statusBar->resetToDefaultText();
824 } else {
825 m_statusBar->setText(item.getStatusBarInfo());
826 }
827 }
828
829 void DolphinViewContainer::closeFilterBar()
830 {
831 m_filterBar->closeFilterBar();
832 m_view->setFocus();
833 Q_EMIT showFilterBarChanged(false);
834 }
835
836 void DolphinViewContainer::clearFilterBar()
837 {
838 m_filterBar->clearIfUnlocked();
839 }
840
841 void DolphinViewContainer::setNameFilter(const QString &nameFilter)
842 {
843 m_view->hideToolTip(ToolTipManager::HideBehavior::Instantly);
844 m_view->setNameFilter(nameFilter);
845 delayedStatusBarUpdate();
846 }
847
848 void DolphinViewContainer::activate()
849 {
850 setActive(true);
851 }
852
853 void DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged(const QUrl &)
854 {
855 saveViewState();
856 }
857
858 void DolphinViewContainer::slotUrlNavigatorLocationChanged(const QUrl &url)
859 {
860 if (m_urlNavigatorConnected) {
861 m_urlNavigatorConnected->slotReturnPressed();
862 }
863
864 if (KProtocolManager::supportsListing(url)) {
865 const bool searchBoxInitialized = isSearchModeEnabled() && m_searchBox->text().isEmpty();
866 setSearchModeEnabled(isSearchUrl(url) || searchBoxInitialized);
867
868 m_view->setUrl(url);
869 tryRestoreViewState();
870
871 if (m_autoGrabFocus && isActive() && !isSearchModeEnabled()) {
872 // When an URL has been entered, the view should get the focus.
873 // The focus must be requested asynchronously, as changing the URL might create
874 // a new view widget.
875 QTimer::singleShot(0, this, &DolphinViewContainer::requestFocus);
876 }
877 } else if (KProtocolManager::isSourceProtocol(url)) {
878 if (url.scheme().startsWith(QLatin1String("http"))) {
879 showMessage(i18nc("@info:status", // krazy:exclude=qmethods
880 "Dolphin does not support web pages, the web browser has been launched"),
881 KMessageWidget::Information);
882 } else {
883 showMessage(i18nc("@info:status", "Protocol not supported by Dolphin, default application has been launched"), KMessageWidget::Information);
884 }
885
886 QDesktopServices::openUrl(url);
887 redirect(QUrl(), m_urlNavigator->locationUrl(1));
888 } else {
889 if (!url.scheme().isEmpty()) {
890 showMessage(i18nc("@info:status", "Invalid protocol '%1'", url.scheme()), KMessageWidget::Error);
891 } else {
892 showMessage(i18nc("@info:status", "Invalid protocol"), KMessageWidget::Error);
893 }
894 m_urlNavigator->goBack();
895 }
896 }
897
898 void DolphinViewContainer::slotUrlSelectionRequested(const QUrl &url)
899 {
900 // We do not want to select any item here because there is no reason to assume that the user wants to edit the folder we are emerging from. BUG: 424723
901
902 m_view->markUrlAsCurrent(url); // makes the item scroll into view
903 }
904
905 void DolphinViewContainer::disableUrlNavigatorSelectionRequests()
906 {
907 disconnect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested);
908 }
909
910 void DolphinViewContainer::enableUrlNavigatorSelectionRequests()
911 {
912 connect(m_urlNavigator.get(), &KUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested);
913 }
914
915 void DolphinViewContainer::redirect(const QUrl &oldUrl, const QUrl &newUrl)
916 {
917 Q_UNUSED(oldUrl)
918 const bool block = m_urlNavigator->signalsBlocked();
919 m_urlNavigator->blockSignals(true);
920
921 // Assure that the location state is reset for redirection URLs. This
922 // allows to skip redirection URLs when going back or forward in the
923 // URL history.
924 m_urlNavigator->saveLocationState(QByteArray());
925 m_urlNavigator->setLocationUrl(newUrl);
926 if (m_searchBox->isActive()) {
927 m_searchBox->setSearchPath(newUrl);
928 }
929 setSearchModeEnabled(isSearchUrl(newUrl));
930
931 m_urlNavigator->blockSignals(block);
932 }
933
934 void DolphinViewContainer::requestFocus()
935 {
936 m_view->setFocus();
937 }
938
939 void DolphinViewContainer::startSearching()
940 {
941 Q_CHECK_PTR(m_urlNavigatorConnected);
942 const QUrl url = m_searchBox->urlForSearching();
943 if (url.isValid() && !url.isEmpty()) {
944 m_view->setViewPropertiesContext(QStringLiteral("search"));
945 // If we open a new tab that has a search assigned to it, we can't
946 // update the urlNavigator, since there is none connected to that tab.
947 // See BUG:500101
948 if (m_urlNavigatorConnected) {
949 m_urlNavigatorConnected->setLocationUrl(url);
950 }
951 }
952 }
953
954 void DolphinViewContainer::openSearchBox()
955 {
956 setSearchModeEnabled(true);
957 }
958
959 void DolphinViewContainer::closeSearchBox()
960 {
961 setSearchModeEnabled(false);
962 }
963
964 void DolphinViewContainer::stopDirectoryLoading()
965 {
966 m_view->stopLoading();
967 m_statusBar->showProgress(QString(), 100);
968 }
969
970 void DolphinViewContainer::slotStatusBarZoomLevelChanged(int zoomLevel)
971 {
972 m_view->setZoomLevel(zoomLevel);
973 }
974
975 void DolphinViewContainer::slotErrorMessageFromView(const QString &message, const int kioErrorCode)
976 {
977 if (kioErrorCode == KIO::ERR_CANNOT_ENTER_DIRECTORY && m_view->url().scheme() == QStringLiteral("file")
978 && KProtocolInfo::isKnownProtocol(QStringLiteral("admin")) && !rootItem().isReadable()) {
979 // Explain to users that they need authentication to see the folder contents.
980 if (!m_authorizeToEnterFolderAction) { // This code is similar to parts of Admin::Bar::hideTheNextTimeAuthorizationExpires().
981 // We should not simply use the actAsAdminAction() itself here because that one always refers to the active view instead of this->m_view.
982 auto actAsAdminAction = Admin::WorkerIntegration::FriendAccess::actAsAdminAction();
983 m_authorizeToEnterFolderAction = new QAction{actAsAdminAction->icon(), actAsAdminAction->text(), this};
984 m_authorizeToEnterFolderAction->setToolTip(actAsAdminAction->toolTip());
985 m_authorizeToEnterFolderAction->setWhatsThis(actAsAdminAction->whatsThis());
986 connect(m_authorizeToEnterFolderAction, &QAction::triggered, this, [this, actAsAdminAction]() {
987 setActive(true);
988 actAsAdminAction->trigger();
989 });
990 }
991 showMessage(i18nc("@info", "Authorization required to enter this folder."), KMessageWidget::Error, {m_authorizeToEnterFolderAction});
992 return;
993 }
994 Q_EMIT showErrorMessage(message);
995 }
996
997 void DolphinViewContainer::showErrorMessage(const QString &message)
998 {
999 showMessage(message, KMessageWidget::Error);
1000 }
1001
1002 void DolphinViewContainer::slotPlacesModelChanged()
1003 {
1004 if (!GeneralSettings::showFullPathInTitlebar() && !isSearchModeEnabled()) {
1005 Q_EMIT captionChanged();
1006 }
1007 }
1008
1009 void DolphinViewContainer::slotHiddenFilesShownChanged(bool showHiddenFiles)
1010 {
1011 if (m_urlNavigatorConnected) {
1012 m_urlNavigatorConnected->setShowHiddenFolders(showHiddenFiles);
1013 }
1014 }
1015
1016 void DolphinViewContainer::slotSortHiddenLastChanged(bool hiddenLast)
1017 {
1018 if (m_urlNavigatorConnected) {
1019 m_urlNavigatorConnected->setSortHiddenFoldersLast(hiddenLast);
1020 }
1021 }
1022
1023 void DolphinViewContainer::slotCurrentDirectoryRemoved()
1024 {
1025 const QString location(url().toDisplayString(QUrl::PreferLocalFile));
1026 if (url().isLocalFile()) {
1027 const QString dirPath = url().toLocalFile();
1028 const QString newPath = getNearestExistingAncestorOfPath(dirPath);
1029 const QUrl newUrl = QUrl::fromLocalFile(newPath);
1030 // #473377: Delay changing the url to avoid modifying KCoreDirLister before KCoreDirListerCache::deleteDir() returns.
1031 QTimer::singleShot(0, this, [&, newUrl, location] {
1032 setUrl(newUrl);
1033 showMessage(xi18n("Current location changed, <filename>%1</filename> is no longer accessible.", location), KMessageWidget::Warning);
1034 });
1035 } else
1036 showMessage(xi18n("Current location changed, <filename>%1</filename> is no longer accessible.", location), KMessageWidget::Warning);
1037 }
1038
1039 void DolphinViewContainer::slotOpenUrlFinished(KJob *job)
1040 {
1041 if (job->error() && job->error() != KIO::ERR_USER_CANCELED) {
1042 showErrorMessage(job->errorString());
1043 }
1044 }
1045
1046 bool DolphinViewContainer::isSearchUrl(const QUrl &url) const
1047 {
1048 return url.scheme().contains(QLatin1String("search"));
1049 }
1050
1051 void DolphinViewContainer::saveViewState()
1052 {
1053 QByteArray locationState;
1054 QDataStream stream(&locationState, QIODevice::WriteOnly);
1055 m_view->saveState(stream);
1056 m_urlNavigator->saveLocationState(locationState);
1057 }
1058
1059 void DolphinViewContainer::tryRestoreViewState()
1060 {
1061 QByteArray locationState = m_urlNavigator->locationState();
1062 if (!locationState.isEmpty()) {
1063 QDataStream stream(&locationState, QIODevice::ReadOnly);
1064 m_view->restoreState(stream);
1065 }
1066 }
1067
1068 QString DolphinViewContainer::getNearestExistingAncestorOfPath(const QString &path) const
1069 {
1070 QDir dir(path);
1071 do {
1072 dir.setPath(QDir::cleanPath(dir.filePath(QStringLiteral(".."))));
1073 } while (!dir.exists() && !dir.isRoot());
1074
1075 return dir.exists() ? dir.path() : QString{};
1076 }
1077
1078 void DolphinViewContainer::updateStatusBarGeometry()
1079 {
1080 if (!m_statusBar) {
1081 return;
1082 }
1083 if (GeneralSettings::showStatusBar() == GeneralSettings::EnumShowStatusBar::Small) {
1084 QRect statusBarRect(preferredSmallStatusBarGeometry());
1085 if (view()->layoutDirection() == Qt::RightToLeft) {
1086 const int splitterWidth = m_statusBar->clippingAmount();
1087 statusBarRect.setLeft(rect().width() - m_statusBar->width() + splitterWidth); // Add clipping amount.
1088 }
1089 // Move statusbar to bottomLeft, or bottomRight with right-to-left-layout.
1090 m_statusBar->setGeometry(statusBarRect);
1091 // Add 1 due to how qrect coordinates work.
1092 m_view->setStatusBarOffset(m_statusBar->geometry().height() - m_statusBar->clippingAmount() + 1);
1093 } else {
1094 m_view->setStatusBarOffset(0);
1095 }
1096 }
1097
1098 bool DolphinViewContainer::eventFilter(QObject *object, QEvent *event)
1099 {
1100 if (GeneralSettings::showStatusBar() == GeneralSettings::EnumShowStatusBar::Small && object == m_view) {
1101 switch (event->type()) {
1102 case QEvent::Resize: {
1103 m_statusBar->updateWidthToContent();
1104 break;
1105 }
1106 case QEvent::LayoutRequest: {
1107 m_statusBar->updateWidthToContent();
1108 break;
1109 }
1110 default:
1111 break;
1112 }
1113 }
1114 return false;
1115 }
1116
1117 QRect DolphinViewContainer::preferredSmallStatusBarGeometry()
1118 {
1119 // Adjust to clipping, we need to add 1 due to how QRects coordinates work.
1120 int clipAdjustment = m_statusBar->clippingAmount() + 1;
1121 // Add offset depending if horizontal scrollbar or filterbar is visible.
1122 const int yPos = m_view->geometry().bottom() - m_view->horizontalScrollBarHeight() - m_statusBar->minimumHeight() + clipAdjustment;
1123 QRect statusBarRect = rect().adjusted(-clipAdjustment, yPos, 0, 0);
1124 return statusBarRect;
1125 }
1126
1127 #include "moc_dolphinviewcontainer.cpp"