Esempio n. 1
0
    def __init__(self, main_window):
        """
		desc:
			Constructor.

		arguments:
			main_window:	The main-window object.
		"""

        self.setup(main_window)
        self.main_window.set_status(_(u'Loading extensions'),
                                    timeout=None,
                                    status=u'busy')
        QtGui.QApplication.processEvents()
        self._extensions = []
        self.events = {}
        for ext_name in plugins.list_plugins(_type=u'extensions'):
            try:
                ext = plugins.load_extension(ext_name, self.main_window)
            except Exception as e:
                if not isinstance(e, osexception):
                    e = osexception(msg=u'Extension error', exception=e)
                self.notify(
                 u'Failed to load extension %s (see debug window for stack trace)' \
                 % ext_name)
                self.main_window.print_debug_window(e)
            self._extensions.append(ext)
            for event in ext.supported_events():
                if event not in self.events:
                    self.events[event] = []
                self.events[event].append(ext)
        self.main_window.set_status(_(u'Done'), status=u'ready')
Esempio n. 2
0
	def __init__(self, main_window):

		"""
		desc:
			Constructor.

		arguments:
			main_window:	The main-window object.
		"""

		self.setup(main_window)
		self.main_window.set_status(_(u'Loading extensions'), timeout=None,
			status=u'busy')
		QtGui.QApplication.processEvents()
		self._extensions = []
		self.events = {}
		for ext_name in plugins.list_plugins(_type=u'extensions'):
			try:
				ext = plugins.load_extension(ext_name, self.main_window)
			except Exception as e:
				if not isinstance(e, osexception):
					e = osexception(msg=u'Extension error', exception=e)
				self.notify(
					u'Failed to load extension %s (see debug window for stack trace)' \
					% ext_name)
				self.main_window.print_debug_window(e)
			self._extensions.append(ext)
			for event in ext.supported_events():
				if event not in self.events:
					self.events[event] = []
				self.events[event].append(ext)
		self.main_window.set_status(_(u'Done'), status=u'ready')
Esempio n. 3
0
	def __init__(self, main_window):

		"""
		desc:
			Constructor.

		arguments:
			main_window:	The main-window object.
		"""

		self.setup(main_window)
		self.main_window.set_busy()
		QtWidgets.QApplication.processEvents()
		self._extensions = []
		self.events = {}
		self._suspended = False
		self._suspended_until = None
		for ext_name in plugins.list_plugins(_type=u'extensions'):
			try:
				ext = plugins.load_extension(ext_name, self.main_window)
			except Exception as e:
				if not isinstance(e, osexception):
					e = osexception(msg=u'Extension error', exception=e)
				self.notify(
					u'Failed to load extension %s (see debug window for stack trace)' \
					% ext_name)
				self.console.write(e)
				continue
			self._extensions.append(ext)
			for event in ext.supported_events():
				if event not in self.events:
					self.events[event] = []
				self.events[event].append(ext)
		self.main_window.set_busy(False)
Esempio n. 4
0
    def __init__(self, main_window):
        """
		desc:
			Constructor.

		arguments:
			main_window:	The main-window object.
		"""

        super(plugin_manager_widget,
              self).__init__(main_window,
                             ui=u'extensions.plugin_manager.plugin_manager')
        self.plugin_list = plugins.list_plugins(
         filter_disabled=False, _type=u'plugins') \
         + plugins.list_plugins(filter_disabled=False, _type=u'extensions')
        for plugin in sorted(self.plugin_list):
            w = plugin_widget(plugin, main_window)
            self.ui.layout_container.addWidget(w)
	def __init__(self, main_window):

		"""
		desc:
			Constructor.

		arguments:
			main_window:	The main-window object.
		"""

		super(plugin_manager_widget, self).__init__(main_window,
			ui=u'extensions.plugin_manager.plugin_manager')
		self.plugin_list = plugins.list_plugins(
			filter_disabled=False, _type=u'plugins') \
			+ plugins.list_plugins(filter_disabled=False, _type=u'extensions')
		for plugin in sorted(self.plugin_list):
			w = plugin_widget(plugin, main_window)
			self.ui.layout_container.addWidget(w)
	def set_controls(self):

		"""Updates the controls."""

		if self.lock:
			return
		self.lock = True
		debug.msg()

		self.ui.checkbox_immediately_rename.setChecked( \
			config.get_config(u'immediate_rename'))
		self.ui.checkbox_autoresponse.setChecked( \
			self.main_window.experiment.auto_response)
		self.ui.checkbox_toolbar_text.setChecked( \
			self.main_window.ui.toolbar_main.toolButtonStyle() == \
			QtCore.Qt.ToolButtonTextUnderIcon)
		self.ui.checkbox_small_toolbar.setChecked( \
			config.get_config(u"toolbar_size") == 16)		
		self.ui.checkbox_enable_autosave.setChecked( \
			config.get_config(u'autosave_interval') > 0)
		self.ui.spinbox_autosave_interval.setValue( \
			config.get_config(u'autosave_interval') / 60000) # Show in minutes
		self.ui.spinbox_autosave_max_age.setValue( \
			config.get_config(u'autosave_max_age'))
		self.ui.checkbox_auto_update_check.setChecked(config.get_config( \
			u'auto_update_check'))		
		self.ui.combobox_runner.setCurrentIndex( \
			self.ui.combobox_runner.findText(config.get_config(u'runner'), \
			flags=QtCore.Qt.MatchContains))		
		# Disable some of the controls, if they depend on other controls
		if config.get_config(u'autosave_interval') <= 0:
			self.ui.spinbox_autosave_interval.setDisabled(True)
		# Set the style combobox
		i = 0
		if config.get_config(u'style') == u'':
			self.ui.combobox_style.addItem(u"[Default]")
			self.ui.combobox_style.setCurrentIndex(i)
			i += 1
		for style in QtGui.QStyleFactory.keys():
			self.ui.combobox_style.addItem(style)
			if config.get_config(u'style') == unicode(style):
				self.ui.combobox_style.setCurrentIndex(i)
			i += 1
		# Set the theme combobox
		i = 0
		for _theme in theme.available_themes:
			self.ui.combobox_theme.addItem(_theme)
			if config.get_config(u'theme') == _theme:
				self.ui.combobox_theme.setCurrentIndex(i)
			i += 1
		# Set the plugin status
		for plugin in plugins.list_plugins(filter_disabled=False):
			self.checkbox_plugins[plugin].setChecked(not \
				plugins.plugin_disabled(plugin))
		self.lock = False
