def __init__(self, choices, help_texts=[], parent=None): super(ChoiceDialog, self).__init__(parent) title = "select one from choices" self.setWindowTitle(title) layout = QVBoxLayout(self) self.choiceButtonGroup = QButtonGroup(self) # it is not a visible UI self.choiceButtonGroup.setExclusive(True) if choices and len(choices) >= 1: if len(help_texts) < len(choices): help_texts = choices self.choices = choices for id, choice in enumerate(self.choices): rb = QRadioButton(choice) rb.setToolTip(help_texts[id]) self.choiceButtonGroup.addButton(rb) self.choiceButtonGroup.setId( rb, id) # negative id if not specified layout.addWidget(rb) if id == 0: rb.setChecked(True) self.choiceButtonGroup.buttonClicked.connect(self.choiceChanged) # OK and Cancel buttons buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons) self.setLayout(layout)
def _createChoiceGroup(valueTypes, valueTypeTips): _buttonGroupLayout = QHBoxLayout() buttonGroupValueType = QButtonGroup() buttonGroupValueType.setExclusive(True) for id, choice in enumerate(valueTypes): rb = QRadioButton(choice) rb.setToolTip(valueTypeTips[id]) buttonGroupValueType.addButton(rb, id) _buttonGroupLayout.addWidget(rb) if id == 0: rb.setChecked(True) return buttonGroupValueType, _buttonGroupLayout
class ConfigDialog(QtGui.QDialog): pressedclosebutton = False moreToggling = False def moreToggled(self): if self.moreToggling == False: self.moreToggling = True if self.showmoreCheckbox.isChecked() and self.showmoreCheckbox.isVisible(): self.showmoreCheckbox.setChecked(False) self.moreSettingsGroup.setChecked(True) self.moreSettingsGroup.show() self.showmoreCheckbox.hide() self.saveMoreState(True) else: self.moreSettingsGroup.setChecked(False) self.moreSettingsGroup.hide() self.showmoreCheckbox.show() self.saveMoreState(False) self.moreToggling = False self.adjustSize() self.setFixedSize(self.sizeHint()) def runButtonTextUpdate(self): if (self.donotstoreCheckbox.isChecked()): self.runButton.setText(getMessage("en", "run-label")) else: self.runButton.setText(getMessage("en", "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" 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.config['host'] = self.hostTextbox.text() if ":" in self.hostTextbox.text() else self.hostTextbox.text() + ":" + unicode(constants.DEFAULT_PORT) self.config['name'] = self.usernameTextbox.text() self.config['room'] = self.defaultroomTextbox.text() self.config['password'] = self.serverpassTextbox.text() 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 self.alwaysshowCheckbox.isChecked() == True: self.config['forceGuiPrompt'] = True else: self.config['forceGuiPrompt'] = False if self.donotstoreCheckbox.isChecked() == True: self.config['noStore'] = True else: self.config['noStore'] = False if self.slowdownCheckbox.isChecked() == True: self.config['slowOnDesync'] = True else: self.config['slowOnDesync'] = False if self.dontslowwithmeCheckbox.isChecked() == True: self.config['dontSlowDownWithMe'] = True else: self.config['dontSlowDownWithMe'] = False if self.pauseonleaveCheckbox.isChecked() == True: self.config['pauseOnLeave'] = True else: self.config['pauseOnLeave'] = False if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True: if self.rewindCheckbox.isChecked() == True: self.config['rewindOnDesync'] = True else: self.config['rewindOnDesync'] = False if self.filenameprivacySendRawOption.isChecked() == True: self.config['filenamePrivacyMode'] = constants.PRIVACY_SENDRAW_MODE elif self.filenameprivacySendHashedOption.isChecked() == True: self.config['filenamePrivacyMode'] = constants.PRIVACY_SENDHASHED_MODE elif self.filenameprivacyDontSendOption.isChecked() == True: self.config['filenamePrivacyMode'] = constants.PRIVACY_DONTSEND_MODE if self.filesizeprivacySendRawOption.isChecked() == True: self.config['filesizePrivacyMode'] = constants.PRIVACY_SENDRAW_MODE elif self.filesizeprivacySendHashedOption.isChecked() == True: self.config['filesizePrivacyMode'] = constants.PRIVACY_SENDHASHED_MODE elif self.filesizeprivacyDontSendOption.isChecked() == True: self.config['filesizePrivacyMode'] = constants.PRIVACY_DONTSEND_MODE 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('linux'): dropfilepath = unicode(urls[0].path()) else: dropfilepath = unicode(urls[0].path())[1:] # Removes starting slash if dropfilepath[-4:].lower() == ".exe": self.executablepathCombobox.setEditText(dropfilepath) else: self.mediapathTextbox.setText(dropfilepath) def __init__(self, config, playerpaths, error): from syncplay import utils self.config = config self.datacleared = False if config['clearGUIData'] == True: settings = QSettings("Syncplay", "PlayerList") settings.clear() settings = QSettings("Syncplay", "MediaBrowseDialog") settings.clear() settings = QSettings("Syncplay", "MainWindow") settings.clear() settings = QSettings("Syncplay", "MoreSettings") settings.clear() self.datacleared = True self.QtGui = QtGui self.error = error if sys.platform.startswith('linux'): resourcespath = utils.findWorkingDir() + "/resources/" else: resourcespath = utils.findWorkingDir() + "\\resources\\" self.resourcespath = resourcespath super(ConfigDialog, self).__init__() self.setWindowTitle(getMessage("en", "config-window-title")) self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint) self.setWindowIcon(QtGui.QIcon(resourcespath + "syncplay.png")) if(config['host'] == None): host = "" elif(":" in config['host']): host = config['host'] else: host = config['host'] + ":" + str(config['port']) self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("en", "connection-group-title")) self.hostTextbox = QLineEdit(host, self) self.hostLabel = QLabel(getMessage("en", "host-label"), self) self.usernameTextbox = QLineEdit(config['name'], self) self.serverpassLabel = QLabel(getMessage("en", "password-label"), self) self.defaultroomTextbox = QLineEdit(config['room'], self) self.usernameLabel = QLabel(getMessage("en", "username-label"), self) self.serverpassTextbox = QLineEdit(config['password'], self) self.defaultroomLabel = QLabel(getMessage("en", "room-label"), self) if (constants.SHOW_TOOLTIPS == True): self.hostLabel.setToolTip(getMessage("en", "host-tooltip")) self.hostTextbox.setToolTip(getMessage("en", "host-tooltip")) self.usernameLabel.setToolTip(getMessage("en", "username-tooltip")) self.usernameTextbox.setToolTip(getMessage("en", "username-tooltip")) self.serverpassLabel.setToolTip(getMessage("en", "password-tooltip")) self.serverpassTextbox.setToolTip(getMessage("en", "password-tooltip")) self.defaultroomLabel.setToolTip(getMessage("en", "room-tooltip")) self.defaultroomTextbox.setToolTip(getMessage("en", "room-tooltip")) 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("en", "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.setMinimumWidth(200) self.executablepathCombobox.setMaximumWidth(200) self.executablepathCombobox.editTextChanged.connect(self.updateExecutableIcon) self.executablepathLabel = QLabel(getMessage("en", "executable-path-label"), self) self.executablebrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'), getMessage("en", "browse-label")) self.executablebrowseButton.clicked.connect(self.browsePlayerpath) self.mediapathTextbox = QLineEdit(config['file'], self) self.mediapathLabel = QLabel(getMessage("en", "media-path-label"), self) self.mediabrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'), getMessage("en", "browse-label")) self.mediabrowseButton.clicked.connect(self.browseMediapath) if (constants.SHOW_TOOLTIPS == True): self.executablepathLabel.setToolTip(getMessage("en", "executable-path-tooltip")) self.executablepathCombobox.setToolTip(getMessage("en", "executable-path-tooltip")) self.mediapathLabel.setToolTip(getMessage("en", "media-path-tooltip")) self.mediapathTextbox.setToolTip(getMessage("en", "media-path-tooltip")) if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True: self.rewindCheckbox = QCheckBox(getMessage("en", "rewind-label")) if (constants.SHOW_TOOLTIPS == True): self.rewindCheckbox.setToolTip(getMessage("en", "rewind-tooltip")) 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.moreSettingsGroup = QtGui.QGroupBox(getMessage("en", "more-title")) self.moreSettingsGroup.setCheckable(True) self.filenameprivacyLabel = QLabel(getMessage("en", "filename-privacy-label"), self) self.filenameprivacyButtonGroup = QButtonGroup() self.filenameprivacySendRawOption = QRadioButton(getMessage("en", "privacy-sendraw-option")) self.filenameprivacySendHashedOption = QRadioButton(getMessage("en", "privacy-sendhashed-option")) self.filenameprivacyDontSendOption = QRadioButton(getMessage("en", "privacy-dontsend-option")) self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendRawOption) self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendHashedOption) self.filenameprivacyButtonGroup.addButton(self.filenameprivacyDontSendOption) self.filesizeprivacyLabel = QLabel(getMessage("en", "filesize-privacy-label"), self) self.filesizeprivacyButtonGroup = QButtonGroup() self.filesizeprivacySendRawOption = QRadioButton(getMessage("en", "privacy-sendraw-option")) self.filesizeprivacySendHashedOption = QRadioButton(getMessage("en", "privacy-sendhashed-option")) self.filesizeprivacyDontSendOption = QRadioButton(getMessage("en", "privacy-dontsend-option")) self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendRawOption) self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendHashedOption) self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacyDontSendOption) self.slowdownCheckbox = QCheckBox(getMessage("en", "slowdown-label")) self.dontslowwithmeCheckbox = QCheckBox(getMessage("en", "dontslowwithme-label")) self.pauseonleaveCheckbox = QCheckBox(getMessage("en", "pauseonleave-label")) self.alwaysshowCheckbox = QCheckBox(getMessage("en", "alwayshow-label")) self.donotstoreCheckbox = QCheckBox(getMessage("en", "donotstore-label")) filenamePrivacyMode = config['filenamePrivacyMode'] if filenamePrivacyMode == constants.PRIVACY_DONTSEND_MODE: self.filenameprivacyDontSendOption.setChecked(True) elif filenamePrivacyMode == constants.PRIVACY_SENDHASHED_MODE: self.filenameprivacySendHashedOption.setChecked(True) else: self.filenameprivacySendRawOption.setChecked(True) filesizePrivacyMode = config['filesizePrivacyMode'] if filesizePrivacyMode == constants.PRIVACY_DONTSEND_MODE: self.filesizeprivacyDontSendOption.setChecked(True) elif filesizePrivacyMode == constants.PRIVACY_SENDHASHED_MODE: self.filesizeprivacySendHashedOption.setChecked(True) else: self.filesizeprivacySendRawOption.setChecked(True) if config['slowOnDesync'] == True: self.slowdownCheckbox.setChecked(True) if config['dontSlowDownWithMe'] == True: self.dontslowwithmeCheckbox.setChecked(True) if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True and config['rewindOnDesync'] == True: self.rewindCheckbox.setChecked(True) if config['pauseOnLeave'] == True: self.pauseonleaveCheckbox.setChecked(True) if (constants.SHOW_TOOLTIPS == True): self.filenameprivacyLabel.setToolTip(getMessage("en", "filename-privacy-tooltip")) self.filenameprivacySendRawOption.setToolTip(getMessage("en", "privacy-sendraw-tooltip")) self.filenameprivacySendHashedOption.setToolTip(getMessage("en", "privacy-sendhashed-tooltip")) self.filenameprivacyDontSendOption.setToolTip(getMessage("en", "privacy-dontsend-tooltip")) self.filesizeprivacyLabel.setToolTip(getMessage("en", "filesize-privacy-tooltip")) self.filesizeprivacySendRawOption.setToolTip(getMessage("en", "privacy-sendraw-tooltip")) self.filesizeprivacySendHashedOption.setToolTip(getMessage("en", "privacy-sendhashed-tooltip")) self.filesizeprivacyDontSendOption.setToolTip(getMessage("en", "privacy-dontsend-tooltip")) self.slowdownCheckbox.setToolTip(getMessage("en", "slowdown-tooltip")) self.dontslowwithmeCheckbox.setToolTip(getMessage("en", "dontslowwithme-tooltip")) self.pauseonleaveCheckbox.setToolTip(getMessage("en", "pauseonleave-tooltip")) self.alwaysshowCheckbox.setToolTip(getMessage("en", "alwayshow-tooltip")) self.donotstoreCheckbox.setToolTip(getMessage("en", "donotstore-tooltip")) self.slowdownCheckbox.setToolTip(getMessage("en", "slowdown-tooltip")) self.moreSettingsLayout = QtGui.QGridLayout() self.privacySettingsLayout = QtGui.QGridLayout() self.privacyFrame = QtGui.QFrame() self.privacyFrame.setLineWidth(0) self.privacyFrame.setMidLineWidth(0) self.privacySettingsLayout.setContentsMargins(0, 0, 0, 0) self.privacySettingsLayout.addWidget(self.filenameprivacyLabel, 0, 0) self.privacySettingsLayout.addWidget(self.filenameprivacySendRawOption, 0, 1, Qt.AlignRight) self.privacySettingsLayout.addWidget(self.filenameprivacySendHashedOption, 0, 2, Qt.AlignRight) self.privacySettingsLayout.addWidget(self.filenameprivacyDontSendOption, 0, 3, Qt.AlignRight) self.privacySettingsLayout.addWidget(self.filesizeprivacyLabel, 1, 0) self.privacySettingsLayout.addWidget(self.filesizeprivacySendRawOption, 1, 1, Qt.AlignRight) self.privacySettingsLayout.addWidget(self.filesizeprivacySendHashedOption, 1, 2, Qt.AlignRight) self.privacySettingsLayout.addWidget(self.filesizeprivacyDontSendOption, 1, 3, Qt.AlignRight) self.privacyFrame.setLayout(self.privacySettingsLayout) self.moreSettingsLayout.addWidget(self.privacyFrame, 0, 0, 1, 4) self.moreSettingsLayout.addWidget(self.slowdownCheckbox, 2, 0, 1, 4) self.moreSettingsLayout.addWidget(self.dontslowwithmeCheckbox, 3, 0, 1, 4) if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True: self.moreSettingsLayout.addWidget(self.rewindCheckbox, 4, 0, 1, 4) self.moreSettingsLayout.addWidget(self.pauseonleaveCheckbox, 5, 0, 1, 4) self.moreSettingsLayout.addWidget(self.alwaysshowCheckbox, 6, 0, 1, 4) self.moreSettingsLayout.addWidget(self.donotstoreCheckbox, 7, 0, 1, 4) self.moreSettingsGroup.setLayout(self.moreSettingsLayout) self.showmoreCheckbox = QCheckBox(getMessage("en", "more-title")) if self.getMoreState() == False: self.showmoreCheckbox.setChecked(False) self.moreSettingsGroup.hide() else: self.showmoreCheckbox.hide() self.showmoreCheckbox.toggled.connect(self.moreToggled) self.moreSettingsGroup.toggled.connect(self.moreToggled) if config['forceGuiPrompt'] == True: self.alwaysshowCheckbox.setChecked(True) if (constants.SHOW_TOOLTIPS == True): self.showmoreCheckbox.setToolTip(getMessage("en", "more-tooltip")) self.donotstoreCheckbox.toggled.connect(self.runButtonTextUpdate) self.mainLayout = QtGui.QVBoxLayout() if error: self.errorLabel = QLabel(error, self) self.errorLabel.setAlignment(Qt.AlignCenter) self.errorLabel.setStyleSheet("QLabel { color : red; }") self.mainLayout.addWidget(self.errorLabel) self.mainLayout.addWidget(self.connectionSettingsGroup) self.mainLayout.addSpacing(12) self.mainLayout.addWidget(self.mediaplayerSettingsGroup) self.mainLayout.addSpacing(12) self.mainLayout.addWidget(self.showmoreCheckbox) self.mainLayout.addWidget(self.moreSettingsGroup) self.mainLayout.addSpacing(12) self.topLayout = QtGui.QHBoxLayout() self.helpButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'help.png'), getMessage("en", "help-label")) if (constants.SHOW_TOOLTIPS == True): self.helpButton.setToolTip(getMessage("en", "help-tooltip")) self.helpButton.setMaximumSize(self.helpButton.sizeHint()) self.helpButton.pressed.connect(self.openHelp) self.runButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'accept.png'), getMessage("en", "storeandrun-label")) self.runButton.pressed.connect(self._saveDataAndLeave) if config['noStore'] == True: self.donotstoreCheckbox.setChecked(True) self.runButton.setText(getMessage("en", "run-label")) self.topLayout.addWidget(self.helpButton, Qt.AlignLeft) self.topLayout.addWidget(self.runButton, Qt.AlignRight) self.mainLayout.addLayout(self.topLayout) self.mainLayout.addStretch(1) self.setLayout(self.mainLayout) self.runButton.setFocus() self.setFixedSize(self.sizeHint()) self.setAcceptDrops(True) if self.datacleared == True: QtGui.QMessageBox.information(self, "Syncplay", getMessage("en", "gui-data-cleared-notification"))
class RateView(QGroupBox): '''The box containing the rate value''' def __init__(self, title = 'Rate', parent = None): '''Initialize''' super(RateView, self).__init__(parent) self.setTitle(title) self._createWidgets() def _createWidgets(self): '''Create the widgets contained in this box''' # Rate or lifetime chooser self.rate = QRadioButton('Rate', self) self.rate.setToolTip(ttt('Choose this to express exchange as rate')) self.lifetime = QRadioButton('Lifetime', self) self.lifetime.setToolTip(ttt('Choose this to express exchange as ' 'lifetime')) # Box containing value self.rate_value = QLineEdit(self) validate = QDoubleValidator(self.rate_value) validate.setDecimals(3) validate.setBottom(0.0) self.rate_value.setValidator(validate) self.rate_value.setToolTip(ttt('The rate or lifetime value')) # Unit self.unit = QComboBox(self) self.unit.setToolTip(ttt('Selects the input unit for the rate ' 'or lifetime')) def initUI(self): '''Lays out the widgets''' radios = QVBoxLayout() radios.addWidget(self.rate) radios.addWidget(self.lifetime) rate = QGridLayout() rate.addWidget(QLabel("Unit: "), 1, 1) rate.addWidget(self.unit, 1, 2) rate.addWidget(QLabel("Value: "), 2, 1) rate.addWidget(self.rate_value, 2, 2) total = QHBoxLayout() total.addLayout(radios) total.addStretch() total.addLayout(rate) self.setLayout(total) def makeConnections(self): '''Connect the widgets together''' # When one radio button is checked, change the combo box model # and un-check the other radio button self.rate.clicked.connect(self.setRateModel) self.lifetime.clicked.connect(self.setLifetimeModel) # If the text changes, emit that rate self.rate_value.editingFinished.connect(self.emitRate) # If the underlying model changes, adjust the text self.model.rateChanged.connect(self.updateRate) # If the unit changes, update rate self.unit.currentIndexChanged.connect(self.updateUnit) def setModel(self, model): '''Attaches models to the views''' self.model = model def setRate(self, rate): '''Set the rate manually''' self.rate_value.setText(str(rate)) self.rate_value.editingFinished.emit() def setUnit(self, unit): '''Set the unit manually''' if unit == 's': self.lifetime.click() self.unit.setCurrentIndex(0) elif unit == 'ns': self.lifetime.click() self.unit.setCurrentIndex(1) elif unit == 'ps': self.lifetime.click() self.unit.setCurrentIndex(2) elif unit == 'fs': self.lifetime.click() self.unit.setCurrentIndex(3) elif unit in ('Hz', 'hz'): self.rate.click() self.unit.setCurrentIndex(0) elif unit in ('GHz', 'ghz'): self.rate.click() self.unit.setCurrentIndex(1) elif unit in ('THz', 'thz'): self.rate.click() self.unit.setCurrentIndex(2) elif unit in ('PHz', 'phz'): self.rate.click() self.unit.setCurrentIndex(3) else: error.showMessage('Invalid unit: {0}'.format(unit)) ####### # SLOTS ####### def updateRate(self): '''Updates the rate of the text box''' # Do nothing if rate is not yet defined try: rate = self.model.rate except AttributeError: return if 0.1 > rate or rate > 100: self.rate_value.setText('{0:.3E}'.format(rate)) else: self.rate_value.setText('{0:.3F}'.format(rate)) def emitRate(self): '''Converts the text to a float and emits''' # Do nothing if there is no number try: self.model.setRate(float(self.rate_value.text())) except ValueError: pass def updateUnit(self): '''Update for a change of unit''' # If there is no unit yet, just set it try: unit = self.model.unit except AttributeError: self.model.setConverter(str(self.unit.currentText())) try: self.model.setRate(float(self.rate_value.text())) except ValueError: pass return # Convert unit appropriately if self.rate.isChecked(): if unit == 'Hz': conv = { 'GHz' : 1E-9, 'THz' : 1E-12, 'PHz' : 1E-15 } elif unit == 'GHz': conv = { 'Hz' : 1E9, 'THz' : 1E-3, 'PHz' : 1E-6 } elif unit == 'THz': conv = { 'Hz' : 1E12, 'GHz' : 1E3, 'PHz' : 1E-3 } elif unit == 'PHz': conv = { 'Hz' : 1E15, 'GHz' : 1E6, 'THz' : 1E3 } else: conv = { '' : 1, 'Hz' : 1, 'GHz' : 1, 'THz' : 1, 'PHz' : 1, } else: if unit == 's': conv = { 'ns' : 1E9, 'ps' : 1E12, 'fs' : 1E15 } elif unit == 'ns': conv = { 's' : 1E-9, 'ps' : 1E3, 'fs' : 1E6 } elif unit == 'ps': conv = { 's' : 1E-12, 'ns' : 1E-3, 'fs' : 1E3 } elif unit == 'fs': conv = { 's' : 1E-15, 'ns' : 1E-6, 'ps' : 1E-3 } else: conv = { '' : 1, 's' : 1, 'ns' : 1, 'ps' : 1, 'fs' : 1, } try: # Set the new converter, then change the rate self.model.setConverter(str(self.unit.currentText())) try: self.model.setRate(float(self.rate_value.text()) * conv[str(self.unit.currentText())]) except ValueError: pass except KeyError: pass # Save the new unit self.model.unit = str(self.unit.currentText()) def setRateModel(self): '''Change the model to use the rate''' if self.model.method == 'rate': return self.model.method = 'rate' indx = self.unit.currentIndex() self.unit.setModel(self.model.runits) self.model.unit = str(self.unit.itemText(indx)) self.unit.setCurrentIndex(indx) self.model.setConverter(self.model.unit) try: self.model.setRate(1 / float(self.rate_value.text())) except (ZeroDivisionError, ValueError): pass def setLifetimeModel(self): '''Change the model to use the lifetime''' if self.model.method == 'lifetime': return self.model.method = 'lifetime' indx = self.unit.currentIndex() self.unit.setModel(self.model.lunits) self.model.unit = str(self.unit.itemText(indx)) self.unit.setCurrentIndex(indx) self.model.setConverter(self.model.unit) try: self.model.setRate(1 / float(self.rate_value.text())) except (ZeroDivisionError, ValueError): pass
class ConfigDialog(QtGui.QDialog): pressedclosebutton = False moreToggling = False def moreToggled(self): if self.moreToggling == False: self.moreToggling = True if self.showmoreCheckbox.isChecked() and self.showmoreCheckbox.isVisible(): self.showmoreCheckbox.setChecked(False) self.moreSettingsGroup.setChecked(True) self.moreSettingsGroup.show() self.showmoreCheckbox.hide() self.saveMoreState(True) else: self.moreSettingsGroup.setChecked(False) self.moreSettingsGroup.hide() self.showmoreCheckbox.show() self.saveMoreState(False) self.moreToggling = False self.adjustSize() self.setFixedSize(self.sizeHint()) def runButtonTextUpdate(self): if (self.donotstoreCheckbox.isChecked()): self.runButton.setText(getMessage("en", "run-label")) else: self.runButton.setText(getMessage("en", "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" 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.config['host'] = self.hostTextbox.text() if ":" in self.hostTextbox.text() else self.hostTextbox.text() + ":" + unicode(constants.DEFAULT_PORT) self.config['name'] = self.usernameTextbox.text() self.config['room'] = self.defaultroomTextbox.text() self.config['password'] = self.serverpassTextbox.text() 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 self.alwaysshowCheckbox.isChecked() == True: self.config['forceGuiPrompt'] = True else: self.config['forceGuiPrompt'] = False if self.donotstoreCheckbox.isChecked() == True: self.config['noStore'] = True else: self.config['noStore'] = False if self.slowdownCheckbox.isChecked() == True: self.config['slowOnDesync'] = True else: self.config['slowOnDesync'] = False if self.pauseonleaveCheckbox.isChecked() == True: self.config['pauseOnLeave'] = True else: self.config['pauseOnLeave'] = False if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True: if self.rewindCheckbox.isChecked() == True: self.config['rewindOnDesync'] = True else: self.config['rewindOnDesync'] = False self.config['malUsername'] = self.malusernameTextbox.text() self.config['malPassword'] = self.malpasswordTextbox.text() if self.filenameprivacySendRawOption.isChecked() == True: self.config['filenamePrivacyMode'] = constants.PRIVACY_SENDRAW_MODE elif self.filenameprivacySendHashedOption.isChecked() == True: self.config['filenamePrivacyMode'] = constants.PRIVACY_SENDHASHED_MODE elif self.filenameprivacyDontSendOption.isChecked() == True: self.config['filenamePrivacyMode'] = constants.PRIVACY_DONTSEND_MODE if self.filesizeprivacySendRawOption.isChecked() == True: self.config['filesizePrivacyMode'] = constants.PRIVACY_SENDRAW_MODE elif self.filesizeprivacySendHashedOption.isChecked() == True: self.config['filesizePrivacyMode'] = constants.PRIVACY_SENDHASHED_MODE elif self.filesizeprivacyDontSendOption.isChecked() == True: self.config['filesizePrivacyMode'] = constants.PRIVACY_DONTSEND_MODE 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('linux'): dropfilepath = unicode(urls[0].path()) else: dropfilepath = unicode(urls[0].path())[1:] # Removes starting slash if dropfilepath[-4:].lower() == ".exe": self.executablepathCombobox.setEditText(dropfilepath) else: self.mediapathTextbox.setText(dropfilepath) def __init__(self, config, playerpaths, error): from syncplay import utils self.config = config self.datacleared = False if config['clearGUIData'] == True: settings = QSettings("Syncplay","PlayerList") settings.clear() settings = QSettings("Syncplay","MediaBrowseDialog") settings.clear() settings = QSettings("Syncplay","MainWindow") settings.clear() settings = QSettings("Syncplay","MoreSettings") settings.clear() self.datacleared = True self.QtGui = QtGui self.error = error if sys.platform.startswith('linux'): resourcespath = utils.findWorkingDir() + "/resources/" else: resourcespath = utils.findWorkingDir() + "\\resources\\" self.resourcespath = resourcespath super(ConfigDialog, self).__init__() self.setWindowTitle(getMessage("en", "config-window-title")) self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint) self.setWindowIcon(QtGui.QIcon(resourcespath + "syncplay.png")) if(config['host'] == None): host = "" elif(":" in config['host']): host = config['host'] else: host = config['host']+":"+str(config['port']) self.connectionSettingsGroup = QtGui.QGroupBox(getMessage("en", "connection-group-title")) self.hostTextbox = QLineEdit(host, self) self.hostLabel = QLabel(getMessage("en", "host-label"), self) self.usernameTextbox = QLineEdit(config['name'],self) self.serverpassLabel = QLabel(getMessage("en", "password-label"), self) self.defaultroomTextbox = QLineEdit(config['room'],self) self.usernameLabel = QLabel(getMessage("en", "username-label"), self) self.serverpassTextbox = QLineEdit(config['password'],self) self.defaultroomLabel = QLabel(getMessage("en", "room-label"), self) if (constants.SHOW_TOOLTIPS == True): self.hostLabel.setToolTip(getMessage("en", "host-tooltip")) self.hostTextbox.setToolTip(getMessage("en", "host-tooltip")) self.usernameLabel.setToolTip(getMessage("en", "username-tooltip")) self.usernameTextbox.setToolTip(getMessage("en", "username-tooltip")) self.serverpassLabel.setToolTip(getMessage("en", "password-tooltip")) self.serverpassTextbox.setToolTip(getMessage("en", "password-tooltip")) self.defaultroomLabel.setToolTip(getMessage("en", "room-tooltip")) self.defaultroomTextbox.setToolTip(getMessage("en", "room-tooltip")) 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("en", "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.setMinimumWidth(200) self.executablepathCombobox.setMaximumWidth(200) self.executablepathCombobox.editTextChanged.connect(self.updateExecutableIcon) self.executablepathLabel = QLabel(getMessage("en", "executable-path-label"), self) self.executablebrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'),getMessage("en", "browse-label")) self.executablebrowseButton.clicked.connect(self.browsePlayerpath) self.mediapathTextbox = QLineEdit(config['file'], self) self.mediapathLabel = QLabel(getMessage("en", "media-path-label"), self) self.mediabrowseButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'folder_explore.png'),getMessage("en", "browse-label")) self.mediabrowseButton.clicked.connect(self.browseMediapath) if (constants.SHOW_TOOLTIPS == True): self.executablepathLabel.setToolTip(getMessage("en", "executable-path-tooltip")) self.executablepathCombobox.setToolTip(getMessage("en", "executable-path-tooltip")) self.mediapathLabel.setToolTip(getMessage("en", "media-path-tooltip")) self.mediapathTextbox.setToolTip(getMessage("en", "media-path-tooltip")) if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True: self.rewindCheckbox = QCheckBox(getMessage("en", "rewind-label")) if (constants.SHOW_TOOLTIPS == True): self.rewindCheckbox.setToolTip(getMessage("en", "rewind-tooltip")) 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.moreSettingsGroup = QtGui.QGroupBox(getMessage("en", "more-title")) self.moreSettingsGroup.setCheckable(True) self.malSettingsSplit = QtGui.QSplitter(self) self.malusernameTextbox = QLineEdit(config['malUsername'],self) self.malusernameTextbox.setMaximumWidth(115) self.malusernameLabel = QLabel(getMessage("en", "mal-username-label"), self) self.malpasswordTextbox = QLineEdit(config['malPassword'],self) self.malpasswordTextbox.setEchoMode(QtGui.QLineEdit.Password) self.malpasswordLabel = QLabel(getMessage("en", "mal-password-label"), self) ### <MAL DISABLE> self.malpasswordTextbox.hide() self.malpasswordLabel.hide() self.malusernameTextbox.hide() self.malusernameLabel.hide() ### </MAL DISABLE> self.filenameprivacyLabel = QLabel(getMessage("en", "filename-privacy-label"), self) self.filenameprivacyButtonGroup = QButtonGroup() self.filenameprivacySendRawOption = QRadioButton(getMessage("en", "privacy-sendraw-option")) self.filenameprivacySendHashedOption = QRadioButton(getMessage("en", "privacy-sendhashed-option")) self.filenameprivacyDontSendOption = QRadioButton(getMessage("en", "privacy-dontsend-option")) self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendRawOption) self.filenameprivacyButtonGroup.addButton(self.filenameprivacySendHashedOption) self.filenameprivacyButtonGroup.addButton(self.filenameprivacyDontSendOption) self.filesizeprivacyLabel = QLabel(getMessage("en", "filesize-privacy-label"), self) self.filesizeprivacyButtonGroup = QButtonGroup() self.filesizeprivacySendRawOption = QRadioButton(getMessage("en", "privacy-sendraw-option")) self.filesizeprivacySendHashedOption = QRadioButton(getMessage("en", "privacy-sendhashed-option")) self.filesizeprivacyDontSendOption = QRadioButton(getMessage("en", "privacy-dontsend-option")) self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendRawOption) self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacySendHashedOption) self.filesizeprivacyButtonGroup.addButton(self.filesizeprivacyDontSendOption) self.slowdownCheckbox = QCheckBox(getMessage("en", "slowdown-label")) self.pauseonleaveCheckbox = QCheckBox(getMessage("en", "pauseonleave-label")) self.alwaysshowCheckbox = QCheckBox(getMessage("en", "alwayshow-label")) self.donotstoreCheckbox = QCheckBox(getMessage("en", "donotstore-label")) filenamePrivacyMode = config['filenamePrivacyMode'] if filenamePrivacyMode == constants.PRIVACY_DONTSEND_MODE: self.filenameprivacyDontSendOption.setChecked(True) elif filenamePrivacyMode == constants.PRIVACY_SENDHASHED_MODE: self.filenameprivacySendHashedOption.setChecked(True) else: self.filenameprivacySendRawOption.setChecked(True) filesizePrivacyMode = config['filesizePrivacyMode'] if filesizePrivacyMode == constants.PRIVACY_DONTSEND_MODE: self.filesizeprivacyDontSendOption.setChecked(True) elif filesizePrivacyMode == constants.PRIVACY_SENDHASHED_MODE: self.filesizeprivacySendHashedOption.setChecked(True) else: self.filesizeprivacySendRawOption.setChecked(True) if config['slowOnDesync'] == True: self.slowdownCheckbox.setChecked(True) if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True and config['rewindOnDesync'] == True: self.rewindCheckbox.setChecked(True) if config['pauseOnLeave'] == True: self.pauseonleaveCheckbox.setChecked(True) if (constants.SHOW_TOOLTIPS == True): self.malusernameLabel.setToolTip(getMessage("en", "mal-username-tooltip")) self.malusernameTextbox.setToolTip(getMessage("en", "mal-username-tooltip")) self.malpasswordLabel.setToolTip(getMessage("en", "mal-password-tooltip")) self.malpasswordTextbox.setToolTip(getMessage("en", "mal-password-tooltip")) self.filenameprivacyLabel.setToolTip(getMessage("en", "filename-privacy-tooltip")) self.filenameprivacySendRawOption.setToolTip(getMessage("en", "privacy-sendraw-tooltip")) self.filenameprivacySendHashedOption.setToolTip(getMessage("en", "privacy-sendhashed-tooltip")) self.filenameprivacyDontSendOption.setToolTip(getMessage("en", "privacy-dontsend-tooltip")) self.filesizeprivacyLabel.setToolTip(getMessage("en", "filesize-privacy-tooltip")) self.filesizeprivacySendRawOption.setToolTip(getMessage("en", "privacy-sendraw-tooltip")) self.filesizeprivacySendHashedOption.setToolTip(getMessage("en", "privacy-sendhashed-tooltip")) self.filesizeprivacyDontSendOption.setToolTip(getMessage("en", "privacy-dontsend-tooltip")) self.slowdownCheckbox.setToolTip(getMessage("en", "slowdown-tooltip")) self.pauseonleaveCheckbox.setToolTip(getMessage("en", "pauseonleave-tooltip")) self.alwaysshowCheckbox.setToolTip(getMessage("en", "alwayshow-tooltip")) self.donotstoreCheckbox.setToolTip(getMessage("en", "donotstore-tooltip")) self.slowdownCheckbox.setToolTip(getMessage("en", "slowdown-tooltip")) self.moreSettingsLayout = QtGui.QGridLayout() self.privacySettingsLayout = QtGui.QGridLayout() self.privacyFrame = QtGui.QFrame() self.privacyFrame.setLineWidth(0) self.privacyFrame.setMidLineWidth(0) self.privacySettingsLayout.setContentsMargins(0,0,0,0) self.privacySettingsLayout.addWidget(self.filenameprivacyLabel, 0, 0) self.privacySettingsLayout.addWidget(self.filenameprivacySendRawOption, 0, 1, Qt.AlignRight) self.privacySettingsLayout.addWidget(self.filenameprivacySendHashedOption, 0,2, Qt.AlignRight) self.privacySettingsLayout.addWidget(self.filenameprivacyDontSendOption, 0, 3, Qt.AlignRight) self.privacySettingsLayout.addWidget(self.filesizeprivacyLabel, 1, 0) self.privacySettingsLayout.addWidget(self.filesizeprivacySendRawOption, 1, 1, Qt.AlignRight) self.privacySettingsLayout.addWidget(self.filesizeprivacySendHashedOption, 1, 2, Qt.AlignRight) self.privacySettingsLayout.addWidget(self.filesizeprivacyDontSendOption, 1, 3, Qt.AlignRight) self.privacyFrame.setLayout(self.privacySettingsLayout) self.moreSettingsLayout.addWidget(self.privacyFrame, 0, 0, 1, 4) self.moreSettingsLayout.addWidget(self.malusernameLabel , 1, 0) self.moreSettingsLayout.addWidget(self.malusernameTextbox, 1, 1) self.moreSettingsLayout.addWidget(self.malpasswordLabel , 1, 2) self.moreSettingsLayout.addWidget(self.malpasswordTextbox, 1, 3) self.moreSettingsLayout.addWidget(self.slowdownCheckbox, 2, 0,1,4) if constants.SHOW_REWIND_ON_DESYNC_CHECKBOX == True: self.moreSettingsLayout.addWidget(self.rewindCheckbox, 3, 0, 1, 4) self.moreSettingsLayout.addWidget(self.pauseonleaveCheckbox, 4, 0, 1, 4) self.moreSettingsLayout.addWidget(self.alwaysshowCheckbox, 5, 0, 1, 4) self.moreSettingsLayout.addWidget(self.donotstoreCheckbox, 6, 0, 1, 4) self.moreSettingsGroup.setLayout(self.moreSettingsLayout) self.showmoreCheckbox = QCheckBox(getMessage("en", "more-title")) if self.getMoreState() == False: self.showmoreCheckbox.setChecked(False) self.moreSettingsGroup.hide() else: self.showmoreCheckbox.hide() self.showmoreCheckbox.toggled.connect(self.moreToggled) self.moreSettingsGroup.toggled.connect(self.moreToggled) if config['forceGuiPrompt'] == True: self.alwaysshowCheckbox.setChecked(True) if (constants.SHOW_TOOLTIPS == True): self.showmoreCheckbox.setToolTip(getMessage("en", "more-tooltip")) self.donotstoreCheckbox.toggled.connect(self.runButtonTextUpdate) self.mainLayout = QtGui.QVBoxLayout() if error: self.errorLabel = QLabel(error, self) self.errorLabel.setAlignment(Qt.AlignCenter) self.errorLabel.setStyleSheet("QLabel { color : red; }") self.mainLayout.addWidget(self.errorLabel) self.mainLayout.addWidget(self.connectionSettingsGroup) self.mainLayout.addSpacing(12) self.mainLayout.addWidget(self.mediaplayerSettingsGroup) self.mainLayout.addSpacing(12) self.mainLayout.addWidget(self.showmoreCheckbox) self.mainLayout.addWidget(self.moreSettingsGroup) self.mainLayout.addSpacing(12) self.topLayout = QtGui.QHBoxLayout() self.helpButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'help.png'),getMessage("en", "help-label")) if (constants.SHOW_TOOLTIPS == True): self.helpButton.setToolTip(getMessage("en", "help-tooltip")) self.helpButton.setMaximumSize(self.helpButton.sizeHint()) self.helpButton.pressed.connect(self.openHelp) self.runButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'accept.png'),getMessage("en", "storeandrun-label")) self.runButton.pressed.connect(self._saveDataAndLeave) if config['noStore'] == True: self.donotstoreCheckbox.setChecked(True) self.runButton.setText(getMessage("en", "run-label")) self.topLayout.addWidget(self.helpButton, Qt.AlignLeft) self.topLayout.addWidget(self.runButton, Qt.AlignRight) self.mainLayout.addLayout(self.topLayout) self.mainLayout.addStretch(1) self.setLayout(self.mainLayout) self.runButton.setFocus() self.setFixedSize(self.sizeHint()) self.setAcceptDrops(True) if self.datacleared == True: QtGui.QMessageBox.information(self,"Syncplay", getMessage("en", "gui-data-cleared-notification"))