QGIS API Documentation 3.41.0-Master (3440c17df1d)
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#include "moc_qgsmessageviewer.cpp"
20#include "qgssettings.h"
21#include "qgsgui.h"
22
23QgsMessageViewer::QgsMessageViewer( QWidget *parent, Qt::WindowFlags fl, bool deleteOnClose )
24 : QDialog( parent, fl )
25{
26 setupUi( this );
28
29 connect( checkBox, &QCheckBox::toggled, this, &QgsMessageViewer::checkBox_toggled );
30 if ( deleteOnClose )
31 {
32 setAttribute( Qt::WA_DeleteOnClose );
33 }
34 // Default state for the checkbox
35 setCheckBoxVisible( false );
36 setCheckBoxState( Qt::Unchecked );
37
38 txtMessage->setTextInteractionFlags( Qt::TextBrowserInteraction );
39 txtMessage->setOpenExternalLinks( true );
40}
41
42void QgsMessageViewer::setMessageAsHtml( const QString &msg )
43{
44 txtMessage->setHtml( msg );
45}
46
48{
49 txtMessage->setPlainText( msg );
50}
51
52void QgsMessageViewer::appendMessage( const QString &msg )
53{
54 txtMessage->append( msg );
55}
56
57
58void QgsMessageViewer::setMessage( const QString &message, MessageType msgType )
59{
60 if ( msgType == MessageHtml )
61 setMessageAsHtml( message );
62 else
63 setMessageAsPlainText( message );
64}
65
66void QgsMessageViewer::showMessage( bool blocking )
67{
68 if ( blocking )
69 {
71 exec();
72 }
73 else
74 {
75 show();
76 }
77}
78
79void QgsMessageViewer::setTitle( const QString &title )
80{
81 setWindowTitle( title );
82}
83
84void QgsMessageViewer::setCheckBoxText( const QString &text )
85{
86 checkBox->setText( text );
87}
88
90{
91 checkBox->setVisible( visible );
92}
93
94void QgsMessageViewer::setCheckBoxState( Qt::CheckState state )
95{
96 checkBox->setCheckState( state );
97}
98
100{
101 return checkBox->checkState();
102}
103
105{
106 mCheckBoxQgsSettingsLabel = label;
107}
108
109
110void QgsMessageViewer::checkBox_toggled( bool toggled )
111{
112 Q_UNUSED( toggled )
113 if ( !mCheckBoxQgsSettingsLabel.isEmpty() )
114 {
115 QgsSettings settings;
116 if ( checkBox->checkState() == Qt::Checked )
117 settings.setValue( mCheckBoxQgsSettingsLabel, false );
118 else
119 settings.setValue( mCheckBoxQgsSettingsLabel, true );
120 }
121}
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:209
MessageType
message can be in plain text or in html format
void setCheckBoxQgsSettingsLabel(const QString &label)
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 setMessage(const QString &message, MessageType msgType) override
Sets message, it won't be displayed until.
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
This class is a composition of two QSettings instances:
Definition qgssettings.h:64
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.