Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Background color option for svg annotation. Save frame transparency (…
…was missing also for text annotation)
  • Loading branch information
mhugent committed Nov 19, 2012
1 parent 5f02bc4 commit fad5cf3
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 80 deletions.
23 changes: 23 additions & 0 deletions src/app/qgsannotationwidget.cpp
Expand Up @@ -42,6 +42,7 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * par
}
mFrameWidthSpinBox->setValue( mItem->frameBorderWidth() );
mFrameColorButton->setColor( mItem->frameColor() );
mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );

const QgsMarkerSymbolV2* symbol = mItem->markerSymbol();
if ( symbol )
Expand All @@ -66,6 +67,7 @@ void QgsAnnotationWidget::apply()
mItem->setMapPositionFixed( mMapPositionFixedCheckBox->checkState() == Qt::Checked );
mItem->setFrameBorderWidth( mFrameWidthSpinBox->value() );
mItem->setFrameColor( mFrameColorButton->color() );
mItem->setFrameBackgroundColor( mBackgroundColorButton->color() );
mItem->setMarkerSymbol( mMarkerSymbol );
mMarkerSymbol = 0; //item takes ownership
mItem->update();
Expand Down Expand Up @@ -129,3 +131,24 @@ void QgsAnnotationWidget::updateCenterIcon()
mMapMarkerButton->setIcon( icon );
}

void QgsAnnotationWidget::on_mBackgroundColorButton_clicked()
{
if ( !mItem )
{
return;
}

QColor bgColor;
#if QT_VERSION >= 0x040500
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor(), 0, tr( "Select background color" ), QColorDialog::ShowAlphaChannel );
#else
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor() );
#endif

if ( bgColor.isValid() )
{
mItem->setFrameBackgroundColor( bgColor );
mBackgroundColorButton->setColor( bgColor );
}
}

1 change: 1 addition & 0 deletions src/app/qgsannotationwidget.h
Expand Up @@ -37,6 +37,7 @@ class QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationWidgetBase
private slots:
void on_mMapMarkerButton_clicked();
void on_mFrameColorButton_clicked();
void on_mBackgroundColorButton_clicked();

private:
QgsAnnotationItem* mItem;
Expand Down
22 changes: 0 additions & 22 deletions src/app/qgstextannotationdialog.cpp
Expand Up @@ -32,7 +32,6 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsTextAnnotationItem* item, Q
{
mTextDocument = mItem->document();
mTextEdit->setDocument( mTextDocument );
mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );
}
setCurrentFontPropertiesToGui();

Expand Down Expand Up @@ -148,24 +147,3 @@ void QgsTextAnnotationDialog::deleteItem()
mItem = 0;
}

void QgsTextAnnotationDialog::on_mBackgroundColorButton_clicked()
{
if ( !mItem )
{
return;
}

QColor bgColor;
#if QT_VERSION >= 0x040500
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor(), 0, tr( "Select background color" ), QColorDialog::ShowAlphaChannel );
#else
bgColor = QColorDialog::getColor( mItem->frameBackgroundColor() );
#endif

if ( bgColor.isValid() )
{
mItem->setFrameBackgroundColor( bgColor );
mBackgroundColorButton->setColor( bgColor );
}
}

1 change: 0 additions & 1 deletion src/app/qgstextannotationdialog.h
Expand Up @@ -44,7 +44,6 @@ class QgsTextAnnotationDialog: public QDialog, private Ui::QgsTextAnnotationDial
void on_mFontColorButton_clicked();
void setCurrentFontPropertiesToGui();
void deleteItem();
void on_mBackgroundColorButton_clicked();
};

