# Path: scctool/view/widgets.py
# class IconPushButton(QPushButton):
#     """Define push button with icon."""
# 
#     def __init__(self, label=None, parent=None):
#         """Init button."""
#         super().__init__(label, parent)
# 
#         self.pad = 4     # padding between the icon and the button frame
#         self.minSize = 8  # minimum size of the icon
# 
#         sizePolicy = QSizePolicy(QSizePolicy.Expanding,
#                                  QSizePolicy.Expanding)
#         self.setSizePolicy(sizePolicy)
# 
#     def paintEvent(self, event):
#         """Paint event."""
#         qp = QPainter()
#         qp.begin(self)
# 
#         # ---- get default style ----
# 
#         opt = QStyleOptionButton()
#         self.initStyleOption(opt)
# 
#         # ---- scale icon to button size ----
# 
#         Rect = opt.rect
# 
#         h = Rect.height()
#         w = Rect.width()
#         iconSize = max(min(h, w) - 2 * self.pad, self.minSize)
# 
#         opt.iconSize = QSize(iconSize, iconSize)
# 
#         # ---- draw button ----
# 
#         self.style().drawControl(QStyle.CE_PushButton, opt, qp, self)
# 
#         qp.end()
# 
# class MapLineEdit(QLineEdit):
#     """Define line edit for maps."""
# 
#     textModified = pyqtSignal()  # (before, after)
# 
#     def __init__(self, contents='', parent=None):
#         """Init lineedit."""
#         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 __handleEditingFinished(self):
#         text = self.text()
#         before, after = self._before, text
#         if before != after:
#             after, __ = scctool.matchdata.autoCorrectMap(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()
# 
# 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 scctool.settings
import scctool.settings.config
import scctool.settings.translation
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QCursor, QIcon
from PyQt5.QtWidgets import (QAction, QComboBox, QCompleter, QGridLayout,
                             QGroupBox, QHBoxLayout, QInputDialog, QLabel,
                             QMessageBox, QPushButton, QRadioButton,
                             QSizePolicy, QSlider, QSpacerItem, QTabBar,
                             QVBoxLayout, QWidget)
from scctool.view.widgets import IconPushButton, MapLineEdit, MonitoredLineEdit
        self.sl_score = [QSlider(Qt.Horizontal)
                         for y in range(self.max_no_sets)]
        self.le_map = [MapLineEdit() for y in range(self.max_no_sets)]
        self.label_set = [QPushButton('#{}'.format(y + 1), self)
                          for y in range(self.max_no_sets)]
        self.setContainer = [QHBoxLayout()
                             for y in range(self.max_no_sets)]

        container = QHBoxLayout()
        for team_idx in range(2):
            self.le_team[team_idx].setText("TBD")
            self.le_team[team_idx].setAlignment(
                Qt.AlignCenter)
            self.le_team[team_idx].setPlaceholderText(
                "Team " + str(team_idx + 1))
            policy = QSizePolicy()
            policy.setHorizontalStretch(4)
            policy.setHorizontalPolicy(
                QSizePolicy.Expanding)
            policy.setVerticalStretch(1)
            policy.setVerticalPolicy(QSizePolicy.Fixed)
            self.le_team[team_idx].setSizePolicy(policy)
            self.le_team[team_idx].setMinimumWidth(self.mimumLineEditWidth)
            self.le_team[team_idx].textModified.connect(
                lambda team_idx=team_idx: self.team_changed(team_idx))
            self.le_team[team_idx].setContextMenuPolicy(Qt.CustomContextMenu)
            self.le_team[team_idx].customContextMenuRequested.connect(
                lambda x, team_idx=team_idx:
                self.openTeamContextMenu(team_idx))


# Path: scctool/view/widgets.py
# class IconPushButton(QPushButton):
#     """Define push button with icon."""
# 
#     def __init__(self, label=None, parent=None):
#         """Init button."""
#         super().__init__(label, parent)
# 
#         self.pad = 4     # padding between the icon and the button frame
#         self.minSize = 8  # minimum size of the icon
# 
#         sizePolicy = QSizePolicy(QSizePolicy.Expanding,
#                                  QSizePolicy.Expanding)
#         self.setSizePolicy(sizePolicy)
# 
#     def paintEvent(self, event):
#         """Paint event."""
#         qp = QPainter()
#         qp.begin(self)
# 
#         # ---- get default style ----
# 
#         opt = QStyleOptionButton()
#         self.initStyleOption(opt)
# 
#         # ---- scale icon to button size ----
# 
#         Rect = opt.rect
# 
#         h = Rect.height()
#         w = Rect.width()
#         iconSize = max(min(h, w) - 2 * self.pad, self.minSize)
# 
#         opt.iconSize = QSize(iconSize, iconSize)
# 
#         # ---- draw button ----
# 
#         self.style().drawControl(QStyle.CE_PushButton, opt, qp, self)
# 
#         qp.end()
# 
# class MapLineEdit(QLineEdit):
#     """Define line edit for maps."""
# 
#     textModified = pyqtSignal()  # (before, after)
# 
#     def __init__(self, contents='', parent=None):
#         """Init lineedit."""
#         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 __handleEditingFinished(self):
#         text = self.text()
#         before, after = self._before, text
#         if before != after:
#             after, __ = scctool.matchdata.autoCorrectMap(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()
# 
# 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/matchdataview.py
import logging
import scctool.settings
import scctool.settings.config
import scctool.settings.translation
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QCursor, QIcon
from PyQt5.QtWidgets import (QAction, QComboBox, QCompleter, QGridLayout,
                             QGroupBox, QHBoxLayout, QInputDialog, QLabel,
                             QMessageBox, QPushButton, QRadioButton,
                             QSizePolicy, QSlider, QSpacerItem, QTabBar,
                             QVBoxLayout, QWidget)
from scctool.view.widgets import IconPushButton, MapLineEdit, MonitoredLineEdit

        self.sl_score = [QSlider(Qt.Horizontal)
                         for y in range(self.max_no_sets)]
        self.le_map = [MapLineEdit() for y in range(self.max_no_sets)]
        self.label_set = [QPushButton('#{}'.format(y + 1), self)
                          for y in range(self.max_no_sets)]
        self.setContainer = [QHBoxLayout()
                             for y in range(self.max_no_sets)]

        container = QHBoxLayout()
        for team_idx in range(2):
            self.le_team[team_idx].setText("TBD")
            self.le_team[team_idx].setAlignment(
                Qt.AlignCenter)
            self.le_team[team_idx].setPlaceholderText(
                "Team " + str(team_idx + 1))
            policy = QSizePolicy()
            policy.setHorizontalStretch(4)
            policy.setHorizontalPolicy(
                QSizePolicy.Expanding)
            policy.setVerticalStretch(1)
            policy.setVerticalPolicy(QSizePolicy.Fixed)
            self.le_team[team_idx].setSizePolicy(policy)
            self.le_team[team_idx].setMinimumWidth(self.mimumLineEditWidth)
            self.le_team[team_idx].textModified.connect(
                lambda team_idx=team_idx: self.team_changed(team_idx))
            self.le_team[team_idx].setContextMenuPolicy(Qt.CustomContextMenu)
            self.le_team[team_idx].customContextMenuRequested.connect(
                lambda x, team_idx=team_idx:
                self.openTeamContextMenu(team_idx))


        self.qb_logo1 = IconPushButton()