Skip to content

Commit ce66393

Browse files
committed
Add (non-functional) locator configuration dialog
1 parent 96d8f87 commit ce66393

File tree

10 files changed

+103
-29
lines changed

10 files changed

+103
-29
lines changed

python/gui/locator/qgslocatorwidget.sip

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ class QgsLocatorWidget : QWidget
4949
Triggers the locator widget to focus, open and start searching for a specified ``string``.
5050
%End
5151

52+
signals:
53+
54+
void configTriggered();
55+
%Docstring
56+
Emitted when the configure option is triggered in the widget.
57+
%End
58+
5259
protected:
5360

5461
virtual bool eventFilter( QObject *obj, QEvent *event );

src/app/locator/qgslocatoroptionswidget.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ QgsLocatorFiltersModel::QgsLocatorFiltersModel( QgsLocator *locator, QObject *pa
3737
: QAbstractTableModel( parent )
3838
, mLocator( locator )
3939
{
40-
40+
setHeaderData( Name, Qt::Horizontal, tr( "Filter" ) );
41+
setHeaderData( Prefix, Qt::Horizontal, tr( "Prefix" ) );
42+
setHeaderData( Active, Qt::Horizontal, tr( "Enabled" ) );
43+
setHeaderData( Default, Qt::Horizontal, tr( "Default" ) );
4144
}
4245

4346
int QgsLocatorFiltersModel::rowCount( const QModelIndex & ) const
@@ -111,8 +114,30 @@ Qt::ItemFlags QgsLocatorFiltersModel::flags( const QModelIndex &index ) const
111114
case Active:
112115
case Default:
113116
flags = flags | Qt::ItemIsUserCheckable;
117+
flags = flags | Qt::ItemIsEditable;
114118
break;
115119
}
116120

117121
return flags;
118122
}
123+
124+
QVariant QgsLocatorFiltersModel::zheaderData( int section, Qt::Orientation orientation, int role ) const
125+
{
126+
if ( orientation == Qt::Horizontal && role == Qt::SizeHintRole )
127+
{
128+
QSize size = QAbstractTableModel::headerData( section, orientation, role ).toSize();
129+
switch ( section )
130+
{
131+
case Name:
132+
break;
133+
case Prefix:
134+
case Active:
135+
case Default:
136+
size.setWidth( 100 );
137+
break;
138+
}
139+
return size;
140+
}
141+
142+
return QAbstractTableModel::headerData( section, orientation, role );
143+
}

src/app/locator/qgslocatoroptionswidget.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ class QgsLocatorFiltersModel : public QAbstractTableModel
7474
int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
7575
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
7676
Qt::ItemFlags flags( const QModelIndex &index ) const override;
77-
77+
QVariant zheaderData( int section, Qt::Orientation orientation,
78+
int role = Qt::DisplayRole ) const;
7879
private:
7980

8081
QgsLocator *mLocator = nullptr;

src/app/qgisapp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
967967
new QgsCredentialDialog( this );
968968

969969
mLocatorWidget->setMapCanvas( mMapCanvas );
970+
connect( mLocatorWidget, &QgsLocatorWidget::configTriggered, this, [ = ] { showOptionsDialog( this, QString( "mOptionsPageLocator" ) ); } );
970971

971972
qApp->processEvents();
972973

src/app/qgisapp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
563563
//! Returns map overview canvas
564564
QgsMapOverviewCanvas *mapOverviewCanvas() { return mOverviewCanvas; }
565565

566+
QgsLocatorWidget *locatorWidget() { return mLocatorWidget; }
567+
566568
//! show layer properties
567569
void showLayerProperties( QgsMapLayer *ml );
568570

src/app/qgsoptions.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#include "qgsclipboard.h"
4848
#include "qgssettings.h"
4949
#include "qgsoptionswidgetfactory.h"
50+
#include "qgslocatorwidget.h"
51+
#include "qgslocatoroptionswidget.h"
5052

5153
#include <QInputDialog>
5254
#include <QFileDialog>
@@ -940,6 +942,12 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
940942
mVariableEditor->reloadContext();
941943
mVariableEditor->setEditableScopeIndex( 0 );
942944

