void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos) { QMenu menu(this); QAction* addAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18nc("@item:inmenu", "Add Entry...")); QAction* showAllAction = nullptr; if (m_model->hiddenCount() > 0) { showAllAction = menu.addAction(i18nc("@item:inmenu", "Show All Entries")); showAllAction->setCheckable(true); showAllAction->setChecked(m_model->hiddenItemsShown()); } buildGroupContextMenu(&menu, m_controller->indexCloseToMousePressedPosition()); QMenu* iconSizeSubMenu = new QMenu(i18nc("@item:inmenu", "Icon Size"), &menu); struct IconSizeInfo { int size; const char* context; const char* text; }; const int iconSizeCount = 4; static const IconSizeInfo iconSizes[iconSizeCount] = { {KIconLoader::SizeSmall, I18N_NOOP2_NOSTRIP("Small icon size", "Small (%1x%2)")}, {KIconLoader::SizeSmallMedium, I18N_NOOP2_NOSTRIP("Medium icon size", "Medium (%1x%2)")}, {KIconLoader::SizeMedium, I18N_NOOP2_NOSTRIP("Large icon size", "Large (%1x%2)")}, {KIconLoader::SizeLarge, I18N_NOOP2_NOSTRIP("Huge icon size", "Huge (%1x%2)")} }; QMap<QAction*, int> iconSizeActionMap; QActionGroup* iconSizeGroup = new QActionGroup(iconSizeSubMenu); for (int i = 0; i < iconSizeCount; ++i) { const int size = iconSizes[i].size; const QString text = i18nc(iconSizes[i].context, iconSizes[i].text, size, size); QAction* action = iconSizeSubMenu->addAction(text); iconSizeActionMap.insert(action, size); action->setActionGroup(iconSizeGroup); action->setCheckable(true); action->setChecked(m_view->iconSize() == size); } menu.addMenu(iconSizeSubMenu); menu.addSeparator(); foreach (QAction* action, customContextMenuActions()) { menu.addAction(action); }
AdditionalInfoAccessor::AdditionalInfoAccessor() : m_information(), m_map() { static const AdditionalInfoAccessor::AdditionalInfo additionalInfo[] = { // Entries for view-properties version 1: { "size", I18N_NOOP2_NOSTRIP("@label", "Size"), "Size", DolphinView::SortBySize, 1 }, { "date", I18N_NOOP2_NOSTRIP("@label", "Date"), "Date", DolphinView::SortByDate, 2 }, { "permissions", I18N_NOOP2_NOSTRIP("@label", "Permissions"), "Permissions", DolphinView::SortByPermissions, 4 }, { "owner", I18N_NOOP2_NOSTRIP("@label", "Owner"), "Owner", DolphinView::SortByOwner, 8 }, { "group", I18N_NOOP2_NOSTRIP("@label", "Group"), "Group", DolphinView::SortByGroup, 16 }, { "type", I18N_NOOP2_NOSTRIP("@label", "Type"), "Type", DolphinView::SortByType, 32 }, { "destination", I18N_NOOP2_NOSTRIP("@label", "Link Destination"), "LinkDestination", DolphinView::SortByDestination, 64 }, { "path", I18N_NOOP2_NOSTRIP("@label", "Path"), "Path", DolphinView::SortByPath, 128 } // Entries for view-properties version >= 2 (the last column can be set to 0): }; m_map.insert(KFileItemDelegate::Size, &additionalInfo[0]); m_map.insert(KFileItemDelegate::ModificationTime, &additionalInfo[1]); m_map.insert(KFileItemDelegate::Permissions, &additionalInfo[2]); m_map.insert(KFileItemDelegate::Owner, &additionalInfo[3]); m_map.insert(KFileItemDelegate::OwnerAndGroup, &additionalInfo[4]); m_map.insert(KFileItemDelegate::FriendlyMimeType, &additionalInfo[5]); m_map.insert(KFileItemDelegate::LinkDest, &additionalInfo[6]); m_map.insert(KFileItemDelegate::LocalPathOrUrl, &additionalInfo[7]); // The m_information list defines all available keys and the sort order // (don't use m_information = m_map.keys(), as the order is undefined). m_information.append(KFileItemDelegate::Size); m_information.append(KFileItemDelegate::ModificationTime); m_information.append(KFileItemDelegate::Permissions); m_information.append(KFileItemDelegate::Owner); m_information.append(KFileItemDelegate::OwnerAndGroup); m_information.append(KFileItemDelegate::FriendlyMimeType); m_information.append(KFileItemDelegate::LinkDest); m_information.append(KFileItemDelegate::LocalPathOrUrl); }
#include <config-kio.h> #ifndef KIO_NO_NEPOMUK #define DISABLE_NEPOMUK_LEGACY #include "property.h" #endif struct TranslationItem { const char* const key; const char* const context; const char* const value; }; // TODO: a lot of NFOs are missing yet static const TranslationItem g_translations[] = { { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#comment", I18N_NOOP2_NOSTRIP("@label", "Comment") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentCreated", I18N_NOOP2_NOSTRIP("@label creation date", "Created") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#contentSize", I18N_NOOP2_NOSTRIP("@label file content size", "Size") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#depends", I18N_NOOP2_NOSTRIP("@label file depends from", "Depends") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#description", I18N_NOOP2_NOSTRIP("@label", "Description") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#generator", I18N_NOOP2_NOSTRIP("@label Software used to generate content", "Generator") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#hasPart", I18N_NOOP2_NOSTRIP("@label see http://www.semanticdesktop.org/ontologies/2007/01/19/nie#hasPart", "Has Part") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#hasLogicalPart", I18N_NOOP2_NOSTRIP("@label see http://www.semanticdesktop.org/ontologies/2007/01/19/nie#hasLogicalPart", "Has Logical Part") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#isPartOf", I18N_NOOP2_NOSTRIP("@label parent directory", "Part of") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#keyword", I18N_NOOP2_NOSTRIP("@label", "Keyword") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#lastModified", I18N_NOOP2_NOSTRIP("@label modified date of file", "Modified") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType", I18N_NOOP2_NOSTRIP("@label", "MIME Type") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#plainTextContent", I18N_NOOP2_NOSTRIP("@label", "Content") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#relatedTo", I18N_NOOP2_NOSTRIP("@label", "Related To") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#subject", I18N_NOOP2_NOSTRIP("@label", "Subject") }, { "http://www.semanticdesktop.org/ontologies/2007/01/19/nie#title", I18N_NOOP2_NOSTRIP("@label music title", "Title") },
void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) { PlacesItem* item = m_model->placesItem(index); if (!item) { return; } QMenu menu(this); QAction* emptyTrashAction = 0; QAction* addAction = 0; QAction* mainSeparator = 0; QAction* editAction = 0; QAction* teardownAction = 0; QAction* ejectAction = 0; const QString label = item->text(); const bool isDevice = !item->udi().isEmpty(); if (isDevice) { ejectAction = m_model->ejectAction(index); if (ejectAction) { ejectAction->setParent(&menu); menu.addAction(ejectAction); } teardownAction = m_model->teardownAction(index); if (teardownAction) { teardownAction->setParent(&menu); menu.addAction(teardownAction); } if (teardownAction || ejectAction) { mainSeparator = menu.addSeparator(); } } else { if (item->url() == QUrl(QStringLiteral("trash:/"))) { emptyTrashAction = menu.addAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash")); emptyTrashAction->setEnabled(item->icon() == QLatin1String("user-trash-full")); menu.addSeparator(); } addAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18nc("@item:inmenu", "Add Entry...")); mainSeparator = menu.addSeparator(); editAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18nc("@item:inmenu", "Edit '%1'...", label)); } if (!addAction) { addAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18nc("@item:inmenu", "Add Entry...")); } QAction* openInNewTabAction = menu.addAction(i18nc("@item:inmenu", "Open '%1' in New Tab", label)); openInNewTabAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-new"))); QAction* removeAction = 0; if (!isDevice && !item->isSystemItem()) { removeAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18nc("@item:inmenu", "Remove '%1'", label)); } QAction* hideAction = menu.addAction(i18nc("@item:inmenu", "Hide '%1'", label)); hideAction->setCheckable(true); hideAction->setChecked(item->isHidden()); QAction* showAllAction = 0; if (m_model->hiddenCount() > 0) { if (!mainSeparator) { mainSeparator = menu.addSeparator(); } showAllAction = menu.addAction(i18nc("@item:inmenu", "Show All Entries")); showAllAction->setCheckable(true); showAllAction->setChecked(m_model->hiddenItemsShown()); } menu.addSeparator(); QMenu* iconSizeSubMenu = new QMenu(i18nc("@item:inmenu", "Icon Size"), &menu); struct IconSizeInfo { int size; const char* context; const char* text; }; const int iconSizeCount = 4; static const IconSizeInfo iconSizes[iconSizeCount] = { {KIconLoader::SizeSmall, I18N_NOOP2_NOSTRIP("Small icon size", "Small (%1x%2)")}, {KIconLoader::SizeSmallMedium, I18N_NOOP2_NOSTRIP("Medium icon size", "Medium (%1x%2)")}, {KIconLoader::SizeMedium, I18N_NOOP2_NOSTRIP("Large icon size", "Large (%1x%2)")}, {KIconLoader::SizeLarge, I18N_NOOP2_NOSTRIP("Huge icon size", "Huge (%1x%2)")} }; QHash<QAction*, int> iconSizeActionMap; QActionGroup* iconSizeGroup = new QActionGroup(iconSizeSubMenu); for (int i = 0; i < iconSizeCount; ++i) { const int size = iconSizes[i].size; const QString text = i18nc(iconSizes[i].context, iconSizes[i].text, size, size); QAction* action = iconSizeSubMenu->addAction(text); iconSizeActionMap.insert(action, size); action->setActionGroup(iconSizeGroup); action->setCheckable(true); action->setChecked(m_view->iconSize() == size); } menu.addMenu(iconSizeSubMenu); menu.addSeparator(); foreach (QAction* action, customContextMenuActions()) { menu.addAction(action); }