return viewContainers;
}
+void DolphinMainWindow::setViewsWithInvalidPathsToHome()
+{
+ const QVector<DolphinViewContainer*> theViewContainers = viewContainers();
+ for (DolphinViewContainer *viewContainer : theViewContainers) {
+
+ // Only consider local dirs, not remote locations and abstract protocols
+ if (viewContainer->url().isLocalFile()) {
+ if (!QFileInfo::exists(viewContainer->url().toLocalFile())) {
+ viewContainer->setUrl(QUrl::fromLocalFile(QDir::homePath()));
+ }
+ }
+ }
+}
+
void DolphinMainWindow::openDirectories(const QList<QUrl>& dirs, bool splitView)
{
m_tabWidget->openDirectories(dirs, splitView);
m_tabWidget->openFiles(files, splitView);
}
+bool DolphinMainWindow::isFoldersPanelEnabled() const
+{
+ return actionCollection()->action(QStringLiteral("show_folders_panel"))->isChecked();
+}
+
+bool DolphinMainWindow::isInformationPanelEnabled() const
+{
+ return actionCollection()->action(QStringLiteral("show_information_panel"))->isChecked();
+}
+
void DolphinMainWindow::openFiles(const QStringList& files, bool splitView)
{
openFiles(QUrl::fromStringList(files), splitView);
updateViewActions();
updateGoActions();
- emit urlChanged(url);
+ Q_EMIT urlChanged(url);
}
void DolphinMainWindow::slotTerminalDirectoryChanged(const QUrl& url)
compareFilesAction->setEnabled(false);
}
- emit selectionChanged(selection);
+ Q_EMIT selectionChanged(selection);
}
void DolphinMainWindow::updateHistory()
const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
bool tabCreated = false;
- foreach (const KFileItem& item, list) {
+ for (const KFileItem& item : list) {
const QUrl& url = DolphinView::openItemAsFolderUrl(item);
if (!url.isEmpty()) {
openNewTabAfterCurrentTab(url);
void DolphinMainWindow::togglePanelLockState()
{
const bool newLockState = !GeneralSettings::lockPanels();
- foreach (QObject* child, children()) {
+ const auto childrenObjects = children();
+ for (QObject* child : childrenObjects) {
DolphinDockWidget* dock = qobject_cast<DolphinDockWidget*>(child);
if (dock) {
dock->setLocked(newLockState);
updateSearchAction();
const QUrl url = viewContainer->url();
- emit urlChanged(url);
+ Q_EMIT urlChanged(url);
}
void DolphinMainWindow::tabCountChanged(int count)
void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
{
+ connect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, this, [this, mountPath]() {
+ setViewsToHomeIfMountPathOpen(mountPath);
+ });
+
if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = true;
m_terminalPanel->goHome();
void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString& mountPath)
{
+ connect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, this, [this, mountPath]() {
+ setViewsToHomeIfMountPathOpen(mountPath);
+ });
+
if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = false;
m_terminalPanel->goHome();
}
}
+void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString& mountPath)
+{
+ const QVector<DolphinViewContainer*> theViewContainers = viewContainers();
+ for (DolphinViewContainer *viewContainer : theViewContainers) {
+ if (viewContainer && viewContainer->url().toLocalFile().startsWith(mountPath)) {
+ viewContainer->setUrl(QUrl::fromLocalFile(QDir::homePath()));
+ }
+ }
+ disconnect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, nullptr, nullptr);
+}
+
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
Q_ASSERT(menu);
const KToolBar* toolBarWidget = toolBar();
- foreach (const QWidget* widget, action->associatedWidgets()) {
+ const auto associatedWidgets = action->associatedWidgets();
+ for (const QWidget* widget : associatedWidgets) {
if (widget == toolBarWidget) {
return false;
}
updateWindowTitle();
}
- emit settingsChanged();
+ Q_EMIT settingsChanged();
}
void DolphinMainWindow::clearStatusBar()