class TooltipPositioningWithArrow(TooltipPositioning):
    ARROW_MARGIN = 7
    ARROW_SIZE = 11
    ARROW_ODD_SIZE = 15

    def _getTopOrBottomArrow(self, alignment, tooltip, main_window):
        arrow_alignment = TooltipAlignment.mapToMainWindow(tooltip.hoveredWidget(), main_window).x() - alignment + \
              tooltip.hoveredWidget().width() / 2 - self.ARROW_ODD_SIZE / 2

        if arrow_alignment > tooltip.widget().width():
            arrow_alignment = tooltip.widget().width() - self.ARROW_ODD_SIZE

        self._arrow = QWidget()
        self._arrow.setLayout(self._getTopOrBottomArrowLayout(arrow_alignment))

        self._label_arrow = QLabel()
        self._label_arrow.setStyleSheet(
            self._getArrowStylesheet(tooltip.color()))
        self._label_arrow.setFixedWidth(self.ARROW_ODD_SIZE)
        self._label_arrow.setFixedHeight(self.ARROW_SIZE)

        self._arrow.layout().addWidget(self._label_arrow)
        return self._arrow

    def _getTopOrBottomArrowLayout(self, arrow_alignment):
        self._arrow_layout = QHBoxLayout()
        self._arrow_layout.setAlignment(Qt.AlignLeft)
        self._arrow_layout.setContentsMargins(arrow_alignment, 0, 0, 0)
        return self._arrow_layout

    def _getLeftOrRightArrow(self, alignment, tooltip, main_window):
        arrow_alignment = TooltipAlignment.mapToMainWindow(tooltip.hoveredWidget(), main_window).y() \
              - alignment + tooltip.hoveredWidget().height() / 2 - self.ARROW_ODD_SIZE / 2

        if arrow_alignment > tooltip.widget().height():
            arrow_alignment = tooltip.widget().height() - self.ARROW_ODD_SIZE

        self._arrow = QWidget()
        self._arrow.setLayout(self._getLeftOrRightArrowLayout(arrow_alignment))

        self._label_arrow = QLabel()
        self._label_arrow.setStyleSheet(
            self._getArrowStylesheet(tooltip.color()))
        self._label_arrow.setFixedWidth(self.ARROW_SIZE)
        self._label_arrow.setFixedHeight(self.ARROW_ODD_SIZE)

        self._arrow.layout().addWidget(self._label_arrow)
        return self._arrow

    def _getLeftOrRightArrowLayout(self, arrow_alignment):
        self._arrow_layout = QVBoxLayout()
        self._arrow_layout.setAlignment(Qt.AlignTop)
        self._arrow_layout.setContentsMargins(0, arrow_alignment, 0, 0)
        return self._arrow_layout

    def _getArrowStylesheet(self, color="rgb(255, 255, 255)"):
        raise NotImplementedError("Subclass responsibility")

    def showTooltip(self, tooltip, align, main_window):
        raise NotImplementedError("Subclass responsibility")
Esempio n. 2
0
 def _create_control(self, parent):
     label = QLabel()
     width, height = self.item.width, self.item.height
     if self.item.width != -1.0:
         label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
         label.setFixedWidth(abs(width))
         label.setFixedHeight(abs(height))
     return label
Esempio n. 3
0
 def _create_control(self, parent):
     label = QLabel()
     width, height = self.item.width, self.item.height
     if self.item.width != -1.0:
         label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
         label.setFixedWidth(abs(width))
         label.setFixedHeight(abs(height))
     return label
Esempio n. 4
0
 def getAppLabel(self):
     '''
     Gets label to be displayed in widget
     '''
     appTitle = QLabel(CUSTOMER_NAME)
     appTitle.setAlignment(Qt.AlignCenter)
     appTitle.setFixedHeight(
         QApplication.desktop().screenGeometry().height() / 20)
     appTitle.setStyleSheet(
         "border-style:ridge;border: 2px solid red; border-radius: 3px;"
         "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #7EC0EE, stop: 1 #7EC0EE);"
         "min-width: 40px;color: red;font-size: 54px; font-style=bold italic large 'New Century Schoolbook'"
     )
     return appTitle
Esempio n. 5
0
    def firstPage(self):
        
        for i in range( self.mainLayout.count() ):
            item = self.mainLayout.itemAt(0)
            item.widget().setParent( None )
        
        title = QLabel( "<p style='color:rgb( 137,129,120 )'>Welcome to the PingoTools Installer</p>" )
        title.setFixedHeight( 50 )
        titleFont  = QFont()
        titleFont.setPixelSize( 18 )
        titleFont.setBold( True )
        titleFont.setFamily( "Helvetica [Cronyx]" )
        title.setAlignment( QtCore.Qt.AlignCenter )
        title.setFont( titleFont )
        
        description = QLabel()
        description.setAlignment( QtCore.Qt.AlignCenter )
        
        buttonsWidget = QWidget(); buttonsWidget.setMaximumHeight( 50 )
        buttonsLayout = QHBoxLayout( buttonsWidget )
        emptyArea = QLabel()
        buttonNext = QPushButton( 'Next > ' )
        buttonCancel = QPushButton( 'Cancel' )
        buttonsLayout.addWidget( emptyArea )
        buttonsLayout.addWidget( buttonNext ); buttonNext.setFixedWidth( 100 )
        buttonsLayout.addWidget( buttonCancel ); buttonCancel.setFixedWidth( 100 )
        
        self.mainLayout.addWidget( title )
        self.mainLayout.addWidget( description )
        self.mainLayout.addWidget( buttonsWidget )
        
        origWidth = 500

        frontImage = QImage()
        frontImage.load( os.path.dirname( __file__ ) + '/images/pingoTools_main.jpg' )
        trValue = QTransform().scale( float(origWidth)/frontImage.width(), float(origWidth)/frontImage.width() )
        transformedImage = frontImage.transformed( trValue )
        pixmap     = QPixmap.fromImage( transformedImage )
        description.setPixmap( pixmap )
        description.setGeometry( 0,0, transformedImage.width() , transformedImage.height() )
        description.paintEvent(QPaintEvent(QtCore.QRect( 0,0,self.width(), self.height() )))
        
        QtCore.QObject.connect( buttonNext, QtCore.SIGNAL( 'clicked()' ), self.secondPage )
        QtCore.QObject.connect( buttonCancel, QtCore.SIGNAL( 'clicked()' ), self.cmd_cancel )
