Skip to content
Permalink
Browse files
Add new messages icon, add messages text to log button
Move status bar add logic to qgisapp for QgsMessageLogViewer
  • Loading branch information
NathanW2 committed Jan 1, 2015
1 parent f32dfe9 commit ffac1383b4933585c4895ed285516c8af0585344
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 76 deletions.
@@ -477,6 +477,7 @@
<file>themes/default/cadtools/parallel.png</file>
<file>themes/default/cadtools/perpendicular.png</file>
<file>themes/default/mIconSuccess.png</file>
<file>themes/default/bubble.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -656,6 +656,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
addDockWidget( Qt::BottomDockWidgetArea, mLogDock );
mLogDock->setWidget( mLogViewer );
mLogDock->hide();
connect( mMessageButton, SIGNAL( toggled( bool ) ), mLogDock, SLOT( setVisible(bool)) );
connect( mLogDock, SIGNAL( visibilityChanged( bool ) ), mMessageButton, SLOT( setChecked(bool)) );
mVectorLayerTools = new QgsGuiVectorLayerTools();

// Init the editor widget types
@@ -1827,6 +1829,16 @@ void QgisApp::createStatusBar()
this, SLOT( projectPropertiesProjections() ) );//bring up the project props dialog when clicked
statusBar()->addPermanentWidget( mOnTheFlyProjectionStatusButton, 0 );
statusBar()->showMessage( tr( "Ready" ) );

mMessageButton = new QToolButton( statusBar() );
mMessageButton->setAutoRaise( true );
mMessageButton->setIcon( QgsApplication::getThemeIcon( "bubble.svg" ) );
mMessageButton->setText("Messages");
mMessageButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
mMessageButton->setObjectName( "mMessageLogViewerButton" );
mMessageButton->setMaximumHeight( mScaleLabel->height() );
mMessageButton->setCheckable( true );
statusBar()->addPermanentWidget( mMessageButton, 0 );
}

void QgisApp::setIconSizes( int size )
@@ -1470,6 +1470,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QLabel * mOnTheFlyProjectionStatusLabel;
//! Widget in status bar used to show status of on the fly projection
QToolButton * mOnTheFlyProjectionStatusButton;
QToolButton * mMessageButton;
//! Menu that contains the list of actions of the selected vector layer
QMenu *mFeatureActionMenu;
//! Popup menu
@@ -29,98 +29,29 @@
#include <QPlainTextEdit>
#include <QScrollBar>

static QIcon icon( QString icon )
{
// try active theme
QString path = QgsApplication::activeThemePath();
if ( QFile::exists( path + icon ) )
path += icon;
else
path = QgsApplication::defaultThemePath() + icon;

return QIcon( path );
}

QgsMessageLogViewer::QgsMessageLogViewer( QStatusBar *statusBar, QWidget *parent, Qt::WindowFlags fl )
: QDialog( parent, fl )
, mButton( 0 )
, mShowToolTips( true )
{
setupUi( this );

connect( QgsMessageLog::instance(), SIGNAL( messageReceived( QString, QString, QgsMessageLog::MessageLevel ) ),
this, SLOT( logMessage( QString, QString, QgsMessageLog::MessageLevel ) ) );

if ( statusBar )
{
mButton = new QToolButton( parent );
mButton->setObjectName( "mMessageLogViewerButton" );
mButton->setMaximumWidth( 20 );
mButton->setMaximumHeight( 20 );
mButton->setIcon( icon( "/mIconWarn.png" ) );
#ifndef ANDROID
mButton->setToolTip( tr( "No messages." ) );
#endif
mButton->setCheckable( true );
connect( mButton, SIGNAL( toggled( bool ) ), this, SLOT( buttonToggled( bool ) ) );
connect( mButton, SIGNAL( destroyed() ), this, SLOT( buttonDestroyed() ) );
statusBar->addPermanentWidget( mButton, 0 );
}

connect( tabWidget, SIGNAL( tabCloseRequested( int ) ), this, SLOT( closeTab( int ) ) );
}

QgsMessageLogViewer::~QgsMessageLogViewer()
{
}

void QgsMessageLogViewer::hideEvent( QHideEvent * )
{
if ( mButton )
{
mButton->setChecked( false );
}
}

void QgsMessageLogViewer::showEvent( QShowEvent * )
{
if ( mButton )
{
mButton->setChecked( true );
}
}

void QgsMessageLogViewer::buttonToggled( bool checked )
{
QWidget *w = qobject_cast<QDockWidget *>( parent() );

if ( !w )
w = this;

if ( checked )
w->show();
else
w->hide();
}

void QgsMessageLogViewer::buttonDestroyed()
{
mButton = 0;
}

void QgsMessageLogViewer::logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level )
{
#ifdef ANDROID
mButton->setToolTip( tr( "Message(s) logged." ) );
#endif

if ( !isVisible() && level > QgsMessageLog::INFO )
{
mButton->show();
if ( mShowToolTips )
QToolTip::showText( mButton->mapToGlobal( QPoint( 0, 0 ) ), mButton->toolTip() );
}

if ( tag.isNull() )
tag = tr( "General" );

@@ -46,18 +46,11 @@ class GUI_EXPORT QgsMessageLogViewer: public QDialog, private Ui::QgsMessageLogV
public slots:
void logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level );

protected:
void showEvent( QShowEvent * );
void hideEvent( QHideEvent * );

private:
QToolButton *mButton;
bool mShowToolTips;

private slots:
void closeTab( int index );
void buttonToggled( bool checked );
void buttonDestroyed();
};

#endif

0 comments on commit ffac138

Please sign in to comment.