Beispiel #1
0
    def __init__(self, title, maxLength=64, parent=None):
        super().__init__(parent)

        self.app = QApplication.instance()
        self.title = title

        self.setWindowTitle(iTitle())

        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        buttonBox.setCenterButtons(True)

        layout = QVBoxLayout()
        layout.addWidget(QLabel(iTitle()))

        self.tEdit = QLineEdit(self)
        self.tEdit.setMaxLength(maxLength)
        self.tEdit.setText(title[0:maxLength - 1])

        layout.addWidget(self.tEdit)
        layout.addWidget(buttonBox)

        self.setLayout(layout)
Beispiel #2
0
    def __init__(self, env, *args, **kwargs):
        super(ClearLWTDialog, self).__init__(*args, **kwargs)
        self.setWindowTitle("Clear obsolete retained LWTs")
        self.setMinimumSize(QSize(320, 480))

        self.env = env

        vl = VLayout()

        sel_btns = QDialogButtonBox()
        sel_btns.setCenterButtons(True)
        btnSelAll = sel_btns.addButton("Select all",
                                       QDialogButtonBox.ActionRole)
        btnSelNone = sel_btns.addButton("Select none",
                                        QDialogButtonBox.ActionRole)

        self.lw = QListWidget()

        for lwt in self.env.lwts:
            itm = QListWidgetItem(lwt)
            itm.setCheckState(Qt.Unchecked)
            self.lw.addItem(itm)

        btnSelAll.clicked.connect(lambda: self.select(Qt.Checked))
        btnSelNone.clicked.connect(lambda: self.select(Qt.Unchecked))

        btns = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Close)
        btns.accepted.connect(self.accept)
        btns.rejected.connect(self.reject)

        vl.addWidgets([sel_btns, self.lw, btns])
        self.setLayout(vl)
Beispiel #3
0
    def __init__(self, ipfsPath, downItem, prechoice, parent=None):
        super().__init__(parent)

        self.setWindowTitle(iDownloadOpenDialog())
        self.app = QApplication.instance()
        self.downloadItem = downItem
        self.objectPath = ipfsPath

        self.choiceCombo = QComboBox(self)
        self.choiceCombo.addItem(iDownload())
        self.choiceCombo.addItem(iOpen())
        self.choiceCombo.currentIndexChanged.connect(self.onChoiceChange)

        if prechoice == 'open':
            self.choiceCombo.setCurrentIndex(1)

        label = QLabel(ipfsPath.ipfsUrl)
        label.setMaximumWidth(self.app.desktopGeometry.width() / 2)
        label.setWordWrap(True)
        label.setStyleSheet(boldLabelStyle())

        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
        buttonBox.setCenterButtons(True)

        layout = QVBoxLayout()
        layout.addWidget(label)
        layout.addWidget(self.choiceCombo)
        layout.addWidget(buttonBox)

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        self.setLayout(layout)
Beispiel #4
0
    def __init__(self,
                 label,
                 maxLength=64,
                 inputRegExp=r"[A-Za-z0-9/\-]+",
                 title=None,
                 parent=None):
        super().__init__(parent)

        if title:
            self.setWindowTitle(title)

        self.app = QApplication.instance()
        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        buttonBox.setCenterButtons(True)

        layout = QVBoxLayout()
        layout.addWidget(QLabel(label))

        self.tEdit = QLineEdit(self)
        self.tEdit.setMaxLength(maxLength)
        self.tEdit.setMaxLength(maxLength)

        self.tEdit.setValidator(QRegExpValidator(QRegExp(inputRegExp)))

        layout.addWidget(self.tEdit)
        layout.addWidget(buttonBox)

        self.setLayout(layout)
Beispiel #5
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        self.setLayout(QVBoxLayout())
        self.layout().setSizeConstraint(QLayout.SetFixedSize)

        application_label = QLabel('<h1>%s</h1>' % common.APPLICATION_NAME)
        application_label.setAlignment(Qt.AlignCenter)
        self.layout().addWidget(application_label)

        version_label = QLabel('<h2>Version %s</h2>' % __version__)
        version_label.setAlignment(Qt.AlignCenter)
        self.layout().addWidget(version_label)

        if common.BUILD:
            build_label = QLabel('<h3>Build %s</h3>' % common.BUILD)
            build_label.setAlignment(Qt.AlignCenter)
            self.layout().addWidget(build_label)

        copyright_label = QLabel(__copyright__)
        self.layout().addWidget(copyright_label)

        contact_label = QLabel('    For support, contact %s <%s>.' % (__maintainer__, __email__))
        self.layout().addWidget(contact_label)

        button_box = QDialogButtonBox(QDialogButtonBox.Ok)
        button_box.setCenterButtons(True)
        button_box.accepted.connect(self.accept)
        self.layout().addWidget(button_box)
Beispiel #6
0
def questionBoxCreate(message, title=None):
    app = QApplication.instance()

    msgBox = QDialog()
    msgBox.setObjectName('questionBox')
    msgBox._question_result = False

    buttonBox = QDialogButtonBox(QDialogButtonBox.Yes | QDialogButtonBox.No)
    buttonBox.setCenterButtons(True)

    def _callback(box, val):
        box._question_result = val
        box.done(0)

    buttonBox.accepted.connect(lambda: _callback(msgBox, True))
    buttonBox.rejected.connect(lambda: _callback(msgBox, False))

    label = QLabel(message)
    label.setAlignment(Qt.AlignCenter)
    label.setWordWrap(True)

    layout = QVBoxLayout()
    layout.addWidget(label)
    layout.addWidget(buttonBox)

    msgBox.setLayout(layout)
    msgBox.setMinimumWidth(app.desktopGeometry.width() / 3)
    msgBox.setWindowTitle(title if title else 'galacteek: Question')

    return msgBox
Beispiel #7
0
class SizeWarning(QDialog):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setObjectName("Size Warning")
        self.resize(400, 287)
        self.verticalLayout = QVBoxLayout(self)
        self.verticalLayout.setObjectName("verticalLayout")
        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.No|QDialogButtonBox.Yes)
        self.buttonBox.setCenterButtons(True)
        self.label = QLabel(self)
        self.label.setScaledContents(True)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.label_2 = QLabel(self)
        font = QFont()
        font.setFamily("Ubuntu")
        self.label_2.setFont(font)
        self.label_2.setTextFormat(Qt.RichText)
        self.label_2.setScaledContents(False)
        self.label_2.setAlignment(Qt.AlignHCenter|Qt.AlignTop)
        self.label_2.setWordWrap(True)
        self.label_2.setObjectName("label_2")
        self.verticalLayout.addWidget(self.label_2)
        self.verticalLayout.addWidget(self.buttonBox)

        QMetaObject.connectSlotsByName(self)

        _translate = QCoreApplication.translate
        self.setWindowTitle(_translate("Size Warning", "Size Warning"))
        self.label.setText(_translate("self", "<html><head/><body><p align=\"center\"><img src=\":/icons/dialog-warning.svg\"/></p></body></html>"))
        self.label_2.setText(_translate("self", "<html><head/><body><p align=\"center\">Warning</p><p align=\"center\"><span style=\" font-size:9pt;\">The file you are attempting to open is very large (2000+ lines). Codeblock Visual Studio may freeze or lag. Are you sure you want to continue?</span></p>"))