Esempio n. 7
0
    def set_controls(self):
        """Updates the controls."""

        if self.lock:
            return
        self.lock = True
        debug.msg()

        self.ui.checkbox_immediately_rename.setChecked( \
         config.get_config(u'immediate_rename'))
        self.ui.checkbox_autoresponse.setChecked( \
         self.main_window.experiment.auto_response)
        self.ui.checkbox_toolbar_text.setChecked( \
         self.main_window.ui.toolbar_main.toolButtonStyle() == \
         QtCore.Qt.ToolButtonTextUnderIcon)
        self.ui.checkbox_small_toolbar.setChecked( \
         config.get_config(u"toolbar_size") == 16)
        self.ui.checkbox_enable_autosave.setChecked( \
         config.get_config(u'autosave_interval') > 0)
        self.ui.spinbox_autosave_interval.setValue( \
         config.get_config(u'autosave_interval') / 60000) # Show in minutes
        self.ui.spinbox_autosave_max_age.setValue( \
         config.get_config(u'autosave_max_age'))
        self.ui.checkbox_auto_update_check.setChecked(config.get_config( \
         u'auto_update_check'))
        self.ui.combobox_runner.setCurrentIndex( \
         self.ui.combobox_runner.findText(config.get_config(u'runner'), \
         flags=QtCore.Qt.MatchContains))
        # Disable some of the controls, if they depend on other controls
        if config.get_config(u'autosave_interval') <= 0:
            self.ui.spinbox_autosave_interval.setDisabled(True)
        # Set the style combobox
        i = 0
        if config.get_config(u'style') == u'':
            self.ui.combobox_style.addItem(u"[Default]")
            self.ui.combobox_style.setCurrentIndex(i)
            i += 1
        for style in QtGui.QStyleFactory.keys():
            self.ui.combobox_style.addItem(style)
            if config.get_config(u'style') == unicode(style):
                self.ui.combobox_style.setCurrentIndex(i)
            i += 1
        # Set the theme combobox
        i = 0
        for _theme in theme.available_themes:
            self.ui.combobox_theme.addItem(_theme)
            if config.get_config(u'theme') == _theme:
                self.ui.combobox_theme.setCurrentIndex(i)
            i += 1
        # Set the plugin status
        for plugin in plugins.list_plugins(filter_disabled=False):
            self.checkbox_plugins[plugin].setChecked(not \
             plugins.plugin_disabled(plugin))
        self.lock = False
Esempio n. 8
0
    def new_items_menu(self):

        """
		desc:
			Generates a menu with new items.

		returns:
			type:	QMenu
		"""

        if self._new_items_menu is not None:
            return self._new_items_menu
        self._new_items_menu = QtWidgets.QMenu(self)
        for item_type in self.experiment.core_items + [None] + sorted(plugins.list_plugins()):
            if item_type is None:
                self._new_items_menu.addSeparator()
            else:
                self._new_items_menu.addAction(append_new_action(self, self._new_items_menu, item_type))
        return self._new_items_menu
	def __init__(self, parent):

		"""
		Constructor.

		Arguments:
		parent	--	The parent widget.
		"""

		QtGui.QWidget.__init__(self, parent)
		self.tab_name = u'__preferences__'
		self.main_window = parent
		# Setup the GUI
		self.ui = preferences_widget_ui.Ui_preferences_widget()
		self.ui.setupUi(self)
		self.main_window.theme.apply_theme(self)
		self.lock = False
		# Connect the controls
		self.ui.checkbox_immediately_rename.toggled.connect(self.apply)
		self.ui.checkbox_autoresponse.toggled.connect(self.apply)
		self.ui.checkbox_toolbar_text.toggled.connect(self.apply)
		self.ui.checkbox_small_toolbar.toggled.connect(self.apply)
		self.ui.checkbox_enable_autosave.toggled.connect(self.apply)
		self.ui.spinbox_autosave_interval.valueChanged.connect(self.apply)
		self.ui.spinbox_autosave_max_age.valueChanged.connect(self.apply)
		self.ui.checkbox_auto_update_check.toggled.connect(self.apply)
		self.ui.combobox_runner.currentIndexChanged.connect(self.apply)
		self.ui.button_browse_autosave.clicked.connect( \
			self.main_window.open_autosave_folder)
		self.ui.button_update_check.clicked.connect( \
			self.main_window.check_update)
		self.ui.combobox_style.currentIndexChanged.connect(self.apply)
		self.ui.combobox_theme.currentIndexChanged.connect(self.apply)
		# Construct the plugin section
		self.checkbox_plugins = {}
		self.ui.edit_plugin_folders.setText(u'; '.join(plugins.plugin_folders( \
			only_existing=False)))
		for plugin in sorted(plugins.list_plugins(filter_disabled=False)):
			self.checkbox_plugins[plugin] = QtGui.QCheckBox(plugin)
			self.checkbox_plugins[plugin].toggled.connect(self.apply)
			self.ui.layout_plugin_list.addWidget(self.checkbox_plugins[plugin])
		self.set_controls()
