diff --git a/IPython/frontend/qt/console/console_widget.py b/IPython/frontend/qt/console/console_widget.py index 0119666..f587ab2 100644 --- a/IPython/frontend/qt/console/console_widget.py +++ b/IPython/frontend/qt/console/console_widget.py @@ -620,8 +620,7 @@ class ConsoleWidget(LoggingConfigurable, QtGui.QWidget): # Remove any trailing newline, which confuses the GUI and forces the # user to backspace. - if not text: - text = QtGui.QApplication.clipboard().text(mode).rstrip() + text = QtGui.QApplication.clipboard().text(mode).rstrip() self._insert_plain_text_into_buffer(cursor, dedent(text)) def print_(self, printer = None): @@ -872,17 +871,17 @@ class ConsoleWidget(LoggingConfigurable, QtGui.QWidget): """ menu = QtGui.QMenu(self) - cut_action = menu.addAction('Cut', self.cut) - cut_action.setEnabled(self.can_cut()) - cut_action.setShortcut(QtGui.QKeySequence.Cut) + self.cut_action = menu.addAction('Cut', self.cut) + self.cut_action.setEnabled(self.can_cut()) + self.cut_action.setShortcut(QtGui.QKeySequence.Cut) - copy_action = menu.addAction('Copy', self.copy) - copy_action.setEnabled(self.can_copy()) - copy_action.setShortcut(QtGui.QKeySequence.Copy) + self.copy_action = menu.addAction('Copy', self.copy) + self.copy_action.setEnabled(self.can_copy()) + self.copy_action.setShortcut(QtGui.QKeySequence.Copy) - paste_action = menu.addAction('Paste', self.paste) - paste_action.setEnabled(self.can_paste()) - paste_action.setShortcut(QtGui.QKeySequence.Paste) + self.paste_action = menu.addAction('Paste', self.paste) + self.paste_action.setEnabled(self.can_paste()) + self.paste_action.setShortcut(QtGui.QKeySequence.Paste) menu.addSeparator() menu.addAction(self.select_all_action) diff --git a/IPython/frontend/qt/console/history_console_widget.py b/IPython/frontend/qt/console/history_console_widget.py index 7b388b6..944f9bd 100644 --- a/IPython/frontend/qt/console/history_console_widget.py +++ b/IPython/frontend/qt/console/history_console_widget.py @@ -204,9 +204,6 @@ class HistoryConsoleWidget(ConsoleWidget): """ return self._history[-n:] - def history_magic(self): - self.execute("%history") - def _request_update_session_history_length(self): msg_id = self.kernel_manager.shell_channel.execute('', silent=True, diff --git a/IPython/frontend/qt/console/qtconsoleapp.py b/IPython/frontend/qt/console/qtconsoleapp.py index 8fe2927..a04e968 100644 --- a/IPython/frontend/qt/console/qtconsoleapp.py +++ b/IPython/frontend/qt/console/qtconsoleapp.py @@ -326,7 +326,6 @@ class MainWindow(QtGui.QMainWindow): #create menu in the order they should appear in the menu bar self.file_menu = self.menuBar().addMenu("&File") self.edit_menu = self.menuBar().addMenu("&Edit") - self.font_menu = self.menuBar().addMenu("F&ont") self.window_menu = self.menuBar().addMenu("&Window") self.magic_menu = self.menuBar().addMenu("&Magic") self.all_magic_menu = self.magic_menu.addMenu("&All Magic") @@ -362,6 +361,29 @@ class MainWindow(QtGui.QMainWindow): ) self.file_menu.addAction(self.select_all_action) + self.paste_action = QtGui.QAction("&Paste", + self, + shortcut=QtGui.QKeySequence.Paste, + triggered=self.paste_active_frontend + ) + self.edit_menu.addAction(self.paste_action) + + self.copy_action = QtGui.QAction("&Copy", + self, + shortcut=QtGui.QKeySequence.Copy, + triggered=self.copy_active_frontend + ) + self.edit_menu.addAction(self.copy_action) + + self.cut_action = QtGui.QAction("&Cut", + self, + shortcut=QtGui.QKeySequence.Cut, + triggered=self.cut_active_frontend + ) + self.edit_menu.addAction(self.cut_action) + + self.edit_menu.addSeparator() + self.undo_action = QtGui.QAction("&Undo", self, shortcut="Ctrl+Z", @@ -377,26 +399,30 @@ class MainWindow(QtGui.QMainWindow): triggered=self.redo_active_frontend) self.edit_menu.addAction(self.redo_action) + self.window_menu.addSeparator() + self.increase_font_size = QtGui.QAction("&Increase Font Size", self, shortcut="Ctrl++", triggered=self.increase_font_size_active_frontend ) - self.font_menu.addAction(self.increase_font_size) + self.window_menu.addAction(self.increase_font_size) self.decrease_font_size = QtGui.QAction("&Decrease Font Size", self, shortcut="Ctrl+-", triggered=self.decrease_font_size_active_frontend ) - self.font_menu.addAction(self.decrease_font_size) + self.window_menu.addAction(self.decrease_font_size) self.reset_font_size = QtGui.QAction("&Reset Font Size", self, shortcut="Ctrl+0", triggered=self.reset_font_size_active_frontend ) - self.font_menu.addAction(self.reset_font_size) + self.window_menu.addAction(self.reset_font_size) + + self.window_menu.addSeparator() self.reset_action = QtGui.QAction("&Reset", self, @@ -416,11 +442,12 @@ class MainWindow(QtGui.QMainWindow): triggered=self.save_magic_active_frontend) self.magic_menu.addAction(self.save_action) - self.clear_action = QtGui.QAction("&Clear", + self.clear_action = QtGui.QAction("&Clear Screen", self, + shortcut='Ctrl+L', statusTip="Clear the console", triggered=self.clear_magic_active_frontend) - self.magic_menu.addAction(self.clear_action) + self.window_menu.addAction(self.clear_action) self.who_action = QtGui.QAction("&Who", self, @@ -482,6 +509,14 @@ class MainWindow(QtGui.QMainWindow): ) self.all_magic_menu.addAction(xaction) + def cut_active_frontend(self): + self.active_frontend.cut_action.trigger() + + def copy_active_frontend(self): + self.active_frontend.copy_action.trigger() + + def paste_active_frontend(self): + self.active_frontend.paste_action.trigger() def undo_active_frontend(self): self.active_frontend.undo() @@ -493,7 +528,7 @@ class MainWindow(QtGui.QMainWindow): self.active_frontend.execute("%reset") def history_magic_active_frontend(self): - self.active_frontend.history_magic() + self.active_frontend.execute("%history") def save_magic_active_frontend(self): self.active_frontend.save_magic() @@ -608,7 +643,7 @@ aliases.update(qt_aliases) class IPythonQtConsoleApp(BaseIPythonApplication): name = 'ipython-qtconsole' default_config_file_name='ipython_config.py' - + description = """ The IPython QtConsole. @@ -1012,11 +1047,14 @@ class IPythonQtConsoleApp(BaseIPythonApplication): statusTip="Toggle between Fullscreen and Normal Size", triggered=self.toggleFullScreen) + + self.tabAndNewKernelAct =QtGui.QAction("Tab with &New kernel", self.window, shortcut="Ctrl+T", triggered=self.create_tab_with_new_frontend) self.window.window_menu.addAction(self.tabAndNewKernelAct) + self.tabSameKernalAct =QtGui.QAction("Tab with Sa&me kernel", self.window, shortcut="Ctrl+Shift+T", @@ -1059,6 +1097,22 @@ class IPythonQtConsoleApp(BaseIPythonApplication): # that it can still be triggerd by shortcut self.window.addAction(self.fullScreenAct) + # Don't activate toggleMenubar on mac, doen't work, + # as toolbar always here + self.toggle_menu_bar_act = QtGui.QAction("&Toggle Menu Bar", + self.window, + shortcut="Ctrl+Meta+H", + statusTip="Toggle menubar betwin visible and not", + triggered=self.toggle_menu_bar) + self.window_menu.addAction(self.toggle_menu_bar_act) + + def toggle_menu_bar(self): + menu_bar = self.window.menuBar(); + if not menu_bar.isVisible(): + menu_bar.setVisible(False) + else: + menu_bar.setVisible(True) + def toggleMinimized(self): if not self.window.isMinimized(): self.window.showMinimized()