Beispiel #8
0
 def __init__(self, *args) -> None:
     super().__init__(*args)
     self.setWindowTitle("Choose Index Size")
     self.set_size(360, 320)
     self._heading = heading = QLabel(self)  # Index size description label.
     heading.setWordWrap(True)
     self._slider = slider = TooltipSlider(
         self)  # Horizontal slider widget.
     slider.setOrientation(Qt.Horizontal)
     slider.setTickPosition(QSlider.TicksBelow)
     slider.setTickInterval(1)
     desc_label = QLabel(self)
     desc_label.setWordWrap(True)
     desc_label.setText(SIZE_WARNING)
     button_box = QDialogButtonBox(self)
     button_box.setStandardButtons(QDialogButtonBox.Ok
                                   | QDialogButtonBox.Cancel)
     button_box.setCenterButtons(True)
     button_box.accepted.connect(self._check_accept)
     button_box.rejected.connect(self.reject)
     layout = QVBoxLayout(self)
     layout.addWidget(heading)
     layout.addWidget(slider)
     layout.addWidget(desc_label)
     layout.addWidget(button_box)
     self.call_on_size_accept = self._sig_accept.connect
Beispiel #9
0
    def __init__(self, rscPath, mType, secureEnv, parent=None):
        super().__init__(parent)

        self.rscPath = rscPath
        self.setWindowTitle('Open IPFS object')

        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        buttonBox.setCenterButtons(True)

        layout = QVBoxLayout()

        label = QLabel(self.message.format(p=str(rscPath), mtype=mType.type))
        label.setMaximumWidth(600)
        label.setWordWrap(True)

        layout.addWidget(label)

        if not secureEnv:
            wLabel = QLabel('<p style="color: red"> '
                            'You are trying to open this object '
                            'from an insecure context.'
                            '</font>')
            layout.addWidget(wLabel)

        layout.addWidget(buttonBox)

        self.setLayout(layout)
Beispiel #10
0
class frmQuotesSaveResult(MyModalQDialog):
    def __init__(self, parent=None):
        MyModalQDialog.__init__(self, parent=None)
        self._fileToDelete = None
        self.wdg = wdgQuotesSaveResult(self)
        self.setWindowTitle(self.tr("Report after saving quotes"))

        self.chkDeleteFile = QCheckBox(self)
        self.chkDeleteFile.setChecked(True)
        self.bb = QDialogButtonBox(self)
        self.bb.setStandardButtons(QDialogButtonBox.Cancel
                                   | QDialogButtonBox.Ok)
        self.bb.setCenterButtons(True)
        self.bb.accepted.connect(self.on_bb_accepted)
        self.bb.rejected.connect(self.on_bb_rejected)

    ## Sets the filename to delete before clossing
    def setFileToDelete(self, filename):
        self._fileToDelete = filename
        self.chkDeleteFile.setText(
            self.tr(
                "Delete '{}' after accepting this dialog".format(filename)))

    def fileToDelete(self):
        return self._fileToDelete

    @pyqtSlot()
    def on_bb_accepted(self):
        if self.chkDeleteFile.isChecked() == True:
            remove(self.fileToDelete())
            if path.exists(self.fileToDelete()) == True:
                qmessagebox(self.tr("There was an error deleting file"))
        self.mem.con.commit()
        self.accept()

    @pyqtSlot()
    def on_bb_rejected(self):
        self.mem.con.rollback()
        self.reject()  #No haría falta pero para recordar que hay buttonbox

    def setQuotesManagers(self, added, ignored, updated, errors):
        self.mem = added.mem
        self.setSettings(self.mem.settings, "frmQuotesSaveResult", "myqdialog")
        self.setWidgets(self.wdg, self.chkDeleteFile, self.bb)
        self.wdg.display(self.mem, added, ignored, updated, errors)

    def exec_(self):
        if self.fileToDelete() == None:
            self.chkDeleteFile.hide()
        MyModalQDialog.exec_(self)
Beispiel #11
0
    def __init__(self, text, parent=None):
        super().__init__(parent)

        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok, self)
        buttonBox.accepted.connect(self.accept)
        buttonBox.setCenterButtons(True)

        self.setWindowTitle('About')

        layout = QVBoxLayout()
        layout.addWidget(LabelWithURLOpener(text, parent=self))
        layout.addWidget(buttonBox)

        self.setLayout(layout)
Beispiel #12
0
    def __init__(self, zwift_uid, parent=None):
        super().__init__(parent=parent)
        self.zwift_uid = zwift_uid
        self.profile_bin = STORAGE_DIR_PATH / str(
            self.zwift_uid) / 'profile.bin'
        self.profile_proto = Profile()
        only_int_validator = QIntValidator(0, 999999999, self)
        layout = QGridLayout(self)
        self.setLayout(layout)
        distance_label = QLabel('骑行里程 (m)', self)
        self.distance_editor = QLineEdit(self)
        self.distance_editor.setValidator(only_int_validator)
        layout.addWidget(distance_label, 0, 0)
        layout.addWidget(self.distance_editor, 0, 1)

        elevation_gain_label = QLabel('爬升里程 (m)', self)
        self.elevation_gain_editor = QLineEdit(self)
        self.elevation_gain_editor.setValidator(only_int_validator)
        layout.addWidget(elevation_gain_label, 1, 0)
        layout.addWidget(self.elevation_gain_editor, 1, 1)

        ride_time_label = QLabel('骑行时间 (min)', self)
        self.ride_time_edit = QLineEdit(self)
        self.ride_time_edit.setValidator(only_int_validator)
        layout.addWidget(ride_time_label, 2, 0)
        layout.addWidget(self.ride_time_edit, 2, 1)

        self.xp_label = QLabel('经验值', self)
        self.xp_edit = QLineEdit(self)
        self.xp_edit.setValidator(only_int_validator)
        layout.addWidget(self.xp_label, 3, 0)
        layout.addWidget(self.xp_edit, 3, 1)

        drops_label = QLabel('汗水', self)
        self.drops_edit = QLineEdit(self)
        self.drops_edit.setValidator(only_int_validator)
        layout.addWidget(drops_label, 4, 0)
        layout.addWidget(self.drops_edit, 4, 1)

        button_box = QDialogButtonBox(self)
        button_box.setStandardButtons(QDialogButtonBox.Close
                                      | QDialogButtonBox.Save)
        button_box.setCenterButtons(True)
        layout.addWidget(button_box, 5, 1)

        button_box.accepted.connect(self.accept)
        button_box.rejected.connect(self.reject)
        self.xp_edit.textChanged.connect(self.xp_to_level)
        self.load_profile()
