Dynamically set number of columns to show in character widget

based on widget width, and avoid unnecessary horizontal scroll bar
This commit is contained in:
Nyall Dawson 2019-05-02 09:37:58 +10:00
parent ffe02c37b6
commit 243acb328f
6 changed files with 12 additions and 1 deletions

View File

@ -128,6 +128,8 @@ Emitted when a character is selected in the widget.
virtual void paintEvent( QPaintEvent *event );
virtual void resizeEvent( QResizeEvent *event );
};

View File

@ -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

View File

@ -256,3 +256,9 @@ void CharacterWidget::paintEvent( QPaintEvent *event )
}
}
}
void CharacterWidget::resizeEvent( QResizeEvent *event )
{
mColumns = event->size().width() / mSquareSize;
QWidget::resizeEvent( event );
}

View File

@ -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;

View File

@ -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" ) );

View File

@ -360,7 +360,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<width>0</width>
<height>40</height>
</size>
</property>