#endif // QGSTEXTANNOTATIONDIALOG_H
2 changes: 2 additions & 0 deletions src/gui/qgsannotationitem.cpp
Expand Up @@ -397,6 +397,7 @@ void QgsAnnotationItem::_writeXML( QDomDocument& doc, QDomElement& itemElem ) co
annotationElem.setAttribute( "canvasPosY", QString::number( canvasPos.y() ) );
annotationElem.setAttribute( "frameBorderWidth", QString::number( mFrameBorderWidth ) );
annotationElem.setAttribute( "frameColor", mFrameColor.name() );
annotationElem.setAttribute( "frameColorAlpha", mFrameColor.alpha() );
annotationElem.setAttribute( "frameBackgroundColor", mFrameBackgroundColor.name() );
annotationElem.setAttribute( "frameBackgroundColorAlpha", mFrameBackgroundColor.alpha() );
annotationElem.setAttribute( "visible", isVisible() );
Expand Down Expand Up @@ -428,6 +429,7 @@ void QgsAnnotationItem::_readXML( const QDomDocument& doc, const QDomElement& an
mMapPosition = mapPos;
mFrameBorderWidth = annotationElem.attribute( "frameBorderWidth", "0.5" ).toDouble();
mFrameColor.setNamedColor( annotationElem.attribute( "frameColor", "#000000" ) );
mFrameColor.setAlpha( annotationElem.attribute( "frameColorAlpha", "255" ).toInt() );
mFrameBackgroundColor.setNamedColor( annotationElem.attribute( "frameBackgroundColor" ) );
mFrameBackgroundColor.setAlpha( annotationElem.attribute( "frameBackgroundColorAlpha", "255" ).toInt() );
mFrameSize.setWidth( annotationElem.attribute( "frameWidth", "50" ).toDouble() );
Expand Down
53 changes: 34 additions & 19 deletions src/ui/qgsannotationwidgetbase.ui
Expand Up @@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>213</width>
<height>152</height>
<width>180</width>
<height>151</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="mMapPositionFixedCheckBox">
<property name="text">
Expand All @@ -22,8 +22,8 @@
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="mMapMarkerLabel">
<property name="text">
<string>Map marker</string>
Expand All @@ -33,18 +33,14 @@
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QPushButton" name="mMapMarkerButton">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<item row="1" column="0">
<widget class="QLabel" name="mFrameWidthLabel">
<property name="text">
<string>Frame width</string>
Expand All @@ -54,14 +50,33 @@
</property>
</widget>
</item>
<item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="mFrameWidthSpinBox"/>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<item row="2" column="0">
<widget class="QLabel" name="mBackgroundColorLabel">
<property name="text">
<string>Background color</string>
</property>
<property name="buddy">
<cstring>mBackgroundColorButton</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsColorButton" name="mBackgroundColorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mFrameColorLabel">
<property name="text">
<string>Frame color</string>
Expand All @@ -71,10 +86,10 @@
</property>
</widget>
</item>
<item>
<item row="3" column="1">
<widget class="QgsColorButton" name="mFrameColorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down
48 changes: 10 additions & 38 deletions src/ui/qgstextannotationdialogbase.ui
Expand Up @@ -70,37 +70,20 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QDialogButtonBox" name="mButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QTextEdit" name="mTextEdit"/>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="mBackgroundColorLabel">
<property name="text">
<string>Background color</string>
</property>
<property name="buddy">
<cstring>mBackgroundColorButton</cstring>
</property>
</widget>
</item>
<item>
<widget class="QgsColorButton" name="mBackgroundColorButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QStackedWidget" name="mStackedWidget">
<property name="currentIndex">
<number>0</number>
Expand All @@ -109,16 +92,6 @@
<widget class="QWidget" name="page_2"/>
</widget>
</item>
<item row="4" column="0">
<widget class="QDialogButtonBox" name="mButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand All @@ -135,7 +108,6 @@
<tabstop>mItalicsPushButton</tabstop>
<tabstop>mFontColorButton</tabstop>
<tabstop>mTextEdit</tabstop>
<tabstop>mBackgroundColorButton</tabstop>
<tabstop>mButtonBox</tabstop>
</tabstops>
<resources/>
Expand Down

0 comments on commit fad5cf3

Please sign in to comment.