Continued implementing the standalone shell window.

Fri, 21 Apr 2017 19:39:31 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 21 Apr 2017 19:39:31 +0200
changeset 5710
b5809b948010
parent 5709
f81d0eca2c62
child 5711
50b6867ffcd3

Continued implementing the standalone shell window.

Debugger/DebugServer.py file | annotate | diff | comparison | revisions
QScintilla/Shell.py file | annotate | diff | comparison | revisions
QScintilla/ShellWindow.py file | annotate | diff | comparison | revisions
UI/SearchWidget.py file | annotate | diff | comparison | revisions
UI/SearchWidgetLine.ui file | annotate | diff | comparison | revisions
eric6.e4p file | annotate | diff | comparison | revisions
eric6_shell.py file | annotate | diff | comparison | revisions
icons/default/restartDelete.png file | annotate | diff | comparison | revisions
--- a/Debugger/DebugServer.py	Thu Apr 20 20:09:53 2017 +0200
+++ b/Debugger/DebugServer.py	Fri Apr 21 19:39:31 2017 +0200
@@ -154,9 +154,12 @@
     callTraceInfo = pyqtSignal(bool, str, str, str, str, str, str)
     appendStdout = pyqtSignal(str)
     
-    def __init__(self):
+    def __init__(self, preventPassiveDebugging=False):
         """
         Constructor
+        
+        @param preventPassiveDebugging flag overriding the PassiveDbgEnabled
+            setting (boolean)
         """
         super(DebugServer, self).__init__()
         
@@ -185,7 +188,8 @@
         self.networkInterfaceName, self.networkInterfaceIndex = \
             self.__getNetworkInterfaceAndIndex(self.networkInterface)
         
-        if Preferences.getDebugger("PassiveDbgEnabled"):
+        if not preventPassiveDebugging and \
+           Preferences.getDebugger("PassiveDbgEnabled"):
             sock = Preferences.getDebugger("PassiveDbgPort")  # default: 42424
             self.listen(hostAddress, sock)
             self.passive = True
--- a/QScintilla/Shell.py	Thu Apr 20 20:09:53 2017 +0200
+++ b/QScintilla/Shell.py	Fri Apr 21 19:39:31 2017 +0200
@@ -101,9 +101,9 @@
         
         @param dbs reference to the debug server object
         @param vm reference to the viewmanager object
-        @param parent parent widget (QWidget)
         @param windowedVariant flag indicating the shell window variant
             (boolean)
+        @param parent parent widget (QWidget)
         """
         super(Shell, self).__init__(parent)
         self.setUtf8(True)
@@ -115,8 +115,8 @@
         
         self.linesepRegExp = r"\r\n|\n|\r"
         
-        # TODO: change this for Shell Window
-        self.passive = Preferences.getDebugger("PassiveDbgEnabled")
+        self.passive = ((not self.__windowed) and
+                        Preferences.getDebugger("PassiveDbgEnabled"))
         if self.passive:
             self.setWindowTitle(self.tr('Shell - Passive'))
         else:
@@ -235,33 +235,33 @@
         if self.passive:
             self.__getBanner()
         
-        # Create a little language context menu
-        self.lmenu = QMenu(self.tr('Start'))
-        self.lmenu.aboutToShow.connect(self.__showLanguageMenu)
-        self.lmenu.triggered.connect(self.__startDebugClient)
-        
-        # Create the history context menu
-        self.hmenu = QMenu(self.tr('History'))
-        self.hmenu.addAction(self.tr('Select entry'), self.__selectHistory)
-        self.hmenu.addAction(self.tr('Show'), self.__showHistory)
-        self.hmenu.addAction(self.tr('Clear'), self.__clearHistory)
-        
-        # Create a little context menu
-        self.menu = QMenu(self)
-        self.menu.addAction(self.tr('Cut'), self.cut)
-        self.menu.addAction(self.tr('Copy'), self.copy)
-        self.menu.addAction(self.tr('Paste'), self.paste)
-        self.menu.addMenu(self.hmenu)
-        self.menu.addSeparator()
-        self.menu.addAction(self.tr('Find'), self.__find)
-        self.menu.addSeparator()
-        self.menu.addAction(self.tr('Clear'), self.clear)
-        self.menu.addAction(self.tr('Reset'), self.__reset)
-        self.menu.addAction(
-            self.tr('Reset and Clear'), self.__resetAndClear)
-        self.menu.addSeparator()
-        self.menu.addMenu(self.lmenu)
         if not self.__windowed:
+            # Create a little language context menu
+            self.lmenu = QMenu(self.tr('Start'))
+            self.lmenu.aboutToShow.connect(self.__showLanguageMenu)
+            self.lmenu.triggered.connect(self.__startDebugClient)
+            
+            # Create the history context menu
+            self.hmenu = QMenu(self.tr('History'))
+            self.hmenu.addAction(self.tr('Select entry'), self.selectHistory)
+            self.hmenu.addAction(self.tr('Show'), self.showHistory)
+            self.hmenu.addAction(self.tr('Clear'), self.clearHistory)
+            
+            # Create a little context menu
+            self.menu = QMenu(self)
+            self.menu.addAction(self.tr('Cut'), self.cut)
+            self.menu.addAction(self.tr('Copy'), self.copy)
+            self.menu.addAction(self.tr('Paste'), self.paste)
+            self.menu.addMenu(self.hmenu)
+            self.menu.addSeparator()
+            self.menu.addAction(self.tr('Find'), self.__find)
+            self.menu.addSeparator()
+            self.menu.addAction(self.tr('Clear'), self.clear)
+            self.menu.addAction(self.tr('Reset'), self.__reset)
+            self.menu.addAction(
+                self.tr('Reset and Clear'), self.__resetAndClear)
+            self.menu.addSeparator()
+            self.menu.addMenu(self.lmenu)
             self.menu.addSeparator()
             self.menu.addAction(self.tr("Configure..."), self.__configure)
         
@@ -607,9 +607,9 @@
         else:
             return []
         
-    def __clearHistory(self):
+    def clearHistory(self):
         """
