Skip to content

Commit 0fccb07

Browse files
nirvnNathanW2
authored andcommitted
[gui] improve load min/max widget UI/UX (#3253)
1 parent f470dfb commit 0fccb07

7 files changed

+110
-160
lines changed

src/gui/raster/qgsmultibandcolorrendererwidget.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ QgsMultiBandColorRendererWidget::QgsMultiBandColorRendererWidget( QgsRasterLayer
3737
mMinMaxWidget = new QgsRasterMinMaxWidget( layer, this );
3838
mMinMaxWidget->setExtent( extent );
3939
mMinMaxWidget->setMapCanvas( mCanvas );
40-
layout()->addWidget( mMinMaxWidget );
40+
QHBoxLayout *layout = new QHBoxLayout();
41+
layout->setContentsMargins( 0, 0, 0, 0 );
42+
mMinMaxContainerWidget->setLayout( layout );
43+
layout->addWidget( mMinMaxWidget );
4144
connect( mMinMaxWidget, SIGNAL( load( int, double, double, int ) ),
4245
this, SLOT( loadMinMax( int, double, double, int ) ) );
4346

src/gui/raster/qgsrasterminmaxwidget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ QgsMapCanvas* QgsRasterMinMaxWidget::mapCanvas()
6464

6565
QgsRectangle QgsRasterMinMaxWidget::extent()
6666
{
67-
if ( !mCurrentExtentRadioButton->isChecked() )
67+
if ( !cbxClipExtent->isChecked() )
6868
return QgsRectangle();
6969

7070
if ( mLayer && mCanvas )
@@ -91,7 +91,7 @@ void QgsRasterMinMaxWidget::on_mLoadPushButton_clicked()
9191
double myMax = std::numeric_limits<double>::quiet_NaN();
9292

9393
QgsRectangle myExtent = extent(); // empty == full
94-
if ( mCurrentExtentRadioButton->isChecked() )
94+
if ( cbxClipExtent->isChecked() )
9595
{
9696
origin |= QgsRasterRenderer::MinMaxSubExtent;
9797
}
@@ -102,7 +102,7 @@ void QgsRasterMinMaxWidget::on_mLoadPushButton_clicked()
102102
QgsDebugMsg( QString( "myExtent.isEmpty() = %1" ).arg( myExtent.isEmpty() ) );
103103

104104
int mySampleSize = sampleSize(); // 0 == exact
105-
if ( mEstimateRadioButton->isChecked() )
105+
if ( cboAccuracy->currentIndex() == 0 )
106106
{
107107
origin |= QgsRasterRenderer::MinMaxEstimated;
108108
}

src/gui/raster/qgsrasterminmaxwidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class GUI_EXPORT QgsRasterMinMaxWidget: public QWidget, private Ui::QgsRasterMin
6262
QgsRectangle extent();
6363

6464
/** Return the selected sample size. */
65-
int sampleSize() { return mEstimateRadioButton->isChecked() ? 250000 : 0; }
65+
int sampleSize() { return cboAccuracy->currentIndex() == 0 ? 250000 : 0; }
6666

6767
// Load programmaticaly with current values
6868
void load() { on_mLoadPushButton_clicked(); }

src/ui/qgsmultibandcolorrendererwidgetbase.ui

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ enhancement</string>
156156
</property>
157157
</widget>
158158
</item>
159-
<item row="3" column="4">
159+
<item row="3" column="2">
160160
<widget class="QLineEdit" name="mGreenMinLineEdit">
161161
<property name="maxLength">
162162
<number>16</number>
@@ -209,7 +209,7 @@ enhancement</string>
209209
</property>
210210
</widget>
211211
</item>
212-
<item row="3" column="2">
212+
<item row="3" column="4">
213213
<widget class="QLineEdit" name="mGreenMaxLineEdit">
214214
<property name="maxLength">
215215
<number>16</number>
@@ -218,6 +218,9 @@ enhancement</string>
218218
</item>
219219
</layout>
220220
</item>
221+
<item row="4" column="0" colspan="5">
222+
<widget class="QWidget" name="mMinMaxContainerWidget" native="true"/>
223+
</item>
221224
</layout>
222225
</widget>
223226
<tabstops>

src/ui/qgsrasterminmaxwidgetbase.ui

Lines changed: 71 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,23 @@
2727
<number>0</number>
2828
</property>
2929
<item>
30-
<widget class="QGroupBox" name="mLoadMinMaxValuesGroupBox">
30+
<widget class="QgsCollapsibleGroupBox" name="mLoadMinMaxValuesGroupBox">
3131
<property name="title">
3232
<string>Load min/max values</string>
3333
</property>
3434
<property name="flat">
3535
<bool>true</bool>
3636
</property>
37+
<property name="checkable">
38+
<bool>false</bool>
39+
</property>
40+
<property name="collapsed" stdset="0">
41+
<bool>true</bool>
42+
</property>
43+
<property name="saveCollapsedState" stdset="0">
44+
<bool>false</bool>
45+
</property>
3746
<layout class="QVBoxLayout" name="verticalLayout_4">
38-
<property name="leftMargin">
39-
<number>6</number>
40-
</property>
41-
<property name="topMargin">
42-
<number>6</number>
43-
</property>
44-
<property name="rightMargin">
45-
<number>6</number>
46-
</property>
47-
<property name="bottomMargin">
48-
<number>6</number>
49-
</property>
5047
<item>
5148
<layout class="QHBoxLayout" name="horizontalLayout">
5249
<item>
@@ -174,121 +171,68 @@ standard deviation ×</string>
174171
</item>
175172
</layout>
176173
</item>
177-
<item>
178-
<layout class="QHBoxLayout" name="horizontalLayout_2">
179-
<property name="spacing">
180-
<number>3</number>
174+
175+
<item>
176+
<layout class="QHBoxLayout" name="horizontalLayout_1">
177+
<item>
178+
<widget class="QPushButton" name="mLoadPushButton">
179+
<property name="text">
180+
<string>Load</string>
181+
</property>
182+
</widget>
183+
</item>
184+
<item>
185+
<spacer name="horizontalSpacer_7">
186+
<property name="orientation">
187+
<enum>Qt::Horizontal</enum>
188+
</property>
189+
<property name="sizeHint" stdset="0">
190+
<size>
191+
<width>0</width>
192+
<height>20</height>
193+
</size>
194+
</property>
195+
</spacer>
196+
</item>
197+
<item>
198+
<widget class="QLabel" name="mColorInterpolationLabel_2">
199+
<property name="text">
200+
<string>Accuracy</string>
201+
</property>
202+
</widget>
203+
</item>
204+
<item>
205+
<widget class="QComboBox" name="cboAccuracy">
206+
<item>
207+
<property name="text">
208+
<string>Estimate (faster)</string>
181209
</property>
182-
<item>
183-
<widget class="QGroupBox" name="mExtentGroupBox">
184-
<layout class="QVBoxLayout" name="verticalLayout_2">
185-
<property name="leftMargin">
186-
<number>0</number>
187-
</property>
188-
<property name="topMargin">
189-
<number>0</number>
190-
</property>
191-
<property name="rightMargin">
192-
<number>0</number>
193-
</property>
194-
<property name="bottomMargin">
195-
<number>0</number>
196-
</property>
197-
<item>
198-
<widget class="QLabel" name="label_3">
199-
<property name="text">
200-
<string>Extent</string>
201-
</property>
202-
</widget>
203-
</item>
204-
<item>
205-
<widget class="QRadioButton" name="mFullExtentRadioButton">
206-
<property name="text">
207-
<string>Full</string>
208-
</property>
209-
<property name="checked">
210-
<bool>true</bool>
211-
</property>
212-
</widget>
213-
</item>
214-
<item>
215-
<widget class="QRadioButton" name="mCurrentExtentRadioButton">
216-
<property name="text">
217-
<string>Current</string>
218-
</property>
219-
</widget>
220-
</item>
221-
</layout>
222-
</widget>
223-
</item>
224-
<item>
225-
<widget class="QGroupBox" name="mAccuracyGroupBox">
226-
<layout class="QVBoxLayout" name="verticalLayout">
227-
<property name="leftMargin">
228-
<number>0</number>
229-
</property>
230-
<property name="topMargin">
231-
<number>0</number>
232-
</property>
233-
<property name="rightMargin">
234-
<number>0</number>
235-
</property>
236-
<property name="bottomMargin">
237-
<number>0</number>
238-
</property>
239-
<item>
240-
<widget class="QLabel" name="label_5">
241-
<property name="text">
242-
<string>Accuracy</string>
243-
</property>
244-
</widget>
245-
</item>
246-
<item>
247-
<widget class="QRadioButton" name="mEstimateRadioButton">
248-
<property name="text">
249-
<string>Estimate (faster)</string>
250-
</property>
251-
<property name="checked">
252-
<bool>true</bool>
253-
</property>
254-
</widget>
255-
</item>
256-
<item>
257-
<widget class="QRadioButton" name="mActualRadioButton">
258-
<property name="text">
259-
<string>Actual (slower)</string>
260-
</property>
261-
</widget>
262-
</item>
263-
</layout>
264-
</widget>
265-
</item>
266-
</layout>
267-
</item>
268-
<item>
269-
<layout class="QHBoxLayout" name="horizontalLayout_4">
270-
<item>
271-
<spacer name="horizontalSpacer_5">
272-
<property name="orientation">
273-
<enum>Qt::Horizontal</enum>
274-
</property>
275-
<property name="sizeHint" stdset="0">
276-
<size>
277-
<width>0</width>
278-
<height>20</height>
279-
</size>
280-
</property>
281-
</spacer>
282-
</item>
283-
<item>
284-
<widget class="QPushButton" name="mLoadPushButton">
285-
<property name="text">
286-
<string>Load</string>
287-
</property>
288-
</widget>
289-
</item>
290-
</layout>
291-
</item>
210+
</item>
211+
<item>
212+
<property name="text">
213+
<string>Actual (slower)</string>
214+
</property>
215+
</item>
216+
</widget>
217+
</item>
218+
</layout>
219+
</item>
220+
<item>
221+
<layout class="QHBoxLayout" name="horizontalLayout_6">
222+
<item>
223+
<widget class="QCheckBox" name="cbxClipExtent">
224+
<property name="text">
225+
<string>Clip extent to canvas</string>
226+
</property>
227+
<property name="checked">
228+
<bool>false</bool>
229+
</property>
230+
</widget>
231+
</item>
232+
</layout>
233+
</item>
234+
235+
292236
</layout>
293237
</widget>
294238
</item>

src/ui/qgsrendererrasterpropswidgetbase.ui

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -359,19 +359,6 @@
359359
</item>
360360
<item row="6" column="2" colspan="3">
361361
<layout class="QHBoxLayout" name="horizontalLayout_13">
362-
<item>
363-
<spacer name="horizontalSpacer_3">
364-
<property name="orientation">
365-
<enum>Qt::Horizontal</enum>
366-
</property>
367-
<property name="sizeHint" stdset="0">
368-
<size>
369-
<width>40</width>
370-
<height>20</height>
371-
</size>
372-
</property>
373-
</spacer>
374-
</item>
375362
<item>
376363
<widget class="QToolButton" name="mResetColorRenderingBtn">
377364
<property name="toolTip">
@@ -436,6 +423,19 @@
436423
</layout>
437424
</widget>
438425
</item>
426+
<item row="7">
427+
<spacer name="verticalSpacer">
428+
<property name="orientation">
429+
<enum>Qt::Vertical</enum>
430+
</property>
431+
<property name="sizeHint" stdset="0">
432+
<size>
433+
<width>0</width>
434+
<height>0</height>
435+
</size>
436+
</property>
437+
</spacer>
438+
</item>
439439
</layout>
440440
</widget>
441441
<customwidgets>

0 commit comments

Comments
 (0)