# Path: scctool/view/widgets.py
# class Completer(QCompleter):
#     """Define custom auto completer for multiple words."""
# 
#     def __init__(self, items_list, parent=None):
#         """Init completer."""
#         super().__init__(items_list, parent)
# 
#         self.setCaseSensitivity(Qt.CaseInsensitive)
#         self.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
#         self.setFilterMode(Qt.MatchContains)
#         self.setWrapAround(False)
# 
#     def pathFromIndex(self, index):
#         """Add texts instead of replace."""
#         path = QCompleter.pathFromIndex(self, index)
# 
#         lst = str(self.widget().text()).split(' ')
# 
#         if len(lst) > 1:
#             path = '%s %s' % (' '.join(lst[:-1]), path)
# 
#         return path
# 
#     @classmethod
#     def splitPath(cls, path):
#         """Add operator to separate between texts."""
#         path = str(path.split(' ')[-1]).lstrip(' ')
#         return [path]
# 
# class MonitoredLineEdit(QLineEdit):
#     """Define moinitored line edit."""
# 
#     textModified = pyqtSignal()
# 
#     def __init__(self, contents='', parent=None):
#         """Init moinitored line edit."""
#         super().__init__(contents, parent)
#         self.editingFinished.connect(self.__handleEditingFinished)
#         self.textChanged.connect(self.__handleTextChanged)
#         self._before = contents
# 
#     def __handleTextChanged(self, text):
#         if not self.hasFocus():
#             self._before = text
# 
#     def setTextMonitored(self, after):
#         """Set the text and mointor change."""
#         if self._before != after:
#             self.textModified.emit()
# 
#         self.setText(after)
# 
#     def __handleEditingFinished(self):
#         before, after = self._before, self.text()
#         if before != after:
#             self.setText(after)
#             self._before = after
#             self.textModified.emit()
# 
#     def completerFinished(self, text):
#         """Get called when the completer is finished to emit a signal."""
#         before, after = self._before, text
#         if before != after:
#             self.setText(after)
#             self._before = after
#             self.textModified.emit()


import logging
import weakref
import scctool.settings
import scctool.settings.translation
from PyQt5.QtCore import QPoint, QSize, Qt
from PyQt5.QtGui import QIcon, QKeySequence
from PyQt5.QtWidgets import (QBoxLayout, QCheckBox, QFormLayout, QGroupBox,
                             QHBoxLayout, QLabel, QLineEdit, QMessageBox,
                             QPushButton, QScrollArea, QShortcut, QSizePolicy,
                             QSpacerItem, QTabWidget, QVBoxLayout, QWidget)
from scctool.view.widgets import Completer, 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()))


# Path: scctool/view/widgets.py
# class Completer(QCompleter):
#     """Define custom auto completer for multiple words."""
# 
#     def __init__(self, items_list, parent=None):
#         """Init completer."""
#         super().__init__(items_list, parent)
# 
#         self.setCaseSensitivity(Qt.CaseInsensitive)
#         self.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
#         self.setFilterMode(Qt.MatchContains)
#         self.setWrapAround(False)
# 
#     def pathFromIndex(self, index):
#         """Add texts instead of replace."""
#         path = QCompleter.pathFromIndex(self, index)
# 
#         lst = str(self.widget().text()).split(' ')
# 
#         if len(lst) > 1:
#             path = '%s %s' % (' '.join(lst[:-1]), path)
# 
#         return path
# 
#     @classmethod
#     def splitPath(cls, path):
#         """Add operator to separate between texts."""
#         path = str(path.split(' ')[-1]).lstrip(' ')
#         return [path]
# 
# class MonitoredLineEdit(QLineEdit):
#     """Define moinitored line edit."""
# 
#     textModified = pyqtSignal()
# 
#     def __init__(self, contents='', parent=None):
#         """Init moinitored line edit."""
#         super().__init__(contents, parent)
#         self.editingFinished.connect(self.__handleEditingFinished)
#         self.textChanged.connect(self.__handleTextChanged)
#         self._before = contents
# 
#     def __handleTextChanged(self, text):
#         if not self.hasFocus():
#             self._before = text
# 
#     def setTextMonitored(self, after):
#         """Set the text and mointor change."""
#         if self._before != after:
#             self.textModified.emit()
# 
#         self.setText(after)
# 
#     def __handleEditingFinished(self):
#         before, after = self._before, self.text()
#         if before != after:
#             self.setText(after)
#             self._before = after
#             self.textModified.emit()
# 
#     def completerFinished(self, text):
#         """Get called when the completer is finished to emit a signal."""
#         before, after = self._before, text
#         if before != after:
#             self.setText(after)
#             self._before = after
#             self.textModified.emit()


# Path: scctool/view/subConnections.py
import logging
import weakref
import scctool.settings
import scctool.settings.translation
from PyQt5.QtCore import QPoint, QSize, Qt
from PyQt5.QtGui import QIcon, QKeySequence
from PyQt5.QtWidgets import (QBoxLayout, QCheckBox, QFormLayout, QGroupBox,
                             QHBoxLayout, QLabel, QLineEdit, QMessageBox,
                             QPushButton, QScrollArea, QShortcut, QSizePolicy,
                             QSpacerItem, QTabWidget, QVBoxLayout, QWidget)
from scctool.view.widgets import Completer, 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(