Skip to content
Permalink
Browse files

[ui] Fix broken text annotation background color

  • Loading branch information
nirvn committed May 1, 2019
1 parent 3747cf7 commit 107c7a8d54d574c65db9dea8b984b4aaa5797983
Showing with 24 additions and 1 deletion.
  1. +12 −0 src/app/qgsannotationwidget.cpp
  2. +9 −0 src/app/qgsannotationwidget.h
  3. +3 −1 src/app/qgstextannotationdialog.cpp
@@ -74,6 +74,18 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsMapCanvasAnnotationItem *item, QWid
mMapMarkerButton->setMessageBar( QgisApp::instance()->messageBar() );
mFrameStyleButton->setMapCanvas( QgisApp::instance()->mapCanvas() );
mFrameStyleButton->setMessageBar( QgisApp::instance()->messageBar() );

connect( mFrameStyleButton, &QgsSymbolButton::changed, this, &QgsAnnotationWidget::frameStyleChanged );
}

QColor QgsAnnotationWidget::backgroundColor()
{
return mFrameStyleButton->symbol() ? mFrameStyleButton->symbol()->color() : QColor();
}

void QgsAnnotationWidget::frameStyleChanged()
{
emit backgroundColorChanged( backgroundColor() );
}

void QgsAnnotationWidget::apply()
@@ -33,16 +33,25 @@ class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationW
{
Q_OBJECT
public:

QgsAnnotationWidget( QgsMapCanvasAnnotationItem *item, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr );

//! Returns the annotation frame symbol fill color
QColor backgroundColor();

void apply();

private:

void frameStyleChanged();

signals:

//! Emitted when the background color of the annotation is changed
void backgroundColorChanged( const QColor &color );

private:

QgsMapCanvasAnnotationItem *mItem = nullptr;

void blockAllSignals( bool block );
@@ -38,7 +38,7 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsMapCanvasAnnotationItem *it
mStackedWidget->addWidget( mEmbeddedWidget );
mStackedWidget->setCurrentWidget( mEmbeddedWidget );
connect( mEmbeddedWidget, &QgsAnnotationWidget::backgroundColorChanged, this, &QgsTextAnnotationDialog::backgroundColorChanged );
mTextEdit->setAttribute( Qt::WA_TranslucentBackground );

if ( mItem && mItem->annotation() )
{
QgsTextAnnotation *annotation = static_cast< QgsTextAnnotation * >( mItem->annotation() );
@@ -53,6 +53,7 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsMapCanvasAnnotationItem *it
mFontColorButton->setContext( QStringLiteral( "symbology" ) );

setCurrentFontPropertiesToGui();
backgroundColorChanged( mEmbeddedWidget->backgroundColor() );

QObject::connect( mButtonBox, &QDialogButtonBox::accepted, this, &QgsTextAnnotationDialog::applyTextToItem );
QObject::connect( mButtonBox, &QDialogButtonBox::helpRequested, this, &QgsTextAnnotationDialog::showHelp );
@@ -86,6 +87,7 @@ void QgsTextAnnotationDialog::backgroundColorChanged( const QColor &color )
QPalette p = mTextEdit->viewport()->palette();
p.setColor( QPalette::Base, color );
mTextEdit->viewport()->setPalette( p );
mTextEdit->setStyleSheet( QStringLiteral( "QTextEdit { background-color: %1; }" ).arg( color.name() ) );
}

void QgsTextAnnotationDialog::applyTextToItem()

0 comments on commit 107c7a8

Please sign in to comment.
You can’t perform that action at this time.