QGIS API Documentation  2.99.0-Master (dcec6bb)
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 #include "qgssettings.h"
19 
20 #include <QMessageBox>
21 
22 QgsErrorDialog::QgsErrorDialog( const QgsError &error, const QString &title, QWidget *parent, Qt::WindowFlags fl )
23  : QDialog( parent, fl )
24  , mError( error )
25 {
26  setupUi( this );
27 
28  if ( title.isEmpty() )
29  setWindowTitle( tr( "Error" ) );
30  else
31  setWindowTitle( title );
32 
33  // QMessageBox has static standardIcon( Icon icon ), but it is marked as obsolete
34  QMessageBox messageBox( QMessageBox::Critical, QLatin1String( "" ), QLatin1String( "" ) );
35  mIconLabel->setPixmap( messageBox.iconPixmap() );
36  mSummaryTextBrowser->setOpenExternalLinks( true );
37  mDetailTextBrowser->setOpenExternalLinks( true );
38  mDetailTextBrowser->hide();
39 
40  QPalette p = palette();
41  p.setColor( QPalette::Base, Qt::transparent );
42  mSummaryTextBrowser->setPalette( p );
43 
44  mDetailCheckBox->hide();
45 
46  mSummaryTextBrowser->setText( mError.summary() );
47  mDetailTextBrowser->setText( mError.message( QgsErrorMessage::Html ) );
48 
49  resize( width(), 150 );
50 
51  QgsSettings settings;
52  Qt::CheckState state = ( Qt::CheckState ) settings.value( QStringLiteral( "Error/dialog/detail" ), 0 ).toInt();
53  mDetailCheckBox->setCheckState( state );
54  if ( state == Qt::Checked ) on_mDetailPushButton_clicked();
55 }
56 
57 void QgsErrorDialog::show( const QgsError &error, const QString &title, QWidget *parent, Qt::WindowFlags fl )
58 {
59  QgsErrorDialog d( error, title, parent, fl );
60  d.exec();
61 }
62 
64 {
65  mSummaryTextBrowser->hide();
66  mDetailTextBrowser->show();
67  mDetailCheckBox->show();
68  mDetailPushButton->hide();
69  resize( width(), 400 );
70 }
71 
73 {
74  QgsSettings settings;
75  settings.setValue( QStringLiteral( "Error/dialog/detail" ), state );
76 }
77 
This class is a composition of two QSettings instances:
Definition: qgssettings.h:54
void on_mDetailCheckBox_stateChanged(int state)
static void show(const QgsError &error, const QString &title, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
Show dialog with error.
void setValue(const QString &key, const QVariant &value, const QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QString summary() const
Short error description, usually the first error in chain, the real error.
Definition: qgserror.cpp:129
QString message(QgsErrorMessage::Format format=QgsErrorMessage::Html) const
Full error messages description.
Definition: qgserror.cpp:50
QgsErrorDialog(const QgsError &error, const QString &title, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
QgsErrorDialog constructor for QgsErrorDialog.
QgsError is container for error messages (report).
Definition: qgserror.h:82
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
void on_mDetailPushButton_clicked()