Skip to content

Commit

Permalink
Added ability to enable / disable project selector through settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mostlyAtNight committed Dec 12, 2017
1 parent 398f90d commit 453a79a
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 37 deletions.
Binary file modified Images/moor_tools_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions QGIS Plugin/metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name=Project Selector
qgisMinimumVersion=2.0
qgisMaximumVersion=2.99
description=Tool for selecting pre-defined QGIS projects.
version=1.1.4
version=1.2.0
author=Dartmoor National Park Authority
[email protected]
about=Tools for simplifying and automating common tasks for national parks and other protected areas. Catchy name courtesy of Dartmoor National Park, UK.
Expand All @@ -24,9 +24,11 @@ about=Tools for simplifying and automating common tasks for national parks and o

# Uncomment the following line and add your changelog entries:

changelog=1.1.4 - New features:
changelog=1.2.0 - New features:
- Added ability to enable / disable project selector through settings
<p>1.1.4 - New features:
- Added option for setting custom dpi values for printing
<p>changelog=1.1.3 - New features:
<p>1.1.3 - New features:
- added defaults.txt with predefined paths to projects and templates
<p>1.1.2 - Bug fixes:
- Fixed plugin crashing when choosing current map canvas scale
Expand Down
5 changes: 3 additions & 2 deletions QGIS Plugin/projectselector.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ def unload(self):
self.iface.removeToolBarIcon(self.templateSelectorAction)

def onInitializationCompleted(self):
if len(QgsProject.instance().fileName()) == 0:
project_selector_enabled = QSettings().value("MoorTools/ProjectSelector/isEnabled", True, type=bool)
if len(QgsProject.instance().fileName()) == 0 and project_selector_enabled:
# The project file name will only be populated after the initializationCompleted() signal is emitted if QGIS has
# been invoked on a .qgs (project) file. So only show the selector if we've not been opened on an existing .qgs
# file
self.selectProject()
self.selectProject()

# run method that performs all the real work
def selectProject(self):
Expand Down
4 changes: 4 additions & 0 deletions QGIS Plugin/settingsdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def __init__(self):
templates = paths.readline().strip().split(':', 1)[-1]
self.ui.projectsFolderLineEdit.setText(projects)
self.ui.templateRootLineEdit.setText(templates)
project_selector_enabled = self.settings.value("MoorTools/ProjectSelector/isEnabled", True, type=bool)
self.ui.projectSelectorEnabledCheckBox.setChecked(project_selector_enabled)

def browseForProjectRoot(self):
startingDir = str(self.settings.value("MoorTools/ProjectSelector/projectRoot", os.path.expanduser("~"), type=str))
Expand All @@ -68,4 +70,6 @@ def accept(self):
with open(DEFAULTS, 'w') as paths:
paths.write('projects:{}\n'.format(projects))
paths.write('templates:{}\n'.format(templates))
project_selector_enabled = self.ui.projectSelectorEnabledCheckBox.isChecked()
self.settings.setValue("MoorTools/ProjectSelector/isEnabled", project_selector_enabled)
QtGui.QDialog.accept(self)
38 changes: 22 additions & 16 deletions QGIS Plugin/ui_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'ui_settings.ui'
#
# Created: Mon Aug 17 16:56:46 2015
# Created: Tue Dec 12 09:20:31 2017
# by: PyQt4 UI code generator 4.10.2
#
# WARNING! All changes made in this file will be lost!
Expand All @@ -26,29 +26,34 @@ def _translate(context, text, disambig):
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(428, 107)
Dialog.resize(428, 156)
self.gridLayout_2 = QtGui.QGridLayout(Dialog)
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
self.gridLayout = QtGui.QGridLayout()
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.projectsFolderLabel = QtGui.QLabel(Dialog)
self.projectsFolderLabel.setObjectName(_fromUtf8("projectsFolderLabel"))
self.gridLayout.addWidget(self.projectsFolderLabel, 0, 0, 1, 1)
self.projectsFolderLineEdit = QtGui.QLineEdit(Dialog)
self.projectsFolderLineEdit.setObjectName(_fromUtf8("projectsFolderLineEdit"))
self.gridLayout.addWidget(self.projectsFolderLineEdit, 0, 1, 1, 1)
self.templateRootPushButton = QtGui.QPushButton(Dialog)
self.templateRootPushButton.setObjectName(_fromUtf8("templateRootPushButton"))
self.gridLayout.addWidget(self.templateRootPushButton, 1, 2, 1, 1)
self.projectsFolderPushButton = QtGui.QPushButton(Dialog)
self.projectsFolderPushButton.setObjectName(_fromUtf8("projectsFolderPushButton"))
self.gridLayout.addWidget(self.projectsFolderPushButton, 0, 2, 1, 1)
self.templateRootLabel = QtGui.QLabel(Dialog)
self.templateRootLabel.setObjectName(_fromUtf8("templateRootLabel"))
self.gridLayout.addWidget(self.templateRootLabel, 1, 0, 1, 1)
self.templateRootLineEdit = QtGui.QLineEdit(Dialog)
self.templateRootLineEdit.setObjectName(_fromUtf8("templateRootLineEdit"))
self.gridLayout.addWidget(self.templateRootLineEdit, 1, 1, 1, 1)
self.templateRootPushButton = QtGui.QPushButton(Dialog)
self.templateRootPushButton.setObjectName(_fromUtf8("templateRootPushButton"))
self.gridLayout.addWidget(self.templateRootPushButton, 1, 2, 1, 1)
self.projectsFolderLineEdit = QtGui.QLineEdit(Dialog)
self.projectsFolderLineEdit.setObjectName(_fromUtf8("projectsFolderLineEdit"))
self.gridLayout.addWidget(self.projectsFolderLineEdit, 0, 1, 1, 1)
self.projectsFolderLabel = QtGui.QLabel(Dialog)
self.projectsFolderLabel.setObjectName(_fromUtf8("projectsFolderLabel"))
self.gridLayout.addWidget(self.projectsFolderLabel, 0, 0, 1, 1)
self.templateRootLabel = QtGui.QLabel(Dialog)
self.templateRootLabel.setObjectName(_fromUtf8("templateRootLabel"))
self.gridLayout.addWidget(self.templateRootLabel, 1, 0, 1, 1)
self.projectSelectorEnabledCheckBox = QtGui.QCheckBox(Dialog)
self.projectSelectorEnabledCheckBox.setChecked(True)
self.projectSelectorEnabledCheckBox.setTristate(False)
self.projectSelectorEnabledCheckBox.setObjectName(_fromUtf8("projectSelectorEnabledCheckBox"))
self.gridLayout.addWidget(self.projectSelectorEnabledCheckBox, 2, 0, 1, 3)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
spacerItem = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self.gridLayout_2.addItem(spacerItem, 1, 0, 1, 1)
Expand All @@ -67,8 +72,9 @@ def setupUi(self, Dialog):