-        Private slot to clear the current history.
+        Public slot to clear the current history.
         """
         if self.clientType:
             self.historyLists[self.clientType] = []
@@ -618,9 +618,9 @@
             self.history = []
         self.histidx = -1
         
-    def __selectHistory(self):
+    def selectHistory(self):
         """
-        Private slot to select a history entry to execute.
+        Public slot to select a history entry to execute.
         """
         cmd, ok = QInputDialog.getItem(
             self,
@@ -632,9 +632,9 @@
         if ok:
             self.__insertHistory(cmd)
         
-    def __showHistory(self):
+    def showHistory(self):
         """
-        Private slot to show the shell history dialog.
+        Public slot to show the shell history dialog.
         """
         from .ShellHistoryDialog import ShellHistoryDialog
         dlg = ShellHistoryDialog(self.history, self.vm, self)
@@ -653,7 +653,7 @@
             self.saveHistory(clientType)
         Preferences.Prefs.settings.endGroup()
         
-        self.__clearHistory()
+        self.clearHistory()
         
     def getClientType(self):
         """
@@ -1570,8 +1570,9 @@
         
         @param ev context menu event (QContextMenuEvent)
         """
-        self.menu.popup(ev.globalPos())
-        ev.accept()
+        if not self.__windowed:
+            self.menu.popup(ev.globalPos())
+            ev.accept()
         
     def clear(self):
         """
