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