Esempio n. 10
0
    def new_items_menu(self):
        """
		desc:
			Generates a menu with new items.

		returns:
			type:	QMenu
		"""

        if self._new_items_menu is not None:
            return self._new_items_menu
        self._new_items_menu = QtWidgets.QMenu(self)
        for item_type in self.experiment.core_items + [None] + \
         sorted(plugins.list_plugins()):
            if item_type is None:
                self._new_items_menu.addSeparator()
            else:
                self._new_items_menu.addAction(
                    append_new_action(self, self._new_items_menu, item_type))
        return self._new_items_menu
Esempio n. 11
0
    def __init__(self, parent):
        """
		Constructor.

		Arguments:
		parent	--	The parent widget.
		"""

        QtGui.QWidget.__init__(self, parent)
        self.tab_name = u'__preferences__'
        self.main_window = parent
        # Setup the GUI
        self.ui = preferences_widget_ui.Ui_preferences_widget()
        self.ui.setupUi(self)
        self.main_window.theme.apply_theme(self)
        self.lock = False
        # Connect the controls
        self.ui.checkbox_immediately_rename.toggled.connect(self.apply)
        self.ui.checkbox_autoresponse.toggled.connect(self.apply)
        self.ui.checkbox_toolbar_text.toggled.connect(self.apply)
        self.ui.checkbox_small_toolbar.toggled.connect(self.apply)
        self.ui.checkbox_enable_autosave.toggled.connect(self.apply)
        self.ui.spinbox_autosave_interval.valueChanged.connect(self.apply)
        self.ui.spinbox_autosave_max_age.valueChanged.connect(self.apply)
        self.ui.checkbox_auto_update_check.toggled.connect(self.apply)
        self.ui.combobox_runner.currentIndexChanged.connect(self.apply)
        self.ui.button_browse_autosave.clicked.connect( \
         self.main_window.open_autosave_folder)
        self.ui.button_update_check.clicked.connect( \
         self.main_window.check_update)
        self.ui.combobox_style.currentIndexChanged.connect(self.apply)
        self.ui.combobox_theme.currentIndexChanged.connect(self.apply)
        # Construct the plugin section
        self.checkbox_plugins = {}
        self.ui.edit_plugin_folders.setText(u'; '.join(plugins.plugin_folders( \
         only_existing=False)))
        for plugin in sorted(plugins.list_plugins(filter_disabled=False)):
            self.checkbox_plugins[plugin] = QtGui.QCheckBox(plugin)
            self.checkbox_plugins[plugin].toggled.connect(self.apply)
            self.ui.layout_plugin_list.addWidget(self.checkbox_plugins[plugin])
        self.set_controls()
Esempio n. 12
0
	def build(self):

		"""
		desc:
			Populates the toolbar with items.
		"""

		# This function is called first when no experiment has been loaded yet.
		try:
			self.experiment
		except:
			return
		self.clear()
		if self.orientation() == QtCore.Qt.Vertical:
			self.addWidget(toolbar_items_label(self, _(u'Commonly used')))
		# Add the core items
		self.add_content([toolbar_items_item(self, item) \
			for item in self.experiment.core_items])
		# Create a dictionary of plugins by category. We also maintain a list
		# to preserve the order of the categories.
		cat_dict = OrderedDict()
		for plugin in plugins.list_plugins():
			cat = plugins.plugin_category(plugin)
			if cat not in cat_dict:
				cat_dict[cat] = []
			cat_dict[cat].append(plugin)
		# Add the plugins
		for cat, cat_plugins in cat_dict.items():
			self.addSeparator()
			if self.orientation() == QtCore.Qt.Vertical:
				self.addWidget(toolbar_items_label(self, cat))
			content = []
			for plugin in cat_plugins:
				debug.msg(u"adding plugin '%s'" % plugin)
				pixmap = self.theme.qpixmap(plugins.plugin_icon_large(plugin))
				content.append(toolbar_items_item(self, plugin, pixmap))
			self.add_content(content)