Beispiel #13
0
 def __init__(self, parent=None, flags=Qt.Dialog | Qt.WindowCloseButtonHint):
     super(ConsoleWidget, self).__init__(parent, flags)
     self.parent = parent
     self.edit = VideoPanel(self)
     buttons = QDialogButtonBox()
     buttons.setCenterButtons(True)
     clearButton = buttons.addButton('Clear', QDialogButtonBox.ResetRole)
     clearButton.clicked.connect(self.edit.clear)
     closeButton = buttons.addButton(QDialogButtonBox.Close)
     closeButton.clicked.connect(self.close)
     closeButton.setDefault(True)
     layout = QVBoxLayout()
     layout.addWidget(self.edit)
     layout.addWidget(buttons)
     self.setLayout(layout)
     self.setWindowTitle('{0} Console'.format(qApp.applicationName()))
     self.setWindowModality(Qt.NonModal)
Beispiel #14
0
    def _overviewDisplay(self):
        dlg = QDialog(self)
        dlg.setWindowTitle("Opis gry!")
        overviewLayout = QVBoxLayout()
        overview = QLabel(OVERVIEW_TEXT)
        overview.setWordWrap(True)
        overviewLayout.addWidget(overview)

        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
        buttonBox.setCenterButtons(True)
        buttonBox.accepted.connect(dlg.accept)
        overviewLayout.addWidget(buttonBox)

        dlg.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        dlg.setLayout(overviewLayout)

        dlg.show()
Beispiel #15
0
    def __init__(self, parent, worker, show):
        QDialog.__init__(self, parent)
        self.setMinimumSize(530, 550)
        self.setWindowTitle('Details')
        self.worker = worker

        main_layout = QVBoxLayout()
        details = DetailsWidget(self, worker)

        bottom_buttons = QDialogButtonBox(QDialogButtonBox.Close)
        bottom_buttons.setCenterButtons(True)
        bottom_buttons.rejected.connect(self.close)

        main_layout.addWidget(details)
        main_layout.addWidget(bottom_buttons)

        self.setLayout(main_layout)
        details.load(show)
Beispiel #16
0
    def initUI(self):

        layout = QVBoxLayout()

        self.nameEdit = QLineEdit()
        self.nameEdit.setPlaceholderText("Enter a name")
        self.nameEdit.setText(self.name)

        layout.addWidget(self.nameEdit)

        buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
        buttons.setCenterButtons(True)
        buttons.accepted.connect(self.onAccept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons, Qt.AlignCenter)

        self.setLayout(layout)
Beispiel #17
0
 def __init__(self, mainwindow):
     """Creates the about dialog. You can simply exec_() it."""
     super(AboutDialog, self).__init__(mainwindow)
     
     self.setWindowTitle(_("About {appname}").format(appname = appinfo.appname))
     layout = QVBoxLayout()
     self.setLayout(layout)
     
     tabw = QTabWidget()
     layout.addWidget(tabw)
     
     tabw.addTab(About(self), _("About"))
     tabw.addTab(Credits(self), _("Credits"))
     tabw.addTab(Version(self), _("Version"))
     
     button = QDialogButtonBox(QDialogButtonBox.Ok)
     button.setCenterButtons(True)
     button.accepted.connect(self.accept)
     layout.addWidget(button)
     layout.setSizeConstraint(QLayout.SetFixedSize)
Beispiel #18
0
    def __init__(self, mainwindow):
        """Creates the about dialog. You can simply exec_() it."""
        super(AboutDialog, self).__init__(mainwindow)

        self.setWindowTitle(_("About {appname}").format(appname = appinfo.appname))
        layout = QVBoxLayout()
        self.setLayout(layout)

        tabw = QTabWidget()
        layout.addWidget(tabw)

        tabw.addTab(About(self), _("About"))
        tabw.addTab(Credits(self), _("Credits"))
        tabw.addTab(Version(self), _("Version"))

        button = QDialogButtonBox(QDialogButtonBox.Ok)
        button.setCenterButtons(True)
        button.accepted.connect(self.accept)
        layout.addWidget(button)
        layout.setSizeConstraint(QLayout.SetFixedSize)
Beispiel #19
0
 def __init__(self, *args) -> None:
     super().__init__(*args)
     self.setWindowTitle("Configuration Options")
     self.setMinimumSize(250, 300)
     self.setMaximumSize(250, 300)
     self._tabs = QTabWidget(
     )  # Central tab widget for the config info rows.
     self._widgets = OptionWidgets(
     )  # Contains all active config option widgets.
     self._pages = {}  # Contains each tab page layout indexed by name.
     button_box = QDialogButtonBox(self)
     button_box.setStandardButtons(QDialogButtonBox.Ok
                                   | QDialogButtonBox.Cancel)
     button_box.setCenterButtons(True)
     button_box.accepted.connect(self._check_accept)
     button_box.rejected.connect(self.reject)
     layout = QVBoxLayout(self)
     layout.addWidget(self._tabs)
     layout.addWidget(button_box)
     self.call_on_options_accept = self._sig_accept.connect
    def _showAboutDialog(self):
        try:
            dialogAbout = QDialog()
            dialogAbout.resize(320, 180)
            dialogButtonBoxAbout = QDialogButtonBox(dialogAbout)
            dialogButtonBoxAbout.setLayoutDirection(Qt.LeftToRight)
            dialogButtonBoxAbout.setAutoFillBackground(False)
            dialogButtonBoxAbout.setOrientation(Qt.Horizontal)
            dialogButtonBoxAbout.setStandardButtons(QtWidgets.QDialogButtonBox.Ok)
            dialogButtonBoxAbout.setCenterButtons(True)
            dialogButtonBoxAbout.accepted.connect(dialogAbout.accept)

            verticalLayoutAboutDialog = QVBoxLayout(dialogAbout)

            dialogAbout.setWindowTitle('About ' + AppInfo.Name)

            labelPowerBIThemeGeneratorFont = QFont()
            labelPowerBIThemeGeneratorFont.setPointSize(16)
            labelPowerBIThemeGeneratorFont.setFamily('Calibri')
            labelPowerBIThemeGenerator = QLabel(AppInfo.Name)
            labelPowerBIThemeGenerator.setFont(labelPowerBIThemeGeneratorFont)

            labelVersionFont = QFont()
            labelVersionFont.setPointSize(8)
            labelVersion = QLabel(AppInfo.Version)
            labelVersion.setContentsMargins(0, 0, 0, 0)

            labelCreatedBy = QLabel('Created By ' + AppInfo.Author)
            link = '<a href="' + AppInfo.GitHubRepoIssuesURL + '">Click here to report bugs</a>'
            labelBugs = QLabel(link)
            labelBugs.setOpenExternalLinks(True)

            verticalLayoutAboutDialog.addWidget(labelPowerBIThemeGenerator)
            verticalLayoutAboutDialog.addWidget(labelVersion)
            verticalLayoutAboutDialog.addWidget(labelCreatedBy)
            verticalLayoutAboutDialog.addWidget(labelBugs)
            verticalLayoutAboutDialog.addStretch()
            verticalLayoutAboutDialog.addWidget(dialogButtonBoxAbout)
            dialogAbout.exec_()
        except Exception as e:
            ShowErrorDialog(LogException(e))
