Skip to content

Commit

Permalink
Expression widget ux fixes (#8194)
Browse files Browse the repository at this point in the history
* Add default custom function file

* Set default size of custom expression list
  • Loading branch information
NathanW2 authored Oct 15, 2018
1 parent 0fb0023 commit bc51a60
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
13 changes: 13 additions & 0 deletions src/gui/qgsexpressionbuilderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
txtSearchEditValues->setShowSearchIcon( true );
txtSearchEditValues->setPlaceholderText( tr( "Search…" ) );

editorSplit->setSizes( QList<int>( {175, 300} ) );

QgsSettings settings;
splitter->restoreState( settings.value( QStringLiteral( "Windows/QgsExpressionBuilderWidget/splitter" ) ).toByteArray() );
editorSplit->restoreState( settings.value( QStringLiteral( "Windows/QgsExpressionBuilderWidget/editorsplitter" ) ).toByteArray() );
Expand Down Expand Up @@ -294,7 +296,18 @@ void QgsExpressionBuilderWidget::updateFunctionFileList( const QString &path )
cmbFileNames->addItem( item );
}
if ( !cmbFileNames->currentItem() )
{
cmbFileNames->setCurrentRow( 0 );
}

if ( cmbFileNames->count() == 0 )
{
// Create default sample entry.
newFunctionFile( "default" );
txtPython->setText( QString( "'''\n#Sample custom function file\n "
"(uncomment to use and customize or Add button to create a new file) \n%1 \n '''" ).arg( txtPython->text() ) );
saveFunctionFile( "default" );
}
}

void QgsExpressionBuilderWidget::newFunctionFile( const QString &fileName )
Expand Down
42 changes: 36 additions & 6 deletions src/ui/qgsexpressionbuilder.ui
Original file line number Diff line number Diff line change
Expand Up @@ -624,9 +624,27 @@
<property name="childrenCollapsible">
<bool>false</bool>
</property>
<widget class="QWidget" name="layoutWidget3">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QWidget" name="widget3" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QListWidget" name="cmbFileNames">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
Expand All @@ -645,7 +663,7 @@
</property>
</widget>
</item>
<item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="topMargin">
<number>0</number>
Expand Down Expand Up @@ -689,11 +707,23 @@ Change the name of the script and save to allow QGIS to auto load on startup.</s
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="bottomMargin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QgsCodeEditorPython" name="txtPython" native="true"/>
</item>
Expand Down

0 comments on commit bc51a60

Please sign in to comment.