Example #1
0
    def drawGUI(self):
        form_layout = QFormLayout(self)
        form_layout.setFormAlignment(Qt.AlignLeft)
        title = QLabel(tr("<H1>DHCP Configuration</H1>"))
        form_layout.addRow(title)

        self.enable = QCheckBox(tr("Enable DHCP Server on configured LANs"))
        form_layout.addRow(self.enable)
        self.main_window.writeAccessNeeded(self.enable)

        self.add_button = AddButton()
        self.add_button.setText(tr("Add a range"))
        self.main_window.writeAccessNeeded(self.add_button)
        form_layout.addRow(self.add_button, QLabel())
        if not self.main_window.readonly:
            self.connect(self.enable, SIGNAL('stateChanged(int)'), self.setDHCPEnabled)
            self.connect(self.add_button, SIGNAL('clicked()'), self.addRange)

        self.setLayout(form_layout)
Example #2
0
class RegSubmitDialog(QDialog):
    def __init__(self, parent, reg):
        flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
        QDialog.__init__(self, parent, flags)
        self._setupUi()
        self.reg = reg
        
        self.submitButton.clicked.connect(self.submitClicked)
        self.contributeButton.clicked.connect(self.contributeClicked)
        self.cancelButton.clicked.connect(self.reject)
    
    def _setupUi(self):
        self.setWindowTitle(tr("Enter your registration key"))
        self.resize(365, 126)
        self.verticalLayout = QVBoxLayout(self)
        self.promptLabel = QLabel(self)
        appname = str(QCoreApplication.instance().applicationName())
        prompt = tr("Type the key you received when you contributed to $appname, as well as the "
            "e-mail used as a reference for the purchase.").replace('$appname', appname)
        self.promptLabel.setText(prompt)
        self.promptLabel.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
        self.promptLabel.setWordWrap(True)
        self.verticalLayout.addWidget(self.promptLabel)
        self.formLayout = QFormLayout()
        self.formLayout.setSizeConstraint(QLayout.SetNoConstraint)
        self.formLayout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
        self.formLayout.setLabelAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
        self.formLayout.setFormAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
        self.label2 = QLabel(self)
        self.label2.setText(tr("Registration key:"))
        self.formLayout.setWidget(0, QFormLayout.LabelRole, self.label2)
        self.label3 = QLabel(self)
        self.label3.setText(tr("Registered e-mail:"))
        self.formLayout.setWidget(1, QFormLayout.LabelRole, self.label3)
        self.codeEdit = QLineEdit(self)
        self.formLayout.setWidget(0, QFormLayout.FieldRole, self.codeEdit)
        self.emailEdit = QLineEdit(self)
        self.formLayout.setWidget(1, QFormLayout.FieldRole, self.emailEdit)
        self.verticalLayout.addLayout(self.formLayout)
        self.horizontalLayout = QHBoxLayout()
        self.contributeButton = QPushButton(self)
        self.contributeButton.setText(tr("Contribute"))
        self.contributeButton.setAutoDefault(False)
        self.horizontalLayout.addWidget(self.contributeButton)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.cancelButton = QPushButton(self)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.cancelButton.sizePolicy().hasHeightForWidth())
        self.cancelButton.setSizePolicy(sizePolicy)
        self.cancelButton.setText(tr("Cancel"))
        self.cancelButton.setAutoDefault(False)
        self.horizontalLayout.addWidget(self.cancelButton)
        self.submitButton = QPushButton(self)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.submitButton.sizePolicy().hasHeightForWidth())
        self.submitButton.setSizePolicy(sizePolicy)
        self.submitButton.setText(tr("Submit"))
        self.submitButton.setAutoDefault(False)
        self.submitButton.setDefault(True)
        self.horizontalLayout.addWidget(self.submitButton)
        self.verticalLayout.addLayout(self.horizontalLayout)
    
    #--- Events
    def contributeClicked(self):
        self.reg.app.contribute()
    
    def submitClicked(self):
        code = self.codeEdit.text()
        email = self.emailEdit.text()
        if self.reg.app.set_registration(code, email, False):
            self.accept()
