Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.2, 1.9.3, and 2.0

quickbar: greatly simplify GotoQuickBar

Changeset 76b4ac497077

Parent 5c483841a981

by Steve Borho

Changes to one file · Browse files at 76b4ac497077 Showing diff from parent 5c483841a981 Diff from another changeset...

 
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
 
 
 
 
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 
 
 
 
 
 
67
68
69
70
71
72
73
74
75
76
 
77
78
79
 
80
81
82
83
84
85
86
87
 
 
17
18
19
 
 
20
21
22
23
24
25
 
 
 
26
27
28
29
30
31
32
33
34
 
 
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
37
38
39
40
41
42
43
 
 
 
 
 
 
 
 
44
45
46
 
47
48
49
50
51
52
 
 
 
53
@@ -17,71 +17,37 @@
 Qt4 QToolBar-based class for quick bars XXX  """   -from mercurial import util -  from PyQt4.QtCore import *  from PyQt4.QtGui import *    from tortoisehg.hgqt.i18n import _  from tortoisehg.hgqt.qtlib import geticon   -class QuickBar(QToolBar): - def __init__(self, name, key, desc=None, parent=None): - QToolBar.__init__(self, name, parent) +class GotoQuickBar(QToolBar): + gotoSignal = pyqtSignal(QString) + + def __init__(self, parent): + QToolBar.__init__(self, _('Goto'), parent)   self.setIconSize(QSize(16,16))   self.setFloatable(False)   self.setMovable(False)   self.setAllowedAreas(Qt.BottomToolBarArea) - self.createActions(key, desc) - self.createContent()   self.setVisible(False) - - def createActions(self, openkey, desc): - openact = QAction(desc or 'Open', self) - openact.setCheckable(True) - openact.setChecked(False) - openact.setShortcut(QKeySequence(openkey)) - openact.triggered.connect(self.show) - - self._actions = {'open': openact} - - def createContent(self): - self.parent().addAction(self._actions['open']) - - def hide(self): - self.setVisible(False) - - def cancel(self): - self.hide() - -class GotoQuickBar(QuickBar): - gotoSignal = pyqtSignal(unicode) - - def __init__(self, parent): - QuickBar.__init__(self, 'Goto', None, 'Goto', parent) - - def createActions(self, openkey, desc): - QuickBar.createActions(self, openkey, desc) - self._actions['go'] = QAction(geticon('go-jump'), _('Go'), self) - self._actions['go'].triggered.connect(self.goto) + self.goAction = QAction(geticon('go-jump'), _('Go'), self) + self.goAction.triggered.connect(self.goto) + self.entry = QLineEdit(self) + self.entry.returnPressed.connect(self.goAction.trigger) + self.addWidget(self.entry) + self.addAction(self.goAction)     def goto(self): - self.gotoSignal.emit(unicode(self.entry.text())) - - def createContent(self): - QuickBar.createContent(self) - self.entry = QLineEdit(self) - self.addWidget(self.entry) - self.addAction(self._actions['go']) - self.entry.returnPressed.connect(self._actions['go'].trigger) + self.gotoSignal.emit(self.entry.text())     def setVisible(self, visible=True): - QuickBar.setVisible(self, visible) + super(GotoQuickBar, self).setVisible(visible)   if visible:   self.entry.setFocus()   self.entry.selectAll()     def setCompletionKeys(self, keys): - self.entry.setCompleter(QCompleter(keys)) - - + self.entry.setCompleter(QCompleter(keys, self))