|
QGIS API Documentation
master-6227475
|
00001 /*************************************************************************** 00002 qgserrordialog.cpp - error description 00003 ------------------- 00004 begin : October 2012 00005 copyright : (C) October 2012 Radim Blazek 00006 email : radim dot blazek at gmail dot com 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 #include "qgserrordialog.h" 00018 00019 #include <QMessageBox> 00020 #include <QSettings> 00021 00022 QgsErrorDialog::QgsErrorDialog( const QgsError & theError, const QString & theTitle, QWidget *parent, Qt::WFlags fl ) 00023 : QDialog( parent, fl ) 00024 , mError( theError ) 00025 { 00026 setupUi( this ); 00027 QString title = theTitle; 00028 if ( title.isEmpty() ) title = tr( "Error" ); 00029 setWindowTitle( title ); 00030 00031 // QMessageBox has static standardIcon( Icon icon ), but it is marked as obsolete 00032 QMessageBox messageBox( QMessageBox::Critical, "", "" ); 00033 mIconLabel->setPixmap( messageBox.iconPixmap() ); 00034 mSummaryTextBrowser->setOpenExternalLinks( true ); 00035 mDetailTextBrowser->setOpenExternalLinks( true ); 00036 mDetailTextBrowser->hide(); 00037 00038 QPalette p = palette(); 00039 p.setColor( QPalette::Base, Qt::transparent ); 00040 mSummaryTextBrowser->setPalette( p ); 00041 00042 mDetailCheckBox->hide(); 00043 00044 mSummaryTextBrowser->setText( mError.summary() ); 00045 mDetailTextBrowser->setText( mError.message( QgsErrorMessage::Html ) ); 00046 00047 resize( width(), 150 ); 00048 00049 QSettings settings; 00050 Qt::CheckState state = ( Qt::CheckState ) settings.value( "/Error/dialog/detail", 0 ).toInt(); 00051 mDetailCheckBox->setCheckState( state ); 00052 if ( state == Qt::Checked ) on_mDetailPushButton_clicked(); 00053 } 00054 00055 QgsErrorDialog::~QgsErrorDialog() 00056 { 00057 } 00058 00059 void QgsErrorDialog::show( const QgsError & theError, const QString & theTitle, QWidget *parent, Qt::WFlags fl ) 00060 { 00061 QgsErrorDialog d( theError, theTitle, parent, fl ); 00062 d.exec(); 00063 } 00064 00065 void QgsErrorDialog::on_mDetailPushButton_clicked() 00066 { 00067 mSummaryTextBrowser->hide(); 00068 mDetailTextBrowser->show(); 00069 mDetailCheckBox->show(); 00070 mDetailPushButton->hide(); 00071 resize( width(), 400 ); 00072 } 00073 00074 void QgsErrorDialog::on_mDetailCheckBox_stateChanged( int state ) 00075 { 00076 QSettings settings; 00077 settings.setValue( "/Error/dialog/detail", state ); 00078 } 00079