Exemplo n.º 1
0
 def apply(self):
     #validate
     newcachedir = unicode(self.generalCacheLocation.text())
     newcachedir = newcachedir.strip()
     if newcachedir.endswith(os.path.sep):
         newcachedir = newcachedir[:-1]
     if not os.path.isdir(newcachedir):
         QMessageBox.information(self, "QOSM Error", 
             "'%s' is not a directory" % newcachedir)
         return False
     if (not len(os.listdir(newcachedir)) == 0) and \
        ((newcachedir != s._defaultsetting(s.CACHE_DIRECTORY)) and
         (newcachedir != s.get(s.CACHE_DIRECTORY))):
         if QMessageBox.Ok != QMessageBox.question(self, "Question", 
                                     "Use non-emtpy directory for cache?",
                                     QMessageBox.Ok | QMessageBox.Cancel):
             return False
     
     if newcachedir == s._defaultsetting(s.CACHE_DIRECTORY):
         s.reset(s.CACHE_DIRECTORY)
         self.generalCacheLocation.setText(s.get(s.CACHE_DIRECTORY))
     else:
         s.put(s.CACHE_DIRECTORY, newcachedir)
         self.generalCacheLocation.setText(newcachedir)
     
     if self.generalMaxTiles.value() == s._defaultsetting(s.MAX_TILES):
         s.reset(s.MAX_TILES)
     else:
         s.put(s.MAX_TILES, self.generalMaxTiles.value())
     s.put(s.AUTODOWNLOAD, self.autoDownload.isChecked())
     self.apply_customtypes()
     
     self.calculate_cachesize()
     return True
Exemplo n.º 2
0
 def on_generalBrowse_released(self):
     dirtext = self.generalCacheLocation.text()
     if (dirtext != s._defaultsetting(s.CACHE_DIRECTORY)) and \
         (os.path.isdir(dirtext)):
         previousDir = dirtext
     else:
         previousDir = unicode(QDir.homePath())
     directory = QFileDialog.getExistingDirectory(self, "Choose Directory",
                                 previousDir)
     if directory:
         self.generalCacheLocation.setText(directory)