Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add liveUpdate annotation setting
  • Loading branch information
YoannQDQ authored and nyalldawson committed May 12, 2023
1 parent 7ff9b7c commit 9488e0b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/app/qgsannotationwidget.cpp
Expand Up @@ -26,10 +26,15 @@
#include "qgsfillsymbol.h"
#include "qgsmarkersymbol.h"
#include "qgsdoublespinbox.h"
#include "qgssettingsentryimpl.h"
#include "qgssettingstree.h"

#include <QColorDialog>


const QgsSettingsEntryBool *QgsAnnotationWidget::settingLiveUpdate = new QgsSettingsEntryBool( QStringLiteral( "live-update" ), QgsSettingsTree::sTreeAnnotations, false, QObject::tr( "Whether the annotations are dynamically updated while they are edited" ) );


QgsAnnotationWidget::QgsAnnotationWidget( QgsMapCanvasAnnotationItem *item, QWidget *parent, Qt::WindowFlags f )
: QWidget( parent, f )
, mItem( item )
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsannotationwidget.h
Expand Up @@ -25,6 +25,7 @@
class QgsMapCanvasAnnotationItem;
class QgsMarkerSymbol;
class QgsFillSymbol;
class QgsSettingsEntryBool;

/**
* A configuration widget to configure the annotation item properties.
Expand All @@ -36,6 +37,8 @@ class APP_EXPORT QgsAnnotationWidget: public QWidget, private Ui::QgsAnnotationW
Q_OBJECT
public:

static const QgsSettingsEntryBool *settingLiveUpdate;

QgsAnnotationWidget( QgsMapCanvasAnnotationItem *item, QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );

//! Returns the annotation frame symbol fill color
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgsformannotationdialog.cpp
Expand Up @@ -21,6 +21,8 @@
#include "qgsannotationmanager.h"
#include "qgsgui.h"
#include "qgshelp.h"
#include "qgssettingsentryimpl.h"

#include <QFileDialog>
#include <QFileInfo>
#include <QGraphicsScene>
Expand Down Expand Up @@ -58,6 +60,7 @@ QgsFormAnnotationDialog::QgsFormAnnotationDialog( QgsMapCanvasAnnotationItem *it
mButtonBox->addButton( deleteButton, QDialogButtonBox::RejectRole );

connect( mLiveCheckBox, &QCheckBox::toggled, this, &QgsFormAnnotationDialog::onLiveUpdateToggled );
mLiveCheckBox->setChecked( QgsAnnotationWidget::settingLiveUpdate->value() );
connect( mEmbeddedWidget, &QgsAnnotationWidget::changed, this, &QgsFormAnnotationDialog::onSettingsChanged );
connect( mFileLineEdit, &QLineEdit::textChanged, this, &QgsFormAnnotationDialog::onSettingsChanged );
connect( mLiveCheckBox, &QCheckBox::toggled, this, &QgsFormAnnotationDialog::onSettingsChanged );
Expand Down Expand Up @@ -133,4 +136,5 @@ void QgsFormAnnotationDialog::onLiveUpdateToggled( bool checked )
// Apply and Cancel buttons make no sense when live update is on
mButtonBox->button( QDialogButtonBox::Apply )->setHidden( checked );
mButtonBox->button( QDialogButtonBox::Cancel )->setHidden( checked );
QgsAnnotationWidget::settingLiveUpdate->setValue( checked );
}
4 changes: 4 additions & 0 deletions src/app/qgshtmlannotationdialog.cpp
Expand Up @@ -21,6 +21,8 @@
#include "qgsannotationmanager.h"
#include "qgsgui.h"
#include "qgshelp.h"
#include "qgssettingsentryimpl.h"

#include <QFileDialog>
#include <QFileInfo>
#include <QGraphicsScene>
Expand Down Expand Up @@ -66,6 +68,7 @@ QgsHtmlAnnotationDialog::QgsHtmlAnnotationDialog( QgsMapCanvasAnnotationItem *it
mButtonBox->addButton( deleteButton, QDialogButtonBox::RejectRole );

connect( mLiveCheckBox, &QCheckBox::toggled, this, &QgsHtmlAnnotationDialog::onLiveUpdateToggled );
mLiveCheckBox->setChecked( QgsAnnotationWidget::settingLiveUpdate->value() );
connect( mEmbeddedWidget, &QgsAnnotationWidget::changed, this, &QgsHtmlAnnotationDialog::onSettingsChanged );
connect( mHtmlSourceTextEdit, &QgsCodeEditorHTML::textChanged, this, &QgsHtmlAnnotationDialog::onSettingsChanged );
connect( mFileLineEdit, &QLineEdit::textChanged, this, &QgsHtmlAnnotationDialog::onSettingsChanged );
Expand Down Expand Up @@ -162,4 +165,5 @@ void QgsHtmlAnnotationDialog::onLiveUpdateToggled( bool checked )
// Apply and Cancel buttons make no sense when live update is on
mButtonBox->button( QDialogButtonBox::Apply )->setHidden( checked );
mButtonBox->button( QDialogButtonBox::Cancel )->setHidden( checked );
QgsAnnotationWidget::settingLiveUpdate->setValue( checked );
}
4 changes: 4 additions & 0 deletions src/app/qgssvgannotationdialog.cpp
Expand Up @@ -23,6 +23,8 @@
#include "qgsannotationmanager.h"
#include "qgsgui.h"
#include "qgshelp.h"
#include "qgssettingsentryimpl.h"

#include <QFileDialog>
#include <QFileInfo>
#include <QGraphicsScene>
Expand Down Expand Up @@ -61,6 +63,7 @@ QgsSvgAnnotationDialog::QgsSvgAnnotationDialog( QgsMapCanvasAnnotationItem *item
mButtonBox->addButton( deleteButton, QDialogButtonBox::RejectRole );

connect( mLiveCheckBox, &QCheckBox::toggled, this, &QgsSvgAnnotationDialog::onLiveUpdateToggled );
mLiveCheckBox->setChecked( QgsAnnotationWidget::settingLiveUpdate->value() );
connect( mEmbeddedWidget, &QgsAnnotationWidget::changed, this, &QgsSvgAnnotationDialog::onSettingsChanged );
connect( mFileLineEdit, &QLineEdit::textChanged, this, &QgsSvgAnnotationDialog::onSettingsChanged );
connect( mLiveCheckBox, &QCheckBox::toggled, this, &QgsSvgAnnotationDialog::onSettingsChanged );
Expand Down Expand Up @@ -136,4 +139,5 @@ void QgsSvgAnnotationDialog::onLiveUpdateToggled( bool checked )
// Apply and Cancel buttons make no sense when live update is on
mButtonBox->button( QDialogButtonBox::Apply )->setHidden( checked );
mButtonBox->button( QDialogButtonBox::Cancel )->setHidden( checked );
QgsAnnotationWidget::settingLiveUpdate->setValue( checked );
}
3 changes: 3 additions & 0 deletions src/app/qgstextannotationdialog.cpp
Expand Up @@ -24,6 +24,7 @@
#include "qgsgui.h"
#include "qgshelp.h"
#include "qgsfillsymbol.h"
#include "qgssettingsentryimpl.h"

#include <QColorDialog>
#include <QGraphicsScene>
Expand Down Expand Up @@ -71,6 +72,7 @@ QgsTextAnnotationDialog::QgsTextAnnotationDialog( QgsMapCanvasAnnotationItem *it


connect( mLiveCheckBox, &QCheckBox::toggled, this, &QgsTextAnnotationDialog::onLiveUpdateToggled );
mLiveCheckBox->setChecked( QgsAnnotationWidget::settingLiveUpdate->value() );
connect( mLiveCheckBox, &QCheckBox::toggled, this, &QgsTextAnnotationDialog::onSettingsChanged );
connect( mEmbeddedWidget, &QgsAnnotationWidget::changed, this, &QgsTextAnnotationDialog::onSettingsChanged );
connect( mTextEdit, &QTextEdit::textChanged, this, &QgsTextAnnotationDialog::onSettingsChanged );
Expand Down Expand Up @@ -200,4 +202,5 @@ void QgsTextAnnotationDialog::onLiveUpdateToggled( bool checked )
// Apply and Cancel buttons make no sense when live update is on
mButtonBox->button( QDialogButtonBox::Apply )->setHidden( checked );
mButtonBox->button( QDialogButtonBox::Cancel )->setHidden( checked );
QgsAnnotationWidget::settingLiveUpdate->setValue( checked );
}
1 change: 1 addition & 0 deletions src/core/settings/qgssettingstree.h
Expand Up @@ -62,6 +62,7 @@ class CORE_EXPORT QgsSettingsTree
static inline QgsSettingsTreeNode *sTreeSvg = treeRoot()->createChildNode( QStringLiteral( "svg" ) );
static inline QgsSettingsTreeNode *sTreeWms = treeRoot()->createChildNode( QStringLiteral( "wms" ) );
static inline QgsSettingsTreeNode *sTreeMeasure = treeRoot()->createChildNode( QStringLiteral( "measure" ) );
static inline QgsSettingsTreeNode *sTreeAnnotations = treeRoot()->createChildNode( QStringLiteral( "annotations" ) );

#endif

Expand Down

0 comments on commit 9488e0b

Please sign in to comment.