Skip to content

Commit e2d9794

Browse files
committedJan 6, 2016
Add Apply buttons to decoration dialogs
1 parent 36b0f65 commit e2d9794

14 files changed

+151
-116
lines changed
 

‎src/app/qgsdecorationcopyright.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ void QgsDecorationCopyright::saveToProject()
8989
void QgsDecorationCopyright::run()
9090
{
9191
QgsDecorationCopyrightDialog dlg( *this, QgisApp::instance() );
92-
93-
if ( dlg.exec() )
94-
{
95-
update();
96-
}
92+
dlg.exec();
9793
}
9894

9995

‎src/app/qgsdecorationcopyrightdialog.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <QColor>
2121
#include <QFont>
2222
#include <QSettings>
23+
#include <QDialogButtonBox>
24+
#include <QPushButton>
2325

2426
QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyright& deco, QWidget* parent )
2527
: QDialog( parent ), mDeco( deco )
@@ -29,6 +31,9 @@ QgsDecorationCopyrightDialog::QgsDecorationCopyrightDialog( QgsDecorationCopyrig
2931
QSettings settings;
3032
restoreGeometry( settings.value( "/Windows/DecorationCopyright/geometry" ).toByteArray() );
3133

34+
QPushButton* applyButton = buttonBox->button( QDialogButtonBox::Apply );
35+
connect( applyButton, SIGNAL( clicked() ), this, SLOT( apply() ) );
36+
3237
//programmatically hide orientation selection for now
3338
cboOrientation->hide();
3439
textLabel15->hide();
@@ -63,14 +68,7 @@ QgsDecorationCopyrightDialog::~QgsDecorationCopyrightDialog()
6368

6469
void QgsDecorationCopyrightDialog::on_buttonBox_accepted()
6570
{
66-
mDeco.mQFont = txtCopyrightText->currentFont();
67-
mDeco.mLabelQString = txtCopyrightText->toPlainText();
68-
mDeco.mLabelQColor = pbnColorChooser->color();
69-
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
70-
mDeco.mMarginHorizontal = spnHorizontal->value();
71-
mDeco.mMarginVertical = spnVertical->value();
72-
mDeco.setEnabled( grpEnable->isChecked() );
73-
71+
apply();
7472
accept();
7573
}
7674

@@ -87,6 +85,18 @@ void QgsDecorationCopyrightDialog::on_pbnColorChooser_colorChanged( const QColor
8785
txtCopyrightText->setTextCursor( cursor );
8886
}
8987

88+
void QgsDecorationCopyrightDialog::apply()
89+
{
90+
mDeco.mQFont = txtCopyrightText->currentFont();
91+
mDeco.mLabelQString = txtCopyrightText->toPlainText();
92+
mDeco.mLabelQColor = pbnColorChooser->color();
93+
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
94+
mDeco.mMarginHorizontal = spnHorizontal->value();
95+
mDeco.mMarginVertical = spnVertical->value();
96+
mDeco.setEnabled( grpEnable->isChecked() );
97+
mDeco.update();
98+
}
99+
90100
void QgsDecorationCopyrightDialog::on_buttonBox_helpRequested()
91101
{
92102
QgsContextHelp::run( metaObject()->className() );

‎src/app/qgsdecorationcopyrightdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class APP_EXPORT QgsDecorationCopyrightDialog : public QDialog, private Ui::QgsD
3232
void on_buttonBox_rejected();
3333
void on_buttonBox_helpRequested();
3434
void on_pbnColorChooser_colorChanged( const QColor& c );
35+
void apply();
3536

3637
protected:
3738
QgsDecorationCopyright& mDeco;

‎src/app/qgsdecorationitem.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ class APP_EXPORT QgsDecorationItem: public QObject
5555
*/
5656
void setPlacement( Placement placement ) { mPlacement = placement; }
5757

58-
void update();
59-
6058
signals:
6159
void toggled( bool t );
6260

@@ -74,6 +72,9 @@ class APP_EXPORT QgsDecorationItem: public QObject
7472
virtual void setName( const char *name );
7573
virtual QString name() { return mName; }
7674

75+
//! Redraws the decoration
76+
void update();
77+
7778
protected:
7879

7980
/** True if decoration item has to be displayed*/

‎src/app/qgsdecorationnortharrow.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ void QgsDecorationNorthArrow::saveToProject()
9292
void QgsDecorationNorthArrow::run()
9393
{
9494
QgsDecorationNorthArrowDialog dlg( *this, QgisApp::instance() );
95-
96-
if ( dlg.exec() )
97-
{
98-
update();
99-
}
95+
dlg.exec();
10096
}
10197

10298
void QgsDecorationNorthArrow::render( QPainter * theQPainter )

‎src/app/qgsdecorationnortharrowdialog.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
***************************************************************************/
1212

1313
#include "qgsdecorationnortharrowdialog.h"
14-
1514
#include "qgsdecorationnortharrow.h"
16-
1715
#include "qgslogger.h"
1816
#include "qgscontexthelp.h"
1917

2018
#include <QPainter>
2119
#include <QSettings>
2220
#include <cmath>
21+
#include <QDialogButtonBox>
22+
#include <QPushButton>
2323

2424
QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorthArrow& deco, QWidget* parent )
2525
: QDialog( parent ), mDeco( deco )
@@ -29,6 +29,9 @@ QgsDecorationNorthArrowDialog::QgsDecorationNorthArrowDialog( QgsDecorationNorth
2929
QSettings settings;
3030
restoreGeometry( settings.value( "/Windows/DecorationNorthArrow/geometry" ).toByteArray() );
3131

32+
QPushButton* applyButton = buttonBox->button( QDialogButtonBox::Apply );
33+
connect( applyButton, SIGNAL( clicked() ), this, SLOT( apply() ) );
34+
3235
// rotation
3336
rotatePixmap( mDeco.mRotationInt );
3437
// signal/slot connection defined in 'designer' causes the slider to
@@ -64,13 +67,7 @@ void QgsDecorationNorthArrowDialog::on_buttonBox_helpRequested()
6467

6568
void QgsDecorationNorthArrowDialog::on_buttonBox_accepted()
6669
{
67-
mDeco.mRotationInt = sliderRotation->value();
68-
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
69-
mDeco.setEnabled( grpEnable->isChecked() );
70-
mDeco.mAutomatic = cboxAutomatic->isChecked();
71-
mDeco.mMarginHorizontal = spinHorizontal->value();
72-
mDeco.mMarginVertical = spinVertical->value();
73-
70+
apply();
7471
accept();
7572
}
7673

@@ -90,6 +87,17 @@ void QgsDecorationNorthArrowDialog::on_sliderRotation_valueChanged( int theInt )
9087
rotatePixmap( theInt );
9188
}
9289

90+
void QgsDecorationNorthArrowDialog::apply()
91+
{
92+
mDeco.mRotationInt = sliderRotation->value();
93+
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
94+
mDeco.setEnabled( grpEnable->isChecked() );
95+
mDeco.mAutomatic = cboxAutomatic->isChecked();
96+
mDeco.mMarginHorizontal = spinHorizontal->value();
97+
mDeco.mMarginVertical = spinVertical->value();
98+
mDeco.update();
99+
}
100+
93101
void QgsDecorationNorthArrowDialog::rotatePixmap( int theRotationInt )
94102
{
95103
QPixmap myQPixmap;

‎src/app/qgsdecorationnortharrowdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class APP_EXPORT QgsDecorationNorthArrowDialog : public QDialog, private Ui::Qgs
3434
void on_buttonBox_helpRequested();
3535
void on_spinAngle_valueChanged( int theInt );
3636
void on_sliderRotation_valueChanged( int theInt );
37+
void apply();
3738

3839
protected:
3940
QgsDecorationNorthArrow& mDeco;

‎src/app/qgsdecorationscalebar.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@ void QgsDecorationScaleBar::saveToProject()
9898
void QgsDecorationScaleBar::run()
9999
{
100100
QgsDecorationScaleBarDialog dlg( *this, QgisApp::instance()->mapCanvas()->mapUnits(), QgisApp::instance() );
101-
102-
if ( dlg.exec() )
103-
{
104-
update();
105-
}
101+
dlg.exec();
106102
}
107103

108104

‎src/app/qgsdecorationscalebardialog.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
***************************************************************************/
1212

1313
#include "qgsdecorationscalebardialog.h"
14-
1514
#include "qgsdecorationscalebar.h"
16-
1715
#include "qgslogger.h"
1816
#include "qgscontexthelp.h"
1917

2018
#include <QColorDialog>
2119
#include <QSettings>
20+
#include <QDialogButtonBox>
21+
#include <QPushButton>
2222

2323
QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar& deco, int units, QWidget* parent )
2424
: QDialog( parent ), mDeco( deco )
@@ -28,6 +28,9 @@ QgsDecorationScaleBarDialog::QgsDecorationScaleBarDialog( QgsDecorationScaleBar&
2828
QSettings settings;
2929
restoreGeometry( settings.value( "/Windows/DecorationScaleBar/geometry" ).toByteArray() );
3030

31+
QPushButton* applyButton = buttonBox->button( QDialogButtonBox::Apply );
32+
connect( applyButton, SIGNAL( clicked() ), this, SLOT( apply() ) );
33+
3134
// set the map units in the spin box
3235
spnSize->setShowClearButton( false );
3336
switch ( units )
@@ -79,7 +82,7 @@ void QgsDecorationScaleBarDialog::on_buttonBox_helpRequested()
7982
QgsContextHelp::run( metaObject()->className() );
8083
}
8184

82-
void QgsDecorationScaleBarDialog::on_buttonBox_accepted()
85+
void QgsDecorationScaleBarDialog::apply()
8386
{
8487
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
8588
mDeco.mMarginHorizontal = spnHorizontal->value();
@@ -89,7 +92,12 @@ void QgsDecorationScaleBarDialog::on_buttonBox_accepted()
8992
mDeco.setEnabled( grpEnable->isChecked() );
9093
mDeco.mStyleIndex = cboStyle->currentIndex();
9194
mDeco.mColor = pbnChangeColor->color();
95+
mDeco.update();
96+
}
9297

98+
void QgsDecorationScaleBarDialog::on_buttonBox_accepted()
99+
{
100+
apply();
93101
accept();
94102
}
95103

‎src/app/qgsdecorationscalebardialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class APP_EXPORT QgsDecorationScaleBarDialog : public QDialog, private Ui::QgsDe
3232
void on_buttonBox_accepted();
3333
void on_buttonBox_rejected();
3434
void on_buttonBox_helpRequested();
35+
void apply();
3536

3637
protected:
3738
QgsDecorationScaleBar& mDeco;

‎src/ui/qgsdecorationcopyrightdialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ p, li { white-space: pre-wrap; }
256256
<enum>Qt::Horizontal</enum>
257257
</property>
258258
<property name="standardButtons">
259-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
259+
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
260260
</property>
261261
</widget>
262262
</item>

‎src/ui/qgsdecorationgriddialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
<enum>Qt::Horizontal</enum>
322322
</property>
323323
<property name="standardButtons">
324-
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
324+
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
325325
</property>
326326
</widget>
327327
</item>

‎src/ui/qgsdecorationnortharrowdialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@
245245
<enum>Qt::Horizontal</enum>
246246
</property>
247247
<property name="standardButtons">
248-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
248+
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
249249
</property>
250250
</widget>
251251
</item>

‎src/ui/qgsdecorationscalebardialog.ui

Lines changed: 93 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
<normaloff>../../../../../.designer/backup</normaloff>../../../../../.designer/backup</iconset>
1919
</property>
2020
<layout class="QGridLayout" name="gridLayout">
21+
<item row="9" column="0" colspan="3">
22+
<widget class="QDialogButtonBox" name="buttonBox">
23+
<property name="orientation">
24+
<enum>Qt::Horizontal</enum>
25+
</property>
26+
<property name="standardButtons">
27+
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
28+
</property>
29+
</widget>
30+
</item>
2131
<item row="2" column="0" colspan="3">
2232
<widget class="QGroupBox" name="grpEnable">
2333
<property name="sizePolicy">
@@ -57,7 +67,7 @@
5767
<property name="verticalSpacing">
5868
<number>6</number>
5969
</property>
60-
<item row="3" column="0">
70+
<item row="0" column="0">
6171
<widget class="QLabel" name="lblLocation">
6272
<property name="sizePolicy">
6373
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@@ -73,20 +83,23 @@
7383
</property>
7484
</widget>
7585
</item>
76-
<item row="4" column="0">
77-
<widget class="QLabel" name="lblMargin">
86+
<item row="4" column="1">
87+
<widget class="QgsSpinBox" name="spnSize">
88+
<property name="sizePolicy">
89+
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
90+
<horstretch>0</horstretch>
91+
<verstretch>0</verstretch>
92+
</sizepolicy>
93+
</property>
7894
<property name="minimumSize">
7995
<size>
80-
<width>155</width>
96+
<width>338</width>
8197
<height>0</height>
8298
</size>
8399
</property>
84-
<property name="text">
85-
<string>Margin from edge (%)</string>
86-
</property>
87100
</widget>
88101
</item>
89-
<item row="6" column="0">
102+
<item row="3" column="0">
90103
<widget class="QLabel" name="textLabel1_3_2">
91104
<property name="sizePolicy">
92105
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
@@ -99,7 +112,7 @@
99112
</property>
100113
</widget>
101114
</item>
102-
<item row="14" column="0" colspan="3">
115+
<item row="5" column="0" colspan="3">
103116
<widget class="QCheckBox" name="chkSnapping">
104117
<property name="sizePolicy">
105118
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@@ -115,39 +128,7 @@
115128
</property>
116129
</widget>
117130
</item>
118-
<item row="5" column="0">
119-
<widget class="QLabel" name="textLabel1">
120-
<property name="sizePolicy">
121-
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
122-
<horstretch>0</horstretch>
123-
<verstretch>0</verstretch>
124-
</sizepolicy>
125-
</property>
126-
<property name="text">
127-
<string>Scale bar style</string>
128-
</property>
129-
<property name="buddy">
130-
<cstring>cboStyle</cstring>
131-
</property>
132-
</widget>
133-
</item>
134-
<item row="7" column="0">
135-
<widget class="QLabel" name="textLabel1_3">
136-
<property name="sizePolicy">
137-
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
138-
<horstretch>0</horstretch>
139-
<verstretch>0</verstretch>
140-
</sizepolicy>
141-
</property>
142-
<property name="text">
143-
<string>Size of bar</string>
144-
</property>
145-
<property name="buddy">
146-
<cstring>spnSize</cstring>
147-
</property>
148-
</widget>
149-
</item>
150-
<item row="3" column="1">
131+
<item row="0" column="1">
151132
<widget class="QComboBox" name="cboPlacement">
152133
<property name="sizePolicy">
153134
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@@ -163,7 +144,7 @@
163144
</property>
164145
</widget>
165146
</item>
166-
<item row="5" column="1">
147+
<item row="2" column="1">
167148
<widget class="QComboBox" name="cboStyle">
168149
<property name="sizePolicy">
169150
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@@ -202,42 +183,39 @@
202183
</item>
203184
</widget>
204185
</item>
205-
<item row="6" column="1">
206-
<widget class="QgsColorButtonV2" name="pbnChangeColor">
207-
<property name="minimumSize">
208-
<size>
209-
<width>338</width>
210-
<height>0</height>
211-
</size>
212-
</property>
213-
<property name="maximumSize">
214-
<size>
215-
<width>16777215</width>
216-
<height>16777215</height>
217-
</size>
186+
<item row="4" column="0">
187+
<widget class="QLabel" name="textLabel1_3">
188+
<property name="sizePolicy">
189+
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
190+
<horstretch>0</horstretch>
191+
<verstretch>0</verstretch>
192+
</sizepolicy>
218193
</property>
219194
<property name="text">
220-
<string/>
195+
<string>Size of bar</string>
196+
</property>
197+
<property name="buddy">
198+
<cstring>spnSize</cstring>
221199
</property>
222200
</widget>
223201
</item>
224-
<item row="7" column="1">
225-
<widget class="QgsSpinBox" name="spnSize">
202+
<item row="2" column="0">
203+
<widget class="QLabel" name="textLabel1">
226204
<property name="sizePolicy">
227-
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
205+
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
228206
<horstretch>0</horstretch>
229207
<verstretch>0</verstretch>
230208
</sizepolicy>
231209
</property>
232-
<property name="minimumSize">
233-
<size>
234-
<width>338</width>
235-
<height>0</height>
236-
</size>
210+
<property name="text">
211+
<string>Scale bar style</string>
212+
</property>
213+
<property name="buddy">
214+
<cstring>cboStyle</cstring>
237215
</property>
238216
</widget>
239217
</item>
240-
<item row="4" column="1">
218+
<item row="1" column="1">
241219
<layout class="QHBoxLayout" name="hlytMargin" stretch="0,0,0,0,0">
242220
<property name="spacing">
243221
<number>10</number>
@@ -360,19 +338,58 @@
360338
</item>
361339
</layout>
362340
</item>
341+
<item row="1" column="0">
342+
<widget class="QLabel" name="lblMargin">
343+
<property name="minimumSize">
344+
<size>
345+
<width>155</width>
346+
<height>0</height>
347+
</size>
348+
</property>
349+
<property name="text">
350+
<string>Margin from edge (%)</string>
351+
</property>
352+
</widget>
353+
</item>
354+
<item row="3" column="1">
355+
<layout class="QHBoxLayout" name="horizontalLayout">
356+
<item>
357+
<widget class="QgsColorButtonV2" name="pbnChangeColor">
358+
<property name="minimumSize">
359+
<size>
360+
<width>150</width>
361+
<height>0</height>
362+
</size>
363+
</property>
364+
<property name="maximumSize">
365+
<size>
366+
<width>120</width>
367+
<height>16777215</height>
368+
</size>
369+
</property>
370+
<property name="text">
371+
<string/>
372+
</property>
373+
</widget>
374+
</item>
375+
<item>
376+
<spacer name="horizontalSpacer_2">
377+
<property name="orientation">
378+
<enum>Qt::Horizontal</enum>
379+
</property>
380+
<property name="sizeHint" stdset="0">
381+
<size>
382+
<width>40</width>
383+
<height>20</height>
384+
</size>
385+
</property>
386+
</spacer>
387+
</item>
388+
</layout>
389+
</item>
363390
</layout>
364391
</widget>
365392
</item>
366-
<item row="9" column="0" colspan="3">
367-
<widget class="QDialogButtonBox" name="buttonBox">
368-
<property name="orientation">
369-
<enum>Qt::Horizontal</enum>
370-
</property>
371-
<property name="standardButtons">
372-
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
373-
</property>
374-
</widget>
375-
</item>
376393
</layout>
377394
</widget>
378395
<layoutdefault spacing="6" margin="11"/>

0 commit comments

Comments
 (0)
Please sign in to comment.