- m_topLayout->setMargin(0);
-
- m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this);
- connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl&, QDropEvent*)),
- this, SLOT(dropUrls(const KUrl&, QDropEvent*)));
- connect(m_urlNavigator, SIGNAL(activated()),
- this, SLOT(activate()));
- connect(m_urlNavigator->editor(), SIGNAL(completionModeChanged(KGlobalSettings::Completion)),
- this, SLOT(saveUrlCompletionMode(KGlobalSettings::Completion)));
-
- const GeneralSettings* settings = DolphinSettings::instance().generalSettings();
- m_urlNavigator->setUrlEditable(settings->editableUrl());
- m_urlNavigator->setShowFullPath(settings->showFullPath());
- m_urlNavigator->setHomeUrl(KUrl(settings->homeUrl()));
- KUrlComboBox* editor = m_urlNavigator->editor();
- editor->setCompletionMode(KGlobalSettings::Completion(settings->urlCompletionMode()));
-
- m_searchBox = new DolphinSearchBox(this);
- m_searchBox->hide();
- connect(m_searchBox, SIGNAL(closeRequest()), this, SLOT(closeSearchBox()));
- connect(m_searchBox, SIGNAL(search(QString)), this, SLOT(startSearching(QString)));
- connect(m_searchBox, SIGNAL(returnPressed(QString)), this, SLOT(requestFocus()));
-
- m_dirLister = new DolphinDirLister();
- m_dirLister->setAutoUpdate(true);
- m_dirLister->setMainWindow(window());
- m_dirLister->setDelayedMimeTypes(true);
-
- m_dolphinModel = new DolphinModel(this);
- m_dolphinModel->setDirLister(m_dirLister); // m_dolphinModel takes ownership of m_dirLister
- m_dolphinModel->setDropsAllowed(DolphinModel::DropOnDirectory);
-
- m_proxyModel = new DolphinSortFilterProxyModel(this);
- m_proxyModel->setSourceModel(m_dolphinModel);
- m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
-
- connect(m_dirLister, SIGNAL(started(KUrl)),
- this, SLOT(initializeProgress()));
- connect(m_dirLister, SIGNAL(clear()),
- this, SLOT(delayedStatusBarUpdate()));
- connect(m_dirLister, SIGNAL(percent(int)),
- this, SLOT(updateProgress(int)));
- connect(m_dirLister, SIGNAL(itemsDeleted(const KFileItemList&)),
- this, SLOT(delayedStatusBarUpdate()));
- connect(m_dirLister, SIGNAL(completed()),
- this, SLOT(slotDirListerCompleted()));
- connect(m_dirLister, SIGNAL(infoMessage(const QString&)),
- this, SLOT(showInfoMessage(const QString&)));
- connect(m_dirLister, SIGNAL(errorMessage(const QString&)),
- this, SLOT(showErrorMessage(const QString&)));
- connect(m_dirLister, SIGNAL(urlIsFileError(const KUrl&)),
- this, SLOT(openFile(const KUrl&)));
-
- m_view = new DolphinView(this, url, m_proxyModel);
- connect(m_view, SIGNAL(urlChanged(const KUrl&)),
- m_urlNavigator, SLOT(setUrl(const KUrl&)));
- connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
- this, SLOT(showItemInfo(KFileItem)));
- connect(m_view, SIGNAL(errorMessage(const QString&)),
- this, SLOT(showErrorMessage(const QString&)));
- connect(m_view, SIGNAL(infoMessage(const QString&)),
- this, SLOT(showInfoMessage(const QString&)));
- connect(m_view, SIGNAL(operationCompletedMessage(const QString&)),
- this, SLOT(showOperationCompletedMessage(const QString&)));
- connect(m_view, SIGNAL(itemTriggered(KFileItem)),
- this, SLOT(slotItemTriggered(KFileItem)));
- connect(m_view, SIGNAL(redirection(KUrl, KUrl)),
- this, SLOT(redirect(KUrl, KUrl)));
- connect(m_view, SIGNAL(selectionChanged(const KFileItemList&)),
- this, SLOT(delayedStatusBarUpdate()));
-
- connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
- this, SLOT(slotUrlNavigatorLocationChanged(const KUrl&)));
- connect(m_urlNavigator, SIGNAL(urlAboutToBeChanged(const KUrl&)),
- this, SLOT(saveViewState()));
- connect(m_urlNavigator, SIGNAL(historyChanged()),
- this, SLOT(slotHistoryChanged()));
-
- // initialize status bar
- m_statusBar = new DolphinStatusBar(this, m_view);
+ m_topLayout->setContentsMargins(0, 0, 0, 0);
+
+ m_messageWidget = new KMessageWidget(this);
+ m_messageWidget->setCloseButtonVisible(true);
+ m_messageWidget->setPosition(KMessageWidget::Header);
+ m_messageWidget->hide();
+
+#if !defined(Q_OS_WIN) && !defined(Q_OS_HAIKU)
+ if (getuid() == 0) {
+ // We must be logged in as the root user; show a big scary warning
+ showMessage(i18n("Running Dolphin as root can be dangerous. Please be careful."), KMessageWidget::Warning);
+ }
+#endif
+
+ // Initialize filter bar
+ m_filterBar = new FilterBar(this);
+ m_filterBar->setVisible(GeneralSettings::filterBar(), WithoutAnimation);
+
+ connect(m_filterBar, &FilterBar::filterChanged, this, &DolphinViewContainer::setNameFilter);
+ connect(m_filterBar, &FilterBar::closeRequest, this, &DolphinViewContainer::closeFilterBar);
+ connect(m_filterBar, &FilterBar::focusViewRequest, this, &DolphinViewContainer::requestFocus);
+
+ // Initialize the main view
+ m_view = new DolphinView(url, this);
+ connect(m_view, &DolphinView::urlChanged, m_filterBar, &FilterBar::clearIfUnlocked);
+ connect(m_view, &DolphinView::urlChanged, m_messageWidget, &KMessageWidget::hide);
+ // m_urlNavigator stays in sync with m_view's location changes and
+ // keeps track of them so going back and forth in the history works.
+ connect(m_view, &DolphinView::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
+ connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlChanged, this, &DolphinViewContainer::slotUrlNavigatorLocationChanged);
+ connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlAboutToBeChanged, this, &DolphinViewContainer::slotUrlNavigatorLocationAboutToBeChanged);
+ connect(m_urlNavigator.get(), &DolphinUrlNavigator::urlSelectionRequested, this, &DolphinViewContainer::slotUrlSelectionRequested);
+ connect(m_view, &DolphinView::writeStateChanged, this, &DolphinViewContainer::writeStateChanged);
+ connect(m_view, &DolphinView::requestItemInfo, this, &DolphinViewContainer::showItemInfo);
+ connect(m_view, &DolphinView::itemActivated, this, &DolphinViewContainer::slotItemActivated);
+ connect(m_view, &DolphinView::fileMiddleClickActivated, this, &DolphinViewContainer::slotfileMiddleClickActivated);
+ connect(m_view, &DolphinView::itemsActivated, this, &DolphinViewContainer::slotItemsActivated);
+ connect(m_view, &DolphinView::redirection, this, &DolphinViewContainer::redirect);
+ connect(m_view, &DolphinView::directoryLoadingStarted, this, &DolphinViewContainer::slotDirectoryLoadingStarted);
+ connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinViewContainer::slotDirectoryLoadingCompleted);
+ connect(m_view, &DolphinView::directoryLoadingCanceled, this, &DolphinViewContainer::slotDirectoryLoadingCanceled);
+ connect(m_view, &DolphinView::itemCountChanged, this, &DolphinViewContainer::delayedStatusBarUpdate);
+ connect(m_view, &DolphinView::selectionChanged, this, &DolphinViewContainer::delayedStatusBarUpdate);
+ connect(m_view, &DolphinView::errorMessage, this, &DolphinViewContainer::slotErrorMessageFromView);
+ connect(m_view, &DolphinView::urlIsFileError, this, &DolphinViewContainer::slotUrlIsFileError);
+ connect(m_view, &DolphinView::activated, this, &DolphinViewContainer::activate);
+ connect(m_view, &DolphinView::hiddenFilesShownChanged, this, &DolphinViewContainer::slotHiddenFilesShownChanged);
+ connect(m_view, &DolphinView::sortHiddenLastChanged, this, &DolphinViewContainer::slotSortHiddenLastChanged);
+ connect(m_view, &DolphinView::currentDirectoryRemoved, this, &DolphinViewContainer::slotCurrentDirectoryRemoved);
+
+ // Initialize status bar
+ m_statusBar = new DolphinStatusBar(this);
+ m_statusBar->setUrl(m_view->url());
+ m_statusBar->setZoomLevel(m_view->zoomLevel());
+ connect(m_view, &DolphinView::urlChanged, m_statusBar, &DolphinStatusBar::setUrl);
+ connect(m_view, &DolphinView::zoomLevelChanged, m_statusBar, &DolphinStatusBar::setZoomLevel);
+ connect(m_view, &DolphinView::infoMessage, m_statusBar, &DolphinStatusBar::setText);
+ connect(m_view, &DolphinView::operationCompletedMessage, m_statusBar, &DolphinStatusBar::setText);
+ connect(m_view, &DolphinView::statusBarTextChanged, m_statusBar, &DolphinStatusBar::setDefaultText);
+ connect(m_view, &DolphinView::statusBarTextChanged, m_statusBar, &DolphinStatusBar::resetToDefaultText);
+ connect(m_view, &DolphinView::directoryLoadingProgress, m_statusBar, [this](int percent) {
+ m_statusBar->showProgress(i18nc("@info:progress", "Loading folder…"), percent);
+ });
+ connect(m_view, &DolphinView::directorySortingProgress, m_statusBar, [this](int percent) {
+ m_statusBar->showProgress(i18nc("@info:progress", "Sorting…"), percent);
+ });
+ connect(m_statusBar, &DolphinStatusBar::stopPressed, this, &DolphinViewContainer::stopDirectoryLoading);
+ connect(m_statusBar, &DolphinStatusBar::zoomLevelChanged, this, &DolphinViewContainer::slotStatusBarZoomLevelChanged);
+ connect(m_statusBar, &DolphinStatusBar::showMessage, this, [this](const QString &message, KMessageWidget::MessageType messageType) {
+ showMessage(message, messageType);
+ });
+ connect(m_statusBar, &DolphinStatusBar::widthUpdated, this, &DolphinViewContainer::updateStatusBarGeometry);
+ connect(m_statusBar, &DolphinStatusBar::urlChanged, this, &DolphinViewContainer::updateStatusBar);
+ connect(this, &DolphinViewContainer::showFilterBarChanged, this, &DolphinViewContainer::updateStatusBar);
+