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
@@ -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>
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generated by IcoMoon.io -->

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="32"
height="32"
viewBox="0 0 32 32"
id="svg3033"
inkscape:version="0.48.4 r9939"
sodipodi:docname="bubble.svg">
<metadata
id="metadata3041">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs3039" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="936"
inkscape:window-height="698"
id="namedview3037"
showgrid="false"
inkscape:zoom="7.375"
inkscape:cx="16"
inkscape:cy="16"
inkscape:window-x="462"
inkscape:window-y="134"
inkscape:window-maximized="0"
inkscape:current-layer="svg3033" />
<path
d="M 16,2 C 7.163,2 0,7.82 0,15 c 0,7.18 7.163,13 16,13 0.849,0 1.682,-0.054 2.495,-0.158 3.437,3.437 7.539,4.053 11.505,4.144 V 31.145 C 27.858,30.096 26,28.184 26,26 26,25.695 26.024,25.396 26.068,25.103 29.687,22.72 32,19.079 32,15 32,7.82 24.837,2 16,2 z"
id="path3035"
inkscape:connector-curvature="0"
style="fill:#666666" />
</svg>
@@ -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.
You can’t perform that action at this time.