Skip to content

Commit 453a90f

Browse files
author
timlinux
committed
User interface audit updates round #1
git-svn-id: http://svn.osgeo.org/qgis/trunk@11962 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 04e023c commit 453a90f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+6084
-5807
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1+
#TODO: Need to configure cmake to run pyrcc4 and pyuic4 as required when the resource
2+
# file or the ui change
13
SET(INSTALLER_FILES
24
mapserver_export.png
35
__init__.py
46
mapserverexportdialog.py
57
mapserverexport.py
68
ms_export.py
9+
resources.py
10+
ui_mapserverexport.py
711
)
812

9-
PYQT4_WRAP_UI(PYUI_FILES qgsmapserverexportbase.ui)
10-
PYQT4_ADD_RESOURCES(PYRC_FILES resources.qrc)
11-
ADD_CUSTOM_TARGET(mapserverexport ALL DEPENDS ${PYUI_FILES} ${PYRC_FILES})
12-
13-
SET(INSTALLER_FILES ${INSTALLER_FILES} ${PYUI_FILES} ${PYRC_FILES})
14-
1513
INSTALL(FILES ${INSTALLER_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/mapserver_export)

python/plugins/mapserver_export/mapserverexport.py

+48-8
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
* (at your option) any later version. *
1717
* *
1818
***************************************************************************/
19+
/* Adapted by Erik van de Pol, B3Partners BV. */
1920
"""
2021
# Import the PyQt and QGIS libraries
2122
from PyQt4.QtCore import *
2223
from PyQt4.QtGui import *
24+
from xml.dom import minidom
2325
from qgis.core import *
2426
# Initialize Qt resources from file resources.py
25-
import resources_rc
27+
import resources
2628
# Import the code for the dialog
2729
from mapserverexportdialog import MapServerExportDialog
2830
# Import the ms_export script that does the real work
@@ -59,7 +61,7 @@ def initGui(self):
5961
"MapServer Export", self.iface.mainWindow())
6062
#self.action.setWhatsThis("Configuration for Zoom To Point plugin")
6163
# connect the action to the run method
62-
QObject.connect(self.action, SIGNAL("triggered()"), self.run)
64+
QObject.connect(self.action, SIGNAL("activated()"), self.run)
6365
QObject.connect(self.iface, SIGNAL("currentThemeChanged ( QString )"), self.setCurrentTheme)
6466

6567
# Add toolbar button and menu item
@@ -74,17 +76,48 @@ def unload(self):
7476
# run method that performs all the real work
7577
def run(self):
7678
# create and show the MapServerExport dialog
77-
self.dlg = MapServerExportDialog()
79+
self.dlg = MapServerExportDialog()
7880
#dlg.setupUi(self)
81+
82+
project = QgsProject.instance()
83+
# question: save project on loading export dialog?
84+
if project.isDirty():
85+
shouldSave = QMessageBox.question(None,
86+
"Save?",
87+
"Save project to \"" + project.fileName() + "\" before exporting? Only the last saved version of your project will be exported.",
88+
QMessageBox.Yes,
89+
QMessageBox.No,
90+
QMessageBox.Cancel
91+
)
92+
if shouldSave == QMessageBox.Yes:
93+
if project.fileName().size() == 0:
94+
# project has not yet been saved:
95+
saveAsFileName = QFileDialog.getSaveFileName(self.dlg,
96+
"Save QGIS Project file as...",
97+
".",
98+
"QGIS Project Files (*.qgs)",
99+
"Filter list for selecting files from a dialog box")
100+
project.setFileName(saveAsFileName)
101+
project.write()
102+
elif shouldSave == QMessageBox.Cancel:
103+
return # do not show the export dialog
104+
105+
self.dlg.ui.txtQgisFilePath.setText(project.fileName())
106+
self.dlg.ui.txtMapName.setText(project.title())
107+
108+
# TODO: fetch unit used from QSettings
109+
110+
# TODO: fetch width/height guess from QSettings:
79111
# fetch the last used values from settings and intialize the
80112
# dialog with them
81113
#settings = QSettings("MicroResources", "ZoomToPoint")
82114
#xValue = settings.value("coordinate/x")
83-
#dlg.ui.xCoord.setText(str(xValue.toString()))
115+
#self.dlg.ui.xCoord.setText(str(xValue.toString()))
84116
#yValue = settings.value("coordinate/y")
85-
#dlg.ui.yCoord.setText(str(yValue.toString()))
117+
#self.dlg.ui.yCoord.setText(str(yValue.toString()))
86118
#scale = settings.value("zoom/scale", QVariant(4))
87-
#dlg.ui.spinBoxScale.setValue(scale.toInt()[0])
119+
#self.dlg.ui.spinBoxScale.setValue(scale.toInt()[0])
120+
88121
QObject.connect(self.dlg.ui.btnChooseFile, SIGNAL("clicked()"), self.setSaveFile)
89122
QObject.connect(self.dlg.ui.btnChooseProjectFile, SIGNAL("clicked()"), self.setProjectFile)
90123
QObject.connect(self.dlg.ui.chkExpLayersOnly, SIGNAL("clicked(bool)"), self.toggleLayersOnly)
@@ -100,15 +133,22 @@ def run(self):
100133
print "Creating exporter using %s and %s" % (self.dlg.ui.txtQgisFilePath.text(), self.dlg.ui.txtMapFilePath.text())
101134
exporter = Qgis2Map(unicode(self.dlg.ui.txtQgisFilePath.text()), unicode(self.dlg.ui.txtMapFilePath.text()))
102135
print "Setting options"
103-
exporter.setOptions(
136+
exporter.setOptions(
137+
unicode(self.dlg.ui.txtMapServerUrl.text()),
104138
unicode(self.dlg.ui.cmbMapUnits.itemData( self.dlg.ui.cmbMapUnits.currentIndex() ).toString()),
105139
unicode(self.dlg.ui.cmbMapImageType.currentText()),
106140
unicode(self.dlg.ui.txtMapName.text()),
107141
unicode(self.dlg.ui.txtMapWidth.text()),
108142
unicode(self.dlg.ui.txtMapHeight.text()),
109143
unicode(self.dlg.ui.txtWebTemplate.text()),
110144
unicode(self.dlg.ui.txtWebFooter.text()),
111-
unicode(self.dlg.ui.txtWebHeader.text())
145+
unicode(self.dlg.ui.txtWebHeader.text()),
146+
self.dlg.ui.checkBoxDump.isChecked(),
147+
self.dlg.ui.checkBoxForce.isChecked(),
148+
self.dlg.ui.checkBoxAntiAlias.isChecked(),
149+
self.dlg.ui.checkBoxPartials.isChecked(),
150+
unicode(self.dlg.ui.txtFontsetPath.text()),
151+
unicode(self.dlg.ui.txtSymbolsetPath.text())
112152
)
113153
print "Calling writeMapFile"
114154
result = exporter.writeMapFile()

python/plugins/mapserver_export/mapserverexportdialog.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,31 @@
1818
***************************************************************************/
1919
"""
2020
from PyQt4 import QtCore, QtGui
21-
from ui_qgsmapserverexportbase import Ui_QgsMapserverExportBase
21+
from ms_export import defaults
22+
from ui_mapserverexport import Ui_QgsMapserverExportBase
2223
# create the dialog for mapserver export
2324
class MapServerExportDialog(QtGui.QDialog):
24-
def __init__(self):
25+
def __init__(self):
2526
QtGui.QDialog.__init__(self)
2627
# Set up the user interface from Designer.
2728
self.ui = Ui_QgsMapserverExportBase()
2829
self.ui.setupUi(self)
2930

30-
for unit in ["dd", "feet", "meters", "miles", "inches", "kilometers"]:
31+
for unit in ["meters", "dd", "feet", "miles", "inches", "kilometers"]:
3132
self.ui.cmbMapUnits.addItem( QtGui.QApplication.translate("QgsMapserverExportBase", unit, None, QtGui.QApplication.UnicodeUTF8), QtCore.QVariant(unit) )
33+
34+
# TODO: set default unit. Is now the first value entered in the unit-list above
35+
36+
# Set defaults from ms_export.py:
37+
self.ui.txtMapServerUrl.setText(defaults.mapServerUrl)
38+
self.ui.txtFontsetPath.setText(defaults.fontsPath)
39+
self.ui.txtSymbolsetPath.setText(defaults.symbolsPath)
40+
self.ui.checkBoxAntiAlias.setChecked(defaults.antialias)
41+
self.ui.checkBoxDump.setChecked(defaults.dump)
42+
self.ui.checkBoxForce.setChecked(defaults.force)
43+
self.ui.checkBoxPartials.setChecked(defaults.partials)
44+
self.ui.txtMapWidth.setText(defaults.width)
45+
self.ui.txtMapHeight.setText(defaults.height)
46+
3247

3348

0 commit comments

Comments
 (0)