# Path: friture/widgetdict.py
# def getWidgetById(widgetId):
#     return next(widget for widget in widgets if widget["Id"] == widgetId)
# 
# def widgetIds():
#     return [widget['Id'] for widget in widgets]
# 
# Path: friture/controlbar.py
# class ControlBar(QtWidgets.QWidget):
# 
#     def __init__(self, parent):
#         super().__init__(parent)
# 
#         self.setObjectName("controlBar")
# 
#         self.layout = QtWidgets.QHBoxLayout(self)
# 
#         self.combobox_select = QtWidgets.QComboBox(self)
# 
#         for widget in widgets:
#             self.combobox_select.addItem(widget["Name"])
# 
#         self.combobox_select.setCurrentIndex(0)
#         self.combobox_select.setToolTip("Select the type of audio widget")
# 
#         self.settings_button = QtWidgets.QToolButton(self)
#         self.settings_button.setToolTip("Customize the audio widget")
# 
#         settings_icon = QtGui.QIcon()
#         settings_icon.addPixmap(QtGui.QPixmap(":/images-src/dock-settings.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
#         self.settings_button.setIcon(settings_icon)
# 
#         self.close_button = QtWidgets.QToolButton(self)
#         close_icon = QtGui.QIcon()
#         close_icon.addPixmap(QtGui.QPixmap(":/images-src/dock-close.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
#         self.close_button.setIcon(close_icon)
#         self.close_button.setToolTip("Close the audio widget")
# 
#         self.layout.addWidget(self.combobox_select)
#         self.layout.addWidget(self.settings_button)
#         self.layout.addWidget(self.close_button)
#         self.layout.addStretch()
# 
#         self.setLayout(self.layout)
# 
#         self.setMaximumHeight(24)
#         self.layout.setContentsMargins(0, 0, 0, 0)
#         self.layout.setSpacing(0)


from inspect import signature
from PyQt5 import QtWidgets
from friture.widgetdict import getWidgetById, widgetIds
from friture.controlbar import ControlBar
        self.widget_select(widgetId)

    # note that by default the closeEvent is accepted, no need to do it explicitely
    def closeEvent(self, event):
        self.dockmanager.close_dock(self)

    def closeClicked(self, checked):
        self.close()

    # slot
    def indexChanged(self, index):
        if index > len(widgetIds()):
            index = widgetIds()[0]

        self.widget_select(widgetIds()[index])

    # slot
    def widget_select(self, widgetId):
        if self.widgetId == widgetId:
            return

        if self.audiowidget is not None:
            self.audiowidget.close()
            self.audiowidget.deleteLater()

        if widgetId not in widgetIds():
            widgetId = widgetIds()[0]

        self.widgetId = widgetId


# Path: friture/widgetdict.py
# def getWidgetById(widgetId):
#     return next(widget for widget in widgets if widget["Id"] == widgetId)
# 
# def widgetIds():
#     return [widget['Id'] for widget in widgets]
# 
# Path: friture/controlbar.py
# class ControlBar(QtWidgets.QWidget):
# 
#     def __init__(self, parent):
#         super().__init__(parent)
# 
#         self.setObjectName("controlBar")
# 
#         self.layout = QtWidgets.QHBoxLayout(self)
# 
#         self.combobox_select = QtWidgets.QComboBox(self)
# 
#         for widget in widgets:
#             self.combobox_select.addItem(widget["Name"])
# 
#         self.combobox_select.setCurrentIndex(0)
#         self.combobox_select.setToolTip("Select the type of audio widget")
# 
#         self.settings_button = QtWidgets.QToolButton(self)
#         self.settings_button.setToolTip("Customize the audio widget")
# 
#         settings_icon = QtGui.QIcon()
#         settings_icon.addPixmap(QtGui.QPixmap(":/images-src/dock-settings.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
#         self.settings_button.setIcon(settings_icon)
# 
#         self.close_button = QtWidgets.QToolButton(self)
#         close_icon = QtGui.QIcon()
#         close_icon.addPixmap(QtGui.QPixmap(":/images-src/dock-close.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
#         self.close_button.setIcon(close_icon)
#         self.close_button.setToolTip("Close the audio widget")
# 
#         self.layout.addWidget(self.combobox_select)
#         self.layout.addWidget(self.settings_button)
#         self.layout.addWidget(self.close_button)
#         self.layout.addStretch()
# 
#         self.setLayout(self.layout)
# 
#         self.setMaximumHeight(24)
#         self.layout.setContentsMargins(0, 0, 0, 0)
#         self.layout.setSpacing(0)


# Path: friture/dock.py
from inspect import signature
from PyQt5 import QtWidgets
from friture.widgetdict import getWidgetById, widgetIds
from friture.controlbar import ControlBar

        self.widget_select(widgetId)

    # note that by default the closeEvent is accepted, no need to do it explicitely
    def closeEvent(self, event):
        self.dockmanager.close_dock(self)

    def closeClicked(self, checked):
        self.close()

    # slot
    def indexChanged(self, index):
        if index > len(widgetIds()):
            index = widgetIds()[0]

        self.widget_select(widgetIds()[index])

    # slot
    def widget_select(self, widgetId):
        if self.widgetId == widgetId:
            return

        if self.audiowidget is not None:
            self.audiowidget.close()
            self.audiowidget.deleteLater()

        if widgetId not in widgetIds():
            widgetId = widgetIds()[0]

        self.widgetId = widgetId


        constructor = getWidgetById(widgetId)["Class"]