Beispiel #21
0
 def __init__(self, icon_path=None, parent=None):
     if icon_path == None:
         self._icon_path = sys.path[0] + '/icons'
     else:
         self._icon_path = icon_path
     super(OTPUi, self).__init__(parent)
     self.setWindowTitle("OTP Manager")
     self._mainLayout = QVBoxLayout()
     self._otpLayout = QGridLayout()
     self._mainLayout.addLayout(self._otpLayout)
     self.logoutBtn = QPushButton()
     self.logoutBtn.setIcon(QIcon(os.path.join(self._icon_path, "sign-out-alt-solid.svg")))
     self.logoutBtn.setStyleSheet("background-color: rgba(255, 255, 255, 0);")
     self.addBtn = QPushButton()
     self.addBtn.setIcon(QIcon(os.path.join(self._icon_path, "plus-square-solid.svg")))
     self.addBtn.setStyleSheet("background-color: rgba(255, 255, 255, 0);")
     buttonBox = QDialogButtonBox()
     buttonBox.addButton(self.addBtn, QDialogButtonBox.ActionRole)
     buttonBox.addButton(self.logoutBtn, QDialogButtonBox.ActionRole)
     buttonBox.setCenterButtons(True)
     self._mainLayout.addWidget(buttonBox)
     self.setLayout(self._mainLayout)
     self.rows = {}
Beispiel #22
0
 def __init__(self, parent=None):
     super(PasswordDialog, self).__init__(parent)
     lable = QLabel('输入密码')
     self.hint_lable = QLabel()
     self.password = QLineEdit()
     self.usertype = 0
     self.password.setEchoMode(QLineEdit.Password)
     okBtn = QDialogButtonBox(QDialogButtonBox.Ok)
     okBtn.accepted.connect(self.clickOk)
     okBtn.setCenterButtons(True)
     cancelBtn = QDialogButtonBox(QDialogButtonBox.Cancel)
     cancelBtn.rejected.connect(self.clickCancel)
     cancelBtn.setCenterButtons(True)
     hbox = QHBoxLayout()
     hbox.addWidget(okBtn)
     hbox.addWidget(cancelBtn)
     vbox = QVBoxLayout()
     vbox.addWidget(lable)
     vbox.addWidget(self.password)
     vbox.addWidget(self.hint_lable)
     vbox.addLayout(hbox)
     self.setLayout(vbox)
     self.setWindowTitle('密码弹窗')
Beispiel #23
0
class TipInfoDialog(QDialog):
    def __init__(self, parent):
        super(TipInfoDialog, self).__init__(parent)
        self.parent = parent
        self.is_show = False
        self.point = QPoint()
        self.InitUserInterface()

    def __del__(self):
        pass

    def InitUserInterface(self):
        win_size_x = 395
        win_size_y = 90 # 两行文字,110 三行文字
        self.resize(win_size_x, win_size_y)
        self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool)
        
        self.widget = QWidget()
        self.widget.setGeometry(QRect(0, 0, win_size_x, win_size_y))
        
        self.text_edit = QTextEdit()
        self.text_edit.setFont(QFont("SimSun", 10))
        self.text_edit.setReadOnly(True)
        self.text_edit.setLineWrapMode(QTextEdit.WidgetWidth)
        self.text_edit.document().setDefaultTextOption(QTextOption(Qt.AlignCenter))
        
        self.button_box = QDialogButtonBox(self.widget)
        self.button_box.setStandardButtons(QDialogButtonBox.Ok)
        self.button_box.button(QDialogButtonBox.Ok).setText("已  阅")
        self.button_box.setCenterButtons(True)
        self.button_box.accepted.connect(self.OnButtonClose)
        
        self.v_box = QVBoxLayout()
        self.v_box.setContentsMargins(5, 5, 5, 5)
        self.spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.v_box.addWidget(self.text_edit)
        self.v_box.addItem(self.spacer)
        self.v_box.addWidget(self.button_box)
        self.setLayout(self.v_box)
        
        self.timer_show = QTimer()
        self.timer_stay = QTimer()
        self.timer_hide = QTimer()
        
        self.timer_show.timeout.connect(self.OnTimerShow)
        self.timer_stay.timeout.connect(self.OnTimerStay)
        self.timer_hide.timeout.connect(self.OnTimerHide)
        
        pub.subscribe(self.OnTipInfoMessage, "tip.info.message")

    def OnTipInfoMessage(self, msg):
        self.ShowMessage(msg)

    def ShowMessage(self, msg):
        if self.is_show == True:
            self.OnButtonClose()
        
        self.rect_desktop = QApplication.desktop().availableGeometry()
        self.desktop_height = self.rect_desktop.height()
        self.point.setX(self.rect_desktop.width() - self.width())
        self.point.setY(self.rect_desktop.height() - self.height())
        
        self.move(self.point.x(), self.desktop_height)
        
        self.text_edit.clear()
        self.text_edit.append(msg)
        
        self.transparent = 0.9
        self.setWindowOpacity(self.transparent)
        
        self.show()
        
        self.is_show = True
        
        self.timer_show.start(10)

    def OnTimerShow(self):
        self.desktop_height -= 1
        self.move(self.point.x(), self.desktop_height)
        if self.desktop_height <= self.point.y():
            self.timer_show.stop()
            self.timer_stay.start(8000)

    def OnTimerStay(self):
        self.timer_stay.stop()
        self.timer_hide.start(100)

    def OnTimerHide(self):
        self.transparent -= 0.05
        if self.transparent <= 0.0:
            self.timer_hide.stop()
            self.is_show = False
            self.close()
        else:
            self.setWindowOpacity(self.transparent)

    def OnButtonClose(self):
        self.timer_show.stop()
        self.timer_stay.stop()
        self.timer_hide.stop()
        self.is_show = False
        self.close()
