Skip to content

Commit

Permalink
Fix icon size for constraint warning
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 18, 2016
1 parent dc5abfe commit f187707
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/gui/qgsattributeform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <QSettings>
#include <QToolButton>
#include <QMenu>
#include <QSvgWidget>

int QgsAttributeForm::sFormCounter = 0;

Expand Down Expand Up @@ -185,20 +186,20 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )
case QgsAttributeForm::SingleEditMode:
setFeature( mFeature );
mSearchButtonBox->setVisible( false );
mInvalidConstraintMessage->show();
mTopMessageWidget->show();
break;

case QgsAttributeForm::AddFeatureMode:
synchronizeEnabledState();
mSearchButtonBox->setVisible( false );
mInvalidConstraintMessage->show();
mTopMessageWidget->show();
break;

case QgsAttributeForm::MultiEditMode:
resetMultiEdit( false );
synchronizeEnabledState();
mSearchButtonBox->setVisible( false );
mInvalidConstraintMessage->show();
mTopMessageWidget->show();
break;

case QgsAttributeForm::SearchMode:
Expand All @@ -211,7 +212,7 @@ void QgsAttributeForm::setMode( QgsAttributeForm::Mode mode )
}
else
{
mInvalidConstraintMessage->hide();
mTopMessageWidget->hide();
}
break;
}
Expand Down Expand Up @@ -792,9 +793,8 @@ bool QgsAttributeForm::currentFormFeature( QgsFeature &feature )

void QgsAttributeForm::clearInvalidConstraintsMessage()
{
mInvalidConstraintMessage->hide();
mTopMessageWidget->hide();
mInvalidConstraintMessage->clear();
mInvalidConstraintMessage->setStyleSheet( QString() );
}

void QgsAttributeForm::displayInvalidConstraintMessage( const QStringList& f,
Expand All @@ -809,14 +809,10 @@ void QgsAttributeForm::displayInvalidConstraintMessage( const QStringList& f,
for ( int i = 0; i < size; i++ )
descriptions += QString( "<li>%1: <i>%2</i></li>" ).arg( f[i] ).arg( d[i] );

QString icPath = QgsApplication::iconPath( "/mIconWarning.svg" );
QString msg = QString( "<b>%1</b><ul>%2</ul>" ).arg( tr( "Invalid fields" ) ).arg( descriptions ) ;

QString title = QString( "<img src=\"%1\"> <b>%2:" ).arg( icPath ).arg( tr( "Invalid fields" ) );
QString msg = QString( "%1</b><ul>%2</ul>" ).arg( title ).arg( descriptions ) ;

mInvalidConstraintMessage->show();
mInvalidConstraintMessage->setText( msg );
mInvalidConstraintMessage->setStyleSheet( "QLabel { background-color : #ffc800; }" );
mTopMessageWidget->show();
}

void QgsAttributeForm::registerContainerInformation( QgsAttributeForm::ContainerInformation* info )
Expand Down Expand Up @@ -1070,9 +1066,18 @@ void QgsAttributeForm::init()
mMessageBar->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
vl->addWidget( mMessageBar );

mTopMessageWidget = new QWidget();
mTopMessageWidget->hide();
mTopMessageWidget->setLayout( new QHBoxLayout() );

QSvgWidget* warningIcon = new QSvgWidget( QgsApplication::iconPath( "/mIconWarning.svg" ) );
warningIcon->setFixedSize( 48, 48 );
mTopMessageWidget->layout()->addWidget( warningIcon );
mInvalidConstraintMessage = new QLabel( this );
mInvalidConstraintMessage->hide();
vl->addWidget( mInvalidConstraintMessage );
mTopMessageWidget->layout()->addWidget( mInvalidConstraintMessage );
mTopMessageWidget->hide();

vl->addWidget( mTopMessageWidget );

setLayout( vl );

Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsattributeform.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ class GUI_EXPORT QgsAttributeForm : public QWidget
QgsMessageBarItem* mMultiEditUnsavedMessageBarItem;
QgsMessageBarItem* mMultiEditMessageBarItem;
QLabel* mInvalidConstraintMessage;
QWidget* mTopMessageWidget;
QList<QgsWidgetWrapper*> mWidgets;
QgsAttributeEditorContext mContext;
QDialogButtonBox* mButtonBox;
Expand Down

0 comments on commit f187707

Please sign in to comment.