Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Dynamically set number of columns to show in character widget
based on widget width, and avoid unnecessary horizontal scroll bar
  • Loading branch information
nyalldawson committed May 2, 2019
1 parent ffe02c3 commit 243acb3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/gui/auto_generated/symbology/characterwidget.sip.in
Expand Up @@ -128,6 +128,8 @@ Emitted when a character is selected in the widget.

virtual void paintEvent( QPaintEvent *event );

virtual void resizeEvent( QResizeEvent *event );


};

Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsscrollarea.cpp
Expand Up @@ -16,6 +16,7 @@
#include <QEvent>
#include <QMouseEvent>
#include "qgsscrollarea.h"
#include <QScrollBar>

// milliseconds to swallow child wheel events for after a scroll occurs
#define TIMEOUT 1000
Expand Down
6 changes: 6 additions & 0 deletions src/gui/symbology/characterwidget.cpp
Expand Up @@ -256,3 +256,9 @@ void CharacterWidget::paintEvent( QPaintEvent *event )
}
}
}

void CharacterWidget::resizeEvent( QResizeEvent *event )
{
mColumns = event->size().width() / mSquareSize;
QWidget::resizeEvent( event );
}
1 change: 1 addition & 0 deletions src/gui/symbology/characterwidget.h
Expand Up @@ -161,6 +161,7 @@ class GUI_EXPORT CharacterWidget : public QWidget
void mouseMoveEvent( QMouseEvent *event ) override;
void mousePressEvent( QMouseEvent *event ) override;
void paintEvent( QPaintEvent *event ) override;
void resizeEvent( QResizeEvent *event ) override;

private:
QFont mDisplayFont;
Expand Down
1 change: 1 addition & 0 deletions src/gui/symbology/qgssymbollayerwidget.cpp
Expand Up @@ -3253,6 +3253,7 @@ QgsFontMarkerSymbolLayerWidget::QgsFontMarkerSymbolLayerWidget( QgsVectorLayer *

widgetChar = new CharacterWidget();
scrollArea->setWidget( widgetChar );
scrollArea->setVerticalOnly( true );

btnColor->setAllowOpacity( true );
btnColor->setColorDialogTitle( tr( "Select Symbol Fill Color" ) );
Expand Down
2 changes: 1 addition & 1 deletion src/ui/symbollayer/widget_fontmarker.ui
Expand Up @@ -360,7 +360,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<width>0</width>
<height>40</height>
</size>
</property>
Expand Down

0 comments on commit 243acb3

Please sign in to comment.