QGIS API Documentation  3.6.0-Noosa (5873452)
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 
20 
21 QgsCharacterSelectorDialog::QgsCharacterSelectorDialog( QWidget *parent, Qt::WindowFlags fl )
22  : QDialog( parent, fl )
23  , mChar( QChar::Null )
24 {
25  setupUi( this );
26  mCharWidget = new CharacterWidget( this );
27  mCharSelectScrollArea->setWidget( mCharWidget );
28  connect( mCharWidget, &CharacterWidget::characterSelected, this, &QgsCharacterSelectorDialog::setCharacter );
29 }
30 
31 const QChar &QgsCharacterSelectorDialog::selectCharacter( bool *gotChar, const QFont &font, const QString &style )
32 {
33  mCharSelectLabelFont->setText( QStringLiteral( "%1 %2" ).arg( font.family(), style ) );
34  mCharWidget->setFont( font );
35  mCharWidget->setFontStyle( style );
36  mCharWidget->setFontSize( 22.0 );
37  mCharSelectScrollArea->viewport()->update();
38 
39  QApplication::setOverrideCursor( Qt::ArrowCursor );
40  int res = exec();
41  QApplication::restoreOverrideCursor();
42 
43  if ( res == QDialog::Accepted )
44  {
45  if ( !mChar.isNull() && gotChar )
46  {
47  *gotChar = true;
48  }
49  }
50  return mChar;
51 }
52 
53 void QgsCharacterSelectorDialog::setCharacter( QChar chr )
54 {
55  mChar = chr;
56 }
QgsCharacterSelectorDialog(QWidget *parent=nullptr, Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
A widget for displaying characters available in a preset font, and allowing users to select an indivi...
void setFontSize(double fontSize)
Sets the font size (in points) to render in the widget.
const QChar & selectCharacter(bool *gotChar, const QFont &font, const QString &style)
void setFont(const QFont &font)
Sets the font to show in the widget.
void setFontStyle(const QString &fontStyle)
Sets the font style to show in the widget.
void characterSelected(QChar character)
Emitted when a character is selected in the widget.