945+
// locator
946+
mLocatorOptionsWidget = new QgsLocatorOptionsWidget( QgisApp::instance()->locatorWidget()->locator(), this );
947+
QVBoxLayout *locatorLayout = new QVBoxLayout();
948+
locatorLayout->addWidget( mLocatorOptionsWidget );
949+
mOptionsLocatorGroupBox->setLayout( locatorLayout );
950+
943951
mAdvancedSettingsEditor->setSettingsObject( mSettings );
944952

945953
Q_FOREACH ( QgsOptionsWidgetFactory *factory, optionsFactories )

src/app/qgsoptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
class QgsExpressionContext;
3333
class QgsOptionsPageWidget;
34+
class QgsLocatorOptionsWidget;
3435

3536
/**
3637
* \class QgsOptions
@@ -254,6 +255,7 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
254255
private:
255256

256257
QList< QgsOptionsPageWidget * > mAdditionalOptionWidgets;
258+
QgsLocatorOptionsWidget *mLocatorOptionsWidget = nullptr;
257259

258260
};
259261

src/gui/locator/qgslocatorwidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ void QgsLocatorWidget::configMenuAboutToShow()
268268
}
269269
mMenu->addSeparator();
270270
QAction *configAction = new QAction( trUtf8( "Configure…" ), mMenu );
271+
connect( configAction, &QAction::triggered, this, &QgsLocatorWidget::configTriggered );
271272
mMenu->addAction( configAction );
272273

273274
}

src/gui/locator/qgslocatorwidget.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ class GUI_EXPORT QgsLocatorWidget : public QWidget
7474
*/
7575
void search( const QString &string );
7676

77+
signals:
78+
79+
/**
80+
* Emitted when the configure option is triggered in the widget.
81+
*/
82+
void configTriggered();
83+
7784
protected:
7885

7986
bool eventFilter( QObject *obj, QEvent *event ) override;

