QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
18
19#include "characterwidget.h"
20
21#include "moc_qgscharacterselectordialog.cpp"
22
23QgsCharacterSelectorDialog::QgsCharacterSelectorDialog( QWidget *parent, Qt::WindowFlags fl )
24 : QDialog( parent, fl )
25 , mChar( QChar::Null )
26{
27 setupUi( this );
28 mCharWidget = new CharacterWidget( this );
29 mCharSelectScrollArea->setWidget( mCharWidget );
30 mCharSelectScrollArea->setVerticalOnly( true );
31 connect( mCharWidget, &CharacterWidget::characterSelected, this, &QgsCharacterSelectorDialog::setCharacter );
32}
33
34QChar QgsCharacterSelectorDialog::selectCharacter( bool *gotChar, const QFont &font, const QString &style, QChar initialSelection )
35{
36 mCharSelectLabelFont->setText( QStringLiteral( "%1 %2" ).arg( font.family(), style ) );
37 mCharWidget->setFont( font );
38 mCharWidget->setFontStyle( style );
39 mCharWidget->setFontSize( 22.0 );
40 mCharSelectScrollArea->viewport()->update();
41
42 mCharWidget->setCharacter( initialSelection );
43
44 QApplication::setOverrideCursor( Qt::ArrowCursor );
45 const int res = exec();
46 QApplication::restoreOverrideCursor();
47
48 if ( res == QDialog::Accepted )
49 {
50 if ( !mChar.isNull() && gotChar )
51 {
52 *gotChar = true;
53 }
54 }
55 return mChar;
56}
57
58void QgsCharacterSelectorDialog::setCharacter( QChar chr )
59{
60 mChar = chr;
61}
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.
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)