Esempio n. 13
0
    def build(self):
        """
		desc:
			Populates the toolbar with items.
		"""

        # This function is called first when no experiment has been loaded yet.
        try:
            self.experiment
        except:
            return
        self.clear()
        if self.orientation() == QtCore.Qt.Vertical:
            self.addWidget(toolbar_items_label(self, _(u'Commonly used')))
        # Add the core items
        self.add_content([toolbar_items_item(self, item) \
         for item in self.experiment.core_items])
        # Create a dictionary of plugins by category. We also maintain a list
        # to preserve the order of the categories.
        cat_dict = OrderedDict()
        for plugin in plugins.list_plugins():
            cat = plugins.plugin_category(plugin)
            if cat not in cat_dict:
                cat_dict[cat] = []
            cat_dict[cat].append(plugin)
        # Add the plugins
        for cat, cat_plugins in cat_dict.items():
            self.addSeparator()
            if self.orientation() == QtCore.Qt.Vertical:
                self.addWidget(toolbar_items_label(self, cat))
            content = []
            for plugin in cat_plugins:
                debug.msg(u"adding plugin '%s'" % plugin)
                pixmap = self.theme.qpixmap(plugins.plugin_icon_large(plugin))
                content.append(toolbar_items_item(self, plugin, pixmap))
            self.add_content(content)
Esempio n. 14
0
	def set_controls(self):

		"""Update the controls"""

		if self.lock:
			return
		self.lock = True
		debug.msg()

		self.ui.checkbox_immediately_rename.setChecked(self.main_window.immediate_rename)
		self.ui.checkbox_autoresponse.setChecked(self.main_window.experiment.auto_response)
		self.ui.checkbox_show_random_tips.setChecked(self.main_window.show_startup_tip)
		self.ui.checkbox_toolbar_text.setChecked(self.main_window.ui.toolbar_main.toolButtonStyle() == QtCore.Qt.ToolButtonTextUnderIcon)
		self.ui.checkbox_small_toolbar.setChecked( \
			config.get_config("toolbar_size") == 16)		
		self.ui.checkbox_enable_autosave.setChecked(self.main_window.autosave_interval > 0)
		self.ui.spinbox_autosave_interval.setValue(self.main_window.autosave_interval / 60000) # Show in minutes, not milliseconds
		self.ui.spinbox_autosave_max_age.setValue(self.main_window.autosave_max_age)
		self.ui.checkbox_auto_update_check.setChecked(self.main_window.auto_check_update)
		self.ui.checkbox_opensesamerun.setChecked(self.main_window.opensesamerun)
		self.ui.checkbox_auto_opensesamerun_exec.setChecked(self.main_window.opensesamerun_exec == "")
		self.ui.edit_opensesamerun_exec.setText(self.main_window.opensesamerun_exec)

		self.ui.checkbox_new_experiment_dialog.setChecked(config.get_config("new_experiment_dialog"))
		self.ui.checkbox_scintilla_auto_indent.setChecked(config.get_config("scintilla_auto_indent"))
		self.ui.checkbox_scintilla_brace_match.setChecked(config.get_config("scintilla_brace_match"))
		self.ui.checkbox_scintilla_custom_font.setChecked(config.get_config("scintilla_custom_font"))
		self.ui.checkbox_scintilla_eol_visible.setChecked(config.get_config("scintilla_eol_visible"))
		self.ui.checkbox_scintilla_folding.setChecked(config.get_config("scintilla_folding"))
		self.ui.checkbox_scintilla_indentation_guides.setChecked(config.get_config("scintilla_indentation_guides"))
		self.ui.checkbox_scintilla_line_numbers.setChecked(config.get_config("scintilla_line_numbers"))
		self.ui.checkbox_scintilla_right_margin.setChecked(config.get_config("scintilla_right_margin"))
		self.ui.checkbox_scintilla_auto_indent.setChecked(config.get_config("scintilla_auto_indent"))
		self.ui.checkbox_scintilla_syntax_highlighting.setChecked(config.get_config("scintilla_syntax_highlighting"))
		self.ui.checkbox_scintilla_whitespace_visible.setChecked(config.get_config("scintilla_whitespace_visible"))
		self.ui.font_scintilla_font_family.setCurrentFont(QtGui.QFont(config.get_config("scintilla_font_family")))
		self.ui.spinbox_scintilla_font_size.setValue(config.get_config("scintilla_font_size"))

		# Disable some of the controls, if they depend on other controls
		if self.main_window.autosave_interval <= 0:
			self.ui.spinbox_autosave_interval.setDisabled(True)

		if not self.main_window.opensesamerun:
			self.ui.checkbox_auto_opensesamerun_exec.setDisabled(True)
			self.ui.edit_opensesamerun_exec.setDisabled(True)
			self.ui.label_opensesamerun_exec.setDisabled(True)

		if self.main_window.opensesamerun_exec == "":
			self.ui.edit_opensesamerun_exec.setDisabled(True)
			self.ui.label_opensesamerun_exec.setDisabled(True)

		i = 0
		if self.main_window.style == "":
			self.ui.combobox_style.addItem("[Default]")
			self.ui.combobox_style.setCurrentIndex(i)
			i += 1
		for style in QtGui.QStyleFactory.keys():
			self.ui.combobox_style.addItem(style)
			if self.main_window.style == str(style):
				self.ui.combobox_style.setCurrentIndex(i)
			i += 1

		# Set the plugin status
		for plugin in plugins.list_plugins(filter_disabled=False):
			self.checkbox_plugins[plugin].setChecked(not plugins.plugin_disabled(plugin))

		self.lock = False