@@ -1716,7 +1717,7 @@
         
         @param event the drop event (QDropEvent)
         """
-        if event.mimeData().hasUrls():
+        if event.mimeData().hasUrls() and not self.__windowed:
             for url in event.mimeData().urls():
                 fname = url.toLocalFile()
                 if fname:
--- a/QScintilla/ShellWindow.py	Thu Apr 20 20:09:53 2017 +0200
+++ b/QScintilla/ShellWindow.py	Fri Apr 21 19:39:31 2017 +0200
@@ -9,10 +9,10 @@
 
 from __future__ import unicode_literals
 
-from PyQt5.QtCore import QCoreApplication, QPoint, QSize, QSignalMapper
+from PyQt5.QtCore import Qt, QCoreApplication, QPoint, QSize, QSignalMapper
 from PyQt5.QtGui import QKeySequence
 from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QAction, \
-    QWhatsThis
+    QWhatsThis, QDialog
 from PyQt5.Qsci import QsciScintilla
 
 from E5Gui.E5MainWindow import E5MainWindow
@@ -21,6 +21,7 @@
 from E5Gui.E5ZoomWidget import E5ZoomWidget
 from E5Gui import E5MessageBox
 
+import UI.Config
 import UI.PixmapCache
 import Preferences
 
@@ -58,9 +59,9 @@
         self.__apisManager = APIsManager(parent=self)
         
         # initialize the debug server and shell widgets
-        self.__debugServer = DebugServer()
+        self.__debugServer = DebugServer(preventPassiveDebugging=True)
         self.__shell = Shell(self.__debugServer, self, True, self)
-        self.__searchWidget = SearchWidget(self.__shell, self)
+        self.__searchWidget = SearchWidget(self.__shell, self, showLine=True)
         
         centralWidget = QWidget()
         layout = QVBoxLayout()
@@ -71,7 +72,6 @@
         self.setCentralWidget(centralWidget)
         self.__searchWidget.hide()
         
-        
         self.__searchWidget.searchNext.connect(self.__shell.searchNext)
         self.__searchWidget.searchPrevious.connect(self.__shell.searchPrev)
         self.__shell.searchStringFound.connect(
@@ -80,8 +80,8 @@
         self.__shell.zoomValueChanged.connect(self.__zoomValueChanged)
         
         self.__createActions()
-##        self.__createMenus()
-##        self.__createToolBars()
+        self.__createMenus()
+        self.__createToolBars()
         self.__createStatusBar()
         
         self.__readSettings()
@@ -155,7 +155,9 @@
         self.__createFileActions()
         self.__createEditActions()
         self.__createSearchActions()
+        self.__createViewActions()
         self.__createHelpActions()
+        self.__createHistoryActions()
         
         # read the keyboard shortcuts and make them identical to the main
         # eric6 shortcuts
@@ -202,6 +204,35 @@
 ##        ))
 ##        self.newWindowAct.triggered.connect(self.__newWindow)
 ##        self.fileActions.append(self.newWindowAct)
+
+        self.restartAct = E5Action(
+            self.tr('Restart'),
+            UI.PixmapCache.getIcon("restart.png"),
+            self.tr('Restart'),
+            0, 0, self, 'shell_restart')
+        self.restartAct.setStatusTip(self.tr(
+            'Restart the shell'))
+        self.restartAct.setWhatsThis(self.tr(
+            """<b>Restart</b>"""
+            """<p>Restart the shell for the currently selected language.</p>"""
+        ))
+        self.restartAct.triggered.connect(self.__doRestart)
+        self.fileActions.append(self.restartAct)
+
+        self.clearRestartAct = E5Action(
+            self.tr('Restart and Clear'),
+            UI.PixmapCache.getIcon("restartDelete.png"),
+            self.tr('Restart and Clear'),
+            Qt.Key_F4, 0, self, 'shell_clear_restart')
+        self.clearRestartAct.setStatusTip(self.tr(
+            'Clear the window and restart the shell'))
+        self.clearRestartAct.setWhatsThis(self.tr(
+            """<b>Restart and Clear</b>"""
+            """<p>Clear the shell window and restart the shell for the"""
+            """ currently selected language.</p>"""
+        ))
+        self.clearRestartAct.triggered.connect(self.__doClearRestart)
+        self.fileActions.append(self.clearRestartAct)
     
     def __createEditActions(self):
         """
@@ -271,7 +302,7 @@
         self.pasteAct.triggered.connect(self.__shell.paste)
         self.editActions.append(self.pasteAct)
         
-        self.deleteAct = E5Action(
+        self.clearAct = E5Action(
             QCoreApplication.translate('ViewManager', 'Clear'),
             UI.PixmapCache.getIcon("editDelete.png"),
             QCoreApplication.translate('ViewManager', 'Clear'),
@@ -279,15 +310,15 @@
                 'ViewManager', "Alt+Shift+C", "Edit|Clear")),
             0,
             self.copyActGrp, 'vm_edit_clear')
