Skip to content

Commit

Permalink
Added feature from request #234.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldebek committed May 18, 2017
1 parent 81dc331 commit b383ccd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion QGIS Plugin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PLUGINNAME = projectselector

PY_FILES = projectselector.py projectselectordialog.py __init__.py

EXTRAS = icon.png metadata.txt
EXTRAS = icon.png metadata.txt defaults.txt

UI_FILES = ui_projectselector.py

Expand Down
2 changes: 2 additions & 0 deletions QGIS Plugin/defaults.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
projects:<projects_path>
templates:<templates_path>
4 changes: 2 additions & 2 deletions QGIS Plugin/install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PAUSE
SET NAME=moor-tools

rem Install for current user
SET DEST=%HOMEPATH%\.qgis2\python\plugins\%NAME%
SET DEST=%USERPROFILE%\.qgis2\python\plugins\%NAME%

rem Install for all users (required script to be run as Administrator)
rem SET DEST=C:\Program Files (x86)\Quantum GIS Lisboa\apps\qgis\python\plugins\%NAME%
Expand All @@ -19,8 +19,8 @@ mkdir %DEST%\Templates\Logos
xcopy /y *.py %DEST%
xcopy /y *.png %DEST%
xcopy /y metadata.txt %DEST%
xcopy /y defaults.txt %DEST%
xcopy /y *.ui %DEST%
xcopy /y examples\*.* %DEST%\examples
xcopy /y Templates\*.* %DEST%\Templates
xcopy /y Templates\Logos\*.* %DEST%\Templates\Logos

7 changes: 5 additions & 2 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.2
version=1.1.3
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,7 +24,10 @@ 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.2 - Bug fixes and new features:
changelog=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
- Added Autofit button to adjust map scales to paper format
- Fixed mixed up combo boxes with scales
- Fixed example templates
Expand Down
35 changes: 20 additions & 15 deletions QGIS Plugin/settingsdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@

import os

PARENT_DIR = os.path.dirname(os.path.abspath(__file__))
DEFAULTS = os.path.join(PARENT_DIR, 'defaults.txt')


class SettingsDialog(QtGui.QDialog):



def __init__(self):

QtGui.QDialog.__init__(self)
Expand All @@ -40,27 +42,30 @@ def __init__(self):
self.settings = QtCore.QSettings()

# Populate the values
v = self.settings.value('MoorTools/ProjectSelector/projectRoot', '', type=str)
self.ui.projectsFolderLineEdit.setText(v)
v = self.settings.value('MoorTools/TemplateSelector/templateRoot', '', type=str)
self.ui.templateRootLineEdit.setText(v)

with open(DEFAULTS) as paths:
projects = paths.readline().strip().split(':', 1)[-1]
templates = paths.readline().strip().split(':', 1)[-1]
self.ui.projectsFolderLineEdit.setText(projects)
self.ui.templateRootLineEdit.setText(templates)

def browseForProjectRoot(self):
startingDir = str(self.settings.value("MoorTools/ProjectSelector/projectRoot", os.path.expanduser("~"), type=str))
d = str( QtGui.QFileDialog.getExistingDirectory(None, 'Select Projects Folder', startingDir) )
if d <> os.sep and d.lower() <> 'c:\\' and d <> '':
d = str(QtGui.QFileDialog.getExistingDirectory(None, 'Select Projects Folder', startingDir))
if d != os.sep and d.lower() != 'c:\\' and d != '':
self.ui.projectsFolderLineEdit.setText(d)

def browseForTemplateRoot(self):
startingDir = str(self.settings.value("MoorTools/TemplateSelector/templateRoot", os.path.expanduser("~"), type=str))
d = str( QtGui.QFileDialog.getExistingDirectory(None, 'Select Root of Template Folder Structure', startingDir) )
if d <> os.sep and d.lower() <> 'c:\\' and d <> '':
d = str(QtGui.QFileDialog.getExistingDirectory(None, 'Select Root of Template Folder Structure', startingDir))
if d != os.sep and d.lower() != 'c:\\' and d != '':
self.ui.templateRootLineEdit.setText(d)

def accept(self):
d = self.ui.projectsFolderLineEdit.text()
self.settings.setValue("MoorTools/ProjectSelector/projectRoot", d)
d = self.ui.templateRootLineEdit.text()
self.settings.setValue("MoorTools/TemplateSelector/templateRoot", d)
projects = self.ui.projectsFolderLineEdit.text()
self.settings.setValue("MoorTools/ProjectSelector/projectRoot", projects)
templates = self.ui.templateRootLineEdit.text()
self.settings.setValue("MoorTools/TemplateSelector/templateRoot", templates)
with open(DEFAULTS, 'w') as paths:
paths.write('projects:{}\n'.format(projects))
paths.write('templates:{}\n'.format(templates))
QtGui.QDialog.accept(self)

0 comments on commit b383ccd

Please sign in to comment.