Skip to content
Permalink
Browse files

Add apply buttons to annotation dialogs

(cherry-picked from 0352745)
  • Loading branch information
nyalldawson committed Jul 21, 2016
1 parent 8a9afcc commit 6fef0fa2a7292ca991ffac33c2ab2605a02464b7
@@ -59,7 +59,7 @@ QgsAnnotationWidget::QgsAnnotationWidget( QgsAnnotationItem* item, QWidget * par
const QgsMarkerSymbolV2* symbol = mItem->markerSymbol();
if ( symbol )
{
mMarkerSymbol = symbol->clone();
mMarkerSymbol.reset( symbol->clone() );
updateCenterIcon();
}

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

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

void QgsAnnotationWidget::apply()
@@ -80,8 +79,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();
}
}
@@ -108,8 +106,7 @@ void QgsAnnotationWidget::on_mMapMarkerButton_clicked()
}
else
{
delete mMarkerSymbol;
mMarkerSymbol = markerSymbol;
mMarkerSymbol.reset( markerSymbol );
updateCenterIcon();
}
}
@@ -120,7 +117,7 @@ void QgsAnnotationWidget::updateCenterIcon()
{
return;
}
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mMarkerSymbol, mMapMarkerButton->iconSize() );
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( mMarkerSymbol.data(), mMapMarkerButton->iconSize() );
mMapMarkerButton->setIcon( icon );
}

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

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

void blockAllSignals( bool block );
void updateCenterIcon();
@@ -89,3 +89,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
@@ -94,3 +94,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
@@ -58,6 +58,15 @@ QgsTextAnnotationDialog::~QgsTextAnnotationDialog()
delete mTextDocument;
}

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

void QgsTextAnnotationDialog::showEvent( QShowEvent* )
{
backgroundColorChanged( mItem ? mItem->frameBackgroundColor() : Qt::white );
@@ -49,6 +49,7 @@ class APP_EXPORT QgsTextAnnotationDialog: public QDialog, private Ui::QgsTextAnn
void setCurrentFontPropertiesToGui();
void deleteItem();
void backgroundColorChanged( const QColor& color );
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 6fef0fa

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