X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/7d49cb567b595570f59156965332428c9490a04d..ffce84e759714e94de01a546009b4b41c64cdf28:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 4cba46554..8bc066455 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -8,6 +8,7 @@ #include "dolphinmainwindow.h" +#include "admin/workerintegration.h" #include "dolphin_generalsettings.h" #include "dolphinbookmarkhandler.h" #include "dolphincontextmenu.h" @@ -40,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -81,6 +84,7 @@ #include #include #include +#include #include @@ -181,7 +185,7 @@ DolphinMainWindow::DolphinMainWindow() m_disabledActionNotifier = new DisabledActionNotifier(this); connect(m_disabledActionNotifier, &DisabledActionNotifier::disabledActionTriggered, this, [this](const QAction *, QString reason) { - m_activeViewContainer->showMessage(reason, DolphinViewContainer::Warning); + m_activeViewContainer->showMessage(reason, KMessageWidget::Warning); }); setupDockWidgets(); @@ -362,6 +366,9 @@ void DolphinMainWindow::changeUrl(const QUrl &url) updateViewActions(); updateGoActions(); + // will signal used urls to activities manager, too + m_recentFiles->addUrl(url); + Q_EMIT urlChanged(url); } @@ -559,7 +566,7 @@ void DolphinMainWindow::showTarget() KIO::StatJob *statJob = static_cast(job); if (statJob->error()) { - m_activeViewContainer->showMessage(job->errorString(), DolphinViewContainer::Error); + m_activeViewContainer->showMessage(job->errorString(), KMessageWidget::Error); } else { KIO::highlightInFileManager({destinationUrl}); } @@ -781,8 +788,14 @@ void DolphinMainWindow::updateNewMenu() void DolphinMainWindow::createDirectory() { - m_newFileMenu->setWorkingDirectory(activeViewContainer()->url()); - m_newFileMenu->createDirectory(); + // When creating directory, namejob is being run. In network folders, + // this job can take long time, so instead of starting multiple namejobs, + // just check if we are already running one. This prevents opening multiple + // dialogs. BUG:481401 + if (!m_newFileMenu->isCreateDirectoryRunning()) { + m_newFileMenu->setWorkingDirectory(activeViewContainer()->url()); + m_newFileMenu->createDirectory(); + } } void DolphinMainWindow::quit() @@ -792,7 +805,7 @@ void DolphinMainWindow::quit() void DolphinMainWindow::showErrorMessage(const QString &message) { - m_activeViewContainer->showMessage(message, DolphinViewContainer::Error); + m_activeViewContainer->showMessage(message, KMessageWidget::Error); } void DolphinMainWindow::slotUndoAvailable(bool available) @@ -861,8 +874,8 @@ void DolphinMainWindow::updatePasteAction() pasteAction->setEnabled(pasteInfo.first); m_disabledActionNotifier->setDisabledReason(pasteAction, m_activeViewContainer->rootItem().isWritable() - ? i18nc("@info", "Could not paste: The clipboard is empty.") - : i18nc("@info", "Could not paste: You do not have permission to write into this folder.")); + ? i18nc("@info", "Cannot paste: The clipboard is empty.") + : i18nc("@info", "Cannot paste: You do not have permission to write into this folder.")); pasteAction->setText(pasteInfo.second); } @@ -1396,7 +1409,7 @@ void DolphinMainWindow::slotWriteStateChanged(bool isFolderWritable) // 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_dir")), - i18nc("@info", "Could not create new folder: You do not have permission to create items in this folder.")); + i18nc("@info", "Cannot create new folder: You do not have permission to create items in this folder.")); }); } @@ -1856,6 +1869,8 @@ void DolphinMainWindow::setupActions() // setup 'View' menu // (note that most of it is set up in DolphinViewActionHandler) + Admin::WorkerIntegration::createActAsAdminAction(actionCollection(), this); + m_splitViewAction = actionCollection()->add(QStringLiteral("split_view")); m_splitViewMenuAction = actionCollection()->addAction(QStringLiteral("split_view_menu")); @@ -2146,6 +2161,8 @@ void DolphinMainWindow::setupActions() connect(openInSplitViewAction, &QAction::triggered, this, [this]() { openInSplitView(QUrl()); }); + + m_recentFiles = new KRecentFilesAction(this); } void DolphinMainWindow::setupDockWidgets() @@ -2180,7 +2197,7 @@ void DolphinMainWindow::setupDockWidgets() connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl); infoDock->setWidget(infoPanel); - createPanelAction(QIcon::fromTheme(QStringLiteral("dialog-information")), Qt::Key_F11, infoDock, QStringLiteral("show_information_panel")); + createPanelAction(QIcon::fromTheme(QStringLiteral("documentinfo")), Qt::Key_F11, infoDock, QStringLiteral("show_information_panel")); addDockWidget(Qt::RightDockWidgetArea, infoDock); connect(this, &DolphinMainWindow::urlChanged, infoPanel, &InformationPanel::setUrl); @@ -2431,18 +2448,17 @@ void DolphinMainWindow::updateFileAndEditActions() const bool enableMoveToTrash = capabilitiesSource.isLocal() && capabilitiesSource.supportsMoving(); renameAction->setEnabled(capabilitiesSource.supportsMoving()); - m_disabledActionNotifier->setDisabledReason(renameAction, - i18nc("@info", "Could not rename: You do not have permission to rename items in this folder.")); + m_disabledActionNotifier->setDisabledReason(renameAction, i18nc("@info", "Cannot rename: You do not have permission to rename items in this folder.")); deleteAction->setEnabled(capabilitiesSource.supportsDeleting()); m_disabledActionNotifier->setDisabledReason(deleteAction, - i18nc("@info", "Could not delete: You do not have permission to remove items from this folder.")); + i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder.")); cutAction->setEnabled(capabilitiesSource.supportsMoving()); - m_disabledActionNotifier->setDisabledReason(cutAction, i18nc("@info", "Could not cut: You do not have permission to move items from this folder.")); + m_disabledActionNotifier->setDisabledReason(cutAction, i18nc("@info", "Cannot cut: You do not have permission to move items from this folder.")); copyLocation->setEnabled(list.length() == 1); showTarget->setEnabled(list.length() == 1 && list.at(0).isLink()); duplicateAction->setEnabled(capabilitiesSource.supportsWriting()); m_disabledActionNotifier->setDisabledReason(duplicateAction, - i18nc("@info", "Could not duplicate here: You do not have permission to create items in this folder.")); + i18nc("@info", "Cannot duplicate here: You do not have permission to create items in this folder.")); if (enableMoveToTrash) { moveToTrashAction->setEnabled(true); @@ -2452,7 +2468,7 @@ void DolphinMainWindow::updateFileAndEditActions() moveToTrashAction->setEnabled(false); deleteWithTrashShortcut->setEnabled(capabilitiesSource.supportsDeleting()); m_disabledActionNotifier->setDisabledReason(deleteWithTrashShortcut, - i18nc("@info", "Could not delete: You do not have permission to remove items from this folder.")); + i18nc("@info", "Cannot delete: You do not have permission to remove items from this folder.")); } } @@ -2464,9 +2480,9 @@ void DolphinMainWindow::updateFileAndEditActions() m_disabledActionNotifier->clearDisabledReason(moveToOtherViewAction); } else if (list.isEmpty()) { copyToOtherViewAction->setEnabled(false); - m_disabledActionNotifier->setDisabledReason(copyToOtherViewAction, i18nc("@info", "Could not copy to other view: No files selected.")); + m_disabledActionNotifier->setDisabledReason(copyToOtherViewAction, i18nc("@info", "Cannot copy to other view: No files selected.")); moveToOtherViewAction->setEnabled(false); - m_disabledActionNotifier->setDisabledReason(moveToOtherViewAction, i18nc("@info", "Could not move to other view: No files selected.")); + m_disabledActionNotifier->setDisabledReason(moveToOtherViewAction, i18nc("@info", "Cannot move to other view: No files selected.")); } else { DolphinTabPage *tabPage = m_tabWidget->currentTabPage(); KFileItem capabilitiesDestination; @@ -2485,25 +2501,25 @@ void DolphinMainWindow::updateFileAndEditActions() if (!allNotTargetOrigin) { copyToOtherViewAction->setEnabled(false); m_disabledActionNotifier->setDisabledReason(copyToOtherViewAction, - i18nc("@info", "Could not copy to other view: The other view already contains these items.")); + i18nc("@info", "Cannot copy to other view: The other view already contains these items.")); moveToOtherViewAction->setEnabled(false); m_disabledActionNotifier->setDisabledReason(moveToOtherViewAction, - i18nc("@info", "Could not move to other view: The other view already contains these items.")); + i18nc("@info", "Cannot move to other view: The other view already contains these items.")); } else if (!capabilitiesDestination.isWritable()) { copyToOtherViewAction->setEnabled(false); m_disabledActionNotifier->setDisabledReason( copyToOtherViewAction, - i18nc("@info", "Could not copy to other view: You do not have permission to write into the destination folder.")); + i18nc("@info", "Cannot copy to other view: You do not have permission to write into the destination folder.")); moveToOtherViewAction->setEnabled(false); m_disabledActionNotifier->setDisabledReason( moveToOtherViewAction, - i18nc("@info", "Could not move to other view: You do not have permission to write into the destination folder.")); + i18nc("@info", "Cannot move to other view: You do not have permission to write into the destination folder.")); } else { copyToOtherViewAction->setEnabled(true); moveToOtherViewAction->setEnabled(capabilitiesSource.supportsMoving()); m_disabledActionNotifier->setDisabledReason( moveToOtherViewAction, - i18nc("@info", "Could not move to other view: You do not have permission to move items from this folder.")); + i18nc("@info", "Cannot move to other view: You do not have permission to move items from this folder.")); } } } @@ -2587,6 +2603,7 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer *container) connect(view, &DolphinView::goForwardRequested, this, &DolphinMainWindow::goForward); connect(view, &DolphinView::urlActivated, this, &DolphinMainWindow::handleUrl); connect(view, &DolphinView::goUpRequested, this, &DolphinMainWindow::goUp); + connect(view, &DolphinView::doubleClickViewBackground, this, &DolphinMainWindow::slotDoubleClickViewBackground); connect(container->urlNavigatorInternalWithHistory(), &KUrlNavigator::urlChanged, this, &DolphinMainWindow::changeUrl); connect(container->urlNavigatorInternalWithHistory(), &KUrlNavigator::historyChanged, this, &DolphinMainWindow::updateHistory); @@ -2887,7 +2904,7 @@ void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job *job) DolphinMainWindow *mainWin = qobject_cast(parentWidget()); if (mainWin) { DolphinViewContainer *container = mainWin->activeViewContainer(); - container->showMessage(job->errorString(), DolphinViewContainer::Error); + container->showMessage(job->errorString(), KMessageWidget::Error); } else { KIO::FileUndoManager::UiInterface::jobError(job); } @@ -2903,4 +2920,38 @@ bool DolphinMainWindow::isItemVisibleInAnyView(const QString &urlOfItem) return m_tabWidget->isItemVisibleInAnyView(QUrl::fromUserInput(urlOfItem)); } +void DolphinMainWindow::slotDoubleClickViewBackground(Qt::MouseButton button) +{ + Q_UNUSED(button) // might be of use later + + GeneralSettings *settings = GeneralSettings::self(); + QString clickAction = settings->doubleClickViewAction(); + + DolphinView *view = activeViewContainer()->view(); + if (view == nullptr || clickAction == "none") { + return; + } + + if (clickAction == customCommand) { + // run custom command set by the user + QString path = view->url().toLocalFile(); + QString clickCustomAction = settings->doubleClickViewCustomAction(); + clickCustomAction.replace("{path}", path.prepend('"').append('"')); + + m_job = new KIO::CommandLauncherJob(clickCustomAction); + m_job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); + m_job->start(); + + } else { + // get the action set by the user and trigger it + const KActionCollection *actions = actionCollection(); + QAction *action = actions->action(clickAction); + if (action == nullptr) { + qCWarning(DolphinDebug) << QStringLiteral("Double-click view: action `%1` was not found").arg(clickAction); + return; + } + action->trigger(); + } +} + #include "moc_dolphinmainwindow.cpp"