Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Add file list and dock to move faster
Browse files Browse the repository at this point in the history
  • Loading branch information
tzutalin committed Sep 6, 2016
1 parent 4a3a47a commit f2712d4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions labelImg.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ def __init__(self, filename=None):
self.dock.setObjectName(u'Labels')
self.dock.setWidget(self.labelListContainer)

# Tzutalin 20160906 : Add file list and dock to move faster
self.fileListWidget = QListWidget()
self.fileListWidget.itemDoubleClicked.connect(self.fileitemDoubleClicked)
filelistLayout = QVBoxLayout()
filelistLayout.setContentsMargins(0, 0, 0, 0)
filelistLayout.addWidget(self.fileListWidget)
self.fileListContainer = QWidget()
self.fileListContainer.setLayout(filelistLayout)
self.filedock = QDockWidget(u'File List', self)
self.filedock.setObjectName(u'Files')
self.filedock.setWidget(self.fileListContainer)

self.zoomWidget = ZoomWidget()
self.colorDialog = ColorDialog(parent=self)

Expand All @@ -123,6 +135,8 @@ def __init__(self, filename=None):

self.setCentralWidget(scroll)
self.addDockWidget(Qt.RightDockWidgetArea, self.dock)
# Tzutalin 20160906 : Add file list and dock to move faster
self.addDockWidget(Qt.RightDockWidgetArea, self.filedock)
self.dockFeatures = QDockWidget.DockWidgetClosable\
| QDockWidget.DockWidgetFloatable
self.dock.setFeatures(self.dock.features() ^ self.dockFeatures)
Expand Down Expand Up @@ -500,6 +514,14 @@ def editLabel(self, item=None):
if text is not None:
item.setText(text)
self.setDirty()

# Tzutalin 20160906 : Add file list and dock to move faster
def fileitemDoubleClicked(self, item=None):
currIndex = self.mImgList.index(str(item.text()))
if currIndex < len(self.mImgList):
filename = self.mImgList[currIndex]
if filename:
self.loadFile(filename)

# React to canvas signals.
def shapeSelectionChanged(self, selected=False):
Expand Down Expand Up @@ -665,6 +687,14 @@ def loadFile(self, filename=None):
if filename is None:
filename = self.settings['filename']
filename = unicode(filename)

# Tzutalin 20160906 : Add file list and dock to move faster
# Highlight the file item
if filename and self.fileListWidget.count() > 0:
index = self.mImgList.index(filename)
fileWidgetItem = self.fileListWidget.item(index)
self.fileListWidget.setItemSelected(fileWidgetItem, True)

if QFile.exists(filename):
if LabelFile.isLabelFile(filename):
try:
Expand Down Expand Up @@ -845,6 +875,9 @@ def openDir(self, _value=False):
self.dirname = dirpath
self.mImgList = self.scanAllImages(dirpath)
self.openNextImg()
for imgPath in self.mImgList:
item = QListWidgetItem(imgPath)
self.fileListWidget.addItem(item)

def openPrevImg(self, _value=False):
if not self.mayContinue():
Expand Down

0 comments on commit f2712d4

Please sign in to comment.