QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgserrordialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgserrordialog.cpp - error description
3  -------------------
4  begin : October 2012
5  copyright : (C) October 2012 Radim Blazek
6  email : radim dot blazek at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #include "qgserrordialog.h"
18 
19 #include <QMessageBox>
20 #include <QSettings>
21 
22 QgsErrorDialog::QgsErrorDialog( const QgsError & theError, const QString & theTitle, QWidget *parent, const Qt::WindowFlags& fl )
23  : QDialog( parent, fl )
24  , mError( theError )
25 {
26  setupUi( this );
27  QString title = theTitle;
28  if ( title.isEmpty() ) title = tr( "Error" );
29  setWindowTitle( title );
30 
31  // QMessageBox has static standardIcon( Icon icon ), but it is marked as obsolete
32  QMessageBox messageBox( QMessageBox::Critical, "", "" );
33  mIconLabel->setPixmap( messageBox.iconPixmap() );
34  mSummaryTextBrowser->setOpenExternalLinks( true );
35  mDetailTextBrowser->setOpenExternalLinks( true );
36  mDetailTextBrowser->hide();
37 
38  QPalette p = palette();
39  p.setColor( QPalette::Base, Qt::transparent );
40  mSummaryTextBrowser->setPalette( p );
41 
42  mDetailCheckBox->hide();
43 
44  mSummaryTextBrowser->setText( mError.summary() );
45  mDetailTextBrowser->setText( mError.message( QgsErrorMessage::Html ) );
46 
47  resize( width(), 150 );
48 
49  QSettings settings;
50  Qt::CheckState state = ( Qt::CheckState ) settings.value( "/Error/dialog/detail", 0 ).toInt();
51  mDetailCheckBox->setCheckState( state );
52  if ( state == Qt::Checked ) on_mDetailPushButton_clicked();
53 }
54 
56 {
57 }
58 
59 void QgsErrorDialog::show( const QgsError & theError, const QString & theTitle, QWidget *parent, const Qt::WindowFlags& fl )
60 {
61  QgsErrorDialog d( theError, theTitle, parent, fl );
62  d.exec();
63 }
64 
66 {
67  mSummaryTextBrowser->hide();
68  mDetailTextBrowser->show();
69  mDetailCheckBox->show();
70  mDetailPushButton->hide();
71  resize( width(), 400 );
72 }
73 
75 {
76  QSettings settings;
77  settings.setValue( "/Error/dialog/detail", state );
78 }
79 
const QPalette & palette() const
void setupUi(QWidget *widget)
void setColor(ColorGroup group, ColorRole role, const QColor &color)
void on_mDetailCheckBox_stateChanged(int state)
int exec()
QString tr(const char *sourceText, const char *disambiguation, int n)
int width() const
void setValue(const QString &key, const QVariant &value)
void resize(int w, int h)
int toInt(bool *ok) const
QString summary() const
Short error description, usually the first error in chain, the real error.
Definition: qgserror.cpp:129
bool isEmpty() const
QgsErrorDialog(const QgsError &theError, const QString &theTitle, QWidget *parent=nullptr, const Qt::WindowFlags &fl=QgisGui::ModalDialogFlags)
QVariant value(const QString &key, const QVariant &defaultValue) const
QgsError is container for error messages (report).
Definition: qgserror.h:80
void setWindowTitle(const QString &)
void on_mDetailPushButton_clicked()
typedef WindowFlags
void show()
QObject * parent() const
QString message(QgsErrorMessage::Format theFormat=QgsErrorMessage::Html) const
Full error messages description.
Definition: qgserror.cpp:50