mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing] replace two similar dialogs with generic one
This commit is contained in:
parent
eee616c517
commit
6ff487702d
@ -1,66 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
CouldNotLoadResultsDialog.py
|
||||
---------------------
|
||||
Date : August 2012
|
||||
Copyright : (C) 2012 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************
|
||||
"""
|
||||
|
||||
__author__ = 'Victor Olaya'
|
||||
__date__ = 'August 2012'
|
||||
__copyright__ = '(C) 2012, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import webbrowser
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
|
||||
class CouldNotLoadResultsDialog(QtGui.QDialog):
|
||||
|
||||
def __init__(self, wrongLayers, alg):
|
||||
QtGui.QDialog.__init__(self, None, QtCore.Qt.WindowSystemMenuHint
|
||||
| QtCore.Qt.WindowTitleHint)
|
||||
self.alg = alg
|
||||
self.wrongLayers = wrongLayers
|
||||
self.setupUi()
|
||||
|
||||
def setupUi(self):
|
||||
self.resize(600, 350)
|
||||
self.setWindowTitle(self.tr('Problem loading output layers'))
|
||||
layout = QVBoxLayout()
|
||||
browser = QtGui.QTextBrowser()
|
||||
browser.setOpenLinks(False)
|
||||
browser.anchorClicked.connect(self.linkClicked)
|
||||
html = self.alg.getPostProcessingErrorMessage(self.wrongLayers)
|
||||
browser.setHtml(html)
|
||||
button = QPushButton()
|
||||
button.setText(self.tr('Close'))
|
||||
button.clicked.connect(self.closeButtonPressed)
|
||||
buttonBox = QtGui.QDialogButtonBox()
|
||||
buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
buttonBox.addButton(button, QDialogButtonBox.ActionRole)
|
||||
layout.addWidget(browser)
|
||||
layout.addWidget(buttonBox)
|
||||
self.setLayout(layout)
|
||||
|
||||
def linkClicked(self, url):
|
||||
webbrowser.open(str(url))
|
||||
|
||||
def closeButtonPressed(self):
|
||||
self.close()
|
50
python/plugins/processing/gui/MessageDialog.py
Normal file
50
python/plugins/processing/gui/MessageDialog.py
Normal file
@ -0,0 +1,50 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
MessageDialog.py
|
||||
---------------------
|
||||
Date : October 2014
|
||||
Copyright : (C) 2014 by Alexander Bruy
|
||||
Email : alexander dot bruy at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************
|
||||
"""
|
||||
|
||||
__author__ = 'Alexander Bruy'
|
||||
__date__ = 'October 2014'
|
||||
__copyright__ = '(C) 2014, Alexander Bruy'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
|
||||
from processing.ui.ui_DlgMessage import Ui_Dialog
|
||||
|
||||
|
||||
class MessageDialog(QDialog, Ui_Dialog):
|
||||
|
||||
def __init__(self):
|
||||
QDialog.__init__(self)
|
||||
self.setupUi(self)
|
||||
|
||||
self.txtMessage.anchorClicked.connect(self.openLink)
|
||||
|
||||
def setTitle(self, title):
|
||||
self.setWindowTitle(title)
|
||||
|
||||
def setMessage(self, message):
|
||||
self.txtMessage.setHtml(message)
|
||||
|
||||
def openLink(self, url):
|
||||
QDesktopServices.openUrl(QUrl(url))
|
@ -1,66 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
MessingDependencyDialog.py
|
||||
---------------------
|
||||
Date : April 2013
|
||||
Copyright : (C) 2013 by Victor Olaya
|
||||
Email : volayaf at gmail dot com
|
||||
***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************
|
||||
"""
|
||||
|
||||
__author__ = 'Victor Olaya'
|
||||
__date__ = 'April 2013'
|
||||
__copyright__ = '(C) 2013, Victor Olaya'
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import webbrowser
|
||||
from PyQt4 import QtCore, QtGui, QtWebKit
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
|
||||
class MissingDependencyDialog(QtGui.QDialog):
|
||||
|
||||
def __init__(self, msg):
|
||||
QtGui.QDialog.__init__(self, None, QtCore.Qt.WindowSystemMenuHint
|
||||
| QtCore.Qt.WindowTitleHint)
|
||||
self.msg = self.tr('<h3>Missing dependency.This algorithm cannot '
|
||||
'be run :-( </h3>\n%s') % msg
|
||||
self.setupUi()
|
||||
|
||||
def setupUi(self):
|
||||
self.resize(500, 300)
|
||||
self.setWindowTitle(self.tr('Missing dependency'))
|
||||
layout = QVBoxLayout()
|
||||
browser = QtGui.QTextBrowser()
|
||||
browser.setOpenLinks(False)
|
||||
browser.anchorClicked.connect(self.linkClicked)
|
||||
browser.setHtml(self.msg)
|
||||
button = QPushButton()
|
||||
button.setText(self.tr('Close'))
|
||||
button.clicked.connect(self.closeButtonPressed)
|
||||
buttonBox = QtGui.QDialogButtonBox()
|
||||
buttonBox.setOrientation(QtCore.Qt.Horizontal)
|
||||
buttonBox.addButton(button, QDialogButtonBox.ActionRole)
|
||||
layout.addWidget(browser)
|
||||
layout.addWidget(buttonBox)
|
||||
self.setLayout(layout)
|
||||
QtCore.QMetaObject.connectSlotsByName(self)
|
||||
|
||||
def linkClicked(self, url):
|
||||
webbrowser.open(url.toString())
|
||||
|
||||
def closeButtonPressed(self):
|
||||
self.close()
|
@ -29,16 +29,20 @@ import os
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
from qgis.core import *
|
||||
from processing.gui.SilentProgress import SilentProgress
|
||||
|
||||
from processing.core.ProcessingConfig import ProcessingConfig
|
||||
from processing.core.ProcessingResults import ProcessingResults
|
||||
|
||||
from processing.gui.ResultsDialog import ResultsDialog
|
||||
from processing.gui.RenderingStyles import RenderingStyles
|
||||
from processing.gui.CouldNotLoadResultsDialog import CouldNotLoadResultsDialog
|
||||
from processing.gui.MessageDialog import MessageDialog
|
||||
from processing.gui.SilentProgress import SilentProgress
|
||||
|
||||
from processing.core.outputs import OutputRaster
|
||||
from processing.core.outputs import OutputVector
|
||||
from processing.core.outputs import OutputTable
|
||||
from processing.core.ProcessingResults import ProcessingResults
|
||||
from processing.core.outputs import OutputHTML
|
||||
|
||||
from processing.tools import dataobjects
|
||||
|
||||
def handleAlgorithmResults(alg, progress=None, showResults=True):
|
||||
@ -74,7 +78,9 @@ def handleAlgorithmResults(alg, progress=None, showResults=True):
|
||||
i += 1
|
||||
if wrongLayers:
|
||||
QApplication.restoreOverrideCursor()
|
||||
dlg = CouldNotLoadResultsDialog(wrongLayers, alg)
|
||||
dlg = MessageDialog()
|
||||
dlg.setTitle(QCoreApplication.translate('Postprocessing', 'Problem loading output layers'))
|
||||
dlg.setMessage(alg.getPostProcessingErrorMessage(wrongLayers))
|
||||
dlg.exec_()
|
||||
|
||||
if showResults and htmlResults and not wrongLayers:
|
||||
|
@ -34,7 +34,7 @@ from processing.core.Processing import Processing
|
||||
from processing.core.ProcessingLog import ProcessingLog
|
||||
from processing.core.ProcessingConfig import ProcessingConfig
|
||||
from processing.core.GeoAlgorithm import GeoAlgorithm
|
||||
from processing.gui.MissingDependencyDialog import MissingDependencyDialog
|
||||
from processing.gui.MessageDialog import MessageDialog
|
||||
from processing.gui.AlgorithmClassification import AlgorithmDecorator
|
||||
from processing.gui.ParametersDialog import ParametersDialog
|
||||
from processing.gui.BatchProcessingDialog import BatchProcessingDialog
|
||||
@ -186,7 +186,11 @@ class ProcessingToolbox(QDockWidget, Ui_ProcessingToolbox):
|
||||
alg = Processing.getAlgorithm(item.alg.commandLineName())
|
||||
message = alg.checkBeforeOpeningParametersDialog()
|
||||
if message:
|
||||
dlg = MissingDependencyDialog(message)
|
||||
dlg = MessageDialog()
|
||||
dlg.setTitle(self.tr('Missing dependency'))
|
||||
dlg.setMessage(
|
||||
self.tr('<h3>Missing dependency. This algorithm cannot '
|
||||
'be run :-( </h3>\n%s') % message)
|
||||
dlg.exec_()
|
||||
return
|
||||
alg = alg.getCopy()
|
||||
|
71
python/plugins/processing/ui/DlgMessage.ui
Normal file
71
python/plugins/processing/ui/DlgMessage.ui
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>457</width>
|
||||
<height>242</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="txtMessage">
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user