Skip to content
Permalink
Browse files

Add Apply buttons to decoration dialogs

  • Loading branch information
nyalldawson committed Jan 6, 2016
1 parent 36b0f65 commit e2d9794c2eebc818bcc1ade705d0ae2931fca2ab
@@ -89,11 +89,7 @@ void QgsDecorationCopyright::saveToProject()
void QgsDecorationCopyright::run()
{
QgsDecorationCopyrightDialog dlg( *this, QgisApp::instance() );

if ( dlg.exec() )
{
update();
}
dlg.exec();
}


@@ -20,6 +20,8 @@
#include <QColor>
#include <QFont>
#include <QSettings>
#include <QDialogButtonBox>
#include <QPushButton>

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

QPushButton* applyButton = buttonBox->button( QDialogButtonBox::Apply );
connect( applyButton, SIGNAL( clicked() ), this, SLOT( apply() ) );

//programmatically hide orientation selection for now
cboOrientation->hide();
textLabel15->hide();
@@ -63,14 +68,7 @@ QgsDecorationCopyrightDialog::~QgsDecorationCopyrightDialog()

void QgsDecorationCopyrightDialog::on_buttonBox_accepted()
{
mDeco.mQFont = txtCopyrightText->currentFont();
mDeco.mLabelQString = txtCopyrightText->toPlainText();
mDeco.mLabelQColor = pbnColorChooser->color();
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
mDeco.mMarginHorizontal = spnHorizontal->value();
mDeco.mMarginVertical = spnVertical->value();
mDeco.setEnabled( grpEnable->isChecked() );

apply();
accept();
}

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

void QgsDecorationCopyrightDialog::apply()
{
mDeco.mQFont = txtCopyrightText->currentFont();
mDeco.mLabelQString = txtCopyrightText->toPlainText();
mDeco.mLabelQColor = pbnColorChooser->color();
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
mDeco.mMarginHorizontal = spnHorizontal->value();
mDeco.mMarginVertical = spnVertical->value();
mDeco.setEnabled( grpEnable->isChecked() );
mDeco.update();
}

void QgsDecorationCopyrightDialog::on_buttonBox_helpRequested()
{
QgsContextHelp::run( metaObject()->className() );
@@ -32,6 +32,7 @@ class APP_EXPORT QgsDecorationCopyrightDialog : public QDialog, private Ui::QgsD
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
void on_pbnColorChooser_colorChanged( const QColor& c );
void apply();

protected:
QgsDecorationCopyright& mDeco;
@@ -55,8 +55,6 @@ class APP_EXPORT QgsDecorationItem: public QObject
*/
void setPlacement( Placement placement ) { mPlacement = placement; }

void update();

signals:
void toggled( bool t );

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

//! Redraws the decoration
void update();

protected:

/** True if decoration item has to be displayed*/
@@ -92,11 +92,7 @@ void QgsDecorationNorthArrow::saveToProject()
void QgsDecorationNorthArrow::run()
{
QgsDecorationNorthArrowDialog dlg( *this, QgisApp::instance() );

if ( dlg.exec() )
{
update();
}
dlg.exec();
}

void QgsDecorationNorthArrow::render( QPainter * theQPainter )
@@ -11,15 +11,15 @@
***************************************************************************/

#include "qgsdecorationnortharrowdialog.h"

#include "qgsdecorationnortharrow.h"

#include "qgslogger.h"
#include "qgscontexthelp.h"

#include <QPainter>
#include <QSettings>
#include <cmath>
#include <QDialogButtonBox>
#include <QPushButton>

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

QPushButton* applyButton = buttonBox->button( QDialogButtonBox::Apply );
connect( applyButton, SIGNAL( clicked() ), this, SLOT( apply() ) );

// rotation
rotatePixmap( mDeco.mRotationInt );
// signal/slot connection defined in 'designer' causes the slider to
@@ -64,13 +67,7 @@ void QgsDecorationNorthArrowDialog::on_buttonBox_helpRequested()

void QgsDecorationNorthArrowDialog::on_buttonBox_accepted()
{
mDeco.mRotationInt = sliderRotation->value();
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
mDeco.setEnabled( grpEnable->isChecked() );
mDeco.mAutomatic = cboxAutomatic->isChecked();
mDeco.mMarginHorizontal = spinHorizontal->value();
mDeco.mMarginVertical = spinVertical->value();

apply();
accept();
}

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

void QgsDecorationNorthArrowDialog::apply()
{
mDeco.mRotationInt = sliderRotation->value();
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
mDeco.setEnabled( grpEnable->isChecked() );
mDeco.mAutomatic = cboxAutomatic->isChecked();
mDeco.mMarginHorizontal = spinHorizontal->value();
mDeco.mMarginVertical = spinVertical->value();
mDeco.update();
}

void QgsDecorationNorthArrowDialog::rotatePixmap( int theRotationInt )
{
QPixmap myQPixmap;
@@ -34,6 +34,7 @@ class APP_EXPORT QgsDecorationNorthArrowDialog : public QDialog, private Ui::Qgs
void on_buttonBox_helpRequested();
void on_spinAngle_valueChanged( int theInt );
void on_sliderRotation_valueChanged( int theInt );
void apply();

protected:
QgsDecorationNorthArrow& mDeco;
@@ -98,11 +98,7 @@ void QgsDecorationScaleBar::saveToProject()
void QgsDecorationScaleBar::run()
{
QgsDecorationScaleBarDialog dlg( *this, QgisApp::instance()->mapCanvas()->mapUnits(), QgisApp::instance() );

if ( dlg.exec() )
{
update();
}
dlg.exec();
}


@@ -11,14 +11,14 @@
***************************************************************************/

#include "qgsdecorationscalebardialog.h"

#include "qgsdecorationscalebar.h"

#include "qgslogger.h"
#include "qgscontexthelp.h"

#include <QColorDialog>
#include <QSettings>
#include <QDialogButtonBox>
#include <QPushButton>

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

QPushButton* applyButton = buttonBox->button( QDialogButtonBox::Apply );
connect( applyButton, SIGNAL( clicked() ), this, SLOT( apply() ) );

// set the map units in the spin box
spnSize->setShowClearButton( false );
switch ( units )
@@ -79,7 +82,7 @@ void QgsDecorationScaleBarDialog::on_buttonBox_helpRequested()
QgsContextHelp::run( metaObject()->className() );
}

void QgsDecorationScaleBarDialog::on_buttonBox_accepted()
void QgsDecorationScaleBarDialog::apply()
{
mDeco.setPlacement( static_cast< QgsDecorationItem::Placement>( cboPlacement->itemData( cboPlacement->currentIndex() ).toInt() ) );
mDeco.mMarginHorizontal = spnHorizontal->value();
@@ -89,7 +92,12 @@ void QgsDecorationScaleBarDialog::on_buttonBox_accepted()
mDeco.setEnabled( grpEnable->isChecked() );
mDeco.mStyleIndex = cboStyle->currentIndex();
mDeco.mColor = pbnChangeColor->color();
mDeco.update();
}

void QgsDecorationScaleBarDialog::on_buttonBox_accepted()
{
apply();
accept();
}

@@ -32,6 +32,7 @@ class APP_EXPORT QgsDecorationScaleBarDialog : public QDialog, private Ui::QgsDe
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
void apply();

protected:
QgsDecorationScaleBar& mDeco;
@@ -256,7 +256,7 @@ p, li { white-space: pre-wrap; }
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
@@ -321,7 +321,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
@@ -245,7 +245,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>

0 comments on commit e2d9794

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