19
19
#include " pal/pal.h"
20
20
#include " qgshelp.h"
21
21
#include " qgsmessagebar.h"
22
-
22
+ #include " qgisapp.h"
23
+ #include " qgsmapcanvas.h"
24
+ #include " qgsgui.h"
23
25
#include < QPushButton>
24
26
#include < QMessageBox>
25
27
26
- QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog ( QWidget *parent )
27
- : QDialog ( parent )
28
+ QgsLabelEngineConfigWidget::QgsLabelEngineConfigWidget ( QWidget *parent )
29
+ : QgsPanelWidget ( parent )
28
30
{
29
31
setupUi ( this );
30
32
33
+ setPanelTitle ( tr ( " Placement Engine Settings" ) );
34
+
31
35
mMessageBar = new QgsMessageBar ();
32
36
mMessageBar ->setSizePolicy ( QSizePolicy::Minimum, QSizePolicy::Fixed );
33
37
verticalLayout->insertWidget ( 0 , mMessageBar );
34
38
35
- connect ( buttonBox, &QDialogButtonBox::accepted, this , &QgsLabelEngineConfigDialog::onOK );
36
- connect ( buttonBox, &QDialogButtonBox::helpRequested, this , &QgsLabelEngineConfigDialog::showHelp );
37
- connect ( buttonBox->button ( QDialogButtonBox::RestoreDefaults ), &QAbstractButton::clicked,
38
- this , &QgsLabelEngineConfigDialog::setDefaults );
39
-
40
39
QgsLabelingEngineSettings engineSettings = QgsProject::instance ()->labelingEngineSettings ();
41
40
42
41
mTextRenderFormatComboBox ->addItem ( tr ( " Always Render Labels as Paths (Recommended)" ), QgsRenderContext::TextFormatAlwaysOutlines );
@@ -73,9 +72,20 @@ QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QWidget *parent )
73
72
mUnplacedColorButton ->setWindowTitle ( tr ( " Unplaced Label Color" ) );
74
73
75
74
mTextRenderFormatComboBox ->setCurrentIndex ( mTextRenderFormatComboBox ->findData ( engineSettings.defaultTextRenderFormat () ) );
75
+
76
+ connect ( spinCandPoint, qgis::overload<int >::of ( &QSpinBox::valueChanged ), this , &QgsLabelEngineConfigWidget::widgetChanged );
77
+ connect ( spinCandLine, qgis::overload<int >::of ( &QSpinBox::valueChanged ), this , &QgsLabelEngineConfigWidget::widgetChanged );
78
+ connect ( spinCandPolygon, qgis::overload<int >::of ( &QSpinBox::valueChanged ), this , &QgsLabelEngineConfigWidget::widgetChanged );
79
+ connect ( chkShowCandidates, &QCheckBox::toggled, this , &QgsLabelEngineConfigWidget::widgetChanged );
80
+ connect ( chkShowAllLabels, &QCheckBox::toggled, this , &QgsLabelEngineConfigWidget::widgetChanged );
81
+ connect ( chkShowUnplaced, &QCheckBox::toggled, this , &QgsLabelEngineConfigWidget::widgetChanged );
82
+ connect ( chkShowPartialsLabels, &QCheckBox::toggled, this , &QgsLabelEngineConfigWidget::widgetChanged );
83
+ connect ( mTextRenderFormatComboBox , qgis::overload<int >::of ( &QComboBox::currentIndexChanged ), this , &QgsLabelEngineConfigWidget::widgetChanged );
84
+ connect ( mUnplacedColorButton , &QgsColorButton::colorChanged, this , &QgsLabelEngineConfigWidget::widgetChanged );
85
+ connect ( mPlacementVersionComboBox , qgis::overload<int >::of ( &QComboBox::currentIndexChanged ), this , &QgsLabelEngineConfigWidget::widgetChanged );
76
86
}
77
87
78
- void QgsLabelEngineConfigDialog::onOK ()
88
+ void QgsLabelEngineConfigWidget::apply ()
79
89
{
80
90
QgsLabelingEngineSettings engineSettings;
81
91
@@ -94,11 +104,10 @@ void QgsLabelEngineConfigDialog::onOK()
94
104
engineSettings.setPlacementVersion ( static_cast < QgsLabelingEngineSettings::PlacementEngineVersion >( mPlacementVersionComboBox ->currentData ().toInt () ) );
95
105
96
106
QgsProject::instance ()->setLabelingEngineSettings ( engineSettings );
97
-
98
- accept ();
107
+ QgisApp::instance ()->mapCanvas ()->refreshAllLayers ();
99
108
}
100
109
101
- void QgsLabelEngineConfigDialog ::setDefaults ()
110
+ void QgsLabelEngineConfigWidget ::setDefaults ()
102
111
{
103
112
pal::Pal p;
104
113
spinCandPoint->setValue ( p.maximumNumberOfPointCandidates () );
@@ -111,7 +120,37 @@ void QgsLabelEngineConfigDialog::setDefaults()
111
120
mPlacementVersionComboBox ->setCurrentIndex ( mPlacementVersionComboBox ->findData ( QgsLabelingEngineSettings::PlacementEngineVersion2 ) );
112
121
}
113
122
114
- void QgsLabelEngineConfigDialog ::showHelp ()
123
+ void QgsLabelEngineConfigWidget ::showHelp ()
115
124
{
116
125
QgsHelp::openHelp ( QStringLiteral ( " working_with_vector/vector_properties.html#setting-the-automated-placement-engine" ) );
117
126
}
127
+
128
+ //
129
+ // QgsLabelEngineConfigDialog
130
+ //
131
+
132
+ QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog ( QWidget *parent )
133
+ : QDialog( parent )
134
+ {
135
+ mWidget = new QgsLabelEngineConfigWidget ();
136
+ setWindowTitle ( mWidget ->windowTitle () );
137
+ QVBoxLayout *vLayout = new QVBoxLayout ();
138
+ vLayout->addWidget ( mWidget );
139
+ QDialogButtonBox *bbox = new QDialogButtonBox ( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::RestoreDefaults, Qt::Horizontal );
140
+ connect ( bbox, &QDialogButtonBox::accepted, this , &QDialog::accept );
141
+ connect ( bbox, &QDialogButtonBox::rejected, this , &QDialog::reject );
142
+ connect ( bbox, &QDialogButtonBox::helpRequested, mWidget , &QgsLabelEngineConfigWidget::showHelp );
143
+ connect ( bbox->button ( QDialogButtonBox::RestoreDefaults ), &QAbstractButton::clicked,
144
+ mWidget , &QgsLabelEngineConfigWidget::setDefaults );
145
+ vLayout->addWidget ( bbox );
146
+ setLayout ( vLayout );
147
+
148
+ setObjectName ( QStringLiteral ( " QgsLabelSettingsWidgetDialog" ) );
149
+ QgsGui::instance ()->enableAutoGeometryRestore ( this );
150
+ }
151
+
152
+ void QgsLabelEngineConfigDialog::accept ()
153
+ {
154
+ mWidget ->apply ();
155
+ QDialog::accept ();
156
+ }
0 commit comments