Added one-click auto-select from main window feature

git-svn-id: http://comictagger.googlecode.com/svn/trunk@48 6c5673fe-1810-88d6-992b-cd32ca31540c
This commit is contained in:
beville@gmail.com 2012-11-15 18:14:32 +00:00
parent 7b65858219
commit dd694205fe
2 changed files with 22 additions and 7 deletions

View File

@ -186,7 +186,7 @@ class TaggerWindow( QtGui.QMainWindow):
self.actionSearchOnline.setStatusTip( 'Search online for tags' )
self.actionSearchOnline.triggered.connect( self.queryOnline )
#self.actionAutoSearch.triggered.connect( self.autoSearch )
self.actionAutoSearch.triggered.connect( self.autoSelectSearch )
#self.actionClearEntryForm.setShortcut( 'Ctrl+C' )
self.actionClearEntryForm.setStatusTip( 'Clear all the data on the screen' )
@ -619,11 +619,18 @@ class TaggerWindow( QtGui.QMainWindow):
self.openArchive( str(fileList[0]) )
def queryOnline(self):
def autoSelectSearch(self):
if self.comic_archive is None:
QtGui.QMessageBox.warning(self, self.tr("Automatic Search"),
self.tr("You need to load a comic first!"))
return
self.queryOnline( autoselect=True )
def queryOnline(self, autoselect=False):
if self.settings.cv_api_key == "":
QtGui.QMessageBox.warning(self, self.tr("Online Query"),
QtGui.QMessageBox.warning(self, self.tr("Online Search"),
self.tr("You need an API key from ComicVine to search online. " +
"Go to settings and enter it."))
return
@ -637,7 +644,7 @@ class TaggerWindow( QtGui.QMainWindow):
issue_number = str(self.leIssueNum.text()).strip()
selector = VolumeSelectionWindow( self, self.settings.cv_api_key, series_name, issue_number, self.comic_archive, self.settings )
selector = VolumeSelectionWindow( self, self.settings.cv_api_key, series_name, issue_number, self.comic_archive, self.settings, autoselect )
selector.setModal(True)
selector.exec_()

View File

@ -82,7 +82,7 @@ class IdentifyThread( QtCore.QThread):
class VolumeSelectionWindow(QtGui.QDialog):
def __init__(self, parent, cv_api_key, series_name, issue_number, comic_archive, settings):
def __init__(self, parent, cv_api_key, series_name, issue_number, comic_archive, settings, autoselect=False):
super(VolumeSelectionWindow, self).__init__(parent)
uic.loadUi(os.path.join(ComicTaggerSettings.baseDir(), 'volumeselectionwindow.ui' ), self)
@ -93,6 +93,7 @@ class VolumeSelectionWindow(QtGui.QDialog):
self.cv_api_key = cv_api_key
self.volume_id = 0
self.comic_archive = comic_archive
self.immediate_autoselect = autoselect
self.twList.resizeColumnsToContents()
self.twList.currentItemChanged.connect(self.currentItemChanged)
@ -249,7 +250,14 @@ class VolumeSelectionWindow(QtGui.QDialog):
self.twList.sortItems( 2 , QtCore.Qt.DescendingOrder )
self.twList.selectRow(0)
self.twList.resizeColumnsToContents()
if self.immediate_autoselect:
# defer the immediate autoselect so this dialog has time to pop up
QtCore.QTimer.singleShot(10, self.doImmediateAutoselect)
def doImmediateAutoselect( self ):
self.immediate_autoselect = False
self.autoSelect()
def cellDoubleClicked( self, r, c ):
self.showIssues()