Beispiel #24
0
    def __init__(self, marks, pyramidType, parent=None):
        super().__init__(parent)

        self.app = QApplication.instance()

        self.marks = marks
        self.pyramidType = pyramidType
        self.iconCid = None
        self.customCategory = 'general'
        self.autoSyncPath = None

        label = QLabel('Pyramid name')
        restrictRegexp = QRegExp("[0-9A-Za-z-_]+")  # noqa
        restrictRegexp2 = QRegExp("[0-9A-Za-z-_/]+")  # noqa

        self.nameLine = QLineEdit()
        self.nameLine.setMaxLength(32)
        self.nameLine.setValidator(QRegExpValidator(restrictRegexp))
        label.setBuddy(self.nameLine)

        buttonBox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
        buttonBox.setCenterButtons(True)

        catCustomLabel = QLabel('Or create new category')
        catCustomLayout = QHBoxLayout()

        self.catCustom = QLineEdit()
        self.catCustom.setMaxLength(32)
        self.catCustom.setValidator(QRegExpValidator(restrictRegexp2))
        self.catCustom.textChanged.connect(self.onCustomCategory)
        catCustomLabel.setBuddy(self.catCustom)
        catCustomLayout.addWidget(catCustomLabel)
        catCustomLayout.addWidget(self.catCustom)

        descrLabel = QLabel('Description')
        self.descrLine = QLineEdit()
        self.descrLine.setMaxLength(128)
        descrLabel.setBuddy(self.descrLine)
        descrLayout = QHBoxLayout()
        descrLayout.addWidget(descrLabel)
        descrLayout.addWidget(self.descrLine)

        nameLayout = QHBoxLayout()
        nameLayout.addWidget(label)
        nameLayout.addWidget(self.nameLine)

        extraLayout = QVBoxLayout()

        if pyramidType == MultihashPyramid.TYPE_AUTOSYNC:
            layout1 = QHBoxLayout()
            layout2 = QHBoxLayout()

            self.checkBoxHiddenFiles = QCheckBox('Import hidden files')
            self.checkBoxHiddenFiles.setCheckState(Qt.Unchecked)
            self.checkBoxFileStore = QCheckBox('Use Filestore if available')
            self.checkBoxFileStore.setCheckState(Qt.Unchecked)
            self.checkBoxUnpinPrev = QCheckBox('Unpin old content')
            self.checkBoxUnpinPrev.setCheckState(Qt.Unchecked)
            self.checkBoxDirWrap = QCheckBox('Wrap with directory')
            self.checkBoxDirWrap.setCheckState(Qt.Unchecked)
            self.checkBoxStartupSync = QCheckBox('Sync on startup')
            self.checkBoxStartupSync.setCheckState(Qt.Unchecked)

            self.spinBoxSyncDelay = QSpinBox()
            self.spinBoxSyncDelay.setMinimum(1)
            self.spinBoxSyncDelay.setMaximum(3600)
            self.spinBoxSyncDelay.setValue(10)

            self.ignRulesPath = QLineEdit()
            self.ignRulesPath.setMaxLength(32)
            self.ignRulesPath.setText('.gitignore')

            layout1.addWidget(QLabel('Import delay (seconds)'))
            layout1.addWidget(self.spinBoxSyncDelay)

            layout2.addWidget(QLabel('Ignore rules path'))
            layout2.addWidget(self.ignRulesPath)

            labelOr = QLabel('or')
            labelOr.setAlignment(Qt.AlignCenter)

            self.syncDirButton = QPushButton('Choose a directory to auto-sync')
            self.syncDirButton.clicked.connect(self.onChooseSyncDir)
            self.syncFileButton = QPushButton('Choose a file to auto-sync')
            self.syncFileButton.clicked.connect(self.onChooseSyncFile)
            self.syncPathLabel = QLabel('No path selected')
            self.syncPathLabel.setAlignment(Qt.AlignCenter)
            extraLayout.addWidget(self.syncPathLabel)
            extraLayout.addWidget(self.syncDirButton)
            extraLayout.addWidget(labelOr)
            extraLayout.addWidget(self.syncFileButton)
            extraLayout.addWidget(self.checkBoxHiddenFiles)
            extraLayout.addWidget(self.checkBoxDirWrap)
            extraLayout.addWidget(self.checkBoxFileStore)
            extraLayout.addWidget(self.checkBoxStartupSync)
            extraLayout.addLayout(layout1)
            extraLayout.addLayout(layout2)

        self.iconSelector = IconSelector()
        self.iconSelector.iconSelected.connect(self.onIconSelected)

        self.lifetimeCombo = QComboBox(self)
        self.lifetimeCombo.addItem('24h')
        self.lifetimeCombo.addItem('48h')
        self.lifetimeCombo.addItem('96h')
        self.lifetimeCombo.setCurrentText('48h')
        ipnsLTimeLayout = QHBoxLayout()
        ipnsLTimeLayout.addWidget(QLabel('IPNS record lifetime'))
        ipnsLTimeLayout.addWidget(self.lifetimeCombo)

        pickIconLayout = QHBoxLayout()
        pickIconLayout.addWidget(QLabel('Choose an icon'))
        pickIconLayout.addWidget(self.iconSelector)

        mainLayout = QGridLayout()
        mainLayout.addLayout(nameLayout, 0, 0)
        mainLayout.addLayout(descrLayout, 1, 0)
        mainLayout.addWidget(HorizontalLine(self), 2, 0)
        mainLayout.addLayout(extraLayout, 3, 0)
        mainLayout.addWidget(HorizontalLine(self), 4, 0)
        mainLayout.addLayout(ipnsLTimeLayout, 5, 0)
        mainLayout.addLayout(pickIconLayout, 6, 0)
        mainLayout.addWidget(buttonBox, 7, 0)

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        self.setLayout(mainLayout)

        self.nameLine.setFocus(Qt.OtherFocusReason)

        self.setMinimumWidth(self.app.desktopGeometry.width() / 3)
        self.setWindowIcon(getIcon('pyramid-aqua.png'))
    def getvalBtns(self, val):
        if val == 0:

            dlg = QDialog(self, Qt.Dialog |
                          Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
            dlg.setStyleSheet('''background-color:#81848c;''')
            dlg.resize(dlg.width() * 2.5, dlg.height() * 3.2)

            buttonBox = QDialogButtonBox(QDialogButtonBox.Ok)
            buttonBox.setCursor(Qt.PointingHandCursor)
            buttonBox.setStyleSheet('''
                QPushButton{
                    background-color:#585b63;font-size:13px;
                    border:1px solid #21242c;padding:0.2em 0;
                    width:60px;
                }
                QPushButton::pressed{
                    background-color:#76798e;color:#ffffff;
                    border-color:#a3a6bb;
                }''')

            buttonBox.setCenterButtons(True)
            buttonBox.accepted.connect(dlg.close)

            lbl = QLabel('Системные настройки указателя востнановленны.')
            lbl.setAlignment(Qt.AlignCenter)
            fnt = QFont('Helvetica, Arial, sans-serif', 10)
            fnt.setBold(True)
            lbl.setFont(fnt)
            lbl.setWordWrap(True)

            vlayout = QVBoxLayout()
            vlayout.addWidget(lbl)
            vlayout.addWidget(buttonBox)

            dlg.setLayout(vlayout)
            dlg.exec_()
        elif val == 1:
            launch_webbrowser('https://pcompstart.com/')
        elif val == 2:
            # QDialog - контейнер для кнопок
            dlg = QDialog(self, Qt.Dialog |
                          Qt.WindowTitleHint | Qt.WindowCloseButtonHint)
            dlg.setStyleSheet('''background-color:#81848c;''')
            dlg.resize(dlg.width() * 2.5, dlg.height() * 3.2)

            """`ProjButton` создание кнопки для преврашения
                в последующее пустое место, между кнопками в
                `QDialogButtonBox`"""
            projbutton = ProjButton('')

            # `QDialogButtonBox` - кнопки `Reset` и `Cancel`
            buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel)
            buttonBox.addButton('Reset', QDialogButtonBox.AcceptRole)
            buttonBox.addButton(projbutton, QDialogButtonBox.ActionRole)
            buttonBox.setCursor(Qt.PointingHandCursor)
            buttonBox.setStyleSheet('''
                QPushButton{
                    background-color:#585b63;font-size:13px;
                    border:1px solid #21242c;padding:0.2em 0;
                    width:60px;
                }
                QPushButton::pressed{
                    background-color:#76798e;color:#ffffff;
                    border-color:#a3a6bb;
                }''')

            projbutton.setCursor(Qt.ArrowCursor)
            projbutton.setStyleSheet('''
                background:transparent;border:transparent;
                width:20px;''')

            buttonBox.setCenterButtons(True)
            buttonBox.accepted.connect(self.on_quit)
            buttonBox.rejected.connect(dlg.close)

            lbl = QLabel('После сброса, требуется перезапустить программу.')
            lbl.setAlignment(Qt.AlignCenter)
            fnt = QFont('Helvetica, Arial, sans-serif', 10)
            fnt.setBold(True)
            lbl.setFont(fnt)
            lbl.setWordWrap(True)

            vlayout = QVBoxLayout()
            vlayout.addWidget(lbl)
            vlayout.addWidget(buttonBox)

            dlg.setLayout(vlayout)
            dlg.exec_()
