QGIS API Documentation 3.99.0-Master (26c88405ac0)
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, MessageType msgType )
61{
62 if ( msgType == MessageHtml )
63 setMessageAsHtml( message );
64 else
65 setMessageAsPlainText( message );
66}
67
68void QgsMessageViewer::showMessage( bool blocking )
69{
70 if ( blocking )
71 {
73 exec();
74 }
75 else
76 {
77 show();
78 }
79}
80
81void QgsMessageViewer::setTitle( const QString &title )
82{
83 setWindowTitle( title );
84}
85
86void QgsMessageViewer::setCheckBoxText( const QString &text )
87{
88 checkBox->setText( text );
89}
90
92{
93 checkBox->setVisible( visible );
94}
95
96void QgsMessageViewer::setCheckBoxState( Qt::CheckState state )
97{
98 checkBox->setCheckState( state );
99}
100
102{
103 return checkBox->checkState();
104}
105
107{
108 mCheckBoxQgsSettingsLabel = label;
109}
110
111
112void QgsMessageViewer::checkBox_toggled( bool toggled )
113{
114 Q_UNUSED( toggled )
115 if ( !mCheckBoxQgsSettingsLabel.isEmpty() )
116 {
117 QgsSettings settings;
118 if ( checkBox->checkState() == Qt::Checked )
119 settings.setValue( mCheckBoxQgsSettingsLabel, false );
120 else
121 settings.setValue( mCheckBoxQgsSettingsLabel, true );
122 }
123}
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:221
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
Stores settings for use within QGIS.
Definition qgssettings.h:65
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.