def __init__(self, log, parent=None): QDialog.__init__(self, parent) self.log = log self.l = l = QVBoxLayout() self.setLayout(l) self.tb = QTextBrowser(self) l.addWidget(self.tb) self.bb = QDialogButtonBox(QDialogButtonBox.Close) l.addWidget(self.bb) self.copy_button = self.bb.addButton(_('Copy to clipboard'), self.bb.ActionRole) self.copy_button.clicked.connect(self.copy_to_clipboard) self.copy_button.setIcon(QIcon(I('edit-copy.png'))) self.bb.rejected.connect(self.reject) self.bb.accepted.connect(self.accept) self.setWindowTitle(_('Download log')) self.setWindowIcon(QIcon(I('debug.png'))) self.resize(QSize(800, 400)) self.keep_updating = True self.last_html = None self.finished.connect(self.stop) QTimer.singleShot(100, self.update_log) self.show()
def polish(self, action, name): self.commit_all_editors_to_container() with BusyCursor(): self.add_savepoint(name) try: report = tweak_polish(current_container(), {action: True}) except: self.rewind_savepoint() raise self.apply_container_update_to_gui() from calibre.ebooks.markdown import markdown report = markdown('# %s\n\n' % self.current_metadata.title + '\n\n'.join(report), output_format='html4') d = QDialog(self.gui) d.l = QVBoxLayout() d.setLayout(d.l) d.e = QTextBrowser(d) d.l.addWidget(d.e) d.e.setHtml(report) d.bb = QDialogButtonBox(QDialogButtonBox.Close) d.l.addWidget(d.bb) d.bb.rejected.connect(d.reject) d.bb.accepted.connect(d.accept) d.resize(600, 400) d.exec_()
def __init__(self, movie): self.movie = movie QDialog.__init__(self, None) self.setObjectName("movie_warning") self.text_browser = QTextBrowser(self) self.text_browser.setObjectName("movie_warning_textbrowser") self.text_browser.setMinimumSize(400, 40) self.setWindowTitle('Rewind your movie?') self.text_browser.setPlainText( #bruce 080827 revised text "You may want to rewind the movie now. The atoms move as the movie " "progresses, and saving the part without rewinding will save the " "current positions, which is sometimes useful, but will make the " "movie invalid, because .dpb files only store deltas relative to " "the initial atom positions, and don't store the initial positions " "themselves.") self.ok_button = QPushButton(self) self.ok_button.setObjectName("ok_button") self.ok_button.setText("Rewind movie") self.cancel_button = QPushButton(self) self.cancel_button.setObjectName("cancel_button") self.cancel_button.setText( "Exit command without rewinding") #bruce 080827 revised text # Note: this is not, in fact, a cancel button -- # there is no option in the caller to prevent exiting the command. # There is also no option to "forward to final position", # though for a minimize movie, that might be most useful. # [bruce 080827 comment] layout = QGridLayout(self) layout.addWidget(self.text_browser, 0, 0, 0, 1) layout.addWidget(self.ok_button, 1, 0) layout.addWidget(self.cancel_button, 1, 1) self.connect(self.ok_button, SIGNAL("clicked()"), self.rewindMovie) self.connect(self.cancel_button, SIGNAL("clicked()"), self.noThanks)
def __init__(self, movie): self.movie = movie QDialog.__init__(self, None) self.setObjectName("movie_warning") self.text_browser = QTextBrowser(self) self.text_browser.setObjectName("movie_warning_textbrowser") self.text_browser.setMinimumSize(400, 40) self.setWindowTitle('Rewind your movie?') self.text_browser.setPlainText( "You may want to rewind the movie now. If you save the part without " + "rewinding the movie, the movie file will become invalid because it " + "depends upon the initial atom positions. The atoms move as the movie " + "progresses, and saving the part now will save the final positions, " + "which are incorrect for the movie you just watched.") self.ok_button = QPushButton(self) self.ok_button.setObjectName("ok_button") self.ok_button.setText("Rewind movie") self.cancel_button = QPushButton(self) self.cancel_button.setObjectName("cancel_button") self.cancel_button.setText("No thanks") layout = QGridLayout(self) layout.addWidget(self.text_browser, 0, 0, 0, 1) layout.addWidget(self.ok_button, 1, 0) layout.addWidget(self.cancel_button, 1, 1) self.connect(self.ok_button, SIGNAL("clicked()"), self.rewindMovie) self.connect(self.cancel_button, SIGNAL("clicked()"), self.noThanks)
def __init__(self, parent=None): QSplitter.__init__(self, parent) self.setChildrenCollapsible(False) self.items = i = QListWidget(self) i.setContextMenuPolicy(Qt.CustomContextMenu) i.customContextMenuRequested.connect(self.context_menu) self.items.setSpacing(3) self.items.itemDoubleClicked.connect(self.current_item_activated) self.items.currentItemChanged.connect(self.current_item_changed) self.items.setSelectionMode(self.items.NoSelection) self.delegate = Delegate(self.items) self.items.setItemDelegate(self.delegate) self.addWidget(i) self.help = h = QTextBrowser(self) h.anchorClicked.connect(self.link_clicked) h.setOpenLinks(False) self.addWidget(h) self.clear_help(_('Check has not been run')) self.setStretchFactor(0, 100) self.setStretchFactor(1, 50) state = tprefs.get('check-book-splitter-state', None) if state is not None: self.restoreState(state)
def __init__(self, text, parent=None, clicked_func=None, caption="(caption)"): QDialog.__init__(self, parent) self.setWindowTitle(caption) self.setWindowIcon(QtGui.QIcon("ui/border/MainWindow")) self.setObjectName("WikiHelpBrowser") TextBrowserLayout = QGridLayout(self) TextBrowserLayout.setSpacing(5) TextBrowserLayout.setMargin(2) self.text_browser = QTextBrowser(self) self.text_browser.setOpenExternalLinks(True) self.text_browser.setObjectName("text_browser") TextBrowserLayout.addWidget(self.text_browser, 0, 0, 1, 0) self.text_browser.setMinimumSize(400, 200) # make it pale yellow like a post-it note self.text_browser.setHtml("<qt bgcolor=\"#FFFF80\">" + text) self.close_button = QPushButton(self) self.close_button.setObjectName("close_button") self.close_button.setText("Close") TextBrowserLayout.addWidget(self.close_button, 1, 1) spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) TextBrowserLayout.addItem(spacer, 1, 0) self.resize(QSize(300, 300).expandedTo(self.minimumSizeHint())) self.connect(self.close_button, SIGNAL("clicked()"), self.close) return
def __init__(self, win): self.xmlfile = os.path.join(_sponsordir, 'sponsors.xml') self.win = win self.needToAsk = False self.downloadSponsors = False threading.Thread.__init__(self) if not self.refreshWanted(): return if env.prefs[sponsor_permanent_permission_prefs_key]: # We have a permanent answer so no need for a dialog if env.prefs[sponsor_download_permission_prefs_key]: self.downloadSponsors = True return self.needToAsk = True QDialog.__init__(self, None) self.setObjectName("Permission") self.setModal(True) #This fixes bug 2296. Mitigates bug 2297 layout = QGridLayout() self.setLayout(layout) layout.setMargin(0) layout.setSpacing(0) layout.setObjectName("PermissionLayout") self.text_browser = QTextBrowser(self) self.text_browser.setObjectName("text_browser") layout.addWidget(self.text_browser, 0, 0, 1, 4) self.text_browser.setMinimumSize(400, 80) self.setWindowTitle('May we use your network connection?') self.setWindowIcon(geticon('ui/border/MainWindow.png')) self.text_browser.setPlainText(self.text) self.accept_button = QPushButton(self) self.accept_button.setObjectName("accept_button") self.accept_button.setText("Always OK") self.accept_once_button = QPushButton(self) self.accept_once_button.setObjectName("accept_once_button") self.accept_once_button.setText("OK now") self.decline_once_button = QPushButton(self) self.decline_once_button.setObjectName("decline_once_button") self.decline_once_button.setText("Not now") self.decline_always_button = QPushButton(self) self.decline_always_button.setObjectName("decline_always_button") self.decline_always_button.setText("Never") layout.addWidget(self.accept_button, 1, 0) layout.addWidget(self.accept_once_button, 1, 1) layout.addWidget(self.decline_once_button, 1, 2) layout.addWidget(self.decline_always_button, 1, 3) self.connect(self.accept_button, SIGNAL("clicked()"), self.acceptAlways) self.connect(self.accept_once_button, SIGNAL("clicked()"), self.acceptJustOnce) self.connect(self.decline_once_button, SIGNAL("clicked()"), self.declineJustOnce) self.connect(self.decline_always_button, SIGNAL("clicked()"), self.declineAlways)
def show_report(changed, title, report, parent, show_current_diff): report = format_report(title, report) d = QDialog(parent) d.l = QVBoxLayout() d.setLayout(d.l) d.e = QTextBrowser(d) d.l.addWidget(d.e) d.e.setHtml(report) d.bb = QDialogButtonBox(QDialogButtonBox.Close) if changed: b = d.b = d.bb.addButton(_('See what &changed'), d.bb.AcceptRole) b.setIcon(QIcon(I('diff.png'))), b.setAutoDefault(False) b.clicked.connect(partial(show_current_diff, allow_revert=True)) d.bb.button(d.bb.Close).setDefault(True) d.l.addWidget(d.bb) d.bb.rejected.connect(d.reject) d.bb.accepted.connect(d.accept) d.resize(600, 400) d.exec_()
def __init__(self, title, html, parent=None): QDialog.__init__(self, parent) self.l = l = QVBoxLayout() self.setLayout(l) self.tb = QTextBrowser(self) self.tb.setHtml('<pre style="font-family: monospace">%s</pre>' % html) l.addWidget(self.tb) self.bb = QDialogButtonBox(QDialogButtonBox.Ok) self.bb.accepted.connect(self.accept) self.bb.rejected.connect(self.reject) self.copy_button = self.bb.addButton(_('Copy to clipboard'), self.bb.ActionRole) self.copy_button.setIcon(QIcon(I('edit-copy.png'))) self.copy_button.clicked.connect(self.copy_to_clipboard) l.addWidget(self.bb) self.setModal(False) self.resize(QSize(700, 500)) self.setWindowTitle(title) self.setWindowIcon(QIcon(I('debug.png'))) self.show()
def __init__(self, parent, config_name=None, buttons=[], *args): """Creates dialog. 'config_name' is used to get/set default window size from Config object 'buttons' can be a list of names or (QPixmapWrapper,name[,tooltip]) tuples to provide custom buttons at the bottom of the dialog. When a button is clicked, the dialog emits SIGNAL("name"). A "Close" button is always provided, this simply hides the dialog. """ QDialog.__init__(self, parent, *args) self.setModal(False) lo = QVBoxLayout(self) # create viewer self.label = QLabel(self) self.label.setMargin(5) self.label.setWordWrap(True) lo.addWidget(self.label) self.label.hide() self.viewer = QTextBrowser(self) lo.addWidget(self.viewer) # self.viewer.setReadOnly(True) self.viewer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) QObject.connect(self.viewer, SIGNAL("anchorClicked(const QUrl &)"), self._urlClicked) self._source = None lo.addSpacing(5) # create button bar btnfr = QFrame(self) btnfr.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) # btnfr.setMargin(5) lo.addWidget(btnfr) lo.addSpacing(5) btnfr_lo = QHBoxLayout(btnfr) btnfr_lo.setMargin(5) # add user buttons self._user_buttons = {} for name in buttons: if isinstance(name, str): btn = QPushButton(name, btnfr) elif isinstance(name, (list, tuple)): if len(name) < 3: pixmap, name = name tip = None else: pixmap, name, tip = name btn = QPushButton(pixmap.icon(), name, btnfr) if tip: btn.setToolTip(tip) self._user_buttons[name] = btn btn._clicked = Kittens.utils.curry(self.emit, SIGNAL(name)) self.connect(btn, SIGNAL("clicked()"), btn._clicked) btnfr_lo.addWidget(btn, 1) # add a Close button btnfr_lo.addStretch(100) closebtn = QPushButton(pixmaps.grey_round_cross.icon(), "Close", btnfr) self.connect(closebtn, SIGNAL("clicked()"), self.hide) btnfr_lo.addWidget(closebtn, 1) # resize selves self.config_name = config_name or "html-viewer" width = Config.getint('%s-width' % self.config_name, 512) height = Config.getint('%s-height' % self.config_name, 512) self.resize(QSize(width, height))