Show More
@@ -247,7 +247,12 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):' | |||
|
247 | 247 | |
|
248 | 248 | action = QtGui.QAction('Select All', None) |
|
249 | 249 | action.setEnabled(True) |
|
250 |
|
|
|
250 | selectall = QtGui.QKeySequence(QtGui.QKeySequence.SelectAll) | |
|
251 | if selectall.matches("Ctrl+A") and sys.platform != 'darwin': | |
|
252 | # Only override the default if there is a collision. | |
|
253 | # Qt ctrl = cmd on OSX, so the match gets a false positive on OSX. | |
|
254 | selectall = "Ctrl+Shift+A" | |
|
255 | action.setShortcut(selectall) | |
|
251 | 256 | action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut) |
|
252 | 257 | action.triggered.connect(self.select_all) |
|
253 | 258 | self.addAction(action) |
@@ -255,14 +260,14 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):' | |||
|
255 | 260 | |
|
256 | 261 | self.increase_font_size = QtGui.QAction("Bigger Font", |
|
257 | 262 | self, |
|
258 |
shortcut= |
|
|
263 | shortcut=QtGui.QKeySequence.ZoomIn, | |
|
259 | 264 | statusTip="Increase the font size by one point", |
|
260 | 265 | triggered=self._increase_font_size) |
|
261 | 266 | self.addAction(self.increase_font_size) |
|
262 | 267 | |
|
263 | 268 | self.decrease_font_size = QtGui.QAction("Smaller Font", |
|
264 | 269 | self, |
|
265 |
shortcut= |
|
|
270 | shortcut=QtGui.QKeySequence.ZoomOut, | |
|
266 | 271 | statusTip="Decrease the font size by one point", |
|
267 | 272 | triggered=self._decrease_font_size) |
|
268 | 273 | self.addAction(self.decrease_font_size) |
@@ -301,14 +301,21 b' class MainWindow(QtGui.QMainWindow):' | |||
|
301 | 301 | return slave_list |
|
302 | 302 | |
|
303 | 303 | # Populate the menu bar with common actions and shortcuts |
|
304 | def add_menu_action(self, menu, action): | |
|
304 | def add_menu_action(self, menu, action, defer_shortcut=False): | |
|
305 | 305 | """Add action to menu as well as self |
|
306 | 306 | |
|
307 | 307 | So that when the menu bar is invisible, its actions are still available. |
|
308 | ||
|
309 | If defer_shortcut is True, set the shortcut context to widget-only, | |
|
310 | where it will avoid conflict with shortcuts already bound to the | |
|
311 | widgets themselves. | |
|
308 | 312 | """ |
|
309 | 313 | menu.addAction(action) |
|
310 | 314 | self.addAction(action) |
|
311 | 315 | |
|
316 | if defer_shortcut: | |
|
317 | action.setShortcutContext(QtCore.Qt.WidgetShortcut) | |
|
318 | ||
|
312 | 319 | def init_menu_bar(self): |
|
313 | 320 | #create menu in the order they should appear in the menu bar |
|
314 | 321 | self.init_file_menu() |
@@ -338,28 +345,30 b' class MainWindow(QtGui.QMainWindow):' | |||
|
338 | 345 | |
|
339 | 346 | self.close_action=QtGui.QAction("&Close Tab", |
|
340 | 347 | self, |
|
341 |
shortcut= |
|
|
348 | shortcut=QtGui.QKeySequence.Close, | |
|
342 | 349 | triggered=self.close_active_frontend |
|
343 | 350 | ) |
|
344 | 351 | self.add_menu_action(self.file_menu, self.close_action) |
|
345 | 352 | |
|
346 | 353 | self.export_action=QtGui.QAction("&Save to HTML/XHTML", |
|
347 | 354 | self, |
|
348 |
shortcut= |
|
|
355 | shortcut=QtGui.QKeySequence.Save, | |
|
349 | 356 | triggered=self.export_action_active_frontend |
|
350 | 357 | ) |
|
351 | self.add_menu_action(self.file_menu, self.export_action) | |
|
358 | self.add_menu_action(self.file_menu, self.export_action, True) | |
|
352 | 359 | |
|
353 | 360 | self.file_menu.addSeparator() |
|
354 | 361 | |
|
355 | # Ctrl actually maps to Cmd on OSX, which avoids conflict with history | |
|
356 | # action, which is already bound to true Ctrl+P | |
|
357 | print_shortcut = "Ctrl+P" if sys.platform == 'darwin' else 'Ctrl+Shift+P' | |
|
362 | printkey = QtGui.QKeySequence(QtGui.QKeySequence.Print) | |
|
363 | if printkey.matches("Ctrl+P") and sys.platform != 'darwin': | |
|
364 | # Only override the default if there is a collision. | |
|
365 | # Qt ctrl = cmd on OSX, so the match gets a false positive on OSX. | |
|
366 | printkey = "Ctrl+Shift+P" | |
|
358 | 367 | self.print_action = QtGui.QAction("&Print", |
|
359 | 368 | self, |
|
360 |
shortcut=print |
|
|
369 | shortcut=printkey, | |
|
361 | 370 | triggered=self.print_action_active_frontend) |
|
362 | self.add_menu_action(self.file_menu, self.print_action) | |
|
371 | self.add_menu_action(self.file_menu, self.print_action, True) | |
|
363 | 372 | |
|
364 | 373 | if sys.platform != 'darwin': |
|
365 | 374 | # OSX always has Quit in the Application menu, only add it |
@@ -380,7 +389,7 b' class MainWindow(QtGui.QMainWindow):' | |||
|
380 | 389 | |
|
381 | 390 | self.undo_action = QtGui.QAction("&Undo", |
|
382 | 391 | self, |
|
383 |
shortcut= |
|
|
392 | shortcut=QtGui.QKeySequence.Undo, | |
|
384 | 393 | statusTip="Undo last action if possible", |
|
385 | 394 | triggered=self.undo_active_frontend |
|
386 | 395 | ) |
@@ -388,7 +397,7 b' class MainWindow(QtGui.QMainWindow):' | |||
|
388 | 397 | |
|
389 | 398 | self.redo_action = QtGui.QAction("&Redo", |
|
390 | 399 | self, |
|
391 | shortcut="Ctrl+Shift+Z", | |
|
400 | shortcut=QtGui.QKeySequence.Redo, | |
|
392 | 401 | statusTip="Redo last action if possible", |
|
393 | 402 | triggered=self.redo_active_frontend) |
|
394 | 403 | self.add_menu_action(self.edit_menu, self.redo_action) |
@@ -400,37 +409,42 b' class MainWindow(QtGui.QMainWindow):' | |||
|
400 | 409 | shortcut=QtGui.QKeySequence.Cut, |
|
401 | 410 | triggered=self.cut_active_frontend |
|
402 | 411 | ) |
|
403 | self.add_menu_action(self.edit_menu, self.cut_action) | |
|
412 | self.add_menu_action(self.edit_menu, self.cut_action, True) | |
|
404 | 413 | |
|
405 | 414 | self.copy_action = QtGui.QAction("&Copy", |
|
406 | 415 | self, |
|
407 | 416 | shortcut=QtGui.QKeySequence.Copy, |
|
408 | 417 | triggered=self.copy_active_frontend |
|
409 | 418 | ) |
|
410 | self.add_menu_action(self.edit_menu, self.copy_action) | |
|
419 | self.add_menu_action(self.edit_menu, self.copy_action, True) | |
|
411 | 420 | |
|
412 | 421 | self.copy_raw_action = QtGui.QAction("Copy (&Raw Text)", |
|
413 | 422 | self, |
|
414 | 423 | shortcut="Ctrl+Shift+C", |
|
415 | 424 | triggered=self.copy_raw_active_frontend |
|
416 | 425 | ) |
|
417 | self.add_menu_action(self.edit_menu, self.copy_raw_action) | |
|
426 | self.add_menu_action(self.edit_menu, self.copy_raw_action, True) | |
|
418 | 427 | |
|
419 | 428 | self.paste_action = QtGui.QAction("&Paste", |
|
420 | 429 | self, |
|
421 | 430 | shortcut=QtGui.QKeySequence.Paste, |
|
422 | 431 | triggered=self.paste_active_frontend |
|
423 | 432 | ) |
|
424 | self.add_menu_action(self.edit_menu, self.paste_action) | |
|
433 | self.add_menu_action(self.edit_menu, self.paste_action, True) | |
|
425 | 434 | |
|
426 | 435 | self.edit_menu.addSeparator() |
|
427 | 436 | |
|
437 | selectall = QtGui.QKeySequence(QtGui.QKeySequence.SelectAll) | |
|
438 | if selectall.matches("Ctrl+A") and sys.platform != 'darwin': | |
|
439 | # Only override the default if there is a collision. | |
|
440 | # Qt ctrl = cmd on OSX, so the match gets a false positive on OSX. | |
|
441 | selectall = "Ctrl+Shift+A" | |
|
428 | 442 | self.select_all_action = QtGui.QAction("Select &All", |
|
429 | 443 | self, |
|
430 |
shortcut= |
|
|
444 | shortcut=selectall, | |
|
431 | 445 | triggered=self.select_all_active_frontend |
|
432 | 446 | ) |
|
433 | self.add_menu_action(self.edit_menu, self.select_all_action) | |
|
447 | self.add_menu_action(self.edit_menu, self.select_all_action, True) | |
|
434 | 448 | |
|
435 | 449 | |
|
436 | 450 | def init_view_menu(self): |
@@ -457,24 +471,24 b' class MainWindow(QtGui.QMainWindow):' | |||
|
457 | 471 | |
|
458 | 472 | self.increase_font_size = QtGui.QAction("Zoom &In", |
|
459 | 473 | self, |
|
460 | shortcut="Ctrl++", | |
|
474 | shortcut=QtGui.QKeySequence.ZoomIn, | |
|
461 | 475 | triggered=self.increase_font_size_active_frontend |
|
462 | 476 | ) |
|
463 | self.add_menu_action(self.view_menu, self.increase_font_size) | |
|
477 | self.add_menu_action(self.view_menu, self.increase_font_size, True) | |
|
464 | 478 | |
|
465 | 479 | self.decrease_font_size = QtGui.QAction("Zoom &Out", |
|
466 | 480 | self, |
|
467 | shortcut="Ctrl+-", | |
|
481 | shortcut=QtGui.QKeySequence.ZoomOut, | |
|
468 | 482 | triggered=self.decrease_font_size_active_frontend |
|
469 | 483 | ) |
|
470 | self.add_menu_action(self.view_menu, self.decrease_font_size) | |
|
484 | self.add_menu_action(self.view_menu, self.decrease_font_size, True) | |
|
471 | 485 | |
|
472 | 486 | self.reset_font_size = QtGui.QAction("Zoom &Reset", |
|
473 | 487 | self, |
|
474 | 488 | shortcut="Ctrl+0", |
|
475 | 489 | triggered=self.reset_font_size_active_frontend |
|
476 | 490 | ) |
|
477 | self.add_menu_action(self.view_menu, self.reset_font_size) | |
|
491 | self.add_menu_action(self.view_menu, self.reset_font_size, True) | |
|
478 | 492 | |
|
479 | 493 | self.view_menu.addSeparator() |
|
480 | 494 | |
@@ -696,16 +710,22 b' class MainWindow(QtGui.QMainWindow):' | |||
|
696 | 710 | self.active_frontend.request_interrupt_kernel() |
|
697 | 711 | |
|
698 | 712 | def cut_active_frontend(self): |
|
699 |
self.active_frontend |
|
|
713 | widget = self.active_frontend | |
|
714 | if widget.can_cut(): | |
|
715 | widget.cut() | |
|
700 | 716 | |
|
701 | 717 | def copy_active_frontend(self): |
|
702 |
self.active_frontend |
|
|
718 | widget = self.active_frontend | |
|
719 | if widget.can_copy(): | |
|
720 | widget.copy() | |
|
703 | 721 | |
|
704 | 722 | def copy_raw_active_frontend(self): |
|
705 | 723 | self.active_frontend._copy_raw_action.trigger() |
|
706 | 724 | |
|
707 | 725 | def paste_active_frontend(self): |
|
708 |
self.active_frontend |
|
|
726 | widget = self.active_frontend | |
|
727 | if widget.can_paste(): | |
|
728 | widget.paste() | |
|
709 | 729 | |
|
710 | 730 | def undo_active_frontend(self): |
|
711 | 731 | self.active_frontend.undo() |
General Comments 0
You need to be logged in to leave comments.
Login now