Esempio n. 6
0
 def secondPage(self):
     
     for i in range( self.mainLayout.count() ):
         item = self.mainLayout.itemAt(0)
         item.widget().setParent( None )
     
     title = QLabel( "설치할 플러그인을 선택하십시오.".decode( 'utf-8' ) )
     title.setFixedHeight( 50 )
     
     listWidget = QListWidget()
     listWidget.setFixedHeight( 273 )
     widgetItem_for2015 = QListWidgetItem("PingoTools for Maya2015", listWidget )
     widgetItem_for2016 = QListWidgetItem("PingoTools for Maya2016", listWidget )
     widgetItem_for2017 = QListWidgetItem("PingoTools for Maya2017", listWidget )
     
     widgetItem_for2015.setCheckState( QtCore.Qt.Checked )
     widgetItem_for2016.setCheckState( QtCore.Qt.Checked )
     widgetItem_for2017.setCheckState( QtCore.Qt.Checked )
     #widgetItem_for2015.setFlags( not QtCore.Qt.ItemIsSelectable )
     
     buttonsWidget = QWidget(); buttonsWidget.setMaximumHeight( 50 )
     buttonsLayout = QHBoxLayout( buttonsWidget )
     emptyArea = QLabel()
     buttonBack = QPushButton( 'Back < ' )
     buttonNext = QPushButton( 'Install' )
     buttonCancel = QPushButton( 'Cancel' )
     buttonsLayout.addWidget( emptyArea )
     buttonsLayout.addWidget( buttonBack ); buttonBack.setFixedWidth( 100 )
     buttonsLayout.addWidget( buttonNext ); buttonNext.setFixedWidth( 100 )
     buttonsLayout.addWidget( buttonCancel ); buttonCancel.setFixedWidth( 100 )
     
     self.mainLayout.addWidget( title )
     self.mainLayout.addWidget( listWidget )
     self.mainLayout.addWidget( buttonsWidget )
     
     QtCore.QObject.connect( buttonBack, QtCore.SIGNAL( 'clicked()' ), self.firstPage )
     QtCore.QObject.connect( buttonNext, QtCore.SIGNAL( 'clicked()' ), self.lastPage )
     QtCore.QObject.connect( buttonCancel, QtCore.SIGNAL( 'clicked()' ), self.cmd_cancel )
Esempio n. 7
0
 def lastPage(self):
     
     for i in range( self.mainLayout.count() ):
         item = self.mainLayout.itemAt(0)
         item.widget().setParent( None )
     
     title = QLabel( "".decode( 'utf-8' ) )
     title.setFixedHeight( 50 )
     
     description = QLabel( "<p style='line-height:150%';'><b>PingoTools</b> 인스톨이 완료되었습니다.<p>".decode( 'utf-8' ) )
     description.setAlignment( QtCore.Qt.AlignCenter )
     
     buttonsWidget = QWidget(); buttonsWidget.setMaximumHeight( 50 )
     buttonsLayout = QHBoxLayout( buttonsWidget )
     emptyArea = QLabel()
     buttonClose = QPushButton( 'Close' ); buttonClose.setFixedWidth( 100 )
     buttonsLayout.addWidget( emptyArea )
     buttonsLayout.addWidget( buttonClose )
     
     self.mainLayout.addWidget( title )
     self.mainLayout.addWidget( description )
     self.mainLayout.addWidget( buttonsWidget )
     
     QtCore.QObject.connect( buttonClose, QtCore.SIGNAL( 'clicked()' ), self.cmd_close )
Esempio n. 8
0
class DeviceWidget(QGroupBox):

    PROGRAM_SIGNAL = 0
    INFO_SIGNAL = 1

    program = Signal(str)
    show_info = Signal(str)
    reset = Signal(str)

    def __init__(self, device):
        super(DeviceWidget, self).__init__(None)

        self.device = device
        self.label = None

        self.initUI()

    # label for generic keyplus device
    def setup_keyplus_label(self):
        try:
            self.device.open()
            settingsInfo = protocol.get_device_info(self.device)
            firmwareInfo = protocol.get_firmware_info(self.device)
            self.device.close()
        except TimeoutError as err:
            # Incase opening the device fails
            raise Exception("Error Opening Device: {} | {}:{}".format(
                self.device.path, self.device.vendor_id,
                self.device.product_id),
                            file=sys.stderr)

        if settingsInfo.crc == settingsInfo.computed_crc:
            build_time_str = protocol.timestamp_to_str(settingsInfo.timestamp)
            self.label = QLabel('{} | {} | Firmware v{}.{}.{}\n'
                                'Device id: {}\n'
                                'Serial number: {}\n'
                                'Last time updated: {}'.format(
                                    self.device.manufacturer_string,
                                    self.device.product_string,
                                    firmwareInfo.version_major,
                                    firmwareInfo.version_minor,
                                    firmwareInfo.version_patch,
                                    settingsInfo.id, self.device.serial_number,
                                    build_time_str))
        else:
            # CRC doesn't match
            if settingsInfo.is_empty:
                self.label = QLabel('??? | ??? | Firmware v{}.{}.{}\n'
                                    'Warning: Empty settings!\n'
                                    'Serial number: {}\n'.format(
                                        firmwareInfo.version_major,
                                        firmwareInfo.version_minor,
                                        firmwareInfo.version_patch,
                                        self.device.serial_number,
                                    ))
            else:
                # corrupt settings in the flash
                build_time_str = protocol.timestamp_to_str(
                    settingsInfo.timestamp)
                self.label = QLabel('??? | ??? | Firmware v{}.{}.{}\n'
                                    'WARNING: Settings are uninitialized\n'
                                    'Serial number: {}\n'.format(
                                        firmwareInfo.version_major,
                                        firmwareInfo.version_minor,
                                        firmwareInfo.version_patch,
                                        self.device.serial_number,
                                    ))

    # xusb_boot bootloader device
    def setup_xusb_bootloader_label(self):
        try:
            self.device.open()
            bootloader_info = xusb_boot.get_boot_info(self.device)
            self.device.close()
        except TimeoutError as err:
            # Incase opening the device fails
            raise Exception("Error Opening Device: {} | {}:{}".format(
                self.device.path, self.device.vendor_id,
                self.device.product_id),
                            file=sys.stderr)

        self.label = QLabel(
            '{} | {} | Bootloader v{}.{}\n'
            'MCU: {}\n'
            'Flash size: {}\n'
            'Serial number: {}\n'.format(
                self.device.manufacturer_string, self.device.product_string,
                bootloader_info.version_major, bootloader_info.version_minor,
                bootloader_info.mcu_string, bootloader_info.flash_size,
                self.device.serial_number))

    # nrf24lu1p
    def setup_nrf24lu1p_label(self):
        # try:
        #     self.device.open()
        #     bootloader_info = xusb_boot.get_boot_info(self.device)
        #     self.device.close()
        # except TimeoutError as err:
        #     # Incase opening the device fails
        #     raise Exception ("Error Opening Device: {} | {}:{}"
        #             .format(
        #                 self.device.path,
        #                 self.device.vendor_id,
        #                 self.device.product_id
        #             ),
        #           file=sys.stderr
        #     )

        self.label = QLabel('nRF24LU1+ Bootloader v{}.{}\n'
                            'MCU: nRF24LU1+\n'.format(
                                0,
                                0,
                                self.device.manufacturer_string,
                                self.device.product_string,
                            ))

    def initUI(self):
        programIcon = QIcon('img/download.png')
        infoIcon = QIcon('img/info.png')

        if is_keyplus_device(self.device):
            self.setup_keyplus_label()
        elif is_xusb_bootloader_device(self.device):
            self.setup_xusb_bootloader_label()
        elif is_nrf24lu1p_bootloader_device(self.device):
            self.setup_nrf24lu1p_label()
        else:
            raise Exception("Unsupported USB device {}:{}".format(
                self.device.vendor_id, self.device.product_id))

        if self.label == None:
            return

        self.label.setTextInteractionFlags(Qt.TextSelectableByMouse)
        self.label.setStyleSheet("""
        QLabel {
            background: #FFF;
            border: 1px solid;
            padding: 2px;
            font: 11pt;
        }
        """)
        self.label.setFixedHeight(90)
        self.label.setMinimumWidth(390)

        self.programButton = QPushButton(' Program')
        self.programButton.setIcon(programIcon)
        self.programButton.clicked.connect(self.programSignal)

        if is_bootloader_device(self.device):
            self.secondaryButton = QPushButton('Reset')
            self.secondaryButton.clicked.connect(self.resetSignal)
        else:
            self.secondaryButton = QPushButton('Info')
            self.secondaryButton.setIcon(infoIcon)
            self.secondaryButton.clicked.connect(self.infoSignal)

        self.layout = QGridLayout()
        self.layout.addWidget(self.label, 0, 0, 2, 1)
        self.layout.addWidget(self.programButton, 0, 1)
        self.layout.addWidget(self.secondaryButton, 1, 1)
        self.setLayout(self.layout)

        self.setMaximumHeight(150)
        self.setContentsMargins(0, 0, 0, 0)

        self.setStyleSheet("""
            QGroupBox {
                border: 1px solid #CCC;
            }
        """)

    def infoSignal(self):
        self.show_info.emit(self.device.path)

    def resetSignal(self):
        self.reset.emit(self.device.path)

    def programSignal(self):
        self.program.emit(self.device.path)

    def sizeHint(self):
        return QSize(560, 0)
    def create_browser_pane(self, title):
        # Create the pane widget
        pane = QWidget()
        layout = QVBoxLayout()
        pane.setLayout(layout)

        # Create a label for the title
        title_bar = QLabel("")
        # title_bar.setFixedHeight(32)
        title_bar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
        title_bar.show()
        layout.addWidget(title_bar)

        # Create the "address" box
        address_bar = QLineEdit()
        layout.addWidget(address_bar)

        # todo: we could add some tool buttons here..
        toolbar_layout = QHBoxLayout()
        toolbar = QWidget()
        toolbar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
        toolbar.setLayout(toolbar_layout)
        tool_stop = QPushButton()
        tool_stop.setText('Stop')
        toolbar_layout.addWidget(tool_stop)
        tool_back = QPushButton()
        tool_back.setText('Back')
        toolbar_layout.addWidget(tool_back)
        tool_forward = QPushButton()
        tool_forward.setText('Forward')
        toolbar_layout.addWidget(tool_forward)
        tool_reload = QPushButton()
        tool_reload.setText('Reload')
        toolbar_layout.addWidget(tool_reload)
        layout.addWidget(toolbar)

        # Create the web view
        web_view = QWebView()
        web_view.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        layout.addWidget(web_view)

        # Create a status bar
        status_bar = QLabel("")
        status_bar.setFixedHeight(32)
        status_bar.show()
        status_bar.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
        layout.addWidget(status_bar)

        # Attach signal handlers
        address_bar.editingFinished.connect(functools.partial(
            self._addrbar_changed, address_bar, web_view))

        web_view.loadStarted.connect(
            lambda: status_bar.setText('Loading...'))
        web_view.loadProgress.connect(
            lambda p: status_bar.setText('Loading ({0}%)...'.format(p)))
        web_view.loadFinished.connect(
            lambda p: status_bar.setText('Ready.'.format(p)))
        web_view.statusBarMessage.connect(status_bar.setText)
        web_view.titleChanged.connect(title_bar.setText)
        web_view.urlChanged.connect(functools.partial(
            self._url_changed, web_view))
        web_view.urlChanged.connect(
            lambda url: address_bar.setText(url.toString()))

        # Connect tool buttons
        tool_stop.clicked.connect(web_view.stop)
        tool_back.clicked.connect(web_view.back)
        tool_forward.clicked.connect(web_view.forward)
        tool_reload.clicked.connect(web_view.reload)

        return {
            'main': pane,
            'layout': layout,
            'title': title_bar,
            'address': address_bar,
            'web_view': web_view,
            'status': status_bar,
        }
