Skip to content

Commit

Permalink
User interface audit updates round #1
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@11962 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Nov 7, 2009
1 parent 04e023c commit 453a90f
Show file tree
Hide file tree
Showing 44 changed files with 6,084 additions and 5,807 deletions.
10 changes: 4 additions & 6 deletions python/plugins/mapserver_export/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#TODO: Need to configure cmake to run pyrcc4 and pyuic4 as required when the resource
# file or the ui change
SET(INSTALLER_FILES
mapserver_export.png
__init__.py
mapserverexportdialog.py
mapserverexport.py
ms_export.py
resources.py
ui_mapserverexport.py
)

PYQT4_WRAP_UI(PYUI_FILES qgsmapserverexportbase.ui)
PYQT4_ADD_RESOURCES(PYRC_FILES resources.qrc)
ADD_CUSTOM_TARGET(mapserverexport ALL DEPENDS ${PYUI_FILES} ${PYRC_FILES})

SET(INSTALLER_FILES ${INSTALLER_FILES} ${PYUI_FILES} ${PYRC_FILES})

INSTALL(FILES ${INSTALLER_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/mapserver_export)
56 changes: 48 additions & 8 deletions python/plugins/mapserver_export/mapserverexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
* (at your option) any later version. *
* *
***************************************************************************/
/* Adapted by Erik van de Pol, B3Partners BV. */
"""
# Import the PyQt and QGIS libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from xml.dom import minidom
from qgis.core import *
# Initialize Qt resources from file resources.py
import resources_rc
import resources
# Import the code for the dialog
from mapserverexportdialog import MapServerExportDialog
# Import the ms_export script that does the real work
Expand Down Expand Up @@ -59,7 +61,7 @@ def initGui(self):
"MapServer Export", self.iface.mainWindow())
#self.action.setWhatsThis("Configuration for Zoom To Point plugin")
# connect the action to the run method
QObject.connect(self.action, SIGNAL("triggered()"), self.run)
QObject.connect(self.action, SIGNAL("activated()"), self.run)
QObject.connect(self.iface, SIGNAL("currentThemeChanged ( QString )"), self.setCurrentTheme)

# Add toolbar button and menu item
Expand All @@ -74,17 +76,48 @@ def unload(self):
# run method that performs all the real work
def run(self):
# create and show the MapServerExport dialog
self.dlg = MapServerExportDialog()
self.dlg = MapServerExportDialog()
#dlg.setupUi(self)

project = QgsProject.instance()
# question: save project on loading export dialog?
if project.isDirty():
shouldSave = QMessageBox.question(None,
"Save?",
"Save project to \"" + project.fileName() + "\" before exporting? Only the last saved version of your project will be exported.",
QMessageBox.Yes,
QMessageBox.No,
QMessageBox.Cancel
)
if shouldSave == QMessageBox.Yes:
if project.fileName().size() == 0:
# project has not yet been saved:
saveAsFileName = QFileDialog.getSaveFileName(self.dlg,
"Save QGIS Project file as...",
".",
"QGIS Project Files (*.qgs)",
"Filter list for selecting files from a dialog box")
project.setFileName(saveAsFileName)
project.write()
elif shouldSave == QMessageBox.Cancel:
return # do not show the export dialog

self.dlg.ui.txtQgisFilePath.setText(project.fileName())
self.dlg.ui.txtMapName.setText(project.title())

# TODO: fetch unit used from QSettings

# TODO: fetch width/height guess from QSettings:
# fetch the last used values from settings and intialize the
# dialog with them
#settings = QSettings("MicroResources", "ZoomToPoint")
#xValue = settings.value("coordinate/x")
#dlg.ui.xCoord.setText(str(xValue.toString()))
#self.dlg.ui.xCoord.setText(str(xValue.toString()))
#yValue = settings.value("coordinate/y")
#dlg.ui.yCoord.setText(str(yValue.toString()))
#self.dlg.ui.yCoord.setText(str(yValue.toString()))
#scale = settings.value("zoom/scale", QVariant(4))
#dlg.ui.spinBoxScale.setValue(scale.toInt()[0])
#self.dlg.ui.spinBoxScale.setValue(scale.toInt()[0])

QObject.connect(self.dlg.ui.btnChooseFile, SIGNAL("clicked()"), self.setSaveFile)
QObject.connect(self.dlg.ui.btnChooseProjectFile, SIGNAL("clicked()"), self.setProjectFile)
QObject.connect(self.dlg.ui.chkExpLayersOnly, SIGNAL("clicked(bool)"), self.toggleLayersOnly)
Expand All @@ -100,15 +133,22 @@ def run(self):
print "Creating exporter using %s and %s" % (self.dlg.ui.txtQgisFilePath.text(), self.dlg.ui.txtMapFilePath.text())
exporter = Qgis2Map(unicode(self.dlg.ui.txtQgisFilePath.text()), unicode(self.dlg.ui.txtMapFilePath.text()))
print "Setting options"
exporter.setOptions(
exporter.setOptions(
unicode(self.dlg.ui.txtMapServerUrl.text()),
unicode(self.dlg.ui.cmbMapUnits.itemData( self.dlg.ui.cmbMapUnits.currentIndex() ).toString()),
unicode(self.dlg.ui.cmbMapImageType.currentText()),
unicode(self.dlg.ui.txtMapName.text()),
unicode(self.dlg.ui.txtMapWidth.text()),
unicode(self.dlg.ui.txtMapHeight.text()),
unicode(self.dlg.ui.txtWebTemplate.text()),
unicode(self.dlg.ui.txtWebFooter.text()),
unicode(self.dlg.ui.txtWebHeader.text())
unicode(self.dlg.ui.txtWebHeader.text()),
self.dlg.ui.checkBoxDump.isChecked(),
self.dlg.ui.checkBoxForce.isChecked(),
self.dlg.ui.checkBoxAntiAlias.isChecked(),
self.dlg.ui.checkBoxPartials.isChecked(),
unicode(self.dlg.ui.txtFontsetPath.text()),
unicode(self.dlg.ui.txtSymbolsetPath.text())
)
print "Calling writeMapFile"
result = exporter.writeMapFile()
Expand Down
21 changes: 18 additions & 3 deletions python/plugins/mapserver_export/mapserverexportdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,31 @@
***************************************************************************/
"""
from PyQt4 import QtCore, QtGui
from ui_qgsmapserverexportbase import Ui_QgsMapserverExportBase
from ms_export import defaults
from ui_mapserverexport import Ui_QgsMapserverExportBase
# create the dialog for mapserver export
class MapServerExportDialog(QtGui.QDialog):
def __init__(self):
def __init__(self):
QtGui.QDialog.__init__(self)
# Set up the user interface from Designer.
self.ui = Ui_QgsMapserverExportBase()
self.ui.setupUi(self)

for unit in ["dd", "feet", "meters", "miles", "inches", "kilometers"]:
for unit in ["meters", "dd", "feet", "miles", "inches", "kilometers"]:
self.ui.cmbMapUnits.addItem( QtGui.QApplication.translate("QgsMapserverExportBase", unit, None, QtGui.QApplication.UnicodeUTF8), QtCore.QVariant(unit) )

# TODO: set default unit. Is now the first value entered in the unit-list above

# Set defaults from ms_export.py:
self.ui.txtMapServerUrl.setText(defaults.mapServerUrl)
self.ui.txtFontsetPath.setText(defaults.fontsPath)
self.ui.txtSymbolsetPath.setText(defaults.symbolsPath)
self.ui.checkBoxAntiAlias.setChecked(defaults.antialias)
self.ui.checkBoxDump.setChecked(defaults.dump)
self.ui.checkBoxForce.setChecked(defaults.force)
self.ui.checkBoxPartials.setChecked(defaults.partials)
self.ui.txtMapWidth.setText(defaults.width)
self.ui.txtMapHeight.setText(defaults.height)



Loading

0 comments on commit 453a90f

Please sign in to comment.