Skip to content

Commit c46b052

Browse files
author
brushtyler
committedJun 10, 2010
load modules only on menu triggers, skip the local traslator
git-svn-id: http://svn.osgeo.org/qgis/trunk@13701 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 15897aa commit c46b052

File tree

1 file changed

+60
-42
lines changed

1 file changed

+60
-42
lines changed
 

‎python/plugins/GdalTools/GdalTools.py

Lines changed: 60 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,8 @@
2929
req_mods = { "osgeo": "osgeo [python-gdal]" }
3030

3131
try:
32-
from tools import GdalTools_utils as Utils
33-
34-
from tools import ( doBuildVRT, doContour, doRasterize, doPolygonize, doMerge, doSieve, doProximity, doNearBlack )
35-
from tools import ( doWarp, doGrid, doTranslate, doClipper, doInfo, doProjection, doOverview, doRgbPct, doPctRgb )
36-
from tools import ( doSettings, doAbout )
32+
from osgeo import gdal
33+
from osgeo import ogr
3734
except ImportError, e:
3835
error_str = str(e)
3936
error_mod = error_str.replace( "No module named ", "" )
@@ -52,26 +49,27 @@ def __init__( self, iface ):
5249
except:
5350
self.QgisVersion = unicode( QGis.qgisVersion )[ 0 ]
5451

55-
# For i18n support
56-
userPluginPath = QFileInfo( QgsApplication.qgisUserDbFilePath() ).path() + "/python/plugins/GdalTools"
57-
systemPluginPath = QgsApplication.prefixPath() + "/python/plugins/GdalTools"
52+
if QGis.QGIS_VERSION[0:3] < "1.5":
53+
# For i18n support
54+
userPluginPath = QFileInfo( QgsApplication.qgisUserDbFilePath() ).path() + "/python/plugins/GdalTools"
55+
systemPluginPath = QgsApplication.prefixPath() + "/python/plugins/GdalTools"
5856

59-
overrideLocale = QSettings().value( "locale/overrideFlag", QVariant( False ) ).toBool()
60-
if not overrideLocale:
61-
localeFullName = QLocale.system().name()
62-
else:
63-
localeFullName = QSettings().value( "locale/userLocale", QVariant( "" ) ).toString()
57+
overrideLocale = QSettings().value( "locale/overrideFlag", QVariant( False ) ).toBool()
58+
if not overrideLocale:
59+
localeFullName = QLocale.system().name()
60+
else:
61+
localeFullName = QSettings().value( "locale/userLocale", QVariant( "" ) ).toString()
6462

65-
if QFileInfo( userPluginPath ).exists():
66-
translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
67-
else:
68-
translationPath = systemPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
63+
if QFileInfo( userPluginPath ).exists():
64+
translationPath = userPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
65+
else:
66+
translationPath = systemPluginPath + "/i18n/GdalTools_" + localeFullName + ".qm"
6967

70-
self.localePath = translationPath
71-
if QFileInfo( self.localePath ).exists():
72-
self.translator = QTranslator()
73-
self.translator.load( self.localePath )
74-
QCoreApplication.installTranslator( self.translator )
68+
self.localePath = translationPath
69+
if QFileInfo( self.localePath ).exists():
70+
self.translator = QTranslator()
71+
self.translator.load( self.localePath )
72+
QCoreApplication.installTranslator( self.translator )
7573

7674
def initGui( self ):
7775
if int( self.QgisVersion ) < 1:
@@ -80,7 +78,8 @@ def initGui( self ):
8078
+ QCoreApplication.translate( "GdalTools", "This version of Gdal Tools requires at least QGIS version 1.0.0\nPlugin will not be enabled." ) )
8179
return None
8280

83-
self.GdalVersion = Utils.Version( Utils.GdalConfig.version() )
81+
from tools.GdalTools_utils import Version, GdalConfig
82+
self.GdalVersion = Version( GdalConfig.version() )
8483

8584
self.menu = QMenu()
8685
self.menu.setTitle( QCoreApplication.translate( "GdalTools", "&Raster" ) )
@@ -198,77 +197,96 @@ def unload( self ):
198197
pass
199198

200199
def doBuildVRT( self ):
201-
d = doBuildVRT.GdalToolsDialog( self.iface )
200+
from tools.doBuildVRT import GdalToolsDialog as BuildVRT
201+
d = BuildVRT( self.iface )
202202
d.show_()
203203

