Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 6541470 commit c985674
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/qgsannotationwidget.cpp
Expand Up @@ -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 )
{
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgsannotationwidget.h
Expand Up @@ -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();

Expand Down
14 changes: 14 additions & 0 deletions src/app/qgstextannotationdialog.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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 )
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgstextannotationdialog.h
Expand Up @@ -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)*/
Expand All @@ -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 c985674

Please sign in to comment.