Beispiel #26
0
class MainWindow(QDialog, SetupTabStopsMixin, CenterOnScreenMixin):
    WINDOW_TITLE_TEXT = 'BAON'
    OPTIONS_BOX_TEXT = 'Options'
    SCAN_RECURSIVE_CHECKBOX_TEXT = 'Recursively scan subfolders'
    USE_PATH_CHECKBOX_TEXT = 'Use path'
    USE_EXTENSION_CHECKBOX_TEXT = 'Use extension'
    RULES_BOX_TEXT = 'Rename Rules'
    FILES_BOX_TEXT = 'Renamed Files'

    RENAME_WARNINGS_DIALOG_CAPTION = 'Please Confirm'
    RENAME_WARNINGS_DIALOG_TEXT = 'There are warnings for some of the files. Proceed with the rename operation anyway?'

    RENAME_COMPLETE_DIALOG_CAPTION = 'Rename Complete'
    RENAME_COMPLETE_DIALOG_TEXT =\
        'The files have been renamed successfully. Do you wish to perform another rename operation?'

    DEFAULT_WINDOW_WIDTH = 800
    DEFAULT_WINDOW_HEIGHT = 600
    RULES_BOX_HEIGHT = 112

    base_path_edited = pyqtSignal(str)
    scan_recursive_changed = pyqtSignal(bool)
    rules_text_changed = pyqtSignal(str)
    use_path_changed = pyqtSignal(bool)
    use_extension_changed = pyqtSignal(bool)

    request_add_override = pyqtSignal(BAONPath, BAONPath)
    request_remove_override = pyqtSignal(BAONPath)

    request_do_rename = pyqtSignal()

    request_rescan = pyqtSignal()

    _base_path_panel = None
    _scan_recursive_checkbox = None
    _use_path_checkbox = None
    _use_extension_checkbox = None
    _rules_editor = None
    _files_display = None
    _files_display_summary_panel = None
    _status_box = None
    _dialog_button_box = None

    def __init__(self, args):
        super().__init__()

        self._init_ui()
        self._fill_in_controls(args)
        self._center_on_screen()

    def _init_ui(self):
        self.setWindowTitle(self.WINDOW_TITLE_TEXT)
        self.resize(self.DEFAULT_WINDOW_WIDTH, self.DEFAULT_WINDOW_HEIGHT)

        main_layout = QVBoxLayout(self)
        main_layout.addWidget(self._create_base_path_panel())
        main_layout.addWidget(self._create_options_box())
        main_layout.addWidget(self._create_rules_box())
        main_layout.addWidget(self._create_files_box())
        main_layout.addWidget(self._create_status_box())
        main_layout.addWidget(self._create_dialog_buttons())

        self._setup_tab_stops(
            self._base_path_panel,
            self._scan_recursive_checkbox,
            self._use_path_checkbox,
            self._use_extension_checkbox,
            self._rules_editor,
            self._files_display,
            self._files_display_summary,
            self._dialog_button_box,
        )

    def _create_base_path_panel(self):
        self._base_path_panel = BasePathPanel(self)
        self._base_path_panel.path_edited.connect(self.base_path_edited)

        return self._base_path_panel

    def _create_options_box(self):
        box = QGroupBox(self.OPTIONS_BOX_TEXT, self)

        self._scan_recursive_checkbox = QCheckBox(self.SCAN_RECURSIVE_CHECKBOX_TEXT, box)
        self._scan_recursive_checkbox.toggled.connect(self.scan_recursive_changed)

        self._use_path_checkbox = QCheckBox(self.USE_PATH_CHECKBOX_TEXT, box)
        self._use_path_checkbox.toggled.connect(self.use_path_changed)

        self._use_extension_checkbox = QCheckBox(self.USE_EXTENSION_CHECKBOX_TEXT, box)
        self._use_extension_checkbox.toggled.connect(self.use_extension_changed)

        layout = QHBoxLayout(box)
        layout.addWidget(self._scan_recursive_checkbox)
        layout.addWidget(self._use_path_checkbox)
        layout.addWidget(self._use_extension_checkbox)
        layout.addStretch()

        return box

    def _create_rules_box(self):
        box = QGroupBox(self.RULES_BOX_TEXT, self)
        box.setMaximumHeight(self.RULES_BOX_HEIGHT)

        self._rules_editor = RulesEditor(box)
        self._rules_editor.rules_edited.connect(self.rules_text_changed)

        layout = QHBoxLayout(box)
        layout.addWidget(self._rules_editor)

        return box

    def _create_files_box(self):
        box = QGroupBox(self.FILES_BOX_TEXT, self)
        box.setSizePolicy(QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding))

        self._files_display = FilesDisplay(box)
        self._files_display_summary = FilesDisplaySummaryPanel(box)

        self._files_display.request_add_override.connect(self.request_add_override)
        self._files_display.request_remove_override.connect(self.request_remove_override)

        self._files_display.counts_changed.connect(self._files_display_summary.set_counts)
        self._files_display.is_browsing_category_changed.connect(self._files_display_summary.set_is_browsing_category)
        self._files_display.has_next_in_category_changed.connect(self._files_display_summary.set_has_next_in_category)
        self._files_display.has_prev_in_category_changed.connect(self._files_display_summary.set_has_prev_in_category)

        self._files_display_summary.start_browsing_category.connect(self._files_display.start_browsing_category)
        self._files_display_summary.next_in_category.connect(self._files_display.next_in_category)
        self._files_display_summary.prev_in_category.connect(self._files_display.prev_in_category)

        layout = QVBoxLayout(box)
        layout.addWidget(self._files_display)
        layout.addWidget(self._files_display_summary)

        return box

    def _create_status_box(self):
        self._status_box = StatusBox(self)

        return self._status_box

    def _create_dialog_buttons(self):
        self._dialog_button_box = QDialogButtonBox(self)
        self._dialog_button_box.setOrientation(Qt.Horizontal)
        self._dialog_button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
        self._dialog_button_box.setCenterButtons(True)

        self._dialog_button_box.accepted.connect(self._confirm_rename)
        self._dialog_button_box.rejected.connect(self.reject)

        return self._dialog_button_box

    def _fill_in_controls(self, args):
        if args.base_path is not None:
            self._base_path_panel.set_base_path(args.base_path)
        if args.scan_recursive is not None:
            self._scan_recursive_checkbox.setChecked(args.scan_recursive)
        if args.use_extension is not None:
            self._use_extension_checkbox.setChecked(args.use_extension)
        if args.use_path is not None:
            self._use_path_checkbox.setChecked(args.use_path)
        if args.rules_text is not None:
            self._rules_editor.set_rules(args.rules_text)

    @pyqtSlot()
    def show_first_time(self):
        self.show()
        self.raise_()

        # We need to do this here as otherwise the operation may fail on some platforms
        self.setWindowIcon(QIcon(':/app_icon.png'))

    @pyqtSlot(str)
    def set_base_path(self, base_path):
        self._base_path_panel.set_base_path(base_path)

    @pyqtSlot(BAONStatus)
    def report_status(self, status):
        files_busy = \
            status.scan_status in [BAONStatus.IN_PROGRESS, BAONStatus.PENDING] or \
            status.rename_status in [BAONStatus.IN_PROGRESS, BAONStatus.PENDING]

        self._files_display.setEnabled(not files_busy)

        if status.rules_status == BAONStatus.ERROR:
            self._rules_editor.show_error(status.rules_status_extra.source_span)
        else:
            self._rules_editor.clear_error()

        self._status_box.show_status(status)

        self._dialog_button_box.button(QDialogButtonBox.Ok).setEnabled(
            status.execute_status in [BAONStatus.WAITING_FOR_USER, BAONStatus.ERROR]
        )

        if status.execute_status == BAONStatus.AVAILABLE:
            self._on_rename_completed()

    @pyqtSlot(list)
    def update_scanned_files(self, files):
        self._files_display.set_original_files(files)

    @pyqtSlot(list)
    def update_renamed_files(self, files):
        self._files_display.set_renamed_files(files)

    @pyqtSlot()
    def _confirm_rename(self):
        if self._files_display.has_rename_warnings():
            if not self._ask_user(self.RENAME_WARNINGS_DIALOG_CAPTION, self.RENAME_WARNINGS_DIALOG_TEXT):
                return

        self.request_do_rename.emit()

    def _on_rename_completed(self):
        self._rules_editor.clear()
        self.request_rescan.emit()

        if self._ask_user(self.RENAME_COMPLETE_DIALOG_CAPTION, self.RENAME_COMPLETE_DIALOG_TEXT):
            pass
        else:
            self.reject()

    def _ask_user(self, caption, text):
        on_mac = platform.system() == 'Darwin'

        dialog = QMessageBox(
            QMessageBox.Question,
            caption,
            text,
            QMessageBox.Yes | QMessageBox.No,
            self,
            Qt.Sheet if on_mac else Qt.Dialog | Qt.MSWindowsFixedSizeDialogHint,
        )
        dialog.setDefaultButton(QMessageBox.No)
        dialog.setWindowModality(Qt.WindowModal)

        return dialog.exec_() == QMessageBox.Yes