Esempio n. 15
0
    def apply(self):
        """Apply the controls"""

        if self.lock:
            return
        self.lock = True
        debug.msg()

        config.set_config(u'immediate_rename', \
         self.ui.checkbox_immediately_rename.isChecked())
        self.main_window.experiment.auto_response = \
         self.ui.checkbox_autoresponse.isChecked()
        self.main_window.ui.action_enable_auto_response.setChecked( \
         self.ui.checkbox_autoresponse.isChecked())

        if self.ui.checkbox_toolbar_text.isChecked():
            self.main_window.ui.toolbar_main.setToolButtonStyle( \
             QtCore.Qt.ToolButtonTextUnderIcon)
        else:
            self.main_window.ui.toolbar_main.setToolButtonStyle( \
             QtCore.Qt.ToolButtonIconOnly)

        old_size = config.get_config(u'toolbar_size')
        if self.ui.checkbox_small_toolbar.isChecked():
            new_size = 16
        else:
            new_size = 32
        if old_size != new_size:
            config.set_config(u"toolbar_size", new_size)
            self.main_window.theme.set_toolbar_size(config.get_config( \
             "toolbar_size"))

        if self.ui.checkbox_enable_autosave.isChecked():
            config.set_config(u'autosave_interval', 60000 * \
             self.ui.spinbox_autosave_interval.value())
        else:
            config.set_config(u'autosave_interval', 0)
        config.set_config(u'autosave_max_age', \
         self.ui.spinbox_autosave_max_age.value())
        self.main_window.start_autosave_timer()

        config.set_config(u'auto_update_check', \
         self.ui.checkbox_auto_update_check.isChecked())

        from libqtopensesame import runners
        for runner in runners.runner_list:
            if runner in self.ui.combobox_runner.currentText():
                config.set_config(u'runner', runner)

        config.set_config(u'theme', unicode( \
         self.ui.combobox_theme.currentText()))

        # Create a semicolon-separated list of disabled plugins
        l = []
        for plugin in plugins.list_plugins(filter_disabled=False):
            if not self.checkbox_plugins[plugin].isChecked():
                l.append(plugin)
        config.set_config(u"disabled_plugins", ";".join(l))

        config.set_config(u'style', unicode( \
         self.ui.combobox_style.currentText()))
        self.main_window.save_state()

        self.lock = False
Esempio n. 16
0
	def apply(self):

		"""Apply the controls"""

		if self.lock:
			return
		self.lock = True
		debug.msg()

		self.main_window.immediate_rename = self.ui.checkbox_immediately_rename.isChecked()
		self.main_window.show_startup_tip = self.ui.checkbox_show_random_tips.isChecked()
		self.main_window.experiment.auto_response = self.ui.checkbox_autoresponse.isChecked()
		self.main_window.ui.action_enable_auto_response.setChecked(self.ui.checkbox_autoresponse.isChecked())

		if self.ui.checkbox_toolbar_text.isChecked():
			self.main_window.ui.toolbar_main.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
		else:
			self.main_window.ui.toolbar_main.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
		
		if self.ui.checkbox_small_toolbar.isChecked():
			config.set_config("toolbar_size", 16)
		else:
			config.set_config("toolbar_size", 32)
		self.main_window.theme.set_toolbar_size(config.get_config( \
			"toolbar_size"))		

		if self.ui.checkbox_enable_autosave.isChecked():
			self.main_window.autosave_interval = 60000 * self.ui.spinbox_autosave_interval.value()
		else:
			self.main_window.autosave_interval = 0						
		self.main_window.autosave_max_age = self.ui.spinbox_autosave_max_age.value()
		self.main_window.start_autosave_timer()

		self.main_window.auto_check_update = self.ui.checkbox_auto_update_check.isChecked()
		self.main_window.opensesamerun = self.ui.checkbox_opensesamerun.isChecked()

		self.ui.edit_opensesamerun_exec.setEnabled(self.ui.checkbox_opensesamerun.isChecked() and not self.ui.checkbox_auto_opensesamerun_exec.isChecked())
		self.ui.label_opensesamerun_exec.setEnabled(self.ui.checkbox_opensesamerun.isChecked() and not self.ui.checkbox_auto_opensesamerun_exec.isChecked())

		if self.ui.checkbox_auto_opensesamerun_exec.isChecked():
			self.main_window.opensesamerun_exec = ""
			self.ui.edit_opensesamerun_exec.setText("")
		else:
			if self.ui.edit_opensesamerun_exec.text() == "":
				if os.name == "nt":
					self.ui.edit_opensesamerun_exec.setText("opensesamerun.exe")
				else:
					self.ui.edit_opensesamerun_exec.setText("opensesamerun")
			self.main_window.opensesamerun_exec = str(self.ui.edit_opensesamerun_exec.text())

		config.set_config("new_experiment_dialog", self.ui.checkbox_new_experiment_dialog.isChecked())
		config.set_config("scintilla_auto_indent", self.ui.checkbox_scintilla_auto_indent.isChecked())
		config.set_config("scintilla_brace_match", self.ui.checkbox_scintilla_brace_match.isChecked())
		config.set_config("scintilla_custom_font", self.ui.checkbox_scintilla_custom_font.isChecked())
		config.set_config("scintilla_eol_visible", self.ui.checkbox_scintilla_eol_visible.isChecked())
		config.set_config("scintilla_folding", self.ui.checkbox_scintilla_folding.isChecked())
		config.set_config("scintilla_indentation_guides", self.ui.checkbox_scintilla_indentation_guides.isChecked())
		config.set_config("scintilla_line_numbers", self.ui.checkbox_scintilla_line_numbers.isChecked())
		config.set_config("scintilla_right_margin", self.ui.checkbox_scintilla_right_margin.isChecked())
		config.set_config("scintilla_syntax_highlighting", self.ui.checkbox_scintilla_syntax_highlighting.isChecked())
		config.set_config("scintilla_whitespace_visible", self.ui.checkbox_scintilla_whitespace_visible.isChecked())
		config.set_config("scintilla_font_family", str(self.ui.font_scintilla_font_family.currentFont().family()))
		config.set_config("scintilla_font_size", self.ui.spinbox_scintilla_font_size.value())

		# Create a semicolon-separated list of disabled plugins
		l = []
		for plugin in plugins.list_plugins(filter_disabled=False):
			if not self.checkbox_plugins[plugin].isChecked():
				l.append(plugin)
		config.set_config("disabled_plugins", ";".join(l))

		self.main_window.style = self.ui.combobox_style.currentText()
		self.main_window.set_style()
		self.main_window.save_state()

		self.lock = False
