##// END OF EJS Templates
added 'don't ask again' option to HTML+PNG inline/external save dialog
MinRK -
Show More
@@ -161,7 +161,8 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
161 self._reading_callback = None
161 self._reading_callback = None
162 self._tab_width = 8
162 self._tab_width = 8
163 self._text_completing_pos = 0
163 self._text_completing_pos = 0
164 self._filename = os.path.join(os.curdir, 'ipython.html')
164 self._filename = 'ipython.html'
165 self._png_mode=None
165
166
166 # Set a monospaced font.
167 # Set a monospaced font.
167 self.reset_font()
168 self.reset_font()
@@ -589,15 +590,48 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
589 img_re = re.compile(r'<img src="(?P<name>[\d]+)" />')
590 img_re = re.compile(r'<img src="(?P<name>[\d]+)" />')
590 html = self.fix_html_encoding(
591 html = self.fix_html_encoding(
591 str(self._control.toHtml().toUtf8()))
592 str(self._control.toHtml().toUtf8()))
592 if img_re.search(html):
593 if self._png_mode:
594 # preference saved, don't ask again
595 if img_re.search(html):
596 inline = (self._png_mode == 'inline')
597 else:
598 inline = True
599 elif img_re.search(html):
593 # there are images
600 # there are images
601 widget = QtGui.QWidget()
602 layout = QtGui.QVBoxLayout(widget)
594 title = self.window().windowTitle()
603 title = self.window().windowTitle()
595 reply = QtGui.QMessageBox.question(self, title, "Images found."+
604 msg = "Exporting HTML with PNGs"
596 "\nWould you like inline PNGs (single large html file) or "+
605 info = "Would you like inline PNGs (single large html file) or "+\
597 "external image files?", "inline", "external")
606 "external image files?"
607 checkbox = QtGui.QCheckBox("&Don't ask again")
608 checkbox.setShortcut('D')
609 ib = QtGui.QPushButton("&Inline", self)
610 ib.setShortcut('I')
611 eb = QtGui.QPushButton("&External", self)
612 eb.setShortcut('E')
613 box = QtGui.QMessageBox(QtGui.QMessageBox.Question, title, msg)
614 box.setInformativeText(info)
615 box.addButton(ib,QtGui.QMessageBox.NoRole)
616 box.addButton(eb,QtGui.QMessageBox.YesRole)
617 box.setDefaultButton(ib)
618 layout.setSpacing(0)
619 layout.addWidget(box)
620 layout.addWidget(checkbox)
621 widget.setLayout(layout)
622 widget.show()
623 reply = box.exec_()
598 inline = (reply == 0)
624 inline = (reply == 0)
625 if checkbox.checkState():
626 # don't ask anymore, always use this choice
627 if inline:
628 self._png_mode='inline'
629 else:
630 self._png_mode='external'
599 else:
631 else:
632 # no images
600 inline = True
633 inline = True
634
601 if inline:
635 if inline:
602 path = None
636 path = None
603 else:
637 else:
General Comments 0
You need to be logged in to leave comments. Login now