Beispiel #27
0
class HelpDialog(QDialog):
    def __init__(self, version: str, creator: str):
        """ Opens a dialog showing information about the app, app name, creator
        name and version.
        """
        super(HelpDialog, self).__init__()
        self.version = version
        self.creator = creator

        self.setWindowTitle("Informações")
        self.createLabels()
        self.createButtonBox()
        self.setMainLayout()
        self.moveToCenter()

    def createLabels(self):
        """Creates the widget labelWidget with the app information."""
        self.labelWidget = QtWidgets.QWidget()

        layout = QtWidgets.QVBoxLayout()
        appName = QtWidgets.QLabel("TAGApp")
        version = QtWidgets.QLabel(self.version)
        creator = QtWidgets.QLabel(self.creator)

        appName.setAlignment(Qt.AlignHCenter)
        version.setAlignment(Qt.AlignHCenter)
        creator.setAlignment(Qt.AlignHCenter)

        layout.addWidget(appName)
        layout.addWidget(version)
        layout.addWidget(creator)

        boldFont = QtGui.QFont()
        boldFont.setBold(True)
        appName.setFont(boldFont)

        self.labelWidget.setLayout(layout)

    def createButtonBox(self):
        """Creates a widget named buttonBox with a OK button."""
        buttons = QDialogButtonBox.Ok
        self.buttonBox = QDialogButtonBox(buttons)
        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.setCenterButtons(True)

    def setMainLayout(self):
        """Joins labelWidget and buttonBox widget in a single widget and sets 
        it as the dialog layout.
        """
        mainLayout = QtWidgets.QVBoxLayout()
        mainLayout.addWidget(self.labelWidget)
        mainLayout.addWidget(self.buttonBox)
        self.setLayout(mainLayout)

    def moveToCenter(self):
        """Moves the dialog box to the center of the screen.
        """
        centerPoint = QtWidgets.QDesktopWidget().availableGeometry().center()
        frame = self.frameGeometry()
        frame.moveCenter(centerPoint)
        self.move(frame.topLeft())
    def __init__(self, main_window):
        super().__init__()

        # Obtenemos la QMainWindow para poder llamarla al enviar el formulario
        self.main_window = main_window

        # Inicializar texto de cabecera
        guide = QLabel('<h3>Introduce los siguientes parámetros para' +
                       ' configurar la partida</h3>')

        # Inicializar etiquetas de los campos del formulario
        height_label = QLabel('Altura: ')
        width_label = QLabel('Anchura: ')
        num_of_mines_label = QLabel('Número de minas: ')

        # Inicializar campos del formulario
        self.height_spin = QSpinBox()
        self.height_spin.setRange(1, 10)
        self.width_spin = QSpinBox()
        self.width_spin.setRange(1, 10)
        self.num_of_mines_spin = QSpinBox()
        self.num_of_mines_spin.setMinimum(1)

        # Inicializar botones de envío del formulario
        button_box = QDialogButtonBox()
        button_box.addButton(button_box.Ok)
        button_box.addButton(button_box.Cancel)
        button_box.button(QDialogButtonBox.Ok).setText('Aceptar')
        button_box.button(QDialogButtonBox.Cancel).setText('Cancelar')
        button_box.setCenterButtons(True)

        button_box.accepted.connect(self.init_game)
        button_box.rejected.connect(self.close)

        # Inicializar etiqueta de errores del formulario
        self.form_errors = QLabel('')
        self.form_errors.setStyleSheet('color: red')
        self.form_errors.setWordWrap(True)

        # Configuración de layouts
        self.grid = QGridLayout()
        self.grid.addWidget(height_label, 0, 0)
        self.grid.addWidget(self.height_spin, 0, 1)
        self.grid.addWidget(width_label, 1, 0)
        self.grid.addWidget(self.width_spin, 1, 1)
        self.grid.addWidget(num_of_mines_label, 2, 0)
        self.grid.addWidget(self.num_of_mines_spin, 2, 1)
        self.grid.setSizeConstraint(QLayout.SetFixedSize)

        ver_box = QVBoxLayout()
        ver_box.addWidget(guide)
        ver_box.addLayout(self.grid)
        ver_box.addWidget(button_box)
        ver_box.addWidget(self.form_errors)

        # Pasar a QDialog los layouts con los elementos inicializados
        self.setLayout(ver_box)

        # Inicialización del resto de atributos de la ventana
        self.setWindowTitle('Configuración')
        self.adjustSize()
        self.setFixedSize(self.size())
        self.setWindowIcon(QtGui.QIcon(IMAGE_ICON))
        self.setWindowModality(Qt.NonModal)
        self.show()