Esempio n. 17
0
	def __init__(self, parent):

		"""
		Constructor

		Arguments:
		parent -- the parent widget
		"""

		QtGui.QWidget.__init__(self, parent)
		self.tab_name = "__preferences__"
		self.main_window = parent

		# Setup the GUI
		self.ui = preferences_widget_ui.Ui_Form()
		self.ui.setupUi(self)
		self.main_window.theme.apply_theme(self)
		self.lock = False

		# Connect the controls
		self.ui.checkbox_immediately_rename.toggled.connect(self.apply)
		self.ui.checkbox_autoresponse.toggled.connect(self.apply)
		self.ui.checkbox_show_random_tips.toggled.connect(self.apply)
		self.ui.checkbox_toolbar_text.toggled.connect(self.apply)
		self.ui.checkbox_small_toolbar.toggled.connect(self.apply)
		self.ui.checkbox_enable_autosave.toggled.connect(self.apply)
		self.ui.spinbox_autosave_interval.valueChanged.connect(self.apply)
		self.ui.spinbox_autosave_max_age.valueChanged.connect(self.apply)
		self.ui.checkbox_auto_update_check.toggled.connect(self.apply)
		self.ui.checkbox_opensesamerun.toggled.connect(self.apply)
		self.ui.checkbox_auto_opensesamerun_exec.toggled.connect(self.apply)
		self.ui.edit_opensesamerun_exec.editingFinished.connect(self.apply)
		self.ui.button_browse_autosave.clicked.connect( \
			self.main_window.open_autosave_folder)
		self.ui.button_update_check.clicked.connect( \
			self.main_window.check_update)
		self.ui.combobox_style.currentIndexChanged.connect(self.apply)

		self.ui.checkbox_new_experiment_dialog.toggled.connect(self.apply)
		self.ui.checkbox_scintilla_auto_indent.toggled.connect(self.apply)
		self.ui.checkbox_scintilla_brace_match.toggled.connect(self.apply)
		self.ui.checkbox_scintilla_custom_font.toggled.connect(self.apply)
		self.ui.checkbox_scintilla_eol_visible.toggled.connect(self.apply)
		self.ui.checkbox_scintilla_folding.toggled.connect(self.apply)
		self.ui.checkbox_scintilla_indentation_guides.toggled.connect( \
			self.apply)
		self.ui.checkbox_scintilla_line_numbers.toggled.connect(self.apply)
		self.ui.checkbox_scintilla_right_margin.toggled.connect(self.apply)
		self.ui.checkbox_scintilla_syntax_highlighting.toggled.connect(self.apply)
		self.ui.checkbox_scintilla_whitespace_visible.toggled.connect(self.apply)
		self.ui.font_scintilla_font_family.currentFontChanged.connect(self.apply)
		self.ui.spinbox_scintilla_font_size.valueChanged.connect(self.apply)

		# Construct the plugin section
		self.checkbox_plugins = {}
		self.ui.edit_plugin_folders.setText("; ".join(plugins.plugin_folders(only_existing=False)))
		for plugin in sorted(plugins.list_plugins(filter_disabled=False)):
			self.checkbox_plugins[plugin] = QtGui.QCheckBox(plugin)
			self.checkbox_plugins[plugin].toggled.connect(self.apply)
			self.ui.layout_plugin_list.addWidget(self.checkbox_plugins[plugin])

		self.set_controls()
