QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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 "qgssettings.h"
20#include "qgsgui.h"
21
22QgsMessageViewer::QgsMessageViewer( QWidget *parent, Qt::WindowFlags fl, bool deleteOnClose )
23 : QDialog( parent, fl )
24{
25 setupUi( this );
27
28 connect( checkBox, &QCheckBox::toggled, this, &QgsMessageViewer::checkBox_toggled );
29 if ( deleteOnClose )
30 {
31 setAttribute( Qt::WA_DeleteOnClose );
32 }
33 // Default state for the checkbox
34 setCheckBoxVisible( false );
35 setCheckBoxState( Qt::Unchecked );
36
37 txtMessage->setTextInteractionFlags( Qt::TextBrowserInteraction );
38 txtMessage->setOpenExternalLinks( true );
39}
40
41void QgsMessageViewer::setMessageAsHtml( const QString &msg )
42{
43 txtMessage->setHtml( msg );
44}
45
47{
48 txtMessage->setPlainText( msg );
49}
50
51void QgsMessageViewer::appendMessage( const QString &msg )
52{
53 txtMessage->append( msg );
54}
55
56
57void QgsMessageViewer::setMessage( const QString &message, MessageType msgType )
58{
59 if ( msgType == MessageHtml )
60 setMessageAsHtml( message );
61 else
62 setMessageAsPlainText( message );
63}
64
65void QgsMessageViewer::showMessage( bool blocking )
66{
67 if ( blocking )
68 {
70 exec();
71 }
72 else
73 {
74 show();
75 }
76}
77
78void QgsMessageViewer::setTitle( const QString &title )
79{
80 setWindowTitle( title );
81}
82
83void QgsMessageViewer::setCheckBoxText( const QString &text )
84{
85 checkBox->setText( text );
86}
87
89{
90 checkBox->setVisible( visible );
91}
92
93void QgsMessageViewer::setCheckBoxState( Qt::CheckState state )
94{
95 checkBox->setCheckState( state );
96}
97
99{
100 return checkBox->checkState();
101}
102
104{
105 mCheckBoxQgsSettingsLabel = label;
106}
107
108
109void QgsMessageViewer::checkBox_toggled( bool toggled )
110{
111 Q_UNUSED( toggled )
112 if ( !mCheckBoxQgsSettingsLabel.isEmpty() )
113 {
114 QgsSettings settings;
115 if ( checkBox->checkState() == Qt::Checked )
116 settings.setValue( mCheckBoxQgsSettingsLabel, false );
117 else
118 settings.setValue( mCheckBoxQgsSettingsLabel, true );
119 }
120}
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:178
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:62
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.
Definition: qgsguiutils.h:253