X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/ac6579146784e0fabe5a24b7ee5856658d25e6b3..9cde51e14a25cef7237cb9178fe1538eef8d59c2:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 6f23581b4..a5dd3f9d3 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -176,10 +176,16 @@ DolphinMainWindow::DolphinMainWindow() m_actionHandler = new DolphinViewActionHandler(actionCollection(), m_actionTextHelper, this); connect(m_actionHandler, &DolphinViewActionHandler::actionBeingHandled, this, &DolphinMainWindow::clearStatusBar); connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinMainWindow::createDirectory); + connect(m_actionHandler, &DolphinViewActionHandler::createFileTriggered, this, &DolphinMainWindow::createFile); connect(m_actionHandler, &DolphinViewActionHandler::selectionModeChangeTriggered, this, &DolphinMainWindow::slotSetSelectionMode); - Q_CHECK_PTR(actionCollection()->action(QStringLiteral("create_dir"))); - m_newFileMenu->setNewFolderShortcutAction(actionCollection()->action(QStringLiteral("create_dir"))); + QAction *newDirAction = actionCollection()->action(QStringLiteral("create_dir")); + Q_CHECK_PTR(newDirAction); + m_newFileMenu->setNewFolderShortcutAction(newDirAction); + + QAction *newFileAction = actionCollection()->action(QStringLiteral("create_file")); + Q_CHECK_PTR(newFileAction); + m_newFileMenu->setNewFileShortcutAction(newFileAction); m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler); connect(this, &DolphinMainWindow::urlChanged, m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl); @@ -385,7 +391,7 @@ void DolphinMainWindow::changeUrl(const QUrl &url) updateGoActions(); // will signal used urls to activities manager, too - m_recentFiles->addUrl(url); + m_recentFiles->addUrl(url, QString(), "inode/directory"); Q_EMIT urlChanged(url); } @@ -489,9 +495,9 @@ void DolphinMainWindow::addToPlaces() } } -void DolphinMainWindow::openNewTab(const QUrl &url) +DolphinTabPage *DolphinMainWindow::openNewTab(const QUrl &url) { - m_tabWidget->openNewTab(url, QUrl()); + return m_tabWidget->openNewTab(url, QUrl()); } void DolphinMainWindow::openNewTabAndActivate(const QUrl &url) @@ -816,6 +822,15 @@ void DolphinMainWindow::createDirectory() } } +void DolphinMainWindow::createFile() +{ + // Use the same logic as in createDirectory() + if (!m_newFileMenu->isCreateFileRunning()) { + m_newFileMenu->setWorkingDirectory(activeViewContainer()->url()); + m_newFileMenu->createFile(); + } +} + void DolphinMainWindow::quit() { close(); @@ -981,6 +996,7 @@ void DolphinMainWindow::slotAboutToShowForwardPopupMenu() const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory(); int entries = 0; QMenu *menu = m_forwardAction->popupMenu(); + menu->clear(); for (int i = urlNavigator->historyIndex() - 1; i >= 0 && entries < MaxNumberOfNavigationentries; --i, ++entries) { QAction *action = urlNavigatorHistoryAction(urlNavigator, i, menu); menu->addAction(action); @@ -1445,6 +1461,8 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable) newFileMenu()->setEnabled(isFolderWritable && m_activeViewContainer->url().scheme() != QLatin1String("trash")); // When the menu is disabled, actions in it are disabled later in the event loop, and we need to set the disabled reason after that. QTimer::singleShot(0, this, [this]() { + m_disabledActionNotifier->setDisabledReason(actionCollection()->action(QStringLiteral("create_file")), + i18nc("@info", "Cannot create new file: You do not have permission to create items in this folder.")); m_disabledActionNotifier->setDisabledReason(actionCollection()->action(QStringLiteral("create_dir")), i18nc("@info", "Cannot create new folder: You do not have permission to create items in this folder.")); }); @@ -1563,6 +1581,8 @@ void DolphinMainWindow::slotPlaceActivated(const QUrl &url) // We can end up here if the user clicked a device in the Places Panel // which had been unmounted earlier, see https://bugs.kde.org/show_bug.cgi?id=161385. reloadView(); + + m_activeViewContainer->view()->setFocus(); // We always want the focus on the view after activating a place. } else { view->disableUrlNavigatorSelectionRequests(); changeUrl(url); @@ -1697,7 +1717,7 @@ void DolphinMainWindow::setupActions() auto hamburgerMenuAction = KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection()); // setup 'File' menu - m_newFileMenu = new DolphinNewFileMenu(nullptr, this); + m_newFileMenu = new DolphinNewFileMenu(nullptr, nullptr, this); actionCollection()->addAction(QStringLiteral("new_menu"), m_newFileMenu); QMenu *menu = m_newFileMenu->menu(); menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));