Esempio n. 18
0
	def set_controls(self):

		"""Update the controls"""

		if self.lock:
			return
		self.lock = True
		debug.msg()

		self.ui.checkbox_immediately_rename.setChecked( \
			config.get_config('immediate_rename'))
		self.ui.checkbox_autoresponse.setChecked( \
			self.main_window.experiment.auto_response)
		self.ui.checkbox_toolbar_text.setChecked( \
			self.main_window.ui.toolbar_main.toolButtonStyle() == \
			QtCore.Qt.ToolButtonTextUnderIcon)
		self.ui.checkbox_small_toolbar.setChecked( \
			config.get_config("toolbar_size") == 16)		
		self.ui.checkbox_enable_autosave.setChecked( \
			config.get_config('autosave_interval') > 0)
		self.ui.spinbox_autosave_interval.setValue( \
			config.get_config('autosave_interval') / 60000) # Show in minutes
		self.ui.spinbox_autosave_max_age.setValue( \
			config.get_config('autosave_max_age'))
		self.ui.checkbox_auto_update_check.setChecked(config.get_config( \
			'auto_update_check'))			
		self.ui.checkbox_opensesamerun.setChecked( \
			config.get_config('opensesamerun'))
		self.ui.checkbox_auto_opensesamerun_exec.setChecked( \
			config.get_config('opensesamerun_exec') == '')			
		self.ui.edit_opensesamerun_exec.setText( \
			config.get_config('opensesamerun_exec'))

		self.ui.checkbox_scintilla_auto_indent.setChecked(config.get_config( \
			"scintilla_auto_indent"))
		self.ui.checkbox_scintilla_brace_match.setChecked(config.get_config( \
			"scintilla_brace_match"))
		self.ui.checkbox_scintilla_custom_font.setChecked(config.get_config( \
			"scintilla_custom_font"))
		self.ui.checkbox_scintilla_eol_visible.setChecked(config.get_config( \
			"scintilla_eol_visible"))
		self.ui.checkbox_scintilla_folding.setChecked(config.get_config( \
			"scintilla_folding"))
		self.ui.checkbox_scintilla_indentation_guides.setChecked( \
			config.get_config("scintilla_indentation_guides"))
		self.ui.checkbox_scintilla_line_numbers.setChecked(config.get_config( \
			"scintilla_line_numbers"))
		self.ui.checkbox_scintilla_right_margin.setChecked(config.get_config( \
			"scintilla_right_margin"))
		self.ui.checkbox_scintilla_auto_indent.setChecked(config.get_config( \
			"scintilla_auto_indent"))
		self.ui.checkbox_scintilla_syntax_highlighting.setChecked( \
			config.get_config("scintilla_syntax_highlighting"))
		self.ui.checkbox_scintilla_whitespace_visible.setChecked( \
			config.get_config("scintilla_whitespace_visible"))
		self.ui.font_scintilla_font_family.setCurrentFont(QtGui.QFont( \
			config.get_config("scintilla_font_family")))
		self.ui.spinbox_scintilla_font_size.setValue(config.get_config( \
			"scintilla_font_size"))

		# Disable some of the controls, if they depend on other controls
		if config.get_config('autosave_interval') <= 0:
			self.ui.spinbox_autosave_interval.setDisabled(True)

		if not config.get_config('opensesamerun'):
			self.ui.checkbox_auto_opensesamerun_exec.setDisabled(True)
			self.ui.edit_opensesamerun_exec.setDisabled(True)
			self.ui.label_opensesamerun_exec.setDisabled(True)

		if config.get_config('opensesamerun_exec') == '':
			self.ui.edit_opensesamerun_exec.setDisabled(True)
			self.ui.label_opensesamerun_exec.setDisabled(True)

		# Set the style combobox
		i = 0
		if config.get_config('style') == '':
			self.ui.combobox_style.addItem("[Default]")
			self.ui.combobox_style.setCurrentIndex(i)
			i += 1
		for style in QtGui.QStyleFactory.keys():
			self.ui.combobox_style.addItem(style)
			if config.get_config('style') == unicode(style):
				self.ui.combobox_style.setCurrentIndex(i)
			i += 1
			
		# Set the theme combobox
		i = 0
		for _theme in theme.available_themes:
			self.ui.combobox_theme.addItem(_theme)
			if config.get_config('theme') == _theme:
				self.ui.combobox_theme.setCurrentIndex(i)
			i += 1			

		# Set the plugin status
		for plugin in plugins.list_plugins(filter_disabled=False):
			self.checkbox_plugins[plugin].setChecked(not \
				plugins.plugin_disabled(plugin))

		self.lock = False
