QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgscharacterselectordialog.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgscharacterselectordialog.cpp - single font character selector dialog
3
4 ---------------------
5 begin : November 2012
6 copyright : (C) 2012 by Larry Shaffer
7 email : larrys at dakcarto dot com
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#include "characterwidget.h"
19#include "moc_qgscharacterselectordialog.cpp"
20
21
22QgsCharacterSelectorDialog::QgsCharacterSelectorDialog( QWidget *parent, Qt::WindowFlags fl )
23 : QDialog( parent, fl )
24 , mChar( QChar::Null )
25{
26 setupUi( this );
27 mCharWidget = new CharacterWidget( this );
28 mCharSelectScrollArea->setWidget( mCharWidget );
29 mCharSelectScrollArea->setVerticalOnly( true );
30 connect( mCharWidget, &CharacterWidget::characterSelected, this, &QgsCharacterSelectorDialog::setCharacter );
31}
32
33QChar QgsCharacterSelectorDialog::selectCharacter( bool *gotChar, const QFont &font, const QString &style, QChar initialSelection )
34{
35 mCharSelectLabelFont->setText( QStringLiteral( "%1 %2" ).arg( font.family(), style ) );
36 mCharWidget->setFont( font );
37 mCharWidget->setFontStyle( style );
38 mCharWidget->setFontSize( 22.0 );
39 mCharSelectScrollArea->viewport()->update();
40
41 mCharWidget->setCharacter( initialSelection );
42
43 QApplication::setOverrideCursor( Qt::ArrowCursor );
44 const int res = exec();
45 QApplication::restoreOverrideCursor();
46
47 if ( res == QDialog::Accepted )
48 {
49 if ( !mChar.isNull() && gotChar )
50 {
51 *gotChar = true;
52 }
53 }
54 return mChar;
55}
56
57void QgsCharacterSelectorDialog::setCharacter( QChar chr )
58{
59 mChar = chr;
60}
A widget for displaying characters available in a preset font, and allowing users to select an indivi...
void characterSelected(QChar character)
Emitted when a character is selected in the widget.
void setFontStyle(const QString &fontStyle)
Sets the font style to show in the widget.
void setCharacter(QChar character)
Sets the currently selected character in the widget.
void setFont(const QFont &font)
Sets the font to show in the widget.
void setFontSize(double fontSize)
Sets the font size (in points) to render in the widget.
QChar selectCharacter(bool *gotChar, const QFont &font, const QString &style, QChar initialSelection=QChar())
Opens the dialog modally and returns when the user has selected a character.
QgsCharacterSelectorDialog(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)