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)
  • Loading branch information
jef-n committed Feb 24, 2017
1 parent 2b8487d commit e0c58eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 12 additions & 2 deletions src/gui/qgsmessagelogviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ QgsMessageLogViewer::QgsMessageLogViewer( QStatusBar *statusBar, QWidget *parent
connect( tabWidget, SIGNAL( tabCloseRequested( int ) ), this, SLOT( closeTab( int ) ) );
}

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 @@ -63,6 +72,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 = QStringLiteral( "%1\t%2\t" )
Expand All @@ -74,6 +84,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
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
#include "qgis_gui.h"

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 e0c58eb

Please sign in to comment.