Permalink
Browse files

reorganise menu

	add cut,copy paste, toggle menu bar (but not on os x)
	remove history oneliner from history console
  • Loading branch information...
1 parent 58e0679 commit 0fc39ed74df569bd6634d9b04f2ead8d35b1b1fe @Carreau Carreau committed with fperez Oct 14, 2011
@@ -620,8 +620,7 @@ def paste(self, mode=QtGui.QClipboard.Clipboard):
# 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 @@ def _context_menu_make(self, pos):
"""
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)
@@ -204,9 +204,6 @@ def history_tail(self, n=10):
"""
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,
@@ -326,7 +326,6 @@ def init_menu_bar(self):
#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 @@ def init_menu_bar(self):
)
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 @@ def init_menu_bar(self):
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 @@ def init_menu_bar(self):
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 @@ def inner_dynamic_magic():
)
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 @@ def reset_magic_active_frontend(self):
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 @@ def closeEvent(self, event):
class IPythonQtConsoleApp(BaseIPythonApplication):
name = 'ipython-qtconsole'
default_config_file_name='ipython_config.py'
-
+
description = """
The IPython QtConsole.
@@ -1012,11 +1047,14 @@ def init_window_shortcut(self):
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 @@ def init_window_shortcut(self):
# 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()

0 comments on commit 0fc39ed

Please sign in to comment.