ViewManager/ViewManager.py

branch
5_1_x
changeset 1129
e97a9a2e445e
parent 959
3b5ad7224945
child 1135
ad5f054e2b2c
equal deleted inserted replaced
1126:375edf05ee47 1129:e97a9a2e445e
2187 qtb.addAction(self.quickFindtextAction) 2187 qtb.addAction(self.quickFindtextAction)
2188 qtb.addAction(self.quickSearchAct) 2188 qtb.addAction(self.quickSearchAct)
2189 qtb.addAction(self.quickSearchBackAct) 2189 qtb.addAction(self.quickSearchBackAct)
2190 qtb.addAction(self.quickSearchExtendAct) 2190 qtb.addAction(self.quickSearchExtendAct)
2191 self.quickFindtextCombo.setEnabled(False) 2191 self.quickFindtextCombo.setEnabled(False)
2192 self.__quickSearchToolbar = qtb
2193 self.__quickSearchToolbarVisibility = None
2192 2194
2193 tb = QToolBar(QApplication.translate('ViewManager', 'Search'), self.ui) 2195 tb = QToolBar(QApplication.translate('ViewManager', 'Search'), self.ui)
2194 tb.setIconSize(UI.Config.ToolBarIconSize) 2196 tb.setIconSize(UI.Config.ToolBarIconSize)
2195 tb.setObjectName("SearchToolbar") 2197 tb.setObjectName("SearchToolbar")
2196 tb.setToolTip(QApplication.translate('ViewManager', 'Search')) 2198 tb.setToolTip(QApplication.translate('ViewManager', 'Search'))
3685 """ 3687 """
3686 if not isinstance(now, (Editor, Shell, Terminal)): 3688 if not isinstance(now, (Editor, Shell, Terminal)):
3687 self.editActGrp.setEnabled(False) 3689 self.editActGrp.setEnabled(False)
3688 self.copyActGrp.setEnabled(False) 3690 self.copyActGrp.setEnabled(False)
3689 self.viewActGrp.setEnabled(False) 3691 self.viewActGrp.setEnabled(False)
3692
3693 if not isinstance(now, (Editor, Shell, Terminal)) and \
3694 now is not self.quickFindtextCombo:
3690 self.searchActGrp.setEnabled(False) 3695 self.searchActGrp.setEnabled(False)
3696
3697 if now is self.quickFindtextCombo:
3698 self.searchActGrp.setEnabled(True)
3691 3699
3692 if isinstance(old, (Editor, Shell, Terminal)): 3700 if isinstance(old, (Editor, Shell, Terminal)):
3693 self.__lastFocusWidget = old 3701 self.__lastFocusWidget = old
3694 3702
3695 ################################################################## 3703 ##################################################################
3905 """ 3913 """
3906 Private slot to handle the incremental quick search. 3914 Private slot to handle the incremental quick search.
3907 """ 3915 """
3908 # first we have to check if quick search is active 3916 # first we have to check if quick search is active
3909 # and try to activate it if not 3917 # and try to activate it if not
3918 if self.__quickSearchToolbarVisibility is None:
3919 self.__quickSearchToolbarVisibility = self.__quickSearchToolbar.isVisible()
3920 if not self.__quickSearchToolbar.isVisible():
3921 self.__quickSearchToolbar.show()
3910 if not self.quickFindtextCombo.lineEdit().hasFocus(): 3922 if not self.quickFindtextCombo.lineEdit().hasFocus():
3911 aw = self.activeWindow() 3923 aw = self.activeWindow()
3912 self.quickFindtextCombo.lastActive = aw 3924 self.quickFindtextCombo.lastActive = aw
3913 if aw: 3925 if aw:
3914 self.quickFindtextCombo.lastCursorPos = aw.getCursorPosition() 3926 self.quickFindtextCombo.lastCursorPos = aw.getCursorPosition()
3933 Private slot to handle the incremental quick search return pressed 3945 Private slot to handle the incremental quick search return pressed
3934 (jump back to text) 3946 (jump back to text)
3935 """ 3947 """
3936 if self.quickFindtextCombo.lastActive: 3948 if self.quickFindtextCombo.lastActive:
3937 self.quickFindtextCombo.lastActive.setFocus() 3949 self.quickFindtextCombo.lastActive.setFocus()
3950 if self.__quickSearchToolbarVisibility is not None:
3951 self.__quickSearchToolbar.setVisible(self.__quickSearchToolbarVisibility)
3952 self.__quickSearchToolbarVisibility = None
3938 3953
3939 def __quickSearchEscape(self): 3954 def __quickSearchEscape(self):
3940 """ 3955 """
3941 Private slot to handle the incremental quick search escape pressed 3956 Private slot to handle the incremental quick search escape pressed
3942 (jump back to text) 3957 (jump back to text)
3945 self.quickFindtextCombo.lastActive.setFocus() 3960 self.quickFindtextCombo.lastActive.setFocus()
3946 aw = self.activeWindow() 3961 aw = self.activeWindow()
3947 if aw and self.quickFindtextCombo.lastCursorPos: 3962 if aw and self.quickFindtextCombo.lastCursorPos:
3948 aw.setCursorPosition(self.quickFindtextCombo.lastCursorPos[0], 3963 aw.setCursorPosition(self.quickFindtextCombo.lastCursorPos[0],
3949 self.quickFindtextCombo.lastCursorPos[1]) 3964 self.quickFindtextCombo.lastCursorPos[1])
3965 if self.__quickSearchToolbarVisibility is not None:
3966 self.__quickSearchToolbar.setVisible(self.__quickSearchToolbarVisibility)
3967 self.__quickSearchToolbarVisibility = None
3950 3968
3951 def __quickSearchText(self): 3969 def __quickSearchText(self):
3952 """ 3970 """
3953 Private slot to handle the textChanged signal of the quicksearch edit. 3971 Private slot to handle the textChanged signal of the quicksearch edit.
3954 """ 3972 """
4056 text = aw.text(line) 4074 text = aw.text(line)
4057 4075
4058 re = QRegExp('[^\w_]') 4076 re = QRegExp('[^\w_]')
4059 end = re.indexIn(text, index) 4077 end = re.indexIn(text, index)
4060 if end > index: 4078 if end > index:
4061 ext = text[index:end + 1] 4079 ext = text[index:end]
4062 txt += ext 4080 txt += ext
4063 self.quickFindtextCombo.lineEdit().setText(txt) 4081 self.quickFindtextCombo.lineEdit().setText(txt)
4064 4082
4065 def __search(self): 4083 def __search(self):
4066 """ 4084 """

eric ide

mercurial