QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
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 "qgssettings.h"
20
21#include <QMessageBox>
22
23#include "moc_qgserrordialog.cpp"
24
25QgsErrorDialog::QgsErrorDialog( const QgsError &error, const QString &title, QWidget *parent, Qt::WindowFlags fl )
26 : QDialog( parent, fl )
27 , mError( error )
28{
29 setupUi( this );
30 connect( mDetailPushButton, &QPushButton::clicked, this, &QgsErrorDialog::mDetailPushButton_clicked );
31 connect( mDetailCheckBox, &QCheckBox::stateChanged, this, &QgsErrorDialog::mDetailCheckBox_stateChanged );
32
33 if ( title.isEmpty() )
34 setWindowTitle( tr( "Error" ) );
35 else
36 setWindowTitle( title );
37
38 // QMessageBox has static standardIcon( Icon icon ), but it is marked as obsolete
39 const QMessageBox messageBox( QMessageBox::Critical, QString(), QString() );
40 mIconLabel->setPixmap( messageBox.iconPixmap() );
41 mSummaryTextBrowser->setOpenExternalLinks( true );
42 mDetailTextBrowser->setOpenExternalLinks( true );
43 mDetailTextBrowser->hide();
44
45 QPalette p = palette();
46 p.setColor( QPalette::Base, Qt::transparent );
47 mSummaryTextBrowser->setPalette( p );
48
49 mDetailCheckBox->hide();
50
51 mSummaryTextBrowser->setText( mError.summary() );
52 mDetailTextBrowser->setText( mError.message( QgsErrorMessage::Html ) );
53
54 resize( width(), 150 );
55
56 const QgsSettings settings;
57 const Qt::CheckState state = ( Qt::CheckState ) settings.value( QStringLiteral( "Error/dialog/detail" ), 0 ).toInt();
58 mDetailCheckBox->setCheckState( state );
59 if ( state == Qt::Checked )
60 mDetailPushButton_clicked();
61}
62
63void QgsErrorDialog::show( const QgsError &error, const QString &title, QWidget *parent, Qt::WindowFlags fl )
64{
65 QgsErrorDialog d( error, title, parent, fl );
66 d.exec();
67}
68
69void QgsErrorDialog::mDetailPushButton_clicked()
70{
71 mSummaryTextBrowser->hide();
72 mDetailTextBrowser->show();
73 mDetailCheckBox->show();
74 mDetailPushButton->hide();
75 resize( width(), 400 );
76}
77
78void QgsErrorDialog::mDetailCheckBox_stateChanged( int state )
79{
80 QgsSettings settings;
81 settings.setValue( QStringLiteral( "Error/dialog/detail" ), state );
82}
QgsErrorDialog(const QgsError &error, const QString &title, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
Constructor for QgsErrorDialog.
static void show(const QgsError &error, const QString &title, QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
Show dialog with error.
A container for error messages.
Definition qgserror.h:81
Stores settings for use within QGIS.
Definition qgssettings.h:65
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.