Ejemplo n.º 1
0
  def getAllInstalled(self, testLoad=True):
    """ Build the localCache """
    self.localCache = {}

    # reversed list of the plugin paths: first system plugins -> then user plugins -> finally custom path(s)
    pluginPaths = list(plugin_paths)
    pluginPaths.reverse()

    for pluginsPath in pluginPaths:
      isTheSystemDir = (pluginPaths.index(pluginsPath)==0)  # The curent dir is the system plugins dir
      if isTheSystemDir:
        # temporarily add the system path as the first element to force loading the readonly plugins, even if masked by user ones.
        sys.path = [pluginsPath] + sys.path
      try:
        pluginDir = QDir(pluginsPath)
        pluginDir.setFilter(QDir.AllDirs)
        for key in pluginDir.entryList():
          if key not in [".",".."]:
            path = QDir.convertSeparators( pluginsPath + "/" + key )
            # readOnly = not QFileInfo(pluginsPath).isWritable() # On windows testing the writable status isn't reliable.
            readOnly = isTheSystemDir                            # Assume only the system plugins are not writable.
            # only test those not yet loaded. Loaded plugins already proved they're o.k.
            testLoadThis = testLoad and key not in qgis.utils.plugins
            plugin = self.getInstalledPlugin(key, path=path, readOnly=readOnly, testLoad=testLoadThis)
            self.localCache[key] = plugin
            if key in self.localCache.keys() and compareVersions(self.localCache[key]["version_installed"],plugin["version_installed"]) == 1:
              # An obsolete plugin in the "user" location is masking a newer one in the "system" location!
              self.obsoletePlugins += [key]
      except:
        # it's not necessary to stop if one of the dirs is inaccessible
        pass

      if isTheSystemDir:
        # remove the temporarily added path
        sys.path.remove(pluginsPath)
Ejemplo n.º 2
0
 def load_file(self, path):
     if QApplication.instance().rest.dirty:
         fn = QDir.convertSeparators(QApplication.instance().rest.filename)
         rc = QMessageBox.warning(QApplication.instance().mainwin, 
                 'EzSphinx', 'Save changes to %s before proceeding?' % fn,
                 QMessageBox.Discard|QMessageBox.Save|QMessageBox.Cancel)
         if rc == QMessageBox.Cancel:
             return False
         if rc == QMessageBox.Save:
             if not QApplication.instance().rest.save(fn):
                 return False
     QApplication.instance().rest.load(path)
     QApplication.instance().mainwin.update(('restedit', ))
Ejemplo n.º 3
0
    def on_saveAsImage(self):
        sliceOffsetCheck = False
        if self._shape[1]>1:
            #stack z-view is stored in imageScenes[2], for no apparent reason
            sliceOffsetCheck = True
        timeOffsetCheck = self._shape[0]>1
        formatList = QImageWriter.supportedImageFormats()
        formatList = [x for x in formatList if x in ['png', 'tif']]
        expdlg = ExportDialog(formatList, timeOffsetCheck, sliceOffsetCheck, None, parent=self.ilastik)
        expdlg.exec_()

        tempname = str(expdlg.path.text()) + "/" + str(expdlg.prefix.text())
        filename = str(QDir.convertSeparators(tempname))
        self._saveThread.start()
        stuff = (filename, expdlg.timeOffset, expdlg.sliceOffset, expdlg.format)
        self._saveThread.queue.append(stuff)
        self._saveThread.imagePending.set()
Ejemplo n.º 4
0
def getConfigDir():
    """
    Global function to get the name of the directory storing the config data.
    
    @return directory name of the config dir (string)
    """
    if sys.platform.startswith("win"):
        cdn = "_eric4"
    else:
        cdn = ".eric4"
        
    hp = QDir.homePath()
    dn = QDir(hp)
    dn.mkdir(cdn)
    hp.append("/").append(cdn)
    try:
        return unicode(QDir.toNativeSeparators(hp))
    except AttributeError:
        return unicode(QDir.convertSeparators(hp))
