Пример #1
0
 def closeEvent(self, event):
     """The window was closed"""
     # Determine the window state
     state = self.windowState()
     window_state = 'none'
     if state & QtCore.Qt.WindowFullScreen:
         window_state = 'fullscreen'
     elif state & QtCore.Qt.WindowMaximized:
         window_state = 'maximized'
     elif state & QtCore.Qt.WindowMinimized:
         window_state = 'minimized'
     else:
         # Save the window geometry for normal state
         geometry = self.geometry()
         Config.set('window/geometry', [
             geometry.x(),
             geometry.y(),
             geometry.width(),
             geometry.height()
         ])
     # Save the window state
     Config.set('window/state', window_state)
     # Save the configuration
     Config.save()
     # Continue to close the window
     QtWidgets.QMainWindow.closeEvent(self, event)
Пример #2
0
 def enable(self):
     """Enable the plugin"""
     # Get the enabled plugins
     enabled_plugins = Config.get('plugins', [])
     # Check if this plugin is already enabled
     if isinstance(enabled_plugins, list) and not self.name() in enabled_plugins:
         # Enable this plugin
         enabled_plugins.append(self.name())
         Config.set('plugins', enabled_plugins)
Пример #3
0
 def disable(self):
     """Disable the plugin"""
     # Get the enabled plugins
     enabled_plugins = Config.get('plugins', [])
     # Check if this plugin is already enabled
     if isinstance(enabled_plugins, list) and self.name() in enabled_plugins:
         # Disable this plugin
         enabled_plugins.remove(self.name())
         Config.set('plugins', enabled_plugins)
         # Unload plugin
         self.unload()
Пример #4
0
 def save_repo_entry(repo_path, repo_url=None):
     repos = Config.get('repos', defaultValue=[])
     duplicate_found = False
     for index, repo in enumerate(repos):
         if repo['path'] == repo_path:
             repos[index]['url'] = repo_url
             duplicate_found = True
             break
     if not duplicate_found:
         repos.append({'path': repo_path, 'url': repo_url})
     Config.set('repos', repos)
     Config.save()