Skip to content

Commit

Permalink
Add apply buttons to annotation dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 21, 2016
1 parent a798ba0 commit 0352745
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 @@ -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();
}

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsannotationwidget.h
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions src/app/qgsformannotationdialog.cpp
Expand Up @@ -90,3 +90,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 @@ -95,3 +95,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 @@ -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 )
Expand Down
1 change: 1 addition & 0 deletions src/app/qgstextannotationdialog.h
Expand Up @@ -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
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 0352745

Please sign in to comment.