204204
def doContour( self ):
205-
d = doContour.GdalToolsDialog( self.iface )
205+
from tools.doContour import GdalToolsDialog as Contour
206+
d = Contour( self.iface )
206207
d.show_()
207208

208209
def doRasterize( self ):
209-
d = doRasterize.GdalToolsDialog( self.iface )
210+
from tools.doRasterize import GdalToolsDialog as Rasterize
211+
d = Rasterize( self.iface )
210212
d.show_()
211213

212214
def doPolygonize( self ):
213-
d = doPolygonize.GdalToolsDialog( self.iface )
215+
from tools.doPolygonize import GdalToolsDialog as Polygonize
216+
d = Polygonize( self.iface )
214217
d.show_()
215218

216219
def doMerge( self ):
217-
d = doMerge.GdalToolsDialog( self.iface )
220+
from tools.doMerge import GdalToolsDialog as Merge
221+
d = Merge( self.iface )
218222
d.show_()
219223

220224
def doSieve( self ):
221-
d = doSieve.GdalToolsDialog( self.iface )
225+
from tools.doSieve import GdalToolsDialog as Sieve
226+
d = Sieve( self.iface )
222227
d.show_()
223228

224229
def doProximity( self ):
225-
d = doProximity.GdalToolsDialog( self.iface )
230+
from tools.doProximity import GdalToolsDialog as Proximity
231+
d = Proximity( self.iface )
226232
d.show_()
227233

228234
def doNearBlack( self ):
229-
d = doNearBlack.GdalToolsDialog( self.iface )
235+
from tools.doNearBlack import GdalToolsDialog as NearBlack
236+
d = NearBlack( self.iface )
230237
d.show_()
231238

232239
def doWarp( self ):
233-
d = doWarp.GdalToolsDialog( self.iface )
240+
from tools.doWarp import GdalToolsDialog as Warp
241+
d = Warp( self.iface )
234242
d.show_()
235243

236244
def doGrid( self ):
237-
d = doGrid.GdalToolsDialog( self.iface )
245+
from tools.doGrid import GdalToolsDialog as Grid
246+
d = Grid( self.iface )
238247
d.show_()
239248

240249
def doTranslate( self ):
241-
d = doTranslate.GdalToolsDialog( self.iface )
250+
from tools.doTranslate import GdalToolsDialog as Translate
251+
d = Translate( self.iface )
242252
d.show_()
243253

244254
def doInfo( self ):
245-
d = doInfo.GdalToolsDialog( self.iface )
255+
from tools.doInfo import GdalToolsDialog as Info
256+
d = Info( self.iface )
246257
d.show_()
247258

248259
def doProjection( self ):
249-
d = doProjection.GdalToolsDialog( self.iface )
260+
from tools.doProjection import GdalToolsDialog as Projection
261+
d = Projection( self.iface )
250262
d.show_()
251263

252264
def doOverview( self ):
253-
d = doOverview.GdalToolsDialog( self.iface )
265+
from tools.doOverview import GdalToolsDialog as Overview
266+
d = Overview( self.iface )
254267
d.show_()
255268

256269
def doClipper( self ):
257-
d = doClipper.GdalToolsDialog( self.iface )
270+
from tools.doClipper import GdalToolsDialog as Clipper
271+
d = Clipper( self.iface )
258272
d.show_()
259273

260274
def doPaletted( self ):
261-
d = doRgbPct.GdalToolsDialog( self.iface )
275+
from tools.doRgbPct import GdalToolsDialog as RgbPct
276+
d = RgbPct( self.iface )
262277
d.show_()
263278

264279
def doRGB( self ):
265-
d = doPctRgb.GdalToolsDialog( self.iface )
280+
from tools.doPctRgb import GdalToolsDialog as PctRgb
281+
d = PctRgb( self.iface )
266282
d.show_()
267283

268284
def doSettings( self ):
269-
d = doSettings.GdalToolsSettingsDialog( self.iface )
285+
from tools.doSettings import GdalToolsSettingsDialog as Settings
286+
d = Settings( self.iface )
270287
d.exec_()
271288

272289
def doAbout( self ):
273-
d = doAbout.GdalToolsAboutDialog( self.iface )
290+
from tools.doAbout import GdalToolsAboutDialog as About
291+
d = About( self.iface )
274292
d.exec_()

0 commit comments

Comments
 (0)
Please sign in to comment.