def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface self.wiki_btn = None self.reset_btn = None try: self.plugin_config = parse_config_from_file() except NoOptionError: print "invalid config file!" QMessageBox.information(self.iface.mainWindow(), "Configuration failure", "Plugin config file is invalid") # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( self.plugin_dir, 'i18n', '{}_{}.qm'.format(self.plugin_config.get('name'), locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.dock = OsmaWebServicesDock() # Add dock to main window self.iface.addDockWidget(Qt.RightDockWidgetArea, self.dock) # Declare instance attributes self.actions = [] self.menu = self.tr(u'&{}'.format(self.plugin_config.get('title'))) # self.toolbar = self.iface.addToolBar(u'TheMapCloudWebServices') # self.toolbar.setObjectName(u'TheMapCloudWebServices') # Variable for layers and about/info self.layers_wms = None self.layers_wmts = None self.about = None self.caches = None self.hit_osma = GetOsmaLayers() self.mc_auth = MapCloudAuthentication(self.iface) self.mc_auth.validate_auth_credentials() # Create instance of qtreeview for wms/wmts self.pop_wmts = PopulateTree(self.dock.ui, self.iface, self.mc_auth, wms=False) self.pop_wms = PopulateTree(self.dock.ui, self.iface, self.mc_auth, wms=True)