-        self.deleteAct.setStatusTip(QCoreApplication.translate(
+        self.clearAct.setStatusTip(QCoreApplication.translate(
             'ViewManager', 'Clear all text'))
-        self.deleteAct.setWhatsThis(QCoreApplication.translate(
+        self.clearAct.setWhatsThis(QCoreApplication.translate(
             'ViewManager',
             """<b>Clear</b>"""
             """<p>Delete all text of the current editor.</p>"""
         ))
-        self.deleteAct.triggered.connect(self.__shell.clear)
-        self.editActions.append(self.deleteAct)
+        self.clearAct.triggered.connect(self.__shell.clear)
+        self.editActions.append(self.clearAct)
         
         self.cutAct.setEnabled(False)
         self.copyAct.setEnabled(False)
@@ -667,7 +698,7 @@
             QKeySequence(QCoreApplication.translate(
                 'ViewManager', "Ctrl+F", "Search|Search")),
             0,
-            self.searchActGrp, 'vm_search')
+            self, 'vm_search')
         self.searchAct.setStatusTip(QCoreApplication.translate(
             'ViewManager', 'Search for a text'))
         self.searchAct.setWhatsThis(QCoreApplication.translate(
@@ -688,7 +719,7 @@
             QKeySequence(QCoreApplication.translate(
                 'ViewManager', "F3", "Search|Search next")),
             0,
-            self.searchActGrp, 'vm_search_next')
+            self, 'vm_search_next')
         self.searchNextAct.setStatusTip(QCoreApplication.translate(
             'ViewManager', 'Search next occurrence of text'))
         self.searchNextAct.setWhatsThis(QCoreApplication.translate(
@@ -709,7 +740,7 @@
             QKeySequence(QCoreApplication.translate(
                 'ViewManager', "Shift+F3", "Search|Search previous")),
             0,
-            self.searchActGrp, 'vm_search_previous')
+            self, 'vm_search_previous')
         self.searchPrevAct.setStatusTip(QCoreApplication.translate(
             'ViewManager', 'Search previous occurrence of text'))
         self.searchPrevAct.setWhatsThis(QCoreApplication.translate(
@@ -729,7 +760,6 @@
         commands.
         """
         self.viewActGrp = createActionGroup(self)
-        self.viewFoldActGrp = createActionGroup(self)
         
         self.zoomInAct = E5Action(
             QCoreApplication.translate('ViewManager', 'Zoom in'),
@@ -807,6 +837,40 @@
         self.zoomToAct.triggered.connect(self.__zoom)
         self.viewActions.append(self.zoomToAct)
     
+    def __createHistoryActions(self):
+        """
+        Private method defining the user interface actions for the history
+        commands.
+        """
+        self.showHistoryAct = E5Action(
+            self.tr('Show History'),
+            UI.PixmapCache.getIcon("history.png"),
+            self.tr('&Show History...'),
+            0, 0,
+            self, 'shell_show_history')
+        self.showHistoryAct.setStatusTip(self.tr(
+            "Show the shell history in a dialog"))
+        self.showHistoryAct.triggered.connect(self.__shell.showHistory)
+        
+        self.clearHistoryAct = E5Action(
+            self.tr('Clear History'),
+            UI.PixmapCache.getIcon("historyClear.png"),
+            self.tr('&Clear History...'),
+            0, 0,
+            self, 'shell_clear_history')
+        self.clearHistoryAct.setStatusTip(self.tr(
+            "Clear the shell history"))
+        self.clearHistoryAct.triggered.connect(self.__shell.clearHistory)
+        
+        self.selectHistoryAct = E5Action(
+            self.tr('Select History Entry'),
+            self.tr('Select History &Entry'),
+            0, 0,
+            self, 'shell_select_history')
+        self.selectHistoryAct.setStatusTip(self.tr(
+            "Select an entry of the shell history"))
+        self.selectHistoryAct.triggered.connect(self.__shell.selectHistory)
+    
     def __createHelpActions(self):
         """
         Private method to create the Help actions.
@@ -857,13 +921,17 @@
     
     def __showFind(self):
         """
-        Public method to display the search widget.
+        Private method to display the search widget.
         """
-        self.__searchWidget.showFind("")
+        txt = self.__shell.selectedText()
+        self.__searchWidget.showFind(txt)
     
     def activeWindow(self):
         """
         Public method to get a reference to the active shell.
+        
+        @return reference to the shell widget
+        @rtype Shell
         """
         return self.__shell
     
@@ -891,6 +959,19 @@
         """
         e5App().closeAllWindows()
     
+    def __doRestart(self):
+        """
+        Private slot to handle the 'restart' menu entry.
+        """
+        self.__debugServer.startClient(False)
+    
+    def __doClearRestart(self):
+        """
+        Private slot to handle the 'restart and clear' menu entry.
+        """
+        self.__doRestart()
+        self.__shell.clear()
+    
     ##################################################################
     ## Below are the action methods for the view menu
     ##################################################################
@@ -951,21 +1032,19 @@
         """
         Private slot to show a little About message.
         """
-        # TODO: change this text
         E5MessageBox.about(
             self,
-            self.tr("About eric6 Mini Editor"),
+            self.tr("About eric6 Shell Window"),
             self.tr(
-                "The eric6 Mini Editor is an editor component"
-                " based on QScintilla. It may be used for simple"
-                " editing tasks, that don't need the power of"
-                " a full blown editor."))
+                "The eric6 Shell is a standalone shell window."
+                " It uses the same backend as the debugger of"
+                " the full IDE, but is executed independently."))
     
     def __aboutQt(self):
         """
         Private slot to handle the About Qt dialog.
         """
-        E5MessageBox.aboutQt(self, "eric6 Shell windindow")
+        E5MessageBox.aboutQt(self, "eric6 Shell Window")
     
     def __whatsThis(self):
         """
@@ -974,6 +1053,126 @@
         QWhatsThis.enterWhatsThisMode()
     
     ##################################################################
+    ## Below are the main menu handling methods
+    ##################################################################
+    
+    def __createMenus(self):
+        """
+        Private method to create the menus of the menu bar.
+        """
+        self.__fileMenu = self.menuBar().addMenu(self.tr("&File"))
+        self.__fileMenu.setTearOffEnabled(True)
+##        self.__fileMenu.addAction(self.newAct)
+##        self.__fileMenu.addSeparator()
+        self.__fileMenu.addAction(self.restartAct)
+        self.__fileMenu.addAction(self.clearRestartAct)
+        self.__fileMenu.addSeparator()
+        self.__fileMenu.addAction(self.exitAct)
+        
+        self.__editMenu = self.menuBar().addMenu(self.tr("&Edit"))
+        self.__editMenu.setTearOffEnabled(True)
+        self.__editMenu.addAction(self.cutAct)
+        self.__editMenu.addAction(self.copyAct)
+        self.__editMenu.addAction(self.pasteAct)
+        self.__editMenu.addAction(self.clearAct)
+        self.__editMenu.addSeparator()
+        self.__editMenu.addAction(self.searchAct)
+        self.__editMenu.addAction(self.searchNextAct)
+        self.__editMenu.addAction(self.searchPrevAct)
+        
+        self.__viewMenu = self.menuBar().addMenu(self.tr("&View"))
+        self.__viewMenu.setTearOffEnabled(True)
+        self.__viewMenu.addAction(self.zoomInAct)
+        self.__viewMenu.addAction(self.zoomOutAct)
+        self.__viewMenu.addAction(self.zoomResetAct)
+        self.__viewMenu.addAction(self.zoomToAct)
+        
+        self.__historyMenu = self.menuBar().addMenu(self.tr("Histor&y"))
+        self.__historyMenu.setTearOffEnabled(True)
+        self.__historyMenu.addAction(self.selectHistoryAct)
+        self.__historyMenu.addAction(self.showHistoryAct)
+        self.__historyMenu.addAction(self.clearHistoryAct)
+        
+        self.__startMenu = self.menuBar().addMenu(self.tr("&Start"))
+        self.__startMenu.aboutToShow.connect(self.__showLanguageMenu)
+        self.__startMenu.triggered.connect(self.__startShell)
+        
+        self.menuBar().addSeparator()
+        
+        self.__helpMenu = self.menuBar().addMenu(self.tr("&Help"))
+        self.__helpMenu.setTearOffEnabled(True)
+        self.__helpMenu.addAction(self.aboutAct)
+        self.__helpMenu.addAction(self.aboutQtAct)
+        self.__helpMenu.addSeparator()
+        self.__helpMenu.addAction(self.whatsThisAct)
+    
+    def __showLanguageMenu(self):
+        """
+        Private slot to prepare the language menu.
+        """
+        self.__startMenu.clear()
+        clientLanguages = self.__debugServer.getSupportedLanguages(
+            shellOnly=True)
+        for language in sorted(clientLanguages):
+            act = self.__startMenu.addAction(language)
+            act.setData(language)
+    
+    def __startShell(self, action):
+        """
+        Private slot to start a shell according to the action triggered.
+        
+        @param action menu action that was triggered (QAction)
+        """
+        language = action.data()
+        self.__debugServer.startClient(False, language)
+    
+    ##################################################################
+    ## Below are the toolbar handling methods
+    ##################################################################
+    
+    def __createToolBars(self):
+        """
+        Private method to create the various toolbars.
+        """
+        filetb = self.addToolBar(self.tr("File"))
+        filetb.setIconSize(UI.Config.ToolBarIconSize)
+##        filetb.addAction(self.newAct)
+        filetb.addSeparator()
+        filetb.addAction(self.restartAct)
+        filetb.addAction(self.clearRestartAct)
+        filetb.addSeparator()
+        filetb.addAction(self.exitAct)
+        
+        edittb = self.addToolBar(self.tr("Edit"))
+        edittb.setIconSize(UI.Config.ToolBarIconSize)
+        edittb.addAction(self.cutAct)
+        edittb.addAction(self.copyAct)
+        edittb.addAction(self.pasteAct)
+        edittb.addAction(self.clearAct)
+        
+        findtb = self.addToolBar(self.tr("Find"))
+        findtb.setIconSize(UI.Config.ToolBarIconSize)
+        findtb.addAction(self.searchAct)
+        findtb.addAction(self.searchNextAct)
+        findtb.addAction(self.searchPrevAct)
+        
+        viewtb = self.addToolBar(self.tr("View"))
+        viewtb.setIconSize(UI.Config.ToolBarIconSize)
+        viewtb.addAction(self.zoomInAct)
+        viewtb.addAction(self.zoomOutAct)
+        viewtb.addAction(self.zoomResetAct)
+        viewtb.addAction(self.zoomToAct)
+        
+        historytb = self.addToolBar(self.tr("History"))
+        historytb.setIconSize(UI.Config.ToolBarIconSize)
+        historytb.addAction(self.showHistoryAct)
+        historytb.addAction(self.clearHistoryAct)
+        
+        helptb = self.addToolBar(self.tr("Help"))
+        helptb.setIconSize(UI.Config.ToolBarIconSize)
+        helptb.addAction(self.whatsThisAct)
+    
+    ##################################################################
     ## Below are the status bar handling methods
     ##################################################################
     
--- a/UI/SearchWidget.py	Thu Apr 20 20:09:53 2017 +0200
+++ b/UI/SearchWidget.py	Fri Apr 21 19:39:31 2017 +0200
@@ -12,12 +12,10 @@
 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt
 from PyQt5.QtWidgets import QWidget, QSpacerItem, QSizePolicy
 
-from .Ui_SearchWidget import Ui_SearchWidget
-
 import UI.PixmapCache
 
 
-class SearchWidget(QWidget, Ui_SearchWidget):
+class SearchWidget(QWidget):
     """
     Class implementing the search box for the shell, terminal and log viewer.
     
@@ -29,7 +27,7 @@
     searchNext = pyqtSignal(str, bool, bool)
     searchPrevious = pyqtSignal(str, bool, bool)
     
-    def __init__(self, mainWindow, parent=None, spacer=True):
+    def __init__(self, mainWindow, parent=None, spacer=True, showLine=False):
         """
         Constructor
         
@@ -37,31 +35,43 @@
         @param parent reference to the parent widget (QWidget)
         @param spacer flag indicating to add a vertical spacer to the
             main layout (boolean)
+        @param showLine flag indicating to show all widget in one row (boolean)
         """
         super(SearchWidget, self).__init__(parent)
-        self.setupUi(self)
-        if spacer:
-            spacerItem = QSpacerItem(
-                20, 1, QSizePolicy.Minimum, QSizePolicy.Expanding)
-            self.verticalLayout.addItem(spacerItem)
+        
+        if showLine:
+            from .Ui_SearchWidgetLine import Ui_SearchWidgetLine
+            self.__ui = Ui_SearchWidgetLine()
         else:
-            # change the size policy of the search combo if the spacer is not
-            # wanted, i.e. it is below the to be searched widget
-            sizePolicy = self.findtextCombo.sizePolicy()
-            sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding)
-            self.findtextCombo.setSizePolicy(sizePolicy)
+            from .Ui_SearchWidget import Ui_SearchWidget
+            self.__ui = Ui_SearchWidget()
+        self.__ui.setupUi(self)
+        if not showLine:
+            if spacer:
+                spacerItem = QSpacerItem(
+                    20, 1, QSizePolicy.Minimum, QSizePolicy.Expanding)
+                self.__ui.verticalLayout.addItem(spacerItem)
+            else:
+                # change the size policy of the search combo if the spacer is
+                # not wanted, i.e. it is below the to be searched widget
+                sizePolicy = self.__ui.findtextCombo.sizePolicy()
+                sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding)
+                self.__ui.findtextCombo.setSizePolicy(sizePolicy)
         
         self.__mainWindow = mainWindow
         self.__findBackwards = True
         
-        self.closeButton.setIcon(UI.PixmapCache.getIcon("close.png"))
-        self.findPrevButton.setIcon(UI.PixmapCache.getIcon("1leftarrow.png"))
-        self.findNextButton.setIcon(UI.PixmapCache.getIcon("1rightarrow.png"))
+        self.__ui.closeButton.setIcon(
+            UI.PixmapCache.getIcon("close.png"))
+        self.__ui.findPrevButton.setIcon(
+            UI.PixmapCache.getIcon("1leftarrow.png"))
+        self.__ui.findNextButton.setIcon(
+            UI.PixmapCache.getIcon("1rightarrow.png"))
         
         self.findHistory = []
         
-        self.findtextCombo.setCompleter(None)
-        self.findtextCombo.lineEdit().returnPressed.connect(
+        self.__ui.findtextCombo.setCompleter(None)
+        self.__ui.findtextCombo.lineEdit().returnPressed.connect(
             self.__findByReturnPressed)
         
         msh = self.minimumSizeHint()
@@ -90,7 +100,11 @@
         """
         Private slot to find the next occurrence.
         """
-        txt = self.findtextCombo.currentText()
+        txt = self.__ui.findtextCombo.currentText()
+        if not txt and not self.isVisible():
+            self.showFind()
+            return
+        
         self.__findBackwards = False
         
         # This moves any previous occurrence of this statement to the head
@@ -98,20 +112,24 @@
         if txt in self.findHistory:
             self.findHistory.remove(txt)
         self.findHistory.insert(0, txt)
-        self.findtextCombo.clear()
-        self.findtextCombo.addItems(self.findHistory)
+        self.__ui.findtextCombo.clear()
+        self.__ui.findtextCombo.addItems(self.findHistory)
         
         self.searchNext.emit(
             txt,
-            self.caseCheckBox.isChecked(),
-            self.wordCheckBox.isChecked())
+            self.__ui.caseCheckBox.isChecked(),
+            self.__ui.wordCheckBox.isChecked())
     
     @pyqtSlot()
     def on_findPrevButton_clicked(self):
         """
         Private slot to find the previous occurrence.
         """
-        txt = self.findtextCombo.currentText()
+        txt = self.__ui.findtextCombo.currentText()
+        if not txt and not self.isVisible():
+            self.showFind()
+            return
+        
         self.__findBackwards = True
         
         # This moves any previous occurrence of this statement to the head
@@ -119,13 +137,13 @@
         if txt in self.findHistory:
             self.findHistory.remove(txt)
         self.findHistory.insert(0, txt)
-        self.findtextCombo.clear()
-        self.findtextCombo.addItems(self.findHistory)
+        self.__ui.findtextCombo.clear()
+        self.__ui.findtextCombo.addItems(self.findHistory)
         
         self.searchPrevious.emit(
             txt,
-            self.caseCheckBox.isChecked(),
-            self.wordCheckBox.isChecked())
+            self.__ui.caseCheckBox.isChecked(),
+            self.__ui.wordCheckBox.isChecked())
     
     @pyqtSlot(str)
     def on_findtextCombo_editTextChanged(self, txt):
@@ -142,8 +160,8 @@
         
         @param enabled flag indicating the state (boolean)
         """
-        self.findPrevButton.setEnabled(enabled)
-        self.findNextButton.setEnabled(enabled)
+        self.__ui.findPrevButton.setEnabled(enabled)
+        self.__ui.findNextButton.setEnabled(enabled)
     
     def __findByReturnPressed(self):
         """
@@ -161,10 +179,10 @@
         
         @param txt text to be shown in the combo (string)
         """
-        self.findtextCombo.clear()
-        self.findtextCombo.addItems(self.findHistory)
-        self.findtextCombo.setEditText(txt)
-        self.findtextCombo.setFocus()
+        self.__ui.findtextCombo.clear()
+        self.__ui.findtextCombo.addItems(self.findHistory)
+        self.__ui.findtextCombo.setEditText(txt)
+        self.__ui.findtextCombo.setFocus()
         
         self.__setSearchButtons(txt != "")
         
@@ -177,8 +195,8 @@
         @param found flag indicating success (boolean)
         """
         if found:
-            self.statusLabel.clear()
+            self.__ui.statusLabel.clear()
         else:
-            txt = self.findtextCombo.currentText()
-            self.statusLabel.setText(
+            txt = self.__ui.findtextCombo.currentText()
+            self.__ui.statusLabel.setText(
                 self.tr("'{0}' was not found.").format(txt))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UI/SearchWidgetLine.ui	Fri Apr 21 19:39:31 2017 +0200
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SearchWidgetLine</class>
+ <widget class="QWidget" name="SearchWidgetLine">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>550</width>
+    <height>52</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Find</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="leftMargin">
+    <number>0</number>
+   </property>
+   <property name="topMargin">
+    <number>0</number>
+   </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
+   <property name="bottomMargin">
+    <number>0</number>
+   </property>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QToolButton" name="closeButton">
+       <property name="toolTip">
+        <string>Press to close the window</string>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>Find:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QComboBox" name="findtextCombo">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="minimumSize">
+        <size>
+         <width>200</width>
+         <height>0</height>
+        </size>
+       </property>
+       <property name="editable">
+        <bool>true</bool>
+       </property>
+       <property name="insertPolicy">
+        <enum>QComboBox::InsertAtTop</enum>
+       </property>
+       <property name="duplicatesEnabled">
+        <bool>false</bool>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QToolButton" name="findPrevButton">
+       <property name="toolTip">
+        <string>Press to find the previous occurrence</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QToolButton" name="findNextButton">
+       <property name="toolTip">
+        <string>Press to find the next occurrence</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="caseCheckBox">
+       <property name="text">
+        <string>Match case</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QCheckBox" name="wordCheckBox">
+       <property name="text">
+        <string>Whole word</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QLabel" name="statusLabel">
+     <property name="text">
+      <string/>
+     </property>
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>findtextCombo</tabstop>
+  <tabstop>caseCheckBox</tabstop>
+  <tabstop>wordCheckBox</tabstop>
+  <tabstop>findNextButton</tabstop>
+  <tabstop>findPrevButton</tabstop>
+  <tabstop>closeButton</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
--- a/eric6.e4p	Thu Apr 20 20:09:53 2017 +0200
+++ b/eric6.e4p	Fri Apr 21 19:39:31 2017 +0200
@@ -1860,6 +1860,7 @@
     <Form>UI/NumbersWidget.ui</Form>
     <Form>UI/Previewers/PreviewerQSS.ui</Form>
     <Form>UI/SearchWidget.ui</Form>
+    <Form>UI/SearchWidgetLine.ui</Form>
     <Form>UI/SymbolsWidget.ui</Form>
     <Form>VCS/CommandOptionsDialog.ui</Form>
     <Form>VCS/RepositoryInfoDialog.ui</Form>
@@ -1960,14 +1961,14 @@
   <Interfaces/>
   <Others>
     <Other>.hgignore</Other>
+    <Other>APIs/Python/zope-2.10.7.api</Other>
+    <Other>APIs/Python/zope-2.11.2.api</Other>
+    <Other>APIs/Python/zope-3.3.1.api</Other>
     <Other>APIs/Python3/PyQt4.bas</Other>
     <Other>APIs/Python3/PyQt5.bas</Other>
     <Other>APIs/Python3/QScintilla2.bas</Other>
     <Other>APIs/Python3/eric6.api</Other>
     <Other>APIs/Python3/eric6.bas</Other>
-    <Other>APIs/Python/zope-2.10.7.api</Other>
-    <Other>APIs/Python/zope-2.11.2.api</Other>
-    <Other>APIs/Python/zope-3.3.1.api</Other>
     <Other>APIs/QSS/qss.api</Other>
     <Other>APIs/Ruby/Ruby-1.8.7.api</Other>
     <Other>APIs/Ruby/Ruby-1.8.7.bas</Other>
--- a/eric6_shell.py	Thu Apr 20 20:09:53 2017 +0200
+++ b/eric6_shell.py	Fri Apr 21 19:39:31 2017 +0200
@@ -38,10 +38,6 @@
                           settingsDir)
         sys.argv.remove(arg)
 
-### make ThirdParty package available as a packages repository
-##sys.path.insert(2, os.path.join(os.path.dirname(__file__),
-##                                "ThirdParty", "Pygments"))
-
 from Globals import AppInfo
 
 from Toolbox import Startup
Binary file icons/default/restartDelete.png has changed

eric ide

mercurial