Skip to content
Permalink
Browse files

Add apply buttons to annotation dialogs

  • Loading branch information
nyalldawson committed Jul 21, 2016
1 parent a798ba0 commit 03527452d79c7e712fa494755f7fc71daeaf2a74
@@ -57,7 +57,7 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * par
const QgsMarkerSymbolV2* symbol = mItem->markerSymbol();
if ( symbol )
{
mMarkerSymbol = symbol->clone();
mMarkerSymbol.reset( symbol->clone() );
updateCenterIcon();
}

@@ -67,7 +67,6 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * par

QgsAnnotationWidget::~QgsAnnotationWidget()
{
delete mMarkerSymbol;
}

void QgsAnnotationWidget::apply()
@@ -78,8 +77,7 @@ void QgsAnnotationWidget::apply()
mItem->setFrameBorderWidth( mFrameWidthSpinBox->value() );
mItem->setFrameColor( mFrameColorButton->color() );
mItem->setFrameBackgroundColor( mBackgroundColorButton->color() );
mItem->setMarkerSymbol( mMarkerSymbol );
mMarkerSymbol = nullptr; //item takes ownership
mItem->setMarkerSymbol( mMarkerSymbol->clone() );
mItem->update();
}
}
@@ -106,8 +104,7 @@ void QgsAnnotationWidget::on_mMapMarkerButton_clicked()
}
else
{
delete mMarkerSymbol;
mMarkerSymbol = markerSymbol;
mMarkerSymbol.reset( markerSymbol );
updateCenterIcon();
}
}
@@ -128,7 +125,7 @@ void QgsAnnotationWidget::updateCenterIcon()
{
return;
}
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mMarkerSymbol, mMapMarkerButton->iconSize() );
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mMarkerSymbol.data(), mMapMarkerButton->iconSize() );
mMapMarkerButton->setIcon( icon );
}

@@ -41,7 +41,7 @@ class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationW

private:
QgsAnnotationItem* mItem;
QgsMarkerSymbolV2* mMarkerSymbol;
QScopedPointer< QgsMarkerSymbolV2 > mMarkerSymbol;

void blockAllSignals( bool block );
void updateCenterIcon();
@@ -90,3 +90,11 @@ void QgsFormAnnotationDialog::deleteItem()
mItem = nullptr;
}

void QgsFormAnnotationDialog::on_mButtonBox_clicked( QAbstractButton* button )
{
if ( mButtonBox->buttonRole( button ) == QDialogButtonBox::ApplyRole )
{
applySettingsToItem();
}
}

@@ -35,6 +35,7 @@ class APP_EXPORT QgsFormAnnotationDialog: public QDialog, private Ui::QgsFormAnn
void applySettingsToItem();
void on_mBrowseToolButton_clicked();
void deleteItem();
void on_mButtonBox_clicked( QAbstractButton* button );
};

#endif // QGSFORMANNOTATIONDIALOG_H
@@ -95,3 +95,11 @@ void QgsHtmlAnnotationDialog::deleteItem()
mItem = nullptr;
}

void QgsHtmlAnnotationDialog::on_mButtonBox_clicked( QAbstractButton* button )
{
if ( mButtonBox->buttonRole( button ) == QDialogButtonBox::ApplyRole )
{
applySettingsToItem();
}
}

@@ -35,6 +35,7 @@ class APP_EXPORT QgsHtmlAnnotationDialog: public QDialog, private Ui::QgsFormAnn
void applySettingsToItem();
void on_mBrowseToolButton_clicked();
void deleteItem();
void on_mButtonBox_clicked( QAbstractButton* button );
};

#endif // QgsHTMLAnnotationDialog_H
@@ -89,3 +89,11 @@ void QgsSvgAnnotationDialog::deleteItem()
delete mItem;
mItem = nullptr;
}

void QgsSvgAnnotationDialog::on_mButtonBox_clicked( QAbstractButton* button )
{
if ( mButtonBox->buttonRole( button ) == QDialogButtonBox::ApplyRole )
{
applySettingsToItem();
}
}
@@ -34,6 +34,7 @@ class APP_EXPORT QgsSvgAnnotationDialog: public QDialog, private Ui::QgsFormAnno
void on_mBrowseToolButton_clicked();
void applySettingsToItem();
void deleteItem();
void on_mButtonBox_clicked( QAbstractButton* button );

private:
QgsSvgAnnotationDialog(); //forbidden
@@ -56,6 +56,15 @@ QgsTextAnnotationDialog::~QgsTextAnnotationDialog()
delete mTextDocument;
}

void QgsTextAnnotationDialog::on_mButtonBox_clicked( QAbstractButton *button )
{
if ( mButtonBox->buttonRole( button ) == QDialogButtonBox::ApplyRole )
{
applyTextToItem();
mEmbeddedWidget->apply();
}
}

void QgsTextAnnotationDialog::applyTextToItem()
{
if ( mItem && mTextDocument )
@@ -44,6 +44,7 @@ class APP_EXPORT QgsTextAnnotationDialog: public QDialog, private Ui::QgsTextAnn
void on_mFontColorButton_colorChanged( const QColor& color );
void setCurrentFontPropertiesToGui();
void deleteItem();
void on_mButtonBox_clicked( QAbstractButton* button );
};

#endif // QGSTEXTANNOTATIONDIALOG_H
@@ -40,7 +40,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>517</width>
<width>519</width>
<height>364</height>
</rect>
</property>
@@ -97,7 +97,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

0 comments on commit 0352745

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