Esempio n. 19
0
	def apply(self):

		"""Apply the controls"""

		if self.lock:
			return
		self.lock = True
		debug.msg()

		config.set_config(u'immediate_rename', \
			self.ui.checkbox_immediately_rename.isChecked())
		self.main_window.experiment.auto_response = \
			self.ui.checkbox_autoresponse.isChecked()
		self.main_window.ui.action_enable_auto_response.setChecked( \
			self.ui.checkbox_autoresponse.isChecked())

		if self.ui.checkbox_toolbar_text.isChecked():
			self.main_window.ui.toolbar_main.setToolButtonStyle( \
				QtCore.Qt.ToolButtonTextUnderIcon)
		else:
			self.main_window.ui.toolbar_main.setToolButtonStyle( \
				QtCore.Qt.ToolButtonIconOnly)
		
		old_size = config.get_config(u'toolbar_size')
		if self.ui.checkbox_small_toolbar.isChecked():
			new_size = 16
		else:
			new_size = 32
		if old_size != new_size:
			config.set_config(u"toolbar_size", new_size)
			self.main_window.theme.set_toolbar_size(config.get_config( \
				"toolbar_size"))		

		if self.ui.checkbox_enable_autosave.isChecked():
			config.set_config(u'autosave_interval', 60000 * \
				self.ui.spinbox_autosave_interval.value())
		else:
			config.set_config(u'autosave_interval', 0)	
		config.set_config(u'autosave_max_age', \
			self.ui.spinbox_autosave_max_age.value())
		self.main_window.start_autosave_timer()

		config.set_config(u'auto_update_check', \
			self.ui.checkbox_auto_update_check.isChecked())
		
		from libqtopensesame import runners
		for runner in runners.runner_list:
			if runner in self.ui.combobox_runner.currentText():
				config.set_config(u'runner', runner)

		config.set_config(u'theme', unicode( \
			self.ui.combobox_theme.currentText()))

		# Create a semicolon-separated list of disabled plugins
		l = []
		for plugin in plugins.list_plugins(filter_disabled=False):
			if not self.checkbox_plugins[plugin].isChecked():
				l.append(plugin)
		config.set_config(u"disabled_plugins", ";".join(l))

		config.set_config(u'style', unicode( \
			self.ui.combobox_style.currentText()))
		self.main_window.save_state()

		self.lock = False
    def set_controls(self):
        """Update the controls"""

        if self.lock:
            return
        self.lock = True
        debug.msg()

        self.ui.checkbox_immediately_rename.setChecked( \
         config.get_config('immediate_rename'))
        self.ui.checkbox_autoresponse.setChecked( \
         self.main_window.experiment.auto_response)
        self.ui.checkbox_toolbar_text.setChecked( \
         self.main_window.ui.toolbar_main.toolButtonStyle() == \
         QtCore.Qt.ToolButtonTextUnderIcon)
        self.ui.checkbox_small_toolbar.setChecked( \
         config.get_config("toolbar_size") == 16)
        self.ui.checkbox_enable_autosave.setChecked( \
         config.get_config('autosave_interval') > 0)
        self.ui.spinbox_autosave_interval.setValue( \
         config.get_config('autosave_interval') / 60000) # Show in minutes
        self.ui.spinbox_autosave_max_age.setValue( \
         config.get_config('autosave_max_age'))
        self.ui.checkbox_auto_update_check.setChecked(config.get_config( \
         'auto_update_check'))
        self.ui.checkbox_opensesamerun.setChecked( \
         config.get_config('opensesamerun'))
        self.ui.checkbox_auto_opensesamerun_exec.setChecked( \
         config.get_config('opensesamerun_exec') == '')
        self.ui.edit_opensesamerun_exec.setText( \
         config.get_config('opensesamerun_exec'))

        self.ui.checkbox_scintilla_auto_indent.setChecked(config.get_config( \
         "scintilla_auto_indent"))
        self.ui.checkbox_scintilla_brace_match.setChecked(config.get_config( \
         "scintilla_brace_match"))
        self.ui.checkbox_scintilla_custom_font.setChecked(config.get_config( \
         "scintilla_custom_font"))
        self.ui.checkbox_scintilla_eol_visible.setChecked(config.get_config( \
         "scintilla_eol_visible"))
        self.ui.checkbox_scintilla_folding.setChecked(config.get_config( \
         "scintilla_folding"))
        self.ui.checkbox_scintilla_indentation_guides.setChecked( \
         config.get_config("scintilla_indentation_guides"))
        self.ui.checkbox_scintilla_line_numbers.setChecked(config.get_config( \
         "scintilla_line_numbers"))
        self.ui.checkbox_scintilla_right_margin.setChecked(config.get_config( \
         "scintilla_right_margin"))
        self.ui.checkbox_scintilla_auto_indent.setChecked(config.get_config( \
         "scintilla_auto_indent"))
        self.ui.checkbox_scintilla_syntax_highlighting.setChecked( \
         config.get_config("scintilla_syntax_highlighting"))
        self.ui.checkbox_scintilla_whitespace_visible.setChecked( \
         config.get_config("scintilla_whitespace_visible"))
        self.ui.font_scintilla_font_family.setCurrentFont(QtGui.QFont( \
         config.get_config("scintilla_font_family")))
        self.ui.spinbox_scintilla_font_size.setValue(config.get_config( \
         "scintilla_font_size"))

        # Disable some of the controls, if they depend on other controls
        if config.get_config('autosave_interval') <= 0:
            self.ui.spinbox_autosave_interval.setDisabled(True)

        if not config.get_config('opensesamerun'):
            self.ui.checkbox_auto_opensesamerun_exec.setDisabled(True)
            self.ui.edit_opensesamerun_exec.setDisabled(True)
            self.ui.label_opensesamerun_exec.setDisabled(True)

        if config.get_config('opensesamerun_exec') == '':
            self.ui.edit_opensesamerun_exec.setDisabled(True)
            self.ui.label_opensesamerun_exec.setDisabled(True)

        # Set the style combobox
        i = 0
        if config.get_config('style') == '':
            self.ui.combobox_style.addItem("[Default]")
            self.ui.combobox_style.setCurrentIndex(i)
            i += 1
        for style in QtGui.QStyleFactory.keys():
            self.ui.combobox_style.addItem(style)
            if config.get_config('style') == unicode(style):
                self.ui.combobox_style.setCurrentIndex(i)
            i += 1

        # Set the theme combobox
        i = 0
        for _theme in theme.available_themes:
            self.ui.combobox_theme.addItem(_theme)
            if config.get_config('theme') == _theme:
                self.ui.combobox_theme.setCurrentIndex(i)
            i += 1

        # Set the plugin status
        for plugin in plugins.list_plugins(filter_disabled=False):
            self.checkbox_plugins[plugin].setChecked(not \
             plugins.plugin_disabled(plugin))

        self.lock = False