Skip to content

Commit

Permalink
[processing] replace two similar dialogs with generic one
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 17, 2014
1 parent eee616c commit 6ff4877
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 138 deletions.
66 changes: 0 additions & 66 deletions python/plugins/processing/gui/CouldNotLoadResultsDialog.py

This file was deleted.

50 changes: 50 additions & 0 deletions python/plugins/processing/gui/MessageDialog.py
@@ -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))
66 changes: 0 additions & 66 deletions python/plugins/processing/gui/MissingDependencyDialog.py

This file was deleted.

14 changes: 10 additions & 4 deletions python/plugins/processing/gui/Postprocessing.py
Expand Up @@ -29,16 +29,20 @@
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):
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/ProcessingToolbox.py
Expand Up @@ -34,7 +34,7 @@
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
Expand Down Expand Up @@ -186,7 +186,11 @@ def executeAlgorithm(self):
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()
Expand Down
71 changes: 71 additions & 0 deletions python/plugins/processing/ui/DlgMessage.ui
@@ -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>

0 comments on commit 6ff4877

Please sign in to comment.