Example #3
0
class RegSubmitDialog(QDialog):
    def __init__(self, parent, reg):
        flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint
        QDialog.__init__(self, parent, flags)
        self._setupUi()
        self.reg = reg
        
        self.submitButton.clicked.connect(self.submitClicked)
        self.contributeButton.clicked.connect(self.contributeClicked)
        self.cancelButton.clicked.connect(self.reject)
    
    def _setupUi(self):
        self.setWindowTitle(tr("Enter your registration key"))
        self.resize(365, 126)
        self.verticalLayout = QVBoxLayout(self)
        self.promptLabel = QLabel(self)
        appname = str(QCoreApplication.instance().applicationName())
        prompt = tr("Type the key you received when you contributed to $appname, as well as the "
            "e-mail used as a reference for the purchase.").replace('$appname', appname)
        self.promptLabel.setText(prompt)
        self.promptLabel.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
        self.promptLabel.setWordWrap(True)
        self.verticalLayout.addWidget(self.promptLabel)
        self.formLayout = QFormLayout()
        self.formLayout.setSizeConstraint(QLayout.SetNoConstraint)
        self.formLayout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
        self.formLayout.setLabelAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
        self.formLayout.setFormAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
        self.label2 = QLabel(self)
        self.label2.setText(tr("Registration key:"))
        self.formLayout.setWidget(0, QFormLayout.LabelRole, self.label2)
        self.label3 = QLabel(self)
        self.label3.setText(tr("Registered e-mail:"))
        self.formLayout.setWidget(1, QFormLayout.LabelRole, self.label3)
        self.codeEdit = QLineEdit(self)
        self.formLayout.setWidget(0, QFormLayout.FieldRole, self.codeEdit)
        self.emailEdit = QLineEdit(self)
        self.formLayout.setWidget(1, QFormLayout.FieldRole, self.emailEdit)
        self.verticalLayout.addLayout(self.formLayout)
        self.horizontalLayout = QHBoxLayout()
        self.contributeButton = QPushButton(self)
        self.contributeButton.setText(tr("Contribute"))
        self.contributeButton.setAutoDefault(False)
        self.horizontalLayout.addWidget(self.contributeButton)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.cancelButton = QPushButton(self)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.cancelButton.sizePolicy().hasHeightForWidth())
        self.cancelButton.setSizePolicy(sizePolicy)
        self.cancelButton.setText(tr("Cancel"))
        self.cancelButton.setAutoDefault(False)
        self.horizontalLayout.addWidget(self.cancelButton)
        self.submitButton = QPushButton(self)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.submitButton.sizePolicy().hasHeightForWidth())
        self.submitButton.setSizePolicy(sizePolicy)
        self.submitButton.setText(tr("Submit"))
        self.submitButton.setAutoDefault(False)
        self.submitButton.setDefault(True)
        self.horizontalLayout.addWidget(self.submitButton)
        self.verticalLayout.addLayout(self.horizontalLayout)
    
    #--- Events
    def contributeClicked(self):
        self.reg.app.contribute()
    
    def submitClicked(self):
        code = self.codeEdit.text()
        email = self.emailEdit.text()
        if self.reg.app.set_registration(code, email, False):
            self.accept()
Example #4
0
class BuildPane(QWidget):
    def __init__(self, model):
        QWidget.__init__(self)
        self._setupUi()
        self.model = model
        self.model.view = self
        
        self.generateMarkdownButton.clicked.connect(self.model.generate_markdown)
        self.editMarkdownButton.clicked.connect(self.model.edit_markdown)
        self.revealMarkdownButton.clicked.connect(self.model.reveal_markdown)
        self.viewHtmlButton.clicked.connect(self.model.view_html)
        self.createEbookButton.clicked.connect(self.createEbookClicked)
    
    def _setupUi(self):
        self.mainLayout = QVBoxLayout(self)
        self.label1 = QLabel("Step 1: Generate Markdown")
        self.mainLayout.addWidget(self.label1)
        self.generateMarkdownButton = QPushButton("Generate Markdown")
        self.mainLayout.addWidget(self.generateMarkdownButton)
        self.genDescLabel = QLabel()
        sizePolicy = QSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)
        self.genDescLabel.setSizePolicy(sizePolicy)
        self.mainLayout.addWidget(self.genDescLabel)
        self.label2 = QLabel("Step 2: Post-processing")
        self.mainLayout.addWidget(self.label2)
        self.editMarkdownButton = QPushButton("Edit Markdown")
        self.mainLayout.addWidget(self.editMarkdownButton)
        self.revealMarkdownButton = QPushButton("Reveal Markdown")
        self.mainLayout.addWidget(self.revealMarkdownButton)
        self.viewHtmlButton = QPushButton("View HTML")
        self.mainLayout.addWidget(self.viewHtmlButton)
        self.label2 = QLabel("Step 3: E-book creation")
        self.mainLayout.addWidget(self.label2)
        self.radioLayout = QHBoxLayout()
        self.mobiRadio = QRadioButton("MOBI")
        self.radioLayout.addWidget(self.mobiRadio)
        self.epubRadio = QRadioButton("EPUB")
        self.radioLayout.addWidget(self.epubRadio)
        self.mobiRadio.setChecked(True)
        self.mainLayout.addLayout(self.radioLayout)
        self.metadataLayout = QFormLayout()
        self.metadataLayout.setFormAlignment(Qt.AlignLeft|Qt.AlignTop)
        self.titleEdit = QLineEdit()
        self.metadataLayout.addRow("Title:", self.titleEdit)
        self.authorEdit = QLineEdit()
        self.metadataLayout.addRow("Author:", self.authorEdit)
        self.mainLayout.addLayout(self.metadataLayout)
        self.createEbookButton = QPushButton("Create e-book")
        self.mainLayout.addWidget(self.createEbookButton)
        self.mainLayout.addItem(verticalSpacer())
    
    #--- Signals
        
    def createEbookClicked(self):
        ebook_type = EbookType.EPUB if self.epubRadio.isChecked() else EbookType.MOBI
        self.model.selected_ebook_type = ebook_type
        self.model.ebook_title = self.titleEdit.text()
        self.model.ebook_author = self.authorEdit.text()
        self.model.create_ebook()
    
    #--- model --> view
    def refresh(self):
        self.genDescLabel.setText(self.model.lastgen_desc)
        enabled = self.model.post_processing_enabled
        self.editMarkdownButton.setEnabled(enabled)
        self.revealMarkdownButton.setEnabled(enabled)
        self.viewHtmlButton.setEnabled(enabled)
        self.createEbookButton.setEnabled(enabled)