Exemple #1
0
    def __init__(self, parent, font=None):
        super(MultiFileEditor, self).__init__(parent)
        if not font:
            font = text_font()

        completion_enabled = True
        if CONF.has(ENABLE_COMPLETION_KEY):
            completion_enabled = CONF.get(ENABLE_COMPLETION_KEY)

        # layout
        self.editors = MultiPythonFileInterpreter(
            font=font,
            default_content=DEFAULT_SCRIPT_CONTENT,
            parent=self,
            completion_enabled=completion_enabled)
        layout = QVBoxLayout()
        layout.addWidget(self.editors)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        self.setAcceptDrops(True)

        # attributes
        self.tabs_open_on_closing = None
        self.editors_zoom_level = None
Exemple #2
0
 def action_font_selected(self, font):
     font_string = ""
     if CONF.has(GeneralProperties.FONT.value):
         font_string = CONF.get(GeneralProperties.FONT.value)
     if font_string != font.toString():
         CONF.set(GeneralProperties.FONT.value, font.toString())
         if self.settings_presenter is not None:
             self.settings_presenter.register_change_needs_restart("Main Font Selection")
Exemple #3
0
 def action_main_font_button_clicked(self):
     font = None
     if CONF.has(GeneralProperties.FONT.value):
         font_string = CONF.get(GeneralProperties.FONT.value).split(',')
         if len(font_string) > 2:
             font = QFontDatabase().font(font_string[0], font_string[-1], int(font_string[1]))
     font_dialog = self.view.create_font_dialog(self.parent, font)
     font_dialog.fontSelected.connect(self.action_font_selected)
Exemple #4
0
 def save_settings_to_file(filepath, settings):
     with open(filepath, 'w') as file:
         for setting in settings:
             if CONF.has(setting):
                 if setting != GeneralProperties.USER_LAYOUT.value:
                     value = CONF.get(setting, type=str)
             else:
                 value = ConfigService.getString(setting)
             file.write(setting + '=' + str(value) + '\n')
Exemple #5
0
 def load_settings_from_file(filepath, settings):
     with open(filepath, 'r') as file:
         line = file.readline()
         while line:
             setting = line.rstrip('\n').split('=', 1)
             prop = setting[0].strip()
             if prop in settings:
                 if CONF.has(prop) or prop.find('/') != -1:
                     if prop == GeneralProperties.USER_LAYOUT.value:
                         pass
                     elif prop == GeneralProperties.FONT.value and not setting[1]:
                         # if the font setting is empty removing it will make workbench use the default
                         CONF.remove(prop)
                     else:
                         try:
                             value = ast.literal_eval(setting[1])
                         except (SyntaxError, ValueError):
                             value = setting[1]
                         CONF.set(setting[0].strip(), value)
                 else:
                     ConfigService.setString(prop, setting[1])
             line = file.readline()