def retranslateUi(self, Dialog):
Dialog.setWindowTitle(_translate("Dialog", "Moor Tools Settings", None))
self.projectsFolderLabel.setText(_translate("Dialog", "Projects Folder", None))
self.templateRootPushButton.setText(_translate("Dialog", "Browse", None))
self.projectsFolderPushButton.setText(_translate("Dialog", "Browse", None))
self.templateRootLabel.setText(_translate("Dialog", "Folder Containing Templates", None))
self.templateRootPushButton.setText(_translate("Dialog", "Browse", None))
self.projectsFolderLabel.setText(_translate("Dialog", "Projects Folder", None))
self.projectSelectorEnabledCheckBox.setText(_translate("Dialog", "Show project selector on QGIS startup", None))

43 changes: 28 additions & 15 deletions QGIS Plugin/ui_settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>428</width>
<height>107</height>
<height>156</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -16,37 +16,50 @@
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<widget class="QPushButton" name="projectsFolderPushButton">
<item row="0" column="0">
<widget class="QLabel" name="projectsFolderLabel">
<property name="text">
<string>Projects Folder</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="projectsFolderLineEdit"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="templateRootPushButton">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="templateRootLabel">
<item row="0" column="2">
<widget class="QPushButton" name="projectsFolderPushButton">
<property name="text">
<string>Folder Containing Templates</string>
<string>Browse</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="templateRootLineEdit"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="templateRootPushButton">
<item row="1" column="0">
<widget class="QLabel" name="templateRootLabel">
<property name="text">
<string>Browse</string>
<string>Folder Containing Templates</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="projectsFolderLineEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="projectsFolderLabel">
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="projectSelectorEnabledCheckBox">
<property name="text">
<string>Projects Folder</string>
<string>Show project selector on QGIS startup</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tools for simplifying and automating common tasks for national parks and other p

Although fully functional, this plugin has not yet been polished for release to the official QGIS plugin repository.

Please note this plugin has been developed for very specific use cases and as such may require further work to make it more generic to suit users' wider requirements. Please feel free to create [GitHub *issues*](http://fixme.com) for reporting any bugs, queries or feature requests.
Please note this plugin has been developed for very specific use cases and as such may require further work to make it more generic to suit users' wider requirements. Please feel free to create [GitHub *issues*](https://github.com/lutraconsulting/qgis-moor-tools-plugin/issues) for reporting any bugs, queries or feature requests.

## Configuration

Expand Down Expand Up @@ -62,6 +62,10 @@ In this case the optional _images_ folder contains any logos or other images ref

The optional _Copyrights_ folder contains the copyright text(s) available when using the _Planning Application_ composer template. _default.txt_ can optionally be used to specify the default copyright text for the template. This is configured as described above for the _Project Selector_.

### Show on QGIS startup (Project Selector)

Whether or not to show the project selector dialog on QGIS startup - note that this dialog does not appear if QGIS is invoked directly on a project (.qgs) file.

### Customising the Help URL

You may be using Moor Tools as part of a wider QGIS deployment. In this case you may wish to override the destination URL of the Help button with your own content. This can be achieved by altering the definition of ``helpUrl`` towards the bottom of _templateselectordialog.py_ in the plugin source files.
Expand Down

0 comments on commit 453a79a

Please sign in to comment.