mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +12:00
Adds a 'Rename Item' option to context menu in the Tree view #189
This commit is contained in:
parent
2cc721674a
commit
81de19165b
5
icons/NumixMsk/16x16/actions/edit-rename.svg
Normal file
5
icons/NumixMsk/16x16/actions/edit-rename.svg
Normal file
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16.000001 16.000001">
|
||||
<rect width="16" height="10" y="3" rx="1" style="fill:#888;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<rect width="14" height="8" x="1" y="4" rx="0.5" style="fill:#fff;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<path d="m 3 5 0 1 1 0 0 4 -1 0 l 0 1 l 3 0 0 -1 -1 0 l 0 -4 1 0 0 -1" style="fill:#859900;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
</svg>
|
After Width: | Height: | Size: 421 B |
5
icons/NumixMsk/22x22/actions/edit-rename.svg
Normal file
5
icons/NumixMsk/22x22/actions/edit-rename.svg
Normal file
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22">
|
||||
<rect width="20" height="10" x="1" y="6" rx="1" style="fill:#888;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<rect width="18" height="8" x="2" y="7" rx="0.5" style="fill:#fff;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<path d="m 4 8 l 0 1 l 1 0 l 0 4 l -1 0 l 0 1 l 3 0 l 0 -1 l -1 0 l 0 -4 l 1 0 l 0 -1 l -3 0 z" style="fill:#859900;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
</svg>
|
After Width: | Height: | Size: 438 B |
5
icons/NumixMsk/24x24/actions/edit-rename.svg
Normal file
5
icons/NumixMsk/24x24/actions/edit-rename.svg
Normal file
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<rect width="20" height="10" x="2" y="7" rx="1" style="fill:#888;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<rect width="18" height="8" x="3" y="8" rx="0.5" style="fill:#fff;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<path d="m 5 9 0 1 1 0 0 4 -1 0 0 1 3 0 0 -1 -1 0 0 -4 1 0 0 -1 -3 0 z" style="fill:#859900;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
</svg>
|
After Width: | Height: | Size: 414 B |
5
icons/NumixMsk/32x32/actions/edit-rename.svg
Normal file
5
icons/NumixMsk/32x32/actions/edit-rename.svg
Normal file
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
||||
<rect width="32" height="20" y="6" rx="2" style="fill:#888;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<rect width="28" height="16" x="2" y="8" rx="1" style="fill:#fff;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<path d="m 6 10 0 2 2 0 0 8 -2 0 0 2 6 0 0 -2 -2 0 0 -8 2 0 0 -2 z" style="fill:#859900;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
</svg>
|
After Width: | Height: | Size: 403 B |
5
icons/NumixMsk/48x48/actions/edit-rename.svg
Normal file
5
icons/NumixMsk/48x48/actions/edit-rename.svg
Normal file
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48">
|
||||
<rect width="40" height="20" x="4" y="14" rx="2" style="fill:#888;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<rect width="36" height="16" x="6" y="16" rx="1" style="fill:#fff;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<path d="m 10 18 0 2 2 0 0 8 -2 0 0 2 6 0 0 -2 -2 0 0 -8 2 0 0 -2 -6 0 z" style="fill:#859900;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
</svg>
|
After Width: | Height: | Size: 417 B |
5
icons/NumixMsk/64x64/actions/edit-rename.svg
Normal file
5
icons/NumixMsk/64x64/actions/edit-rename.svg
Normal file
|
@ -0,0 +1,5 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
||||
<rect width="64" height="40" y="12" rx="4" style="fill:#888;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<rect width="56" height="32" x="4" y="16" rx="2" style="fill:#fff;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
<path d="m 12 20 0 4 4 0 l 0 16 l -4 0 0 4 12 0 0 -4 -4 0 0 -16 4 0 0 -4 z" style="fill:#859900;opacity:1;fill-opacity:1;stroke:none"/>
|
||||
</svg>
|
After Width: | Height: | Size: 413 B |
|
@ -39,14 +39,18 @@ class outlineBasics(QAbstractItemView):
|
|||
|
||||
menu = QMenu(self)
|
||||
|
||||
# Add / remove items
|
||||
# Open items
|
||||
self.actOpen = QAction(QIcon.fromTheme("go-right"), qApp.translate("outlineBasics", "Open Item"), menu)
|
||||
self.actOpen.triggered.connect(self.openItem)
|
||||
menu.addAction(self.actOpen)
|
||||
|
||||
menu.addSeparator()
|
||||
|
||||
# Add / remove items
|
||||
# Rename / add / remove items
|
||||
self.actRename = QAction(QIcon.fromTheme("edit-rename"), qApp.translate("outlineBasics", "Rename"), menu)
|
||||
self.actRename.triggered.connect(self.rename)
|
||||
menu.addAction(self.actRename)
|
||||
|
||||
self.actAddFolder = QAction(QIcon.fromTheme("folder-new"), qApp.translate("outlineBasics", "New Folder"), menu)
|
||||
self.actAddFolder.triggered.connect(self.addFolder)
|
||||
menu.addAction(self.actAddFolder)
|
||||
|
@ -184,12 +188,16 @@ class outlineBasics(QAbstractItemView):
|
|||
self.actOpen.setEnabled(False)
|
||||
self.actCopy.setEnabled(False)
|
||||
self.actCut.setEnabled(False)
|
||||
self.actRename.setEnabled(False)
|
||||
self.actDelete.setEnabled(False)
|
||||
self.menuPOV.setEnabled(False)
|
||||
self.menuStatus.setEnabled(False)
|
||||
self.menuLabel.setEnabled(False)
|
||||
self.menuCustomIcons.setEnabled(False)
|
||||
|
||||
if len(sel) > 1:
|
||||
self.actRename.setEnabled(False)
|
||||
|
||||
return menu
|
||||
|
||||
def openItem(self):
|
||||
|
@ -197,6 +205,14 @@ class outlineBasics(QAbstractItemView):
|
|||
from manuskript.functions import MW
|
||||
MW.openIndex(idx)
|
||||
|
||||
def rename(self):
|
||||
if len(self.getSelection()) == 1:
|
||||
index = self.currentIndex()
|
||||
self.edit(index)
|
||||
elif len(self.getSelection()) > 1:
|
||||
# FIXME: add smart rename
|
||||
pass
|
||||
|
||||
def addFolder(self):
|
||||
self.addItem("folder")
|
||||
|
||||
|
|
Loading…
Reference in a new issue