Skip to content
Permalink
Browse files
Fix text annotation edit background should match frame background
Otherwise white text is not visible. Fix #10553.

(cherry-picked from 76c4cae)
  • Loading branch information
nyalldawson committed Jul 26, 2016
1 parent b4f551b commit b351d16093c1563c8983d7dc84dbaab3356bb498
@@ -54,6 +54,8 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * par
mBackgroundColorButton->setNoColorString( tr( "Transparent" ) );
mBackgroundColorButton->setShowNoColor( true );

connect( mBackgroundColorButton, SIGNAL( colorChanged( QColor ) ), this, SIGNAL( backgroundColorChanged( QColor ) ) );

const QgsMarkerSymbolV2* symbol = mItem->markerSymbol();
if ( symbol )
{
@@ -34,6 +34,11 @@ class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationW

void apply();

signals:

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

private slots:
void on_mMapMarkerButton_clicked();

@@ -27,6 +27,8 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsTextAnnotationItem* item, Q
mEmbeddedWidget = new QgsAnnotationWidget( mItem );
mStackedWidget->addWidget( mEmbeddedWidget );
mStackedWidget->setCurrentWidget( mEmbeddedWidget );
connect( mEmbeddedWidget, SIGNAL( backgroundColorChanged( QColor ) ), this, SLOT( backgroundColorChanged( QColor ) ) );
mTextEdit->setAttribute( Qt::WA_TranslucentBackground );
if ( mItem )
{
mTextDocument = mItem->document();
@@ -56,6 +58,18 @@ QgsTextAnnotationDialog::~QgsTextAnnotationDialog()
delete mTextDocument;
}

void QgsTextAnnotationDialog::showEvent( QShowEvent* )
{
backgroundColorChanged( mItem ? mItem->frameBackgroundColor() : Qt::white );
}

void QgsTextAnnotationDialog::backgroundColorChanged( const QColor& color )
{
QPalette p = mTextEdit->viewport()->palette();
p.setColor( QPalette::Base, color );
mTextEdit->viewport()->setPalette( p );
}

void QgsTextAnnotationDialog::applyTextToItem()
{
if ( mItem && mTextDocument )
@@ -30,6 +30,10 @@ class APP_EXPORT QgsTextAnnotationDialog: public QDialog, private Ui::QgsTextAnn
QgsTextAnnotationDialog( QgsTextAnnotationItem* item, QWidget * parent = nullptr, Qt::WindowFlags f = nullptr );
~QgsTextAnnotationDialog();

protected:

virtual void showEvent( QShowEvent * event ) override;

private:
QgsTextAnnotationItem* mItem;
/** Text document (a clone of the annotation items document)*/
@@ -44,6 +48,7 @@ class APP_EXPORT QgsTextAnnotationDialog: public QDialog, private Ui::QgsTextAnn
void on_mFontColorButton_colorChanged( const QColor& color );
void setCurrentFontPropertiesToGui();
void deleteItem();
void backgroundColorChanged( const QColor& color );
};

#endif // QGSTEXTANNOTATIONDIALOG_H

0 comments on commit b351d16

Please sign in to comment.