def __init__(self, book_mi, annotations, parent=None): #QDialog.__init__(self, parent) self.prefs = plugin_prefs super(PreviewDialog, self).__init__(parent, 'annotations_preview_dialog') self.pl = QVBoxLayout(self) self.setLayout(self.pl) self.label = QLabel() self.label.setText("<b>" + _("{0} annotations · {1}").format( book_mi.reader_app, book_mi.title) + "</b>") self.label.setAlignment(Qt.AlignHCenter) self.pl.addWidget(self.label) self.wv = QWebView() self.wv.setHtml(annotations) self.pl.addWidget(self.wv) self.buttonbox = QDialogButtonBox(QDialogButtonBox.Close) # self.buttonbox.addButton('Close', QDialogButtonBox.AcceptRole) self.buttonbox.setOrientation(Qt.Horizontal) # self.buttonbox.accepted.connect(self.close) self.buttonbox.rejected.connect(self.close) # self.connect(self.buttonbox, pyqtSignal('accepted()'), self.close) # self.connect(self.buttonbox, pyqtSignal('rejected()'), self.close) self.pl.addWidget(self.buttonbox) # Sizing sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.resize_dialog()
def __init__(self, parent, icon, prefs, html=None, page=None, title=''): self.prefs = prefs #QDialog.__init__(self, parent=parent) super(HelpView, self).__init__(parent, 'help_dialog') self.setWindowTitle(title) self.setWindowIcon(icon) self.l = QVBoxLayout(self) self.setLayout(self.l) self.wv = QWebView() if html is not None: self.wv.setHtml(html) elif page is not None: self.wv.load(QUrl(page)) self.wv.setMinimumHeight(100) self.wv.setMaximumHeight(16777215) self.wv.setMinimumWidth(400) self.wv.setMaximumWidth(16777215) self.wv.setGeometry(0, 0, 400, 100) self.wv.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.l.addWidget(self.wv) # Sizing sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.resize_dialog()
def showHelpButtonClicked(self): if not hasattr(self, "helpview"): helpBasepath = "%s/help" % os.path.normpath( os.path.dirname(__file__)) helpUrl = QUrl( pathlib.Path("%s/index.html" % helpBasepath).as_uri()) cssUrl = QUrl(pathlib.Path("%s/help.css" % helpBasepath).as_uri()) self.helpview = QWebView() self.helpview.settings().setUserStyleSheetUrl(cssUrl) self.helpview.load(helpUrl) self.helpview.show()
class Ui_MWindow(): # Two column Layout layout_top = QHBoxLayout() # Vertical layout for each column layout_l = QVBoxLayout() layout_r = QVBoxLayout() # Horizontal layout for controls layout_r_h = QHBoxLayout() # Edit raw markdown mdtext = QPlainMdTextEdit() # shows html html_view = QWebView() # Mail Subject subject_edit = QLineEdit() # Recipient Mail to_edit = QLineEdit() # Open recipientsWindow multi_rec_btn = QPushButton() # Send EMail send_btn = QPushButton() # Add attachment add_att_btn = QPushButton() # QProgressBar progress_bar = QProgressBar() # attachment QListWidget attachments = QListWidget() def __init__(self): # build layout self.layout_l.addWidget(self.subject_edit) self.subject_edit.setPlaceholderText("Subject") self.layout_l.addWidget(self.mdtext) self.layout_r.addLayout(self.layout_r_h) self.layout_r_h.addWidget(self.to_edit) self.to_edit.setPlaceholderText("To:") self.layout_r_h.addWidget(self.multi_rec_btn) self.multi_rec_btn.setText("...") self.layout_r_h.addWidget(self.send_btn) self.send_btn.setText("Send") self.layout_r_h.addWidget(self.add_att_btn) self.add_att_btn.setText("Attach..") self.attachments.setMaximumHeight(100) self.layout_r.addWidget(self.html_view) self.progress_bar.setTextVisible(False) self.progress_bar.setFixedHeight(10) self.progress_bar.setValue(1) self.layout_r.addWidget(self.progress_bar) self.layout_r.addWidget(self.attachments) self.layout_top.addLayout(self.layout_l) self.layout_top.addLayout(self.layout_r) self.setLayout(self.layout_top) # other self.attachments.setSelectionMode(QAbstractItemView.ExtendedSelection)
def __init__(self, parent, icon, prefs): self.parent = parent self.prefs = prefs self.icon = icon super(AnnotationsAppearance, self).__init__(parent, 'appearance_dialog') self.setWindowTitle(_('Modify appearance')) self.setWindowIcon(icon) self.l = QVBoxLayout(self) self.setLayout(self.l) # Add a label for description #self.description_label = QLabel(_("Descriptive text here")) #self.l.addWidget(self.description_label) # Add a group box, vertical layout for preview window self.preview_gb = QGroupBox(self) self.preview_gb.setTitle(_("Preview")) self.preview_vl = QVBoxLayout(self.preview_gb) self.l.addWidget(self.preview_gb) self.wv = QWebView() self.wv.setHtml('<p></p>') self.wv.setMinimumHeight(100) self.wv.setMaximumHeight(16777215) self.wv.setGeometry(0, 0, 200, 100) self.wv.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.preview_vl.addWidget(self.wv) # Create a group box, horizontal layout for the table self.css_table_gb = QGroupBox(self) self.css_table_gb.setTitle(_("Annotation elements")) self.elements_hl = QHBoxLayout(self.css_table_gb) self.l.addWidget(self.css_table_gb) # Add the group box to the main layout self.elements_table = AnnotationElementsTable( self, 'annotation_elements_tw') self.elements_hl.addWidget(self.elements_table) self.elements_table.initialize() # Options self.options_gb = QGroupBox(self) self.options_gb.setTitle(_("Options")) self.options_gl = QGridLayout(self.options_gb) self.l.addWidget(self.options_gb) current_row = 0 # <hr/> separator # addWidget(widget, row, col, rowspan, colspan) self.hr_checkbox = QCheckBox( _('Add horizontal rule between annotations')) self.hr_checkbox.stateChanged.connect(self.hr_checkbox_changed) self.hr_checkbox.setCheckState( JSONConfig('plugins/annotations').get('appearance_hr_checkbox', False)) self.options_gl.addWidget(self.hr_checkbox, current_row, 0, 1, 4) current_row += 1 # Timestamp self.timestamp_fmt_label = QLabel(_("Timestamp format:")) self.options_gl.addWidget(self.timestamp_fmt_label, current_row, 0) self.timestamp_fmt_le = QLineEdit( JSONConfig('plugins/annotations').get( 'appearance_timestamp_format', default_timestamp), parent=self) self.timestamp_fmt_le.textEdited.connect(self.timestamp_fmt_changed) self.timestamp_fmt_le.setFont(self.FONT) self.timestamp_fmt_le.setObjectName('timestamp_fmt_le') self.timestamp_fmt_le.setToolTip(_('Format string for timestamp')) self.timestamp_fmt_le.setMaximumWidth(16777215) self.timestamp_fmt_le.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) self.options_gl.addWidget(self.timestamp_fmt_le, current_row, 1) self.timestamp_fmt_reset_tb = QToolButton(self) self.timestamp_fmt_reset_tb.setToolTip(_("Reset to default")) self.timestamp_fmt_reset_tb.setIcon(QIcon(I('trash.png'))) self.timestamp_fmt_reset_tb.clicked.connect( self.reset_timestamp_to_default) self.options_gl.addWidget(self.timestamp_fmt_reset_tb, current_row, 2) self.timestamp_fmt_help_tb = QToolButton(self) self.timestamp_fmt_help_tb.setToolTip(_("Format string reference")) self.timestamp_fmt_help_tb.setIcon(QIcon(I('help.png'))) self.timestamp_fmt_help_tb.clicked.connect(self.show_help) self.options_gl.addWidget(self.timestamp_fmt_help_tb, current_row, 3) # Button box bb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) bb.accepted.connect(self.accept) bb.rejected.connect(self.reject) self.l.addWidget(bb) # Spacer self.spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.l.addItem(self.spacerItem) # Sizing sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.resize_dialog()