def __init__(self, controller, cmd="", msg="", parent=None): """Init dropbox.""" super().__init__(parent) self.controller = controller self._instances.add(weakref.ref(self)) self.ident = len(self._instances) layout = QHBoxLayout() self.command = MonitoredLineEdit() if not cmd: cmd = '' self.command.setText(cmd) self.command.setAlignment(Qt.AlignCenter) self.command.setPlaceholderText(("!command")) layout.addWidget(self.command) self.message = MonitoredLineEdit() self.message.setText(msg) self.message.setAlignment(Qt.AlignCenter) self.message.setPlaceholderText(_('message, e.g.,') + ' (URL)') self.message.setToolTip( _('Available placeholders:') + ' ' + ', '.join(self.controller.placeholders.available())) completer = Completer(self.controller.placeholders.available(), self.message) self.message.setCompleter(completer) layout.addWidget(self.message) self.pushButton1 = QPushButton(_('Test')) self.pushButton1.clicked.connect( lambda: self.testPlaceholder(self.message.text())) layout.addWidget(self.pushButton1) self.pushButton2 = QPushButton(_('Delete')) self.pushButton2.clicked.connect(self.remove) layout.addWidget(self.pushButton2) self.setLayout(layout) for ref in self._instances: obj = ref() if obj is not None: obj.setTitle()
def createFormGroupTwitch(self): """Create forms for twitch.""" self.formGroupTwitch = QWidget() layout = QFormLayout() self.twitchChannel = MonitoredLineEdit() self.twitchChannel.textModified.connect(self.changed) self.twitchChannel.setText( scctool.settings.config.parser.get("Twitch", "channel")) self.twitchChannel.setAlignment(Qt.AlignCenter) self.twitchChannel.setPlaceholderText( _("Name of the Twitch channel that should be updated")) self.twitchChannel.setToolTip( _('The connected twitch user needs to have editor' ' rights for this channel.')) layout.addRow(QLabel("Twitch-Channel:"), self.twitchChannel) container = QHBoxLayout() self.twitchToken = MonitoredLineEdit() self.twitchToken.textModified.connect(self.changed) self.twitchToken.setText( scctool.settings.config.parser.get("Twitch", "oauth")) self.twitchToken.setAlignment(Qt.AlignCenter) self.twitchToken.setPlaceholderText( _("Press 'Get' to generate a token")) self.twitchToken.setEchoMode(QLineEdit.Password) self.twitchToken.setToolTip(_("Press 'Get' to generate a new token.")) container.addWidget(self.twitchToken) self.pb_getTwitch = QPushButton(_('Get')) self.pb_getTwitch.setFixedWidth(100) self.pb_getTwitch.clicked.connect( lambda: self.controller.authThread.requestToken('twitch')) container.addWidget(self.pb_getTwitch) layout.addRow(QLabel(_("Access-Token:")), container) container = QHBoxLayout() self.twitchTemplate = MonitoredLineEdit() self.twitchTemplate.textModified.connect(self.changed) self.twitchTemplate.setText( scctool.settings.config.parser.get("Twitch", "title_template")) self.twitchTemplate.setAlignment(Qt.AlignCenter) self.twitchTemplate.setPlaceholderText("(League) – (Team1) vs (Team2)") self.twitchTemplate.setToolTip( _('Available placeholders:') + " " + ', '.join(self.controller.placeholders.available())) completer = Completer(self.controller.placeholders.available(), self.twitchTemplate) self.twitchTemplate.setCompleter(completer) container.addWidget(self.twitchTemplate) button = QPushButton(_('Test')) button.setFixedWidth(100) button.clicked.connect( lambda: self.testPlaceholder(self.twitchTemplate.text())) container.addWidget(button) label = QLabel(_("Title Template:")) label.setFixedWidth(100) layout.addRow(label, container) container = QVBoxLayout() self.cb_set_game = QCheckBox(_("Set Game to 'StarCraft II'")) self.cb_set_game.setChecked( scctool.settings.config.parser.getboolean("Twitch", "set_game")) self.cb_set_game.stateChanged.connect(self.changed) container.addWidget(self.cb_set_game) label = QLabel(_("Options:") + " ") label.setMinimumWidth(120) layout.addRow(label, container) layout.addItem( QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.formGroupTwitch.setLayout(layout)