#include "dolphindockwidget.h"
#include "dolphincontextmenu.h"
#include "dolphinnewfilemenu.h"
+#include "dolphinplacesmodelsingleton.h"
#include "dolphinrecenttabsmenu.h"
#include "dolphintabwidget.h"
#include "dolphinviewcontainer.h"
#include <KActionMenu>
#include <KAuthorized>
#include <KConfig>
+#include <KDesktopFile>
#include <KFileItemListProperties>
#include <KFilePlacesModel>
#include <KHelpMenu>
#include <KIO/JobUiDelegate>
+#include <KIO/OpenFileManagerWindowJob>
#include <KJobWidgets>
#include <KLocalizedString>
#include <KMessageBox>
#include <QClipboard>
#include <QCloseEvent>
#include <QDialog>
+#include <QFileInfo>
#include <QLineEdit>
#include <QMenu>
#include <QMenuBar>
}
}
+void DolphinMainWindow::showTarget()
+{
+ const auto link = m_activeViewContainer->view()->selectedItems().at(0);
+ const auto linkLocationDir = QFileInfo(link.localPath()).absoluteDir();
+ auto linkDestination = link.linkDest();
+ if (QFileInfo(linkDestination).isRelative()) {
+ linkDestination = linkLocationDir.filePath(linkDestination);
+ }
+ if (QFileInfo::exists(linkDestination)) {
+ KIO::highlightInFileManager({QUrl::fromLocalFile(linkDestination).adjusted(QUrl::StripTrailingSlash)});
+ } else {
+ m_activeViewContainer->showMessage(xi18nc("@info", "Could not access <filename>%1</filename>.", linkDestination),
+ DolphinViewContainer::Warning);
+ }
+}
+
void DolphinMainWindow::showEvent(QShowEvent* event)
{
KXmlGuiWindow::showEvent(event);
dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
dialog->setModal(true);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Yes | QDialogButtonBox::No | QDialogButtonBox::Cancel);
- KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KStandardGuiItem::quit());
+ KDesktopFile dolphinDesktopFile(QStringLiteral("%1.desktop").arg(QGuiApplication::desktopFileName()));
+ KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KGuiItem(i18nc("@action:button 'Quit Dolphin' button", "&Quit %1", dolphinDesktopFile.readName()), QIcon::fromTheme(QStringLiteral("application-exit"))));
KGuiItem::assign(buttons->button(QDialogButtonBox::No), KGuiItem(i18n("C&lose Current Tab"), QIcon::fromTheme(QStringLiteral("tab-close"))));
KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
buttons->button(QDialogButtonBox::Yes)->setDefault(true);
case QDialogButtonBox::No:
// Close only the current tab
m_tabWidget->closeTab();
+ Q_FALLTHROUGH();
default:
event->ignore();
return;
switch (command) {
case DolphinContextMenu::OpenParentFolder:
changeUrl(KIO::upUrl(item.url()));
+ m_activeViewContainer->view()->markUrlsAsSelected({item.url()});
+ m_activeViewContainer->view()->markUrlAsCurrent(item.url());
break;
case DolphinContextMenu::OpenParentFolderInNewWindow:
- Dolphin::openNewWindow({KIO::upUrl(item.url())}, this);
+ Dolphin::openNewWindow({item.url()}, this, Dolphin::OpenNewWindowFlag::Select);
break;
case DolphinContextMenu::OpenParentFolderInNewTab:
void DolphinMainWindow::setUrlAsCaption(const QUrl& url)
{
- static KFilePlacesModel s_placesModel;
-
QString schemePrefix;
if (!url.isLocalFile()) {
schemePrefix.append(url.scheme() + " - ");
return;
}
- const auto& matchedPlaces = s_placesModel.match(s_placesModel.index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly);
+ KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
+ const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly);
if (!matchedPlaces.isEmpty()) {
- setWindowTitle(s_placesModel.text(matchedPlaces.first()));
+ setWindowTitle(placesModel->text(matchedPlaces.first()));
return;
}
actionCollection()->setDefaultShortcuts(activatePrevTab, prevTabKeys);
// for context menu
+ QAction* showTarget = actionCollection()->addAction(QStringLiteral("show_target"));
+ showTarget->setText(i18nc("@action:inmenu", "Show Target"));
+ showTarget->setIcon(QIcon::fromTheme(QStringLiteral("document-open-folder")));
+ showTarget->setEnabled(false);
+ connect(showTarget, &QAction::triggered, this, &DolphinMainWindow::showTarget);
+
QAction* openInNewTab = actionCollection()->addAction(QStringLiteral("open_in_new_tab"));
openInNewTab->setText(i18nc("@action:inmenu", "Open in New Tab"));
openInNewTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
stateChanged(QStringLiteral("has_selection"));
KActionCollection* col = actionCollection();
- QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile));
- QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash));
- QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile));
- QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut));
+ QAction* renameAction = col->action(KStandardAction::name(KStandardAction::RenameFile));
+ QAction* moveToTrashAction = col->action(KStandardAction::name(KStandardAction::MoveToTrash));
+ QAction* deleteAction = col->action(KStandardAction::name(KStandardAction::DeleteFile));
+ QAction* cutAction = col->action(KStandardAction::name(KStandardAction::Cut));
QAction* deleteWithTrashShortcut = col->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
+ QAction* showTarget = col->action(QStringLiteral("show_target"));
KFileItemListProperties capabilities(list);
const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
deleteAction->setEnabled(capabilities.supportsDeleting());
deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
cutAction->setEnabled(capabilities.supportsMoving());
+ showTarget->setEnabled(list.length() == 1 && list.at(0).isLink());
}
}