Skip to content

Commit ee60974

Browse files
committed
Merge pull request #297 from slarosa/master
[FEATURE] - Choose Fontfamily and API files for Python Console
2 parents 8ca2236 + 3fecd44 commit ee60974

14 files changed

+566
-51
lines changed

i18n/qgis_it.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6452,6 +6452,10 @@ Cambiare questa situazione prima, perché il plugin OSM non quale layer è la de
64526452
<source>Save to script file</source>
64536453
<translation>Salva file</translation>
64546454
</message>
6455+
<message>
6456+
<source>Settings</source>
6457+
<translation>Impostazioni</translation>
6458+
</message>
64556459
<message>
64566460
<source>Help</source>
64576461
<translation>Aiuto</translation>

images/console/iconAboutConsole.png

1.38 KB
Loading

python/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ ADD_CUSTOM_COMMAND(TARGET compile_python_files
149149
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
150150
)
151151

152-
FOREACH(file __init__.py utils.py console.py console_sci.py console_help.py)
152+
FILE(GLOB UI_FILES *.ui)
153+
PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES})
154+
ADD_CUSTOM_TARGET(console ALL DEPENDS ${PYUI_FILES})
155+
INSTALL(FILES ${PYUI_FILES} DESTINATION ${QGIS_PYTHON_DIR})
156+
157+
FOREACH(file __init__.py utils.py console.py console_sci.py console_help.py console_settings.py)
153158
ADD_CUSTOM_COMMAND(TARGET compile_python_files
154159
POST_BUILD
155160
COMMAND ${CMAKE_COMMAND} -E copy ${file} ${QGIS_PYTHON_OUTPUT_DIRECTORY}
@@ -163,3 +168,4 @@ PYTHON_INSTALL(utils.py ${QGIS_PYTHON_DIR})
163168
PYTHON_INSTALL(console.py ${QGIS_PYTHON_DIR})
164169
PYTHON_INSTALL(console_sci.py ${QGIS_PYTHON_DIR})
165170
PYTHON_INSTALL(console_help.py ${QGIS_PYTHON_DIR})
171+
PYTHON_INSTALL(console_settings.py ${QGIS_PYTHON_DIR})

python/console.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from qgis.utils import iface
2525
from console_sci import PythonEdit
2626
from console_help import HelpDialog
27+
from console_settings import optionsDialog
2728

2829
import sys
2930
import os
@@ -69,7 +70,7 @@ def get_and_clean_data(self):
6970
def flush(self):
7071
pass
7172

72-
sys.stdout = QgisOutputCatcher()
73+
sys.stdout = QgisOutputCatcher()
7374

7475
class PythonConsole(QDockWidget):
7576
def __init__(self, parent=None):
@@ -98,7 +99,8 @@ def __init__(self, parent=None):
9899
self.setWindowTitle(QCoreApplication.translate("PythonConsole", "Python Console"))
99100

100101
self.widgetButton = QWidget()
101-
102+
self.options = optionsDialog(self)
103+
102104
self.toolBar = QToolBar()
103105
self.toolBar.setEnabled(True)
104106
#self.toolBar.setFont(font)
@@ -130,13 +132,16 @@ def __init__(self, parent=None):
130132
self.clearButton.setIconVisibleInMenu(True)
131133
self.clearButton.setToolTip(clearBt)
132134
self.clearButton.setText(clearBt)
133-
## Action for paste snippets code
134-
# self.currentLayerButton = QAction(parent)
135-
# self.currentLayerButton.setCheckable(False)
136-
# self.currentLayerButton.setEnabled(True)
137-
# self.currentLayerButton.setIcon(QIcon("icon/iconTempConsole.png"))
138-
# self.currentLayerButton.setMenuRole(QAction.PreferencesRole)
139-
# self.currentLayerButton.setIconVisibleInMenu(True)
135+
## Action for settings
136+
optionsBt = QCoreApplication.translate("PythonConsole", "Settings")
137+
self.optionsButton = QAction(parent)
138+
self.optionsButton.setCheckable(False)
139+
self.optionsButton.setEnabled(True)
140+
self.optionsButton.setIcon(QIcon(":/images/console/iconSettingsConsole.png"))
141+
self.optionsButton.setMenuRole(QAction.PreferencesRole)
142+
self.optionsButton.setIconVisibleInMenu(True)
143+
self.optionsButton.setToolTip(optionsBt)
144+
self.optionsButton.setText(optionsBt)
140145
## Action menu for class
141146
actionClassBt = QCoreApplication.translate("PythonConsole", "Import Class")
142147
self.actionClass = QAction(parent)
@@ -241,6 +246,7 @@ def __init__(self, parent=None):
241246
self.toolBar.addAction(self.clearButton)
242247
self.toolBar.addAction(self.actionClass)
243248
self.toolBar.addAction(self.actionScript)
249+
self.toolBar.addAction(self.optionsButton)
244250
self.toolBar.addAction(self.helpButton)
245251
self.toolBar.addAction(self.runButton)
246252
## Menu Import Class
@@ -268,7 +274,7 @@ def __init__(self, parent=None):
268274
self.e.addWidget(self.edit)
269275

270276
self.clearButton.triggered.connect(self.edit.clearConsole)
271-
#self.currentLayerButton.triggered.connect(self.cLayer)
277+
self.optionsButton.triggered.connect(self.openSettings)
272278
self.loadIfaceButton.triggered.connect(self.iface)
273279
self.loadSextanteButton.triggered.connect(self.sextante)
274280
self.loadQtCoreButton.triggered.connect(self.qtCore)
@@ -277,9 +283,8 @@ def __init__(self, parent=None):
277283
self.openFileButton.triggered.connect(self.openScriptFile)
278284
self.saveFileButton.triggered.connect(self.saveScriptFile)
279285
self.helpButton.triggered.connect(self.openHelp)
280-
281-
def cLayer(self):
282-
self.edit.commandConsole('cLayer')
286+
QObject.connect(self.options.buttonBox, SIGNAL("accepted()"),
287+
self.prefChanged)
283288

284289
def sextante(self):
285290
self.edit.commandConsole('sextante')
@@ -295,7 +300,7 @@ def qtGui(self):
295300

296301
def openScriptFile(self):
297302
settings = QSettings()
298-
lastDirPath = settings.value("/pythonConsole/lastDirPath").toString()
303+
lastDirPath = settings.value("pythonConsole/lastDirPath").toString()
299304
scriptFile = QFileDialog.getOpenFileName(
300305
self, "Open File", lastDirPath, "Script file (*.py)")
301306
if scriptFile.isEmpty() == False:
@@ -307,7 +312,7 @@ def openScriptFile(self):
307312
self.edit.insertTextFromFile(listScriptFile)
308313

309314
lastDirPath = QFileInfo(scriptFile).path()
310-
settings.setValue("/pythonConsole/lastDirPath", QVariant(scriptFile))
315+
settings.setValue("pythonConsole/lastDirPath", QVariant(scriptFile))
311316

312317

313318
def saveScriptFile(self):
@@ -336,12 +341,18 @@ def saveScriptFile(self):
336341
def openHelp(self):
337342
dlg = HelpDialog()
338343
dlg.exec_()
344+
345+
def openSettings(self):
346+
#options = optionsDialog()
347+
self.options.exec_()
348+
349+
def prefChanged(self):
350+
self.edit.refreshLexerProperties()
339351

340352
def closeEvent(self, event):
341353
self.edit.writeHistoryFile()
342354
QWidget.closeEvent(self, event)
343355

344-
345356
if __name__ == '__main__':
346357
a = QApplication(sys.argv)
347358
console = PythonConsoleWidget()

python/console_help/help.htm

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h2 id="headerTitle">Python Console for QGIS</h2>
3434
</tr>
3535
</table>
3636
<p align="justify">
37-
<span id="headerSubject">Python Console based on PyQScintilla2. (Developed by Salvatore Larosa)</span>
37+
<span id="headerSubject">Python Console based on PyQScintilla2.</span>
3838
<br><br>
3939
<span id="headerSubjectMain">To access Quantum GIS environment from this console
4040
use qgis.utils.iface object (instance of QgisInterface class).
@@ -64,16 +64,22 @@ <h4 id="features">Features</h4>
6464
<br>
6565
<li><span id="featuresB">CTRL+ALT+SPACE to view the command history list.</span></li>
6666
<br>
67+
<li><span id="featuresLoadAPI">Open Quantum GIS API documentation by typing <b>_api</b>.</span></li>
68+
<br>
69+
<li><span id="featuresLoadCookBook">Open PyQGIS Cookbook by typing <b>_pyqgis</b>.</span>
70+
</li>
71+
<br>
6772
<li><span id="featuresC">Saves the command history by typing <b>_save</b> or closing the widget.<br>
6873
This command saves the history command in the file ~/.qgis/console_history.txt</span>
6974
</li>
7075
<br>
7176
<li><span id="featuresD">Clears the command history by typing <b>_clear</b>.<br>
72-
This command clears the command history from file ~/.qgis/console_history.txt</span>
77+
This command clears the temporary command history</span>
7378
</li>
7479
<br>
7580
<li><span id="featuresE">Clears completely command history by typing <b>_clearAll</b>.<br>
76-
This command clears completely the command history. It has an irreversible effect.</span>
81+
This command clears completely the command history (both temporary and ~/.qgis/console_history.txt).
82+
It has an irreversible effect.</span>
7783
</li>
7884
</ul>
7985
</p>
@@ -120,6 +126,10 @@ <h4 id="toolbar">Toolbar</h4>
120126
<td><img src="qrc:/images/console/iconSaveConsole.png" /></td>
121127
<td><span id="toolbarScriptSave">Tool to save a python script</span></td>
122128
</tr>
129+
<tr>
130+
<td><img src="qrc:/images/console/iconSettingsConsole.png" /></td>
131+
<td colspan="2"><span id="toolbarSettings">Settings</span></td>
132+
</tr>
123133
<tr>
124134
<td><img src="qrc:/images/console/iconHelpConsole.png" /></td>
125135
<td colspan="2"><span id="toolbarHelp">Help</span></td>

python/console_help/i18n/de_DE.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
i18n_dict = {
22
"header.title" : "Python Console für QGIS",
3-
"header.subject" : "Python Console auf PyQScintilla2 basierend (entwickelt von Salvatore Larosa)",
3+
"header.subject" : "Python Console auf PyQScintilla2 basierend",
44
"header.subject.main" : "Das Objekt qgis.utils.iface (Instanz der Klasse QgisInterface) ermöglicht den Zugriff \
55
quf die Quantum GIS Umgebung von der Konsole aus. \
66
Über den defür bestimmten Knopf in der Werkzeugleiste \

python/console_help/i18n/en_US.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
i18n_dict = {
22
"header.title" : "Python Console for QGIS",
3-
"header.subject" : "Python Console based on PyQScintilla2. (Developed by Salvatore Larosa)",
3+
"header.subject" : "Python Console based on PyQScintilla2.",
44
"header.subject.main" : "To access Quantum GIS environment from this console \
55
use qgis.utils.iface object (instance of QgisInterface class). \
66
To import the class QgisInterface can also use the dedicated \
@@ -15,6 +15,8 @@ i18n_dict = {
1515
This command clears the command history from file ~/.qgis/console_history.txt",
1616
"features.e" : "Clears completely command history by typing '_clearAll'. \
1717
This command clears completely the command history. It has an irreversible effect.",
18+
"features.api.doc" : "Open Quantum GIS API documentation by typing '_api'.",
19+
"features.pyqgis.doc" : "Open PyQGIS Cookbook by typing '_pyqgis'.",
1820
"toolbar" : "Toolbar",
1921
"toolbar.title" : "The following is a description of the tools in the toolbar:",
2022
"toolbar.clear" : "Tool to clear python console",
@@ -24,6 +26,7 @@ i18n_dict = {
2426
"toolbar.qtgui" : "Tool to import PyQt4.QtGui class",
2527
"toolbar.script.open" : "Tool to open a python script and load in console",
2628
"toolbar.script.save" : "Tool to save a python script",
29+
"toolbar.settings" : "Settings",
2730
"toolbar.help" : "Help",
2831
"toolbar.run" : "Run command (like Enter key pressed)",
2932
"thanks" : "Acknowledgments",

python/console_help/i18n/it_IT.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
i18n_dict = {
22
"header.title" : "Console Python per QGIS",
3-
"header.subject" : "Console Python basata su PyQScintilla2. (Sviluppata da Salvatore Larosa)",
3+
"header.subject" : "Console Python basata su PyQScintilla2.",
44
"header.subject.main" : "Per accedere all'ambiente Quantum GIS da questa console \
55
usa l'oggetto qgis.utils.iface (istanza della classe QgisInterface). \
66
Per importare la classe QgisInterface puoi usare anche il bottone dedicato che si trova \
@@ -15,6 +15,8 @@ i18n_dict = {
1515
La cronologia verrà cancellata dal file ~/.qgis/console_history.txt",
1616
"features.e" : "Possibilità di cancellare completamente la cronologia dei comandi digitando '_clearAll'. \
1717
La cronologia verrà cancellata sia dal file che dalla memoria temporanea.",
18+
"features.api.doc" : "Apri la documentazione completa sulle API di QuantumGIS digitando '_api'.",
19+
"features.pyqgis.doc" : "Apri il Cookbook PyQGIS digitando '_pyqgis'.",
1820
"toolbar" : "Toolbar",
1921
"toolbar.title" : "Di seguito la descrizione dei comandi disponibile nella toolbar:",
2022
"toolbar.clear" : "Strumento per pulire la console",
@@ -24,6 +26,7 @@ i18n_dict = {
2426
"toolbar.qtgui" : "Strumento per importare la classe PyQt4.QtGui",
2527
"toolbar.script.open" : "Strumento per aprire un script python da eseguire in console",
2628
"toolbar.script.save" : "Strumento per salvare uno script python sul disco",
29+
"toolbar.settings" : "Impostazioni",
2730
"toolbar.help" : "Aiuto",
2831
"toolbar.run" : "Esegui comando (simile al tasto <Invio>)",
2932
"thanks" : "Ringraziamenti",

python/console_help/i18n/ru_RU.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
i18n_dict = {
22
"header.title" : "Консоль Python для QGIS",
3-
"header.subject" : "Консоль Python на основе PyQScintilla2. (Разработана Salvatore Larosa)",
3+
"header.subject" : "Консоль Python на основе PyQScintilla2.",
44
"header.subject.main" : "Для доступа к окружению Quantum GIS из консоли \
55
используйте объект qgis.utils.iface (экземпляр класса QgisInterface). \
66
Также можно импортировать класс QgisInterface при помощи специальной \

0 commit comments

Comments
 (0)