Skip to content

Commit

Permalink
font symbol: add preview in selected font, revert line edit to defaul…
Browse files Browse the repository at this point in the history
…t font and single character replacement. Insert only with Ctrl or if there is already more than one character selected (followup 46eeaa0)
  • Loading branch information
jef-n committed Jun 30, 2019
1 parent d96c738 commit 165b5c2
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
20 changes: 17 additions & 3 deletions src/gui/symbology/qgssymbollayerwidget.cpp
Expand Up @@ -3319,7 +3319,7 @@ void QgsFontMarkerSymbolLayerWidget::setSymbolLayer( QgsSymbolLayer *layer )
}
widgetChar->blockSignals( false );
whileBlocking( mCharLineEdit )->setText( mLayer->character() );
mCharLineEdit->setFont( layerFont );
mCharPreview->setFont( layerFont );

//block
whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
Expand Down Expand Up @@ -3369,7 +3369,7 @@ void QgsFontMarkerSymbolLayerWidget::setFontFamily( const QFont &font )
{
mLayer->setFontFamily( font.family() );
widgetChar->setFont( font );
mCharLineEdit->setFont( font );
mCharPreview->setFont( font );
emit changed();
}

Expand Down Expand Up @@ -3400,6 +3400,8 @@ void QgsFontMarkerSymbolLayerWidget::setAngle( double angle )

void QgsFontMarkerSymbolLayerWidget::setCharacterFromText( const QString &text )
{
mCharPreview->setText( text );

if ( text.isEmpty() )
return;

Expand All @@ -3410,7 +3412,10 @@ void QgsFontMarkerSymbolLayerWidget::setCharacterFromText( const QString &text )
bool ok = false;
unsigned int value = text.toUInt( &ok, 0 );
if ( ok )
{
character = QChar( value );
mCharPreview->setText( character );
}
}

if ( character != mLayer->character() )
Expand All @@ -3430,7 +3435,16 @@ void QgsFontMarkerSymbolLayerWidget::setCharacterFromText( const QString &text )

void QgsFontMarkerSymbolLayerWidget::setCharacter( QChar chr )
{
mCharLineEdit->insert( chr );
if ( mLayer->character().length() > 1 || QGuiApplication::keyboardModifiers() & Qt::ControlModifier )
{
mCharLineEdit->insert( chr );
return;
}

mLayer->setCharacter( chr );
whileBlocking( mCharLineEdit )->setText( chr );
mCharPreview->setText( chr );
emit changed();
}

void QgsFontMarkerSymbolLayerWidget::setOffset()
Expand Down
39 changes: 28 additions & 11 deletions src/ui/symbollayer/widget_fontmarker.ui
Expand Up @@ -71,7 +71,7 @@
</property>
</widget>
</item>
<item row="4" column="3">
<item row="4" column="4">
<widget class="QgsPropertyOverrideButton" name="mStrokeWidthDDBtn">
<property name="text">
<string>…</string>
Expand Down Expand Up @@ -178,7 +178,7 @@
</property>
</widget>
</item>
<item row="3" column="3">
<item row="3" column="4">
<widget class="QgsPropertyOverrideButton" name="mStrokeColorDDBtn">
<property name="text">
<string>…</string>
Expand Down Expand Up @@ -260,21 +260,21 @@
</item>
</widget>
</item>
<item row="2" column="3">
<item row="2" column="4">
<widget class="QgsPropertyOverrideButton" name="mColorDDBtn">
<property name="text">
<string>…</string>
</property>
</widget>
</item>
<item row="11" column="3">
<item row="11" column="4">
<widget class="QgsPropertyOverrideButton" name="mHorizontalAnchorDDBtn">
<property name="text">
<string>…</string>
</property>
</widget>
</item>
<item row="9" column="3">
<item row="9" column="4">
<widget class="QgsPropertyOverrideButton" name="mOffsetDDBtn">
<property name="text">
<string>…</string>
Expand Down Expand Up @@ -303,7 +303,7 @@
</property>
</widget>
</item>
<item row="10" column="3">
<item row="10" column="4">
<widget class="QgsPropertyOverrideButton" name="mVerticalAnchorDDBtn">
<property name="text">
<string>…</string>
Expand All @@ -324,21 +324,21 @@
</property>
</widget>
</item>
<item row="14" column="3">
<item row="14" column="4">
<widget class="QgsPropertyOverrideButton" name="mCharDDBtn">
<property name="text">
<string>…</string>
</property>
</widget>
</item>
<item row="8" column="3">
<item row="8" column="4">
<widget class="QgsPropertyOverrideButton" name="mRotationDDBtn">
<property name="text">
<string>…</string>
</property>
</widget>
</item>
<item row="13" column="0" colspan="4">
<item row="13" column="0" colspan="5">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" rowspan="2">
<widget class="QgsScrollArea" name="scrollArea">
Expand Down Expand Up @@ -375,7 +375,7 @@
</item>
</layout>
</item>
<item row="6" column="3">
<item row="6" column="4">
<widget class="QgsPropertyOverrideButton" name="mJoinStyleDDBtn">
<property name="text">
<string>…</string>
Expand Down Expand Up @@ -473,13 +473,30 @@
</item>
</layout>
</item>
<item row="1" column="3">
<item row="1" column="4">
<widget class="QgsPropertyOverrideButton" name="mSizeDDBtn">
<property name="text">
<string>…</string>
</property>
</widget>
</item>
<item row="15" column="1" colspan="2">
<widget class="QLineEdit" name="mCharPreview">
<property name="toolTip">
<string>Type in characters directly, or enter a character's hexadecimal value.</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Preview</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
Expand Down

0 comments on commit 165b5c2

Please sign in to comment.