Esempio n. 10
0
class ConfigDialog(QtGui.QDialog):

    pressedclosebutton = False
    moreToggling = False

    def moreToggled(self):
        if self.moreToggling == False:
            self.moreToggling = True

            if self.showmoreCheckbox.isChecked():
                self.tabListFrame.show()
                self.resetButton.show()
                self.nostoreCheckbox.show()
                self.alwaysshowCheckbox.show()
                self.saveMoreState(True)
                self.tabListWidget.setCurrentRow(0)
                self.ensureTabListIsVisible()
            else:
                self.tabListFrame.hide()
                self.resetButton.hide()
                self.nostoreCheckbox.hide()
                self.alwaysshowCheckbox.hide()
                self.saveMoreState(False)
                self.stackedLayout.setCurrentIndex(0)

            self.adjustSize()
            self.setFixedSize(self.sizeHint())
        self.moreToggling = False
        self.setFixedWidth(self.minimumSizeHint().width())
        self.executablepathCombobox.setFixedWidth(self.mediapathTextbox.width())

    def runButtonTextUpdate(self):
        if self.nostoreCheckbox.isChecked():
            self.runButton.setText(getMessage("run-label"))
        else:
            self.runButton.setText(getMessage("storeandrun-label"))

    def openHelp(self):
        self.QtGui.QDesktopServices.openUrl("http://syncplay.pl/guide/client/")

    def _tryToFillPlayerPath(self, playerpath, playerpathlist):
        settings = QSettings("Syncplay", "PlayerList")
        settings.beginGroup("PlayerList")
        savedPlayers = settings.value("PlayerList", [])
        if not isinstance(savedPlayers, list):
            savedPlayers = []
        playerpathlist = list(set(os.path.normcase(os.path.normpath(path)) for path in set(playerpathlist + savedPlayers)))
        settings.endGroup()
        foundpath = ""

        if playerpath != None and playerpath != "":
            if not os.path.isfile(playerpath):
                expandedpath = PlayerFactory().getExpandedPlayerPathByPath(playerpath)
                if expandedpath != None and os.path.isfile(expandedpath):
                    playerpath = expandedpath

            if os.path.isfile(playerpath):
                foundpath = playerpath
                self.executablepathCombobox.addItem(foundpath)

        for path in playerpathlist:
            if os.path.isfile(path) and os.path.normcase(os.path.normpath(path)) != os.path.normcase(os.path.normpath(foundpath)):
                self.executablepathCombobox.addItem(path)
                if foundpath == "":
                    foundpath = path

        if foundpath != "":
            settings.beginGroup("PlayerList")
            playerpathlist.append(os.path.normcase(os.path.normpath(foundpath)))
            settings.setValue("PlayerList", list(set(os.path.normcase(os.path.normpath(path)) for path in set(playerpathlist))))
            settings.endGroup()
        return foundpath

    def updateExecutableIcon(self):
        currentplayerpath = unicode(self.executablepathCombobox.currentText())
        iconpath = PlayerFactory().getPlayerIconByPath(currentplayerpath)
        if iconpath != None and iconpath != "":
            self.executableiconImage.load(self.resourcespath + iconpath)
            self.executableiconLabel.setPixmap(QtGui.QPixmap.fromImage(self.executableiconImage))
        else:
            self.executableiconLabel.setPixmap(QtGui.QPixmap.fromImage(QtGui.QImage()))


    def browsePlayerpath(self):
        options = QtGui.QFileDialog.Options()
        defaultdirectory = ""
        browserfilter = "All files (*)"

        if os.name == 'nt':
            browserfilter = "Executable files (*.exe);;All files (*)"
            if "PROGRAMFILES(X86)" in os.environ:
                defaultdirectory = os.environ["ProgramFiles(x86)"]
            elif "PROGRAMFILES" in os.environ:
                defaultdirectory = os.environ["ProgramFiles"]
            elif "PROGRAMW6432" in os.environ:
                defaultdirectory = os.environ["ProgramW6432"]
        elif sys.platform.startswith('linux'):
            defaultdirectory = "/usr/bin"
        elif sys.platform.startswith('darwin'):
            defaultdirectory = "/Applications/"

        fileName, filtr = QtGui.QFileDialog.getOpenFileName(self,
                "Browse for media player executable",
                defaultdirectory,
                browserfilter, "", options)
        if fileName:
            self.executablepathCombobox.setEditText(os.path.normpath(fileName))

    def loadMediaBrowseSettings(self):
        settings = QSettings("Syncplay", "MediaBrowseDialog")
        settings.beginGroup("MediaBrowseDialog")
        self.mediadirectory = settings.value("mediadir", "")
        settings.endGroup()

    def saveMediaBrowseSettings(self):
        settings = QSettings("Syncplay", "MediaBrowseDialog")
        settings.beginGroup("MediaBrowseDialog")
        settings.setValue("mediadir", self.mediadirectory)
        settings.endGroup()

    def getMoreState(self):
        settings = QSettings("Syncplay", "MoreSettings")
        settings.beginGroup("MoreSettings")
        morestate = unicode.lower(unicode(settings.value("ShowMoreSettings", "false")))
        settings.endGroup()
        if morestate == "true":
            return True
        else:
            return False

    def saveMoreState(self, morestate):
        settings = QSettings("Syncplay", "MoreSettings")
        settings.beginGroup("MoreSettings")
        settings.setValue("ShowMoreSettings", morestate)
        settings.endGroup()

    def browseMediapath(self):
        self.loadMediaBrowseSettings()
        options = QtGui.QFileDialog.Options()
        if os.path.isdir(self.mediadirectory):
            defaultdirectory = self.mediadirectory
        elif os.path.isdir(QDesktopServices.storageLocation(QDesktopServices.MoviesLocation)):
            defaultdirectory = QDesktopServices.storageLocation(QDesktopServices.MoviesLocation)
        elif os.path.isdir(QDesktopServices.storageLocation(QDesktopServices.HomeLocation)):
            defaultdirectory = QDesktopServices.storageLocation(QDesktopServices.HomeLocation)
        else:
            defaultdirectory = ""
        browserfilter = "All files (*)"
        fileName, filtr = QtGui.QFileDialog.getOpenFileName(self, "Browse for media files", defaultdirectory,
                browserfilter, "", options)
        if fileName:
            self.mediapathTextbox.setText(os.path.normpath(fileName))
            self.mediadirectory = os.path.dirname(fileName)
            self.saveMediaBrowseSettings()

    def _saveDataAndLeave(self):
        self.processWidget(self, lambda w: self.saveValues(w))
        if self.hostTextbox.text():
            self.config['host'] = self.hostTextbox.text() if ":" in self.hostTextbox.text() else self.hostTextbox.text() + ":" + unicode(constants.DEFAULT_PORT)
        else:
            self.config['host'] = None
        self.config['playerPath'] = unicode(self.executablepathCombobox.currentText())
        if self.mediapathTextbox.text() == "":
            self.config['file'] = None
        elif os.path.isfile(os.path.abspath(self.mediapathTextbox.text())):
            self.config['file'] = os.path.abspath(self.mediapathTextbox.text())
        else:
            self.config['file'] = unicode(self.mediapathTextbox.text())

        if not self.slowdownThresholdSpinbox.text:
            self.slowdownThresholdSpinbox.value = constants.DEFAULT_SLOWDOWN_KICKIN_THRESHOLD
        if not self.rewindThresholdSpinbox.text:
            self.rewindThresholdSpinbox.value = constants.DEFAULT_REWIND_THRESHOLD
        self.config['slowdownThreshold'] = self.slowdownThresholdSpinbox.value()
        self.config['rewindThreshold'] = self.rewindThresholdSpinbox.value()

        self.pressedclosebutton = True
        self.close()
        return

    def closeEvent(self, event):
        if self.pressedclosebutton == False:
            sys.exit()
            raise GuiConfiguration.WindowClosed
            event.accept()

    def dragEnterEvent(self, event):
        data = event.mimeData()
        urls = data.urls()
        if urls and urls[0].scheme() == 'file':
            event.acceptProposedAction()

    def dropEvent(self, event):
        data = event.mimeData()
        urls = data.urls()
        if urls and urls[0].scheme() == 'file':
            if sys.platform.startswith('win'):
                dropfilepath = unicode(urls[0].path())[1:]  # Removes starting slash
            else:
                dropfilepath = unicode(urls[0].path())
            if dropfilepath[-4:].lower() == ".exe":
                self.executablepathCombobox.setEditText(dropfilepath)
            else:
                self.mediapathTextbox.setText(dropfilepath)

    def processWidget(self, container, torun):
        for widget in container.children():
            self.processWidget(widget, torun)
            if hasattr(widget, 'objectName') and widget.objectName() and widget.objectName()[:3] != "qt_":
                torun(widget)

    def loadTooltips(self, widget):
        tooltipName = widget.objectName().lower().split(constants.CONFIG_NAME_MARKER)[0] + "-tooltip"
        if tooltipName[:1] == constants.INVERTED_STATE_MARKER or tooltipName[:1] == constants.LOAD_SAVE_MANUALLY_MARKER:
            tooltipName = tooltipName[1:]
        widget.setToolTip(getMessage(tooltipName))

    def loadValues(self, widget):
        valueName = str(widget.objectName())
        if valueName[:1] == constants.LOAD_SAVE_MANUALLY_MARKER:
            return

        if isinstance(widget, QCheckBox) and widget.objectName():
            if valueName[:1] == constants.INVERTED_STATE_MARKER:
                valueName = valueName[1:]
                inverted = True
            else:
                inverted = False
            widget.setChecked(self.config[valueName] != inverted)
        elif isinstance(widget, QRadioButton):
            radioName, radioValue  = valueName.split(constants.CONFIG_NAME_MARKER)[1].split(constants.CONFIG_VALUE_MARKER)
            if self.config[radioName] == radioValue:
                widget.setChecked(True)
        elif isinstance(widget, QLineEdit):
            widget.setText(self.config[valueName])

    def saveValues(self, widget):
        valueName = str(widget.objectName())
        if valueName[:1] == constants.LOAD_SAVE_MANUALLY_MARKER:
            return

        if isinstance(widget, QCheckBox) and widget.objectName():
            if valueName[:1] == constants.INVERTED_STATE_MARKER:
                valueName = valueName[1:]
                inverted = True
            else:
                inverted = False
            self.config[valueName] = widget.isChecked() != inverted
        elif isinstance(widget, QRadioButton):
            radioName, radioValue  = valueName.split(constants.CONFIG_NAME_MARKER)[1].split(constants.CONFIG_VALUE_MARKER)
            if widget.isChecked():
                self.config[radioName] = radioValue
        elif isinstance(widget, QLineEdit):
            self.config[valueName] = widget.text()

    def connectChildren(self, widget):
        widgetName = str(widget.objectName())
        if self.subitems.has_key(widgetName) and isinstance(widget, QCheckBox):
            widget.stateChanged.connect(lambda: self.updateSubwidgets(self, widget))
            self.updateSubwidgets(self, widget)

    def updateSubwidgets(self, container, parentwidget, subwidgets=None):
        widgetName = parentwidget.objectName()
        if not subwidgets:
            subwidgets = self.subitems[widgetName]
        for widget in container.children():
            self.updateSubwidgets(widget, parentwidget, subwidgets)
            if hasattr(widget, 'objectName') and widget.objectName() and widget.objectName() in subwidgets:
                widget.setDisabled(not parentwidget.isChecked())

    def addBasicTab(self):
        config = self.config
        playerpaths = self.playerpaths
        resourcespath = self.resourcespath
        error = self.error
        if self.datacleared == True:
            error = constants.ERROR_MESSAGE_MARKER + "{}".format(getMessage("gui-data-cleared-notification"))
        if config['host'] == None:
            host = ""
        elif ":" in config['host']:
            host = config['host']
        else:
            host = config['host'] + ":" + str(config['port'])

        self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("connection-group-title"))
        self.hostTextbox = QLineEdit(host, self)
        self.hostLabel = QLabel(getMessage("host-label"), self)
        self.usernameTextbox = QLineEdit(self)
        self.usernameTextbox.setObjectName("name")
        self.serverpassLabel = QLabel(getMessage("password-label"), self)
        self.defaultroomTextbox = QLineEdit(self)
        self.usernameLabel = QLabel(getMessage("name-label"), self)
        self.serverpassTextbox = QLineEdit(self)
        self.defaultroomLabel = QLabel(getMessage("room-label"), self)

        self.hostLabel.setObjectName("host")
        self.hostTextbox.setObjectName(constants.LOAD_SAVE_MANUALLY_MARKER + "host")
        self.usernameLabel.setObjectName("name")
        self.usernameTextbox.setObjectName("name")
        self.serverpassLabel.setObjectName("password")
        self.serverpassTextbox.setObjectName("password")
        self.defaultroomLabel.setObjectName("room")
        self.defaultroomTextbox.setObjectName("room")

        self.connectionSettingsLayout = QtGui.QGridLayout()
        self.connectionSettingsLayout.addWidget(self.hostLabel, 0, 0)
        self.connectionSettingsLayout.addWidget(self.hostTextbox, 0, 1)
        self.connectionSettingsLayout.addWidget(self.serverpassLabel, 1, 0)
        self.connectionSettingsLayout.addWidget(self.serverpassTextbox, 1, 1)
        self.connectionSettingsLayout.addWidget(self.usernameLabel, 2, 0)
        self.connectionSettingsLayout.addWidget(self.usernameTextbox, 2, 1)
        self.connectionSettingsLayout.addWidget(self.defaultroomLabel, 3, 0)
        self.connectionSettingsLayout.addWidget(self.defaultroomTextbox, 3, 1)
        self.connectionSettingsGroup.setLayout(self.connectionSettingsLayout)

        self.mediaplayerSettingsGroup = QtGui.QGroupBox(getMessage("media-setting-title"))
        self.executableiconImage = QtGui.QImage()
        self.executableiconLabel = QLabel(self)
        self.executableiconLabel.setMinimumWidth(16)
        self.executablepathCombobox = QtGui.QComboBox(self)
        self.executablepathCombobox.setEditable(True)
        self.executablepathCombobox.currentIndexChanged.connect(self.updateExecutableIcon)
        self.executablepathCombobox.setEditText(self._tryToFillPlayerPath(config['playerPath'], playerpaths))
        self.executablepathCombobox.setFixedWidth(165)
        self.executablepathCombobox.editTextChanged.connect(self.updateExecutableIcon)

        self.executablepathLabel = QLabel(getMessage("executable-path-label"), self)
        self.executablebrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'), getMessage("browse-label"))
        self.executablebrowseButton.clicked.connect(self.browsePlayerpath)
        self.mediapathTextbox = QLineEdit(config['file'], self)
        self.mediapathLabel = QLabel(getMessage("media-path-label"), self)
        self.mediabrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'), getMessage("browse-label"))
        self.mediabrowseButton.clicked.connect(self.browseMediapath)

        self.executablepathLabel.setObjectName("executable-path")
        self.executablepathCombobox.setObjectName("executable-path")
        self.mediapathLabel.setObjectName("media-path")
        self.mediapathTextbox.setObjectName(constants.LOAD_SAVE_MANUALLY_MARKER + "media-path")

        self.mediaplayerSettingsLayout = QtGui.QGridLayout()
        self.mediaplayerSettingsLayout.addWidget(self.executablepathLabel, 0, 0)
        self.mediaplayerSettingsLayout.addWidget(self.executableiconLabel, 0, 1)
        self.mediaplayerSettingsLayout.addWidget(self.executablepathCombobox, 0, 2)
        self.mediaplayerSettingsLayout.addWidget(self.executablebrowseButton, 0, 3)
        self.mediaplayerSettingsLayout.addWidget(self.mediapathLabel, 1, 0)
        self.mediaplayerSettingsLayout.addWidget(self.mediapathTextbox , 1, 2)
        self.mediaplayerSettingsLayout.addWidget(self.mediabrowseButton , 1, 3)
        self.mediaplayerSettingsGroup.setLayout(self.mediaplayerSettingsLayout)

        self.showmoreCheckbox = QCheckBox(getMessage("more-title"))
        self.showmoreCheckbox.setObjectName(constants.LOAD_SAVE_MANUALLY_MARKER + "more")

        self.basicOptionsFrame = QtGui.QFrame()
        self.basicOptionsLayout = QtGui.QVBoxLayout()
        if error:
            self.errorLabel = QLabel(self)
            if error[:1] != constants.ERROR_MESSAGE_MARKER:
                self.errorLabel.setStyleSheet(constants.STYLE_ERRORLABEL)
            else:
                error = error[1:]
                self.errorLabel.setStyleSheet(constants.STYLE_SUCCESSLABEL)
            self.errorLabel.setText(error)
            self.errorLabel.setAlignment(Qt.AlignCenter)

            self.basicOptionsLayout.addWidget(self.errorLabel, 0, 0)
        self.basicOptionsLayout.addWidget(self.connectionSettingsGroup)
        self.basicOptionsLayout.addSpacing(12)
        self.basicOptionsLayout.addWidget(self.mediaplayerSettingsGroup)

        self.basicOptionsFrame.setLayout(self.basicOptionsLayout)
        self.stackedLayout.addWidget(self.basicOptionsFrame)

    def addSyncTab(self):
        self.syncSettingsFrame = QtGui.QFrame()
        self.syncSettingsLayout = QtGui.QVBoxLayout()

        self.desyncSettingsGroup = QtGui.QGroupBox("If others are lagging behind...")
        self.desyncOptionsFrame = QtGui.QFrame()
        self.desyncSettingsOptionsLayout = QtGui.QHBoxLayout()
        config = self.config

        self.slowdownCheckbox = QCheckBox(getMessage("slowondesync-label"))
        self.slowdownCheckbox.setObjectName("slowOnDesync")
        self.rewindCheckbox = QCheckBox(getMessage("rewindondesync-label"))
        self.rewindCheckbox.setObjectName("rewindOnDesync")

        self.spaceLabel = QLabel()
        self.spaceLabel.setFixedHeight(5)

        self.desyncSettingsLayout = QtGui.QGridLayout()
        self.desyncSettingsLayout.setSpacing(2)
        self.desyncFrame = QtGui.QFrame()
        self.desyncFrame.setLineWidth(0)
        self.desyncFrame.setMidLineWidth(0)

        self.slowdownThresholdLabel = QLabel(getMessage("slowdown-threshold-label"), self)
        self.slowdownThresholdLabel.setStyleSheet(constants.STYLE_SUBLABEL.format(self.posixresourcespath + "bullet_black.png"))

        self.slowdownThresholdSpinbox = QDoubleSpinBox()
        try:
            slowdownThreshold = float(config['slowdownThreshold'])
            self.slowdownThresholdSpinbox.setValue(slowdownThreshold)
            if slowdownThreshold < constants.MINIMUM_SLOWDOWN_THRESHOLD:
                constants.MINIMUM_SLOWDOWN_THRESHOLD = slowdownThreshold
        except ValueError:
            self.slowdownThresholdSpinbox.setValue(constants.DEFAULT_SLOWDOWN_KICKIN_THRESHOLD)
        self.slowdownThresholdSpinbox.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
        self.slowdownThresholdSpinbox.setMinimum(constants.MINIMUM_SLOWDOWN_THRESHOLD)
        self.slowdownThresholdSpinbox.setSingleStep(0.1)
        self.slowdownThresholdSpinbox.setSuffix(getMessage("seconds-suffix"))
        self.slowdownThresholdSpinbox.adjustSize()

        self.rewindThresholdLabel = QLabel(getMessage("rewind-threshold-label"), self)
        self.rewindThresholdLabel.setStyleSheet(constants.STYLE_SUBLABEL.format(self.posixresourcespath + "bullet_black.png"))
        self.rewindThresholdSpinbox = QDoubleSpinBox()
        try:
            rewindThreshold = float(config['rewindThreshold'])
            self.rewindThresholdSpinbox.setValue(rewindThreshold)
            if rewindThreshold < constants.MINIMUM_REWIND_THRESHOLD:
                constants.MINIMUM_REWIND_THRESHOLD = rewindThreshold
        except ValueError:
            self.rewindThresholdSpinbox.setValue(constants.DEFAULT_REWIND_THRESHOLD)
        self.rewindThresholdSpinbox.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)
        self.rewindThresholdSpinbox.setMinimum(constants.MINIMUM_REWIND_THRESHOLD)
        self.rewindThresholdSpinbox.setSingleStep(0.1)
        self.rewindThresholdSpinbox.setSuffix(getMessage("seconds-suffix"))
        self.rewindThresholdSpinbox.adjustSize()

        self.slowdownThresholdLabel.setObjectName("slowdown-threshold")
        self.slowdownThresholdSpinbox.setObjectName("slowdown-threshold")
        self.rewindThresholdLabel.setObjectName("rewind-threshold")
        self.rewindThresholdSpinbox.setObjectName("rewind-threshold")

        self.desyncSettingsLayout.addWidget(self.slowdownCheckbox, 0, 0, 1, 2, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.slowdownThresholdLabel, 1, 0, 1, 1, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.slowdownThresholdSpinbox, 1, 1, 1, 1, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.spaceLabel, 2, 0,1,2, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.rewindCheckbox, 3, 0,1,2, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.rewindThresholdLabel, 4, 0, 1, 1, Qt.AlignLeft)
        self.desyncSettingsLayout.addWidget(self.rewindThresholdSpinbox, 4, 1, Qt.AlignLeft)

        self.subitems['slowOnDesync'] = ["slowdown-threshold"]
        self.subitems['rewindOnDesync'] = ["rewind-threshold"]

        self.desyncSettingsLayout.setAlignment(Qt.AlignLeft)
        self.desyncSettingsGroup.setLayout(self.desyncSettingsLayout)
        self.desyncSettingsOptionsLayout.addWidget(self.desyncFrame)
        self.syncSettingsLayout.addWidget(self.desyncSettingsGroup)
        self.desyncFrame.setLayout(self.syncSettingsLayout)

        self.othersyncSettingsGroup = QtGui.QGroupBox("Other sync options")
        self.othersyncOptionsFrame = QtGui.QFrame()
        self.othersyncSettingsLayout = QtGui.QGridLayout()


        self.dontslowwithmeCheckbox = QCheckBox(getMessage("dontslowdownwithme-label"))
        self.pauseonleaveCheckbox = QCheckBox(getMessage("pauseonleave-label"))
        self.othersyncSettingsLayout.addWidget(self.dontslowwithmeCheckbox)
        self.othersyncSettingsLayout.addWidget(self.pauseonleaveCheckbox)
        self.dontslowwithmeCheckbox.setObjectName("dontSlowDownWithMe")
        self.pauseonleaveCheckbox.setObjectName("pauseOnLeave")

        self.othersyncSettingsGroup.setLayout(self.othersyncSettingsLayout)
        self.syncSettingsLayout.addWidget(self.othersyncSettingsGroup)

        self.syncSettingsFrame.setLayout(self.syncSettingsLayout)
        self.desyncSettingsGroup.setMaximumHeight(self.desyncSettingsGroup.minimumSizeHint().height())
        self.syncSettingsLayout.setAlignment(Qt.AlignTop)
        self.stackedLayout.addWidget(self.syncSettingsFrame)

    def addMessageTab(self):
        self.messageFrame = QtGui.QFrame()
        self.messageLayout = QtGui.QVBoxLayout()

        # OSD
        self.osdSettingsGroup = QtGui.QGroupBox("On-screen Display settings")
        self.osdSettingsLayout = QtGui.QVBoxLayout()
        self.osdSettingsFrame = QtGui.QFrame()

        self.showOSDCheckbox = QCheckBox(getMessage("showosd-label"))
        self.showOSDCheckbox.setObjectName("showOSD")
        self.osdSettingsLayout.addWidget(self.showOSDCheckbox)

        self.showSameRoomOSDCheckbox = QCheckBox(getMessage("showsameroomosd-label"))
        self.showSameRoomOSDCheckbox.setObjectName("showSameRoomOSD")
        self.showSameRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "bullet_black.png"))
        self.osdSettingsLayout.addWidget(self.showSameRoomOSDCheckbox)

        self.showDifferentRoomOSDCheckbox = QCheckBox(getMessage("showdifferentroomosd-label"))
        self.showDifferentRoomOSDCheckbox.setObjectName("showDifferentRoomOSD")
        self.showDifferentRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "bullet_black.png"))
        self.osdSettingsLayout.addWidget(self.showDifferentRoomOSDCheckbox)

        self.slowdownOSDCheckbox = QCheckBox(getMessage("showslowdownosd-label"))
        self.slowdownOSDCheckbox.setObjectName("showSlowdownOSD")
        self.slowdownOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "bullet_black.png"))
        self.osdSettingsLayout.addWidget(self.slowdownOSDCheckbox)

        self.showOSDWarningsCheckbox = QCheckBox(getMessage("showosdwarnings-label"))
        self.showOSDWarningsCheckbox.setObjectName("showOSDWarnings")
        self.showOSDWarningsCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "bullet_black.png"))
        self.osdSettingsLayout.addWidget(self.showOSDWarningsCheckbox)

        self.subitems['showOSD'] = ["showSameRoomOSD", "showDifferentRoomOSD", "showSlowdownOSD", "showOSDWarnings"]

        self.osdSettingsGroup.setLayout(self.osdSettingsLayout)
        self.osdSettingsLayout.setAlignment(Qt.AlignTop)
        self.messageLayout.addWidget(self.osdSettingsGroup)

        # Other display

        self.displaySettingsGroup = QtGui.QGroupBox("Other display settings")
        self.displaySettingsLayout = QtGui.QVBoxLayout()
        self.displaySettingsFrame = QtGui.QFrame()

        self.showDurationNotificationCheckbox = QCheckBox(getMessage("showdurationnotification-label"))
        self.showDurationNotificationCheckbox.setObjectName("showDurationNotification")
        self.displaySettingsLayout.addWidget(self.showDurationNotificationCheckbox)

        self.showcontactinfoCheckbox = QCheckBox(getMessage("showcontactinfo-label"))
        self.showcontactinfoCheckbox.setObjectName("showContactInfo")
        self.displaySettingsLayout.addWidget(self.showcontactinfoCheckbox)

        self.showButtonLabelsCheckbox = QCheckBox(getMessage("showbuttonlabels-label"))
        self.showButtonLabelsCheckbox.setObjectName("showButtonLabels")
        self.displaySettingsLayout.addWidget(self.showButtonLabelsCheckbox)

        self.showTooltipsCheckbox = QCheckBox(getMessage("showtooltips-label"))
        self.showTooltipsCheckbox.setObjectName("showTooltips")
        self.displaySettingsLayout.addWidget(self.showTooltipsCheckbox)


        self.displaySettingsGroup.setLayout(self.displaySettingsLayout)
        self.displaySettingsLayout.setAlignment(Qt.AlignTop)
        self.messageLayout.addWidget(self.displaySettingsGroup)

        # messageFrame
        self.messageFrame.setLayout(self.messageLayout)
        self.stackedLayout.addWidget(self.messageFrame)

    def addPrivacyTab(self):
        self.privacySettingsGroup = QtGui.QGroupBox("Privacy settings")
        self.privacySettingsLayout = QtGui.QVBoxLayout()
        self.privacySettingsFrame = QtGui.QFrame()
        self.privacyFrame = QtGui.QFrame()
        self.privacyLayout = QtGui.QGridLayout()

        self.filenameprivacyLabel = QLabel(getMessage("filename-privacy-label"), self)
        self.filenameprivacyButtonGroup = QButtonGroup()
        self.filenameprivacySendRawOption = QRadioButton(getMessage("privacy-sendraw-option"))
        self.filenameprivacySendHashedOption = QRadioButton(getMessage("privacy-sendhashed-option"))
        self.filenameprivacyDontSendOption = QRadioButton(getMessage("privacy-dontsend-option"))
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendRawOption)
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendHashedOption)
        self.filenameprivacyButtonGroup.addButton(self.filenameprivacyDontSendOption)

        self.filesizeprivacyLabel = QLabel(getMessage("filesize-privacy-label"), self)
        self.filesizeprivacyButtonGroup = QButtonGroup()
        self.filesizeprivacySendRawOption = QRadioButton(getMessage("privacy-sendraw-option"))
        self.filesizeprivacySendHashedOption = QRadioButton(getMessage("privacy-sendhashed-option"))
        self.filesizeprivacyDontSendOption = QRadioButton(getMessage("privacy-dontsend-option"))
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendRawOption)
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendHashedOption)
        self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacyDontSendOption)

        self.filenameprivacyLabel.setObjectName("filename-privacy")
        self.filenameprivacySendRawOption.setObjectName("privacy-sendraw" + constants.CONFIG_NAME_MARKER + "filenamePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_SENDRAW_MODE)
        self.filenameprivacySendHashedOption.setObjectName("privacy-sendhashed" + constants.CONFIG_NAME_MARKER + "filenamePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_SENDHASHED_MODE)
        self.filenameprivacyDontSendOption.setObjectName("privacy-dontsend" + constants.CONFIG_NAME_MARKER + "filenamePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_DONTSEND_MODE)
        self.filesizeprivacyLabel.setObjectName("filesize-privacy")
        self.filesizeprivacySendRawOption.setObjectName("privacy-sendraw" + constants.CONFIG_NAME_MARKER + "filesizePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_SENDRAW_MODE)
        self.filesizeprivacySendHashedOption.setObjectName("privacy-sendhashed" + constants.CONFIG_NAME_MARKER + "filesizePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_SENDHASHED_MODE)
        self.filesizeprivacyDontSendOption.setObjectName("privacy-dontsend" + constants.CONFIG_NAME_MARKER + "filesizePrivacyMode" + constants.CONFIG_VALUE_MARKER + constants.PRIVACY_DONTSEND_MODE)

        self.privacyLayout.addWidget(self.filenameprivacyLabel, 1, 0)
        self.privacyLayout.addWidget(self.filenameprivacySendRawOption, 1, 1, Qt.AlignLeft)
        self.privacyLayout.addWidget(self.filenameprivacySendHashedOption, 1, 2, Qt.AlignLeft)
        self.privacyLayout.addWidget(self.filenameprivacyDontSendOption, 1, 3, Qt.AlignLeft)
        self.privacyLayout.addWidget(self.filesizeprivacyLabel, 2, 0)
        self.privacyLayout.addWidget(self.filesizeprivacySendRawOption, 2, 1, Qt.AlignLeft)
        self.privacyLayout.addWidget(self.filesizeprivacySendHashedOption, 2, 2, Qt.AlignLeft)
        self.privacyLayout.addWidget(self.filesizeprivacyDontSendOption, 2, 3, Qt.AlignLeft)

        self.privacyFrame.setLayout(self.privacyLayout)
        self.privacySettingsGroup.setLayout(self.privacyLayout)
        self.privacySettingsGroup.setMaximumHeight(self.privacySettingsGroup.minimumSizeHint().height())
        self.privacySettingsLayout.addWidget(self.privacySettingsGroup)
        self.privacySettingsLayout.setAlignment(Qt.AlignTop)
        self.privacyFrame.setLayout(self.privacySettingsLayout)
        self.stackedLayout.addWidget(self.privacyFrame)

    def addBottomLayout(self):
        config = self.config
        resourcespath = self.resourcespath

        self.bottomButtonFrame = QtGui.QFrame()
        self.bottomButtonLayout = QtGui.QHBoxLayout()
        self.helpButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'help.png'), getMessage("help-label"))
        self.helpButton.setObjectName("help")
        self.helpButton.setMaximumSize(self.helpButton.sizeHint())
        self.helpButton.pressed.connect(self.openHelp)

        self.resetButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'cog_delete.png'),getMessage("reset-label"))
        self.resetButton.setMaximumSize(self.resetButton.sizeHint())
        self.resetButton.setObjectName("reset")
        self.resetButton.pressed.connect(self.resetSettings)

        self.runButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'accept.png'), getMessage("storeandrun-label"))
        self.runButton.pressed.connect(self._saveDataAndLeave)
        self.bottomButtonLayout.addWidget(self.helpButton)
        self.bottomButtonLayout.addWidget(self.resetButton)
        self.bottomButtonLayout.addWidget(self.runButton)
        self.bottomButtonFrame.setLayout(self.bottomButtonLayout)
        if config['noStore'] == True:
            self.runButton.setText(getMessage("run-label"))
        self.bottomButtonLayout.setContentsMargins(5,0,5,0)
        self.mainLayout.addWidget(self.bottomButtonFrame, 1, 0, 1, 2)

        self.bottomCheckboxFrame = QtGui.QFrame()
        self.bottomCheckboxFrame.setContentsMargins(0,0,0,0)
        self.bottomCheckboxLayout = QtGui.QGridLayout()
        self.alwaysshowCheckbox = QCheckBox(getMessage("forceguiprompt-label"))

        self.nostoreCheckbox = QCheckBox(getMessage("nostore-label"))
        self.bottomCheckboxLayout.addWidget(self.showmoreCheckbox)
        self.bottomCheckboxLayout.addWidget(self.alwaysshowCheckbox, 0, 1, Qt.AlignLeft)
        self.bottomCheckboxLayout.addWidget(self.nostoreCheckbox, 0, 2, Qt.AlignRight)
        self.alwaysshowCheckbox.setObjectName(constants.INVERTED_STATE_MARKER + "forceGuiPrompt")
        self.nostoreCheckbox.setObjectName("noStore")
        self.nostoreCheckbox.toggled.connect(self.runButtonTextUpdate)
        self.bottomCheckboxFrame.setLayout(self.bottomCheckboxLayout)
        self.mainLayout.addWidget(self.bottomCheckboxFrame, 2, 0, 1, 2)

    def tabList(self):
        self.tabListLayout = QtGui.QHBoxLayout()
        self.tabListFrame = QtGui.QFrame()
        self.tabListWidget = QtGui.QListWidget()
        self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "house.png"),getMessage("basics-label")))
        self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "film_link.png"),getMessage("sync-label")))
        self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "comments.png"),getMessage("messages-label")))
        self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "eye.png"),getMessage("privacy-label")))
        self.tabListLayout.addWidget(self.tabListWidget)
        self.tabListFrame.setLayout(self.tabListLayout)
        self.tabListFrame.setFixedWidth(self.tabListFrame.minimumSizeHint().width())
        self.tabListWidget.setStyleSheet(constants.STYLE_TABLIST)

        self.tabListWidget.currentItemChanged.connect(self.tabChange)
        self.tabListWidget.itemClicked.connect(self.tabChange)
        self.tabListWidget.itemPressed.connect(self.tabChange)
        self.mainLayout.addWidget(self.tabListFrame, 0, 0, 1, 1)

    def ensureTabListIsVisible(self):
        self.stackedFrame.setFixedWidth(self.stackedFrame.width())
        while self.tabListWidget.horizontalScrollBar().isVisible() and self.tabListFrame.width() < 200:
            self.tabListFrame.setFixedWidth(self.tabListFrame.width()+1)

    def tabChange(self):
        self.setFocus()
        self.stackedLayout.setCurrentIndex(self.tabListWidget.currentRow())

    def resetSettings(self):
        self.clearGUIData(leaveMore=True)
        self.config['resetConfig'] = True
        self.pressedclosebutton = True
        self.close()

    def showEvent(self, *args, **kwargs):
        self.ensureTabListIsVisible()
        self.setFixedWidth(self.minimumSizeHint().width())
        self.executablepathCombobox.setFixedWidth(self.mediapathTextbox.width())

    def clearGUIData(self, leaveMore=False):
        settings = QSettings("Syncplay", "PlayerList")
        settings.clear()
        settings = QSettings("Syncplay", "MediaBrowseDialog")
        settings.clear()
        settings = QSettings("Syncplay", "MainWindow")
        settings.clear()
        if not leaveMore:
            settings = QSettings("Syncplay", "MoreSettings")
            settings.clear()
        self.datacleared = True

    def __init__(self, config, playerpaths, error, defaultConfig):

        from syncplay import utils
        self.config = config
        self.defaultConfig = defaultConfig
        self.playerpaths = playerpaths
        self.datacleared = False
        self.config['resetConfig'] = False
        self.subitems = {}

        if self.config['clearGUIData'] == True:
            self.config['clearGUIData'] = False
            self.clearGUIData()

        self.QtGui = QtGui
        self.error = error
        if sys.platform.startswith('win'):
            resourcespath = utils.findWorkingDir() + "\\resources\\"
        else:
            resourcespath = utils.findWorkingDir() + "/resources/"
        self.posixresourcespath = utils.findWorkingDir().replace("\\","/") + "/resources/"
        self.resourcespath = resourcespath

        super(ConfigDialog, self).__init__()

        self.setWindowTitle(getMessage("config-window-title"))
        self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
        self.setWindowIcon(QtGui.QIcon(resourcespath + "syncplay.png"))

        self.stackedLayout = QtGui.QStackedLayout()
        self.stackedFrame = QtGui.QFrame()
        self.stackedFrame.setLayout(self.stackedLayout)

        self.mainLayout = QtGui.QGridLayout()
        self.mainLayout.setSpacing(0)
        self.mainLayout.setContentsMargins(0,0,0,0)

        self.addBasicTab()
        self.addSyncTab()
        self.addMessageTab()
        self.addPrivacyTab()
        self.tabList()

        self.mainLayout.addWidget(self.stackedFrame, 0, 1)
        self.addBottomLayout()


        if self.getMoreState() == False:
            self.tabListFrame.hide()
            self.nostoreCheckbox.hide()
            self.alwaysshowCheckbox.hide()
            self.resetButton.hide()
        else:
            self.showmoreCheckbox.setChecked(True)
            self.tabListWidget.setCurrentRow(0)

        self.showmoreCheckbox.toggled.connect(self.moreToggled)

        self.setLayout(self.mainLayout)
        self.runButton.setFocus()
        self.setFixedSize(self.sizeHint())
        self.setAcceptDrops(True)

        if constants.SHOW_TOOLTIPS:
            self.processWidget(self, lambda w: self.loadTooltips(w))
        self.processWidget(self, lambda w: self.loadValues(w))
        self.processWidget(self, lambda w: self.connectChildren(w))