Beispiel #29
0
    def _initUi(self):

        app = Application.instance()

        icon = QIcon(app.findResource('Subtitles.png'))

        iconLabel = QLabel()
        iconLabel.setPixmap(icon.pixmap(128))
        iconLabel.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

        appNameLabel = QLabel(self)
        appNameLabel.setText(app.applicationName())
        appNameLabel.setAlignment(Qt.AlignHCenter | Qt.AlignTop)
        appNameLabel.setStyleSheet('font-weight: bold; font-size: 18pt')
        appNameLabel.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)

        version_labels = self._createVersionLabels()

        licenseLabel = self._createSelectableLabel(
            'Copyright © 2018–2019 Philip Belemezov<br>'
            'Licensed under the <a href="about:blank">'
            'GNU General Public License, version 3</a>.')
        licenseLabel.setStyleSheet('color: gray; font-size: 8pt')
        licenseLabel.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        licenseLabel.setTextFormat(Qt.RichText)
        licenseLabel.setTextInteractionFlags(Qt.TextBrowserInteraction)
        licenseLabel.linkActivated.connect(self.showLicense)

        homepageLabel = self._createLinkLabel(
            text=self.tr("Homepage"),
            href="https://github.io/philipbel/subtitles")
        homepageLabel.setAlignment(Qt.AlignCenter)

        ackLabel = self._createLinkLabel(text=self.tr("Acknowledgements"))
        ackLabel.setAlignment(Qt.AlignCenter)
        ackLabel.linkActivated.connect(self.showAcknowledgements)

        linksLayout = QVBoxLayout()
        linksLayout.addWidget(homepageLabel)
        linksLayout.addSpacing(5)
        linksLayout.addWidget(ackLabel)

        versionInfoLayout = QFormLayout()
        versionInfoLayout.setFormAlignment(Qt.AlignHCenter)
        versionInfoLayout.setHorizontalSpacing(4)
        for name, value in version_labels:
            name.setText(name.text() + ':')
            versionInfoLayout.addRow(name, value)

        mainLayout = QVBoxLayout(self)
        mainLayout.setSpacing(0)
        mainLayout.addWidget(iconLabel)
        mainLayout.addWidget(appNameLabel)
        mainLayout.addSpacing(5)
        mainLayout.addLayout(versionInfoLayout)
        mainLayout.addSpacing(20)
        mainLayout.addLayout(linksLayout)
        mainLayout.addSpacing(20)
        mainLayout.addWidget(licenseLabel)

        if sys.platform != 'darwin':
            buttonBox = QDialogButtonBox(QDialogButtonBox.Close)
            buttonBox.setCenterButtons(True)
            buttonBox.button(QDialogButtonBox.Close).clicked.connect(
                self.reject)

            line = QFrame()
            line.setFrameShape(QFrame.HLine)
            line.setFrameShadow(QFrame.Sunken)

            mainLayout.addSpacing(8)
            mainLayout.addWidget(line)
            mainLayout.addSpacing(8)
            mainLayout.addWidget(buttonBox)