class Fmv: """ Main Class """ def __init__(self, iface): """ Contructor """ self.iface = iface log.initLogging() self.plugin_dir = os.path.dirname(__file__) locale = QSettings().value("locale//userLocale")[0:2] localePath = os.path.join( self.plugin_dir, 'i18n', 'qgisfmv_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '5.9.0': QCoreApplication.installTranslator(self.translator) self._FMVManager = None def initGui(self): ''' FMV Action ''' self.actionFMV = QAction(QIcon(":/imgFMV/images/icon.png"), u"FMV", self.iface.mainWindow(), statusTip=QCoreApplication.translate( "Fmv", "Show Video Manager"), triggered=self.run) self.iface.addToolBarIcon(self.actionFMV) self.iface.addPluginToMenu(QCoreApplication.translate( "Fmv", "Full Motion Video (FMV)"), self.actionFMV) ''' About Action ''' self.actionAbout = QAction(QIcon(":/imgFMV/images/Information.png"), u"About", self.iface.mainWindow(), statusTip=QCoreApplication.translate( "Fmv", "Show About FMV"), triggered=self.About) self.iface.addPluginToMenu(QCoreApplication.translate( "Fmv", "Full Motion Video (FMV)"), self.actionAbout) def unload(self): ''' Unload Plugin ''' self.iface.removePluginMenu(QCoreApplication.translate( "Fmv", "Full Motion Video (FMV)"), self.actionFMV) self.iface.removePluginMenu(QCoreApplication.translate( "Fmv", "Full Motion Video (FMV)"), self.actionAbout) self.iface.removeToolBarIcon(self.actionFMV) log.removeLogging() def About(self): ''' Show About Dialog ''' self.About = FmvAbout() self.About.setWindowFlags(Qt.Window | Qt.WindowCloseButtonHint) self.About.exec_() def run(self): ''' Run method ''' if self._FMVManager is None: self.CreateDockWidget() def CreateDockWidget(self): ''' Show Manager Video Dock ''' self._FMVManager = FmvManager(self.iface) self.iface.addDockWidget(Qt.BottomDockWidgetArea, self._FMVManager)
def About(self): ''' Show About Dialog ''' self.About = FmvAbout() self.About.setWindowFlags(Qt.Window | Qt.WindowCloseButtonHint) self.About.exec_()
class Fmv: """ Main Class """ def __init__(self, iface): """ Contructor """ self.iface = iface log.initLogging() threadcount = QThread.idealThreadCount() # use all available cores and parallel rendering QgsApplication.setMaxThreads(threadcount) QSettings().setValue("/qgis/parallel_rendering", True) # OpenCL acceleration QSettings().setValue("/core/OpenClEnabled", True) self.plugin_dir = os.path.dirname(__file__) locale = QSettings().value("locale//userLocale")[0:2] localePath = os.path.join( self.plugin_dir, 'i18n', 'qgisfmv_{}.qm'.format(locale)) if os.path.exists(localePath): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '5.9.0': QCoreApplication.installTranslator(self.translator) self._FMVManager = None def initGui(self): ''' FMV Action ''' self.actionFMV = QAction(QIcon(":/imgFMV/images/icon.png"), u"FMV", self.iface.mainWindow(), statusTip=QCoreApplication.translate( "Fmv", "Show Video Manager"), triggered=self.run) self.iface.registerMainWindowAction( self.actionFMV, qgsu.SetShortcutForPluginFMV(u"FMV")) self.iface.addToolBarIcon(self.actionFMV) self.iface.addPluginToMenu(QCoreApplication.translate( "Fmv", "Full Motion Video (FMV)"), self.actionFMV) ''' About Action ''' self.actionAbout = QAction(QIcon(":/imgFMV/images/Information.png"), u"FMV About", self.iface.mainWindow(), statusTip=QCoreApplication.translate( "Fmv", "Show About FMV"), triggered=self.About) self.iface.registerMainWindowAction( self.actionAbout, qgsu.SetShortcutForPluginFMV(u"FMV About", "Alt+A")) self.iface.addPluginToMenu(QCoreApplication.translate( "Fmv", "Full Motion Video (FMV)"), self.actionAbout) def unload(self): ''' Unload Plugin ''' self.iface.removePluginMenu(QCoreApplication.translate( "Fmv", "Full Motion Video (FMV)"), self.actionFMV) self.iface.removePluginMenu(QCoreApplication.translate( "Fmv", "Full Motion Video (FMV)"), self.actionAbout) self.iface.removeToolBarIcon(self.actionFMV) log.removeLogging() qgsu.removeMosaicFolder() def About(self): ''' Show About Dialog ''' self.About = FmvAbout() self.About.setWindowFlags(Qt.Window | Qt.WindowCloseButtonHint) self.About.exec_() def run(self): ''' Run method ''' if self._FMVManager is None: self.CreateDockWidget() def CreateDockWidget(self): ''' Show Manager Video Dock ''' self._FMVManager = FmvManager(self.iface) self.iface.addDockWidget(Qt.BottomDockWidgetArea, self._FMVManager)