Changeset View
Changeset View
Standalone View
Standalone View
src/views/dolphinviewactionhandler.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 90 | { | |||
---|---|---|---|---|---|
92 | // KNewFileMenu takes care of the GUI stuff. | 92 | // KNewFileMenu takes care of the GUI stuff. | ||
93 | QAction* newDirAction = m_actionCollection->addAction(QStringLiteral("create_dir")); | 93 | QAction* newDirAction = m_actionCollection->addAction(QStringLiteral("create_dir")); | ||
94 | newDirAction->setText(i18nc("@action", "Create Folder...")); | 94 | newDirAction->setText(i18nc("@action", "Create Folder...")); | ||
95 | m_actionCollection->setDefaultShortcut(newDirAction, Qt::Key_F10); | 95 | m_actionCollection->setDefaultShortcut(newDirAction, Qt::Key_F10); | ||
96 | newDirAction->setIcon(QIcon::fromTheme(QStringLiteral("folder-new"))); | 96 | newDirAction->setIcon(QIcon::fromTheme(QStringLiteral("folder-new"))); | ||
97 | newDirAction->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable | 97 | newDirAction->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable | ||
98 | connect(newDirAction, &QAction::triggered, this, &DolphinViewActionHandler::createDirectoryTriggered); | 98 | connect(newDirAction, &QAction::triggered, this, &DolphinViewActionHandler::createDirectoryTriggered); | ||
99 | 99 | | |||
100 | // This action doesn't appear in the GUI, it's for the shortcut only. | ||||
101 | // KNewFileMenu takes care of the GUI stuff. | ||||
102 | QAction* newFileAction = m_actionCollection->addAction(QStringLiteral("create_file")); | ||||
103 | newFileAction->setText(i18nc("@action", "Create File...")); | ||||
104 | m_actionCollection->setDefaultShortcut(newFileAction, Qt::SHIFT + Qt::Key_F10); | ||||
105 | newFileAction->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); | ||||
106 | newFileAction->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable | ||||
107 | connect(newFileAction, &QAction::triggered, this, &DolphinViewActionHandler::createFileTriggered); | ||||
108 | | ||||
100 | // File menu | 109 | // File menu | ||
101 | 110 | | |||
102 | KStandardAction::renameFile(this, &DolphinViewActionHandler::slotRename, m_actionCollection); | 111 | KStandardAction::renameFile(this, &DolphinViewActionHandler::slotRename, m_actionCollection); | ||
103 | 112 | | |||
104 | auto trashAction = KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated, m_actionCollection); | 113 | auto trashAction = KStandardAction::moveToTrash(this, &DolphinViewActionHandler::slotTrashActivated, m_actionCollection); | ||
105 | auto trashShortcuts = trashAction->shortcuts(); | 114 | auto trashShortcuts = trashAction->shortcuts(); | ||
106 | if (!trashShortcuts.contains(QKeySequence::Delete)) { | 115 | if (!trashShortcuts.contains(QKeySequence::Delete)) { | ||
107 | trashShortcuts.append(QKeySequence::Delete); | 116 | trashShortcuts.append(QKeySequence::Delete); | ||
▲ Show 20 Lines • Show All 371 Lines • ▼ Show 20 Line(s) | 479 | { | |||
479 | 488 | | |||
480 | showHiddenFilesAction->setIcon(QIcon::fromTheme(shown ? QStringLiteral("visibility") : QStringLiteral("hint"))); | 489 | showHiddenFilesAction->setIcon(QIcon::fromTheme(shown ? QStringLiteral("visibility") : QStringLiteral("hint"))); | ||
481 | } | 490 | } | ||
482 | 491 | | |||
483 | void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable) | 492 | void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable) | ||
484 | { | 493 | { | ||
485 | m_actionCollection->action(QStringLiteral("create_dir"))->setEnabled(isFolderWritable && | 494 | m_actionCollection->action(QStringLiteral("create_dir"))->setEnabled(isFolderWritable && | ||
486 | KProtocolManager::supportsMakeDir(currentView()->url())); | 495 | KProtocolManager::supportsMakeDir(currentView()->url())); | ||
496 | m_actionCollection->action(QStringLiteral("create_file"))->setEnabled(isFolderWritable && | ||||
497 | KProtocolManager::supportsWriting(currentView()->url())); | ||||
487 | } | 498 | } | ||
488 | 499 | | |||
489 | KToggleAction* DolphinViewActionHandler::iconsModeAction() | 500 | KToggleAction* DolphinViewActionHandler::iconsModeAction() | ||
490 | { | 501 | { | ||
491 | KToggleAction* iconsView = m_actionCollection->add<KToggleAction>(QStringLiteral("icons")); | 502 | KToggleAction* iconsView = m_actionCollection->add<KToggleAction>(QStringLiteral("icons")); | ||
492 | iconsView->setText(i18nc("@action:inmenu View Mode", "Icons")); | 503 | iconsView->setText(i18nc("@action:inmenu View Mode", "Icons")); | ||
493 | iconsView->setToolTip(i18nc("@info", "Icons view mode")); | 504 | iconsView->setToolTip(i18nc("@info", "Icons view mode")); | ||
494 | m_actionCollection->setDefaultShortcut(iconsView, Qt::CTRL + Qt::Key_1); | 505 | m_actionCollection->setDefaultShortcut(iconsView, Qt::CTRL + Qt::Key_1); | ||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |