Skip to content
Permalink
Browse files

message log viewer: window isn't closeable and last tab has to stay

(fixes #16220)

(cherry picked from commit e0c58eb)
  • Loading branch information
jef-n committed Feb 24, 2017
1 parent 59c1d21 commit 2ccdac770bb6be96f2feeeb5827e312d8c432dae
Showing with 18 additions and 6 deletions.
  1. +13 −3 src/gui/qgsmessagelogviewer.cpp
  2. +5 −3 src/gui/qgsmessagelogviewer.h
@@ -46,6 +46,15 @@ QgsMessageLogViewer::~QgsMessageLogViewer()
{
}

void QgsMessageLogViewer::closeEvent( QCloseEvent *e )
{
e->ignore();
}

void QgsMessageLogViewer::reject()
{
}

void QgsMessageLogViewer::logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level )
{
if ( tag.isNull() )
@@ -55,7 +64,7 @@ void QgsMessageLogViewer::logMessage( QString message, QString tag, QgsMessageLo
for ( i = 0; i < tabWidget->count() && tabWidget->tabText( i ) != tag; i++ )
;

QPlainTextEdit *w;
QPlainTextEdit *w = nullptr;
if ( i < tabWidget->count() )
{
w = qobject_cast<QPlainTextEdit *>( tabWidget->widget( i ) );
@@ -67,6 +76,7 @@ void QgsMessageLogViewer::logMessage( QString message, QString tag, QgsMessageLo
w->setReadOnly( true );
tabWidget->addTab( w, tag );
tabWidget->setCurrentIndex( tabWidget->count() - 1 );
tabWidget->setTabsClosable( true );
}

QString prefix = QString( "%1\t%2\t" )
@@ -78,6 +88,6 @@ void QgsMessageLogViewer::logMessage( QString message, QString tag, QgsMessageLo

void QgsMessageLogViewer::closeTab( int index )
{
if ( tabWidget->count() > 1 )
tabWidget->removeTab( index );
tabWidget->removeTab( index );
tabWidget->setTabsClosable( tabWidget->count() > 1 );
}
@@ -24,9 +24,7 @@
#include <QString>

class QStatusBar;
class QToolButton;
class QShowEvent;
class QHideEvent;
class QCloseEvent;

/** \ingroup gui
* A generic dialog widget for displaying QGIS log messages.
@@ -41,6 +39,10 @@ class GUI_EXPORT QgsMessageLogViewer: public QDialog, private Ui::QgsMessageLogV
public slots:
void logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level );

protected:
void closeEvent( QCloseEvent *e ) override;
void reject() override;

private slots:
void closeTab( int index );
};

0 comments on commit 2ccdac7

Please sign in to comment.
You can’t perform that action at this time.