Skip to content
Permalink
Browse files

Expression widget ux fixes (#8194)

* Add default custom function file

* Set default size of custom expression list
  • Loading branch information
NathanW2 committed Oct 15, 2018
1 parent 0fb0023 commit bc51a60ee4413a3d9dd312382e13949b65971c45
Showing with 49 additions and 6 deletions.
  1. +13 −0 src/gui/qgsexpressionbuilderwidget.cpp
  2. +36 −6 src/ui/qgsexpressionbuilder.ui
@@ -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() );
@@ -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 )
@@ -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">
@@ -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>
@@ -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>

0 comments on commit bc51a60

Please sign in to comment.
You can’t perform that action at this time.