QGIS API Documentation 3.99.0-Master (c03dd32cbdd)
Loading...
Searching...
No Matches
qgsmessageviewer.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmessageviewer.cpp - description
3 -------------------
4 begin : Wed Jun 4 2003
5 copyright : (C) 2002 by Gary E.Sherman
6 email : sherman at mrcc.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
18#include "qgsmessageviewer.h"
19
20#include "qgsgui.h"
21#include "qgssettings.h"
22
23#include "moc_qgsmessageviewer.cpp"
24
25QgsMessageViewer::QgsMessageViewer( QWidget *parent, Qt::WindowFlags fl, bool deleteOnClose )
26 : QDialog( parent, fl )
27{
28 setupUi( this );
30
31 connect( checkBox, &QCheckBox::toggled, this, &QgsMessageViewer::checkBox_toggled );
32 if ( deleteOnClose )
33 {
34 setAttribute( Qt::WA_DeleteOnClose );
35 }
36 // Default state for the checkbox
37 setCheckBoxVisible( false );
38 setCheckBoxState( Qt::Unchecked );
39
40 txtMessage->setTextInteractionFlags( Qt::TextBrowserInteraction );
41 txtMessage->setOpenExternalLinks( true );
42}
43
44void QgsMessageViewer::setMessageAsHtml( const QString &msg )
45{
46 txtMessage->setHtml( msg );
47}
48
50{
51 txtMessage->setPlainText( msg );
52}
53
54void QgsMessageViewer::appendMessage( const QString &msg )
55{
56 txtMessage->append( msg );
57}
58
59
60void QgsMessageViewer::setMessage( const QString &message, Qgis::StringFormat format )
61{
62 switch ( format )
63 {
65 setMessageAsPlainText( message );
66 break;
68 setMessageAsHtml( message );
69 break;
70 };
71}
72
73void QgsMessageViewer::showMessage( bool blocking )
74{
75 if ( blocking )
76 {
78 exec();
79 }
80 else
81 {
82 show();
83 }
84}
85
86void QgsMessageViewer::setTitle( const QString &title )
87{
88 setWindowTitle( title );
89}
90
91void QgsMessageViewer::setCheckBoxText( const QString &text )
92{
93 checkBox->setText( text );
94}
95
97{
98 checkBox->setVisible( visible );
99}
100
101void QgsMessageViewer::setCheckBoxState( Qt::CheckState state )
102{
103 checkBox->setCheckState( state );
104}
105
107{
108 return checkBox->checkState();
109}
110
112{
113 mCheckBoxQgsSettingsLabel = label;
114}
115
116
117void QgsMessageViewer::checkBox_toggled( bool toggled )
118{
119 Q_UNUSED( toggled )
120 if ( !mCheckBoxQgsSettingsLabel.isEmpty() )
121 {
122 QgsSettings settings;
123 if ( checkBox->checkState() == Qt::Checked )
124 settings.setValue( mCheckBoxQgsSettingsLabel, false );
125 else
126 settings.setValue( mCheckBoxQgsSettingsLabel, true );
127 }
128}
StringFormat
Format of log message.
Definition qgis.h:173
@ Html
HTML message.
Definition qgis.h:175
@ PlainText
Text message.
Definition qgis.h:174
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Definition qgsgui.cpp:224
void setCheckBoxQgsSettingsLabel(const QString &label)
void setMessage(const QString &message, Qgis::StringFormat format) override
Sets message, it won't be displayed until.
void setTitle(const QString &title) override
Sets title for the messages.
void setCheckBoxVisible(bool visible)
void setMessageAsPlainText(const QString &msg)
void setCheckBoxState(Qt::CheckState state)
void showMessage(bool blocking=true) override
display the message to the user and deletes itself
void setMessageAsHtml(const QString &msg)
QgsMessageViewer(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags, bool deleteOnClose=true)
void setCheckBoxText(const QString &text)
Qt::CheckState checkBoxState()
void appendMessage(const QString &message) override
message to be appended to the current text
Stores settings for use within QGIS.
Definition qgssettings.h:68
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Temporarily removes all cursor overrides for the QApplication for the lifetime of the object.