Skip to content
Permalink
Browse files

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 fad5cf3f209b5a201649883df8aa9ed680c36380
@@ -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 )
@@ -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();
@@ -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 );
}
}

@@ -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;
@@ -32,7 +32,6 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsTextAnnotationItem* item, Q
{
mTextDocument = mItem->document();
mTextEdit->setDocument( mTextDocument );
mBackgroundColorButton->setColor( mItem->frameBackgroundColor() );
}
setCurrentFontPropertiesToGui();

@@ -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 );
}
}

@@ -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
@@ -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() );
@@ -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() );
@@ -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">
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -135,7 +108,6 @@
<tabstop>mItalicsPushButton</tabstop>
<tabstop>mFontColorButton</tabstop>
<tabstop>mTextEdit</tabstop>
<tabstop>mBackgroundColorButton</tabstop>
<tabstop>mButtonBox</tabstop>
</tabstops>
<resources/>

0 comments on commit fad5cf3

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