# Path: pyteltools/gui/util.py
# class MultiFolderDialog(QFileDialog):
#     """
#     Dialog to select one or more folders
#     """
#     def __init__(self, title, multi_selection=True):
#         super().__init__()
#         self.setWindowTitle(title)
#         self.setFileMode(QFileDialog.DirectoryOnly)
#         self.setOption(QFileDialog.DontUseNativeDialog, True)
#         if multi_selection:
#             file_view = self.findChild(QListView, 'listView')
#             if file_view:
#                 file_view.setSelectionMode(QAbstractItemView.MultiSelection)
#         self.tree = self.findChild(QTreeView)
#         if multi_selection and self.tree:
#             self.tree.setSelectionMode(QAbstractItemView.MultiSelection)
# 
# Path: pyteltools/utils/log.py
# def new_logger(name):
#     """!
#     Get a new logger
#     @param name <str>: logger name
#     """
#     logger = logging.getLogger(name)
#     if settings.COLOR_LOGS:
#         coloredlogs.install(logger=logger, level=settings.LOGGING_LEVEL, fmt=settings.LOGGING_FMT_CLI,
#                             level_styles=LEVEL_STYLES, field_styles=FIELD_STYLES)
#     else:
#         handler = logging.StreamHandler()
#         handler.setFormatter(logging.Formatter(settings.LOGGING_FMT_CLI))
#         logger.addHandler(handler)
#         logger.setLevel(settings.LOGGING_LEVEL)
#     return logger


import sys
import os
import uuid
import shutil
import subprocess
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import (QAbstractItemView, QApplication, QCheckBox, QComboBox, QDialog, QDialogButtonBox,
                             QFileDialog, QGroupBox, QHBoxLayout, QLabel, QLineEdit, QMessageBox, QPushButton,
                             QRadioButton, QSpacerItem, QStyle, QTableWidget, QTableWidgetItem, QVBoxLayout, QWidget)
from pyteltools.conf import settings
from pyteltools.gui.util import MultiFolderDialog
from pyteltools.utils.log import new_logger

    def _setLayout(self):
        mainLayout = QVBoxLayout()
        mainLayout.addItem(QSpacerItem(10, 10))
        mainLayout.setSpacing(15)

        hlayout = QHBoxLayout()
        hlayout.addWidget(self.btnOpen)
        hlayout.addWidget(self.btnRun)
        mainLayout.addLayout(hlayout)
        mainLayout.setSpacing(10)
        mainLayout.addItem(QSpacerItem(10, 10))
        mainLayout.addWidget(QLabel('<p style="font-size:10pt">'
                                    'Choisir un ou plusieurs dossiers contenant un sous-dossier nommé gis.<br>'
                                    'Chaque dossier gis doit contenir un fichier .xml avec le même nom.<br>'))
        mainLayout.addWidget(self.overwriteBox)
        hlayout = QHBoxLayout()
        hlayout.addWidget(QLabel('   Choisir les fichiers .xml  '))
        hlayout.addWidget(self.fileBox, Qt.AlignLeft)
        hlayout.addStretch()
        mainLayout.addLayout(hlayout)
        mainLayout.addStretch()
        self.setLayout(mainLayout)

    def _bindEvents(self):
        self.btnOpen.clicked.connect(self.btnOpenEvent)
        self.btnRun.clicked.connect(self.run)

    def btnOpenEvent(self):
        self.btnRun.setEnabled(False)

# Path: pyteltools/gui/util.py
# class MultiFolderDialog(QFileDialog):
#     """
#     Dialog to select one or more folders
#     """
#     def __init__(self, title, multi_selection=True):
#         super().__init__()
#         self.setWindowTitle(title)
#         self.setFileMode(QFileDialog.DirectoryOnly)
#         self.setOption(QFileDialog.DontUseNativeDialog, True)
#         if multi_selection:
#             file_view = self.findChild(QListView, 'listView')
#             if file_view:
#                 file_view.setSelectionMode(QAbstractItemView.MultiSelection)
#         self.tree = self.findChild(QTreeView)
#         if multi_selection and self.tree:
#             self.tree.setSelectionMode(QAbstractItemView.MultiSelection)
# 
# Path: pyteltools/utils/log.py
# def new_logger(name):
#     """!
#     Get a new logger
#     @param name <str>: logger name
#     """
#     logger = logging.getLogger(name)
#     if settings.COLOR_LOGS:
#         coloredlogs.install(logger=logger, level=settings.LOGGING_LEVEL, fmt=settings.LOGGING_FMT_CLI,
#                             level_styles=LEVEL_STYLES, field_styles=FIELD_STYLES)
#     else:
#         handler = logging.StreamHandler()
#         handler.setFormatter(logging.Formatter(settings.LOGGING_FMT_CLI))
#         logger.addHandler(handler)
#         logger.setLevel(settings.LOGGING_LEVEL)
#     return logger


# Path: pyteltools/outil_carto.py
import sys
import os
import uuid
import shutil
import subprocess
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import (QAbstractItemView, QApplication, QCheckBox, QComboBox, QDialog, QDialogButtonBox,
                             QFileDialog, QGroupBox, QHBoxLayout, QLabel, QLineEdit, QMessageBox, QPushButton,
                             QRadioButton, QSpacerItem, QStyle, QTableWidget, QTableWidgetItem, QVBoxLayout, QWidget)
from pyteltools.conf import settings
from pyteltools.gui.util import MultiFolderDialog
from pyteltools.utils.log import new_logger


    def _setLayout(self):
        mainLayout = QVBoxLayout()
        mainLayout.addItem(QSpacerItem(10, 10))
        mainLayout.setSpacing(15)

        hlayout = QHBoxLayout()
        hlayout.addWidget(self.btnOpen)
        hlayout.addWidget(self.btnRun)
        mainLayout.addLayout(hlayout)
        mainLayout.setSpacing(10)
        mainLayout.addItem(QSpacerItem(10, 10))
        mainLayout.addWidget(QLabel('<p style="font-size:10pt">'
                                    'Choisir un ou plusieurs dossiers contenant un sous-dossier nommé gis.<br>'
                                    'Chaque dossier gis doit contenir un fichier .xml avec le même nom.<br>'))
        mainLayout.addWidget(self.overwriteBox)
        hlayout = QHBoxLayout()
        hlayout.addWidget(QLabel('   Choisir les fichiers .xml  '))
        hlayout.addWidget(self.fileBox, Qt.AlignLeft)
        hlayout.addStretch()
        mainLayout.addLayout(hlayout)
        mainLayout.addStretch()
        self.setLayout(mainLayout)

    def _bindEvents(self):
        self.btnOpen.clicked.connect(self.btnOpenEvent)
        self.btnRun.clicked.connect(self.run)

    def btnOpenEvent(self):
        self.btnRun.setEnabled(False)

        w = MultiFolderDialog('Choisir un ou plusieurs dossiers contenant un sous-dossier gis')