Ejemplo n.º 5
0
class DefaultSettings(QSettings):
    """ The DefaultSettings class encapsulates the infrastructure
    needed to interact with the currently active settings.

    There are two types of settings, default and session. The default
    settings are loaded on startup and also initialize the session settings.
    All further changes in the preferences dialog affect only the
    current session and are thus forgotten upon application shutdown
    (i.e. are session settings). The current session settings for a
    given category (labels, legend, etc.) can be made the default via
    pressing the corresponding 'Make Defaults' button.

    """

    # defaults
    DEFAULT_GRID_CELL_WIDTH = "30"
    DEFAULT_GRID_CELL_HEIGHT = "30"
    DEFAULT_FONT = "Arial,10,-1,5,50,0,0,0,0,0"

    DEFAULT_SHOW_COLUMN_LABELS = "1"
    DEFAULT_SHOW_ROW_LABELS = "1"
    DEFAULT_ROW_LABELS_EDITABLE = "0"
    DEFAULT_COLUMN_LABELS_EDITABLE = "0"

    # options are LABEL_ALL_ROWS, SHOW_ROWS_WITH_INTERVAL,
    # SHOW_ODD_ROWS, SHOW_EVEN_ROWS
    DEFAULT_ROW_LABEL_MODE = "LABEL_ALL_ROWS"
    DEFAULT_ROW_LABEL_START = "1"
    DEFAULT_EVEN_ROW_LABEL_LOCATION = "RIGHT_OF"
    DEFAULT_ODD_ROW_LABEL_LOCATION = "RIGHT_OF"
    DEFAULT_ROW_LABELS_SHOW_INTERVAL = "1"
    DEFAULT_ROW_LABELS_SHOW_INTERVAL_START = "1"
    DEFAULT_ALIGN_ROW_LABELS_TO_VISIBLE_CELLS = "0"

    # options are LABEL_ALL_COLUMNS, SHOW_COLUMNS_WITH_INTERVAL,
    DEFAULT_COLUMN_LABEL_MODE = "LABEL_ALL_COLUMNS"
    DEFAULT_COLUMN_LABELS_SHOW_INTERVAL = "1"
    DEFAULT_COLUMN_LABELS_SHOW_INTERVAL_START = "1"

    DEFAULT_HIGHLIGHT_ROWS = "1"  # 1 corresponds to selected
    DEFAULT_HIGHLIGHT_ROWS_COLOR = "gray"
    DEFAULT_HIGHLIGHT_ROWS_OPACITY = "10"
    DEFAULT_HIGHLIGHT_ROWS_START = "0"  # 0 corresponds to bottom row
    DEFAULT_SNAP_PATTERN_REPEAT_TO_GRID = "2"
    DEFAULT_PERSONAL_SYMBOL_PATH = QDir.convertSeparators(QDir.homePath() +
                                                          "/.sconcho_symbols")
    DEFAULT_LOGGING_PATH = QDir.convertSeparators(QDir.homePath() +
                                                  "/.sconcho_logs")
    DEFAULT_DO_LOGGING = "0"
    DEFAULT_EXPORT_PATH = QDir.homePath()

    DEFAULT_NUM_RECENT_SYMBOLS = "5"

    def __init__(self, organization, application, parent=None):

        super(DefaultSettings, self).__init__(organization, application,
                                              parent)

        # remove old "global" namespace
        self.remove("global")

        # create all settings objects we need
        self.gridCellWidth = PreferenceSetting(
            self, DefaultSettings.DEFAULT_GRID_CELL_WIDTH, "cellWidth", "Int")

        self.gridCellHeight = PreferenceSetting(
            self, DefaultSettings.DEFAULT_GRID_CELL_HEIGHT, "cellHeight",
            "Int")

        self.showColumnLabels = PreferenceSetting(
            self, DefaultSettings.DEFAULT_SHOW_COLUMN_LABELS,
            "showColumnLabels", "Int")

        self.showRowLabels = PreferenceSetting(
            self, DefaultSettings.DEFAULT_SHOW_ROW_LABELS, "showRowLabels",
            "Int")

        self.rowLabelsEditable = PreferenceSetting(
            self, DefaultSettings.DEFAULT_ROW_LABELS_EDITABLE,
            "rowLabelsEditable", "Int")

        self.columnLabelsEditable = PreferenceSetting(
            self, DefaultSettings.DEFAULT_COLUMN_LABELS_EDITABLE,
            "columnLabelsEditable", "Int")

        self.rowLabelsShowInterval = PreferenceSetting(
            self, DefaultSettings.DEFAULT_ROW_LABELS_SHOW_INTERVAL,
            "rowLabelsShowInterval", "Int")

        self.rowLabelsShowIntervalStart = PreferenceSetting(
            self, DefaultSettings.DEFAULT_ROW_LABELS_SHOW_INTERVAL_START,
            "rowLabelsShowIntervalStart", "Int")

        self.rowLabelMode = PreferenceSetting(
            self, DefaultSettings.DEFAULT_ROW_LABEL_MODE, "rowLabelMode",
            "QString")

        self.rowLabelStart = PreferenceSetting(
            self, DefaultSettings.DEFAULT_ROW_LABEL_START, "rowLabelStart",
            "Int")

        self.evenRowLabelLocation = PreferenceSetting(
            self, DefaultSettings.DEFAULT_EVEN_ROW_LABEL_LOCATION,
            "evenRowLabelLocation", "QString")

        self.oddRowLabelLocation = PreferenceSetting(
            self, DefaultSettings.DEFAULT_ODD_ROW_LABEL_LOCATION,
            "oddRowLabelLocation", "QString")

        self.alignRowLabelsToVisibleCells = PreferenceSetting(
            self, DefaultSettings.DEFAULT_ALIGN_ROW_LABELS_TO_VISIBLE_CELLS,
            "alignRowLabelsToVisibleCells", "Int")

        self.columnLabelsShowInterval = PreferenceSetting(
            self, DefaultSettings.DEFAULT_COLUMN_LABELS_SHOW_INTERVAL,
            "columnLabelsShowInterval", "Int")

        self.columnLabelsShowIntervalStart = PreferenceSetting(
            self, DefaultSettings.DEFAULT_COLUMN_LABELS_SHOW_INTERVAL_START,
            "columnLabelsShowIntervalStart", "Int")

        self.columnLabelMode = PreferenceSetting(
            self, DefaultSettings.DEFAULT_COLUMN_LABEL_MODE, "columnLabelMode",
            "QString")

        self.labelFont = PreferenceSetting(self, DefaultSettings.DEFAULT_FONT,
                                           "labelFont", "QFont")

        self.legendFont = PreferenceSetting(self, DefaultSettings.DEFAULT_FONT,
                                            "legendFont", "QFont")

        self.personalSymbolPath = PreferenceSetting(
            self, DefaultSettings.DEFAULT_PERSONAL_SYMBOL_PATH,
            "personalSymbolPath", "QString")

        self.highlightRows = PreferenceSetting(
            self, DefaultSettings.DEFAULT_HIGHLIGHT_ROWS, "highlightRows",
            "Int")

        self.highlightRowsColor = PreferenceSetting(
            self, DefaultSettings.DEFAULT_HIGHLIGHT_ROWS_COLOR,
            "highlightRowsColor", "QString")

        self.highlightRowsOpacity = PreferenceSetting(
            self, DefaultSettings.DEFAULT_HIGHLIGHT_ROWS_OPACITY,
            "highlightRowsOpacity", "Int")

        self.highlightRowsStart = PreferenceSetting(
            self, DefaultSettings.DEFAULT_HIGHLIGHT_ROWS_START,
            "highlightRowsStart", "Int")

        self.snapPatternRepeatToGrid = PreferenceSetting(
            self, DefaultSettings.DEFAULT_SNAP_PATTERN_REPEAT_TO_GRID,
            "snapPatternRepeatToGrid", "Int")

        self.loggingPath = PreferenceSetting(
            self, DefaultSettings.DEFAULT_LOGGING_PATH, "loggingPath",
            "QString")

        self.doLogging = PreferenceSetting(self,
                                           DefaultSettings.DEFAULT_DO_LOGGING,
                                           "doLogging", "Int")

        self.numRecentSymbols = PreferenceSetting(
            self, DefaultSettings.DEFAULT_NUM_RECENT_SYMBOLS,
            "numRecentSymbols", "Int")

    @property
    def main_window_size(self):
        """ Return the size of the main window. """

        return self.value("MainWindow/Size", QSize(1200, 800))

    @main_window_size.setter
    def main_window_size(self, size):
        """ Set the size of the main window. """

        self.setValue("MainWindow/Size", size)

    @property
    def main_window_position(self):
        """ Return the position of the main window. """

        return self.value("MainWindow/Position", QPoint(0, 0))

    @main_window_position.setter
    def main_window_position(self, position):
        """ Set the size of the main window. """

        self.setValue("MainWindow/Position", position)

    @property
    def main_window_state(self):
        """ Return the saved state of the main window. """

        return self.value("MainWindow/State", QByteArray())

    @main_window_state.setter
    def main_window_state(self, state):
        """ Set the state of the main window. """

        self.setValue("MainWindow/State", state)

    @property
    def symbol_selector_state(self):
        """ Return the saved state of the symbol selector splitter. """

        return self.value("SymbolSelector/State", QByteArray())

    @symbol_selector_state.setter
    def symbol_selector_state(self, state):
        """ Set the state of the symbol selector splitter. """

        self.setValue("SymbolSelector/State", state)

    @property
    def recently_used_files(self):
        """ Return the list of recently used files. """

        # handle empty entries
        if not self.value("RecentlyUsedFiles/List"):
            self.recently_used_files = ""

        return self.value("RecentlyUsedFiles/List")

    @recently_used_files.setter
    def recently_used_files(self, values):
        """ Set the list of recently used files. """

        self.setValue("RecentlyUsedFiles/List", values)

    @property
    def export_path(self):
        """ Return the current export path for spf and 
        bitmap files. 

        """

        # handle empty entry
        if not self.value("ExportPath/Path"):
            self.export_path = DefaultSettings.DEFAULT_EXPORT_PATH

        return self.value("ExportPath/Path")

    @export_path.setter
    def export_path(self, path):
        """ Set the new export path for spf and bitmap
        files. 

        """

        self.setValue("ExportPath/Path", path)