Skip to content

Commit

Permalink
Add apply buttons to annotation dialogs
Browse files Browse the repository at this point in the history
(cherry-picked from 0352745)
  • Loading branch information
nyalldawson committed Jul 26, 2016
1 parent 8a9afcc commit 6fef0fa
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 11 deletions.
11 changes: 4 additions & 7 deletions src/app/qgsannotationwidget.cpp
Expand Up @@ -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();
}

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

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

void QgsAnnotationWidget::apply()
Expand All @@ -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();
}
}
Expand All @@ -108,8 +106,7 @@ void QgsAnnotationWidget::on_mMapMarkerButton_clicked()
}
else
{
delete mMarkerSymbol;
mMarkerSymbol = markerSymbol;
mMarkerSymbol.reset( markerSymbol );
updateCenterIcon();
}
}
Expand All @@ -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 );
}

2 changes: 1 addition & 1 deletion src/app/qgsannotationwidget.h
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions src/app/qgsformannotationdialog.cpp
Expand Up @@ -89,3 +89,11 @@ void QgsFormAnnotationDialog::deleteItem()
mItem = nullptr;
}

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

1 change: 1 addition & 0 deletions src/app/qgsformannotationdialog.h
Expand Up @@ -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
8 changes: 8 additions & 0 deletions src/app/qgshtmlannotationdialog.cpp
Expand Up @@ -94,3 +94,11 @@ void QgsHtmlAnnotationDialog::deleteItem()
mItem = nullptr;
}

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

1 change: 1 addition & 0 deletions src/app/qgshtmlannotationdialog.h
Expand Up @@ -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
8 changes: 8 additions & 0 deletions src/app/qgssvgannotationdialog.cpp
Expand Up @@ -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();
}
}
1 change: 1 addition & 0 deletions src/app/qgssvgannotationdialog.h
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/app/qgstextannotationdialog.cpp
Expand Up @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions src/app/qgstextannotationdialog.h
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/ui/qgsformannotationdialogbase.ui
Expand Up @@ -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>
Expand Down
4 changes: 2 additions & 2 deletions src/ui/qgstextannotationdialogbase.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>517</width>
<width>519</width>
<height>364</height>
</rect>
</property>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 6fef0fa

Please sign in to comment.