Skip to content
Permalink
Browse files

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 1, 2019
1 parent ffe02c3 commit 243acb328fa1b95635b5a2e8ac5393a5a3ed9f69
@@ -128,6 +128,8 @@ Emitted when a character is selected in the widget.

virtual void paintEvent( QPaintEvent *event );

virtual void resizeEvent( QResizeEvent *event );


};

@@ -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
@@ -256,3 +256,9 @@ void CharacterWidget::paintEvent( QPaintEvent *event )
}
}
}

void CharacterWidget::resizeEvent( QResizeEvent *event )
{
mColumns = event->size().width() / mSquareSize;
QWidget::resizeEvent( event );
}
@@ -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;
@@ -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" ) );
@@ -360,7 +360,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<width>0</width>
<height>40</height>
</size>
</property>

0 comments on commit 243acb3

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