Skip to content

Commit

Permalink
message log viewer: window isn't closeable and last tab has to stay
Browse files Browse the repository at this point in the history
(fixes #16220)

(cherry picked from commit 2ccdac7)
  • Loading branch information
jef-n committed Feb 24, 2017
1 parent d8da919 commit cbed95c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
16 changes: 13 additions & 3 deletions src/gui/qgsmessagelogviewer.cpp
Expand Up @@ -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() )
Expand All @@ -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 ) );
Expand All @@ -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" )
Expand All @@ -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 );
}
8 changes: 5 additions & 3 deletions src/gui/qgsmessagelogviewer.h
Expand Up @@ -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.
Expand All @@ -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 );
};
Expand Down

0 comments on commit cbed95c

Please sign in to comment.