src/ui/qgsoptionsbase.ui

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,15 @@
269269
<normaloff>:/images/themes/default/mIconExpression.svg</normaloff>:/images/themes/default/mIconExpression.svg</iconset>
270270
</property>
271271
</item>
272+
<item>
273+
<property name="text">
274+
<string>Locator</string>
275+
</property>
276+
<property name="icon">
277+
<iconset resource="../../images/images.qrc">
278+
<normaloff>:/images/themes/default/search.svg</normaloff>:/images/themes/default/search.svg</iconset>
279+
</property>
280+
</item>
272281
<item>
273282
<property name="text">
274283
<string>Advanced</string>
@@ -311,7 +320,7 @@
311320
<item>
312321
<widget class="QStackedWidget" name="mOptionsStackedWidget">
313322
<property name="currentIndex">
314-
<number>2</number>
323+
<number>15</number>
315324
</property>
316325
<widget class="QWidget" name="mOptionsPageGeneral">
317326
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -340,8 +349,8 @@
340349
<rect>
341350
<x>0</x>
342351
<y>0</y>
343-
<width>691</width>
344-
<height>702</height>
352+
<width>856</width>
353+
<height>679</height>
345354
</rect>
346355
</property>
347356
<layout class="QVBoxLayout" name="verticalLayout_28">
@@ -1026,8 +1035,8 @@
10261035
<rect>
10271036
<x>0</x>
10281037
<y>0</y>
1029-
<width>579</width>
1030-
<height>1110</height>
1038+
<width>429</width>
1039+
<height>1009</height>
10311040
</rect>
10321041
</property>
10331042
<layout class="QVBoxLayout" name="verticalLayout_22">
@@ -1556,8 +1565,8 @@
15561565
<rect>
15571566
<x>0</x>
15581567
<y>0</y>
1559-
<width>843</width>
1560-
<height>787</height>
1568+
<width>856</width>
1569+
<height>679</height>
15611570
</rect>
15621571
</property>
15631572
<layout class="QVBoxLayout" name="verticalLayout_27">
@@ -1924,8 +1933,8 @@
19241933
<rect>
19251934
<x>0</x>
19261935
<y>0</y>
1927-
<width>713</width>
1928-
<height>1110</height>
1936+
<width>541</width>
1937+
<height>827</height>
19291938
</rect>
19301939
</property>
19311940
<layout class="QGridLayout" name="gridLayout_22">
@@ -2675,8 +2684,8 @@
26752684
<rect>
26762685
<x>0</x>
26772686
<y>0</y>
2678-
<width>151</width>
2679-
<height>239</height>
2687+
<width>112</width>
2688+
<height>219</height>
26802689
</rect>
26812690
</property>
26822691
<layout class="QHBoxLayout" name="horizontalLayout_46">
@@ -2826,8 +2835,8 @@
28262835
<rect>
28272836
<x>0</x>
28282837
<y>0</y>
2829-
<width>523</width>
2830-
<height>370</height>
2838+
<width>453</width>
2839+
<height>281</height>
28312840
</rect>
28322841
</property>
28332842
<layout class="QVBoxLayout" name="verticalLayout_25">
@@ -3169,8 +3178,8 @@
31693178
<rect>
31703179
<x>0</x>
31713180
<y>0</y>
3172-
<width>640</width>
3173-
<height>660</height>
3181+
<width>506</width>
3182+
<height>533</height>
31743183
</rect>
31753184
</property>
31763185
<layout class="QVBoxLayout" name="verticalLayout_30">
@@ -3613,8 +3622,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
36133622
<rect>
36143623
<x>0</x>
36153624
<y>0</y>
3616-
<width>509</width>
3617-
<height>623</height>
3625+
<width>393</width>
3626+
<height>530</height>
36183627
</rect>
36193628
</property>
36203629
<layout class="QVBoxLayout" name="verticalLayout_39">
@@ -3882,8 +3891,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
38823891
<rect>
38833892
<x>0</x>
38843893
<y>0</y>
3885-
<width>572</width>
3886-
<height>828</height>
3894+
<width>488</width>
3895+
<height>612</height>
38873896
</rect>
38883897
</property>
38893898
<layout class="QVBoxLayout" name="verticalLayout_31">
@@ -4460,8 +4469,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
44604469
<rect>
44614470
<x>0</x>
44624471
<y>0</y>
4463-
<width>435</width>
4464-
<height>402</height>
4472+
<width>345</width>
4473+
<height>350</height>
44654474
</rect>
44664475
</property>
44674476
<layout class="QVBoxLayout" name="verticalLayout_6">
@@ -4599,8 +4608,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
45994608
<rect>
46004609
<x>0</x>
46014610
<y>0</y>
4602-
<width>437</width>
4603-
<height>584</height>
4611+
<width>332</width>
4612+
<height>499</height>
46044613
</rect>
46054614
</property>
46064615
<layout class="QGridLayout" name="gridLayout_15">
@@ -4812,8 +4821,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
48124821
<rect>
48134822
<x>0</x>
48144823
<y>0</y>
4815-
<width>292</width>
4816-
<height>258</height>
4824+
<width>221</width>
4825+
<height>201</height>
48174826
</rect>
48184827
</property>
48194828
<layout class="QVBoxLayout" name="verticalLayout_32">
@@ -4921,8 +4930,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
49214930
<rect>
49224931
<x>0</x>
49234932
<y>0</y>
4924-
<width>534</width>
4925-
<height>790</height>
4933+
<width>393</width>
4934+
<height>618</height>
49264935
</rect>
49274936
</property>
49284937
<layout class="QVBoxLayout" name="verticalLayout_33">
@@ -5336,6 +5345,17 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
53365345
</item>
53375346
</layout>
53385347
</widget>
5348+
<widget class="QWidget" name="mOptionsLocatorSettings">
5349+
<layout class="QHBoxLayout" name="horizontalLayout_6">
5350+
<item>
5351+
<widget class="QGroupBox" name="mOptionsLocatorGroupBox">
5352+
<property name="title">
5353+
<string>Locator Filters</string>
5354+
</property>
5355+
</widget>
5356+
</item>
5357+
</layout>
5358+
</widget>
53395359
<widget class="QWidget" name="mOptionsPageSettingsEditor">
53405360
<layout class="QVBoxLayout" name="verticalLayout_43">
53415361
<item>

0 commit comments

Comments
 (0)