59 changes: 59 additions & 0 deletions src/gui/qgscharacterselectdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/***************************************************************************
qgscharacterselectdialog.cpp - single font character selector dialog
---------------------
begin : November 2012
copyright : (C) 2012 by Larry Shaffer
email : larrys at dakcarto dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "characterwidget.h"
#include "qgscharacterselectdialog.h"


QgsCharacterSelectorDialog::QgsCharacterSelectorDialog( QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl ), mChar( QChar::Null )
{
setupUi( this );
mCharWidget = new CharacterWidget( this );
mCharSelectScrollArea->setWidget( mCharWidget );
connect( mCharWidget, SIGNAL( characterSelected( const QChar & ) ), this, SLOT( setCharacter( const QChar & ) ) );
}

QgsCharacterSelectorDialog::~QgsCharacterSelectorDialog()
{
}

const QChar& QgsCharacterSelectorDialog::selectCharacter( bool* gotChar, const QFont& font, const QString& style )
{
mCharSelectLabelFont->setText( QString( "%1 %2" ).arg( font.family() ).arg( style ) );
mCharWidget->updateFont( font );
mCharWidget->updateStyle( style );
mCharWidget->updateSize( 22.0 );
mCharSelectScrollArea->viewport()->update();

QApplication::setOverrideCursor( Qt::ArrowCursor );
int res = exec();
QApplication::restoreOverrideCursor();

if ( res == QDialog::Accepted )
{
if ( !mChar.isNull() && gotChar )
{
*gotChar = true;
}
}
return mChar;
}

void QgsCharacterSelectorDialog::setCharacter( const QChar & chr )
{
mChar = chr;
}
49 changes: 49 additions & 0 deletions src/gui/qgscharacterselectdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/***************************************************************************
qgscharacterselectdialog.h - single font character selector dialog
---------------------
begin : November 2012
copyright : (C) 2012 by Larry Shaffer
email : larrys at dakcarto dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSCHARACTERSELECTDIALOG_H
#define QGSCHARACTERSELECTDIALOG_H

#include <QDialog>
#include <QChar>
#include "qgisgui.h"
#include "ui_qgscharacterselectdialogbase.h"

class CharacterWidget;

/** A dialog for selecting a single character from a single font
*/

class GUI_EXPORT QgsCharacterSelectorDialog : public QDialog, private Ui::QgsCharacterSelectorBase
{
Q_OBJECT

public:
QgsCharacterSelectorDialog( QWidget* parent = 0, Qt::WFlags fl = QgisGui::ModalDialogFlags );
~QgsCharacterSelectorDialog();

public slots:
const QChar& selectCharacter( bool* gotChar, const QFont& font, const QString& style );

private slots:
void setCharacter( const QChar& chr );

protected:
QChar mChar;
CharacterWidget* mCharWidget;
};

#endif
11 changes: 10 additions & 1 deletion src/gui/symbology-ng/characterwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ void CharacterWidget::updateFontMerging( bool enable )
update();
}

void CharacterWidget::updateColumns( int cols )
{
if ( columns == cols || cols < 1 )
return;
columns = cols;
adjustSize();
update();
}

//! [3]
QSize CharacterWidget::sizeHint() const
{
Expand All @@ -108,7 +117,7 @@ void CharacterWidget::mouseMoveEvent( QMouseEvent *event )
QPoint widgetPosition = mapFromGlobal( event->globalPos() );
uint key = ( widgetPosition.y() / squareSize ) * columns + widgetPosition.x() / squareSize;

QString text = tr( "<p>Character: <span style=\"font-size: 24pt; font-family: %1%2</span><p>Value: 0x%3\">" )
QString text = tr( "<p>Character: <span style=\"font-size: 24pt; font-family: %1\">%2</span><p>Value: 0x%3" )
.arg( displayFont.family() )
.arg( QChar( key ) )
.arg( key, 16 );
Expand Down
4 changes: 4 additions & 0 deletions src/gui/symbology-ng/characterwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ class CharacterWidget : public QWidget
CharacterWidget( QWidget *parent = 0 );
QSize sizeHint() const;

int getColumns() const { return columns; }
int getSquareSize() const { return squareSize; }

public slots:
void updateFont( const QFont &font );
void updateSize( double fontSize );
void updateStyle( const QString &fontStyle );
void updateFontMerging( bool enable );
void updateColumns( int cols );

signals:
void characterSelected( const QChar &character );
Expand Down
123 changes: 123 additions & 0 deletions src/ui/qgscharacterselectdialogbase.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsCharacterSelectorBase</class>
<widget class="QDialog" name="QgsCharacterSelectorBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="windowTitle">
<string>Character Selector</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="mCharSelectLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Font:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mCharSelectLabelFont">
<property name="text">
<string>Current font family and style</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QScrollArea" name="mCharSelectScrollArea">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="widgetResizable">
<bool>false</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>359</width>
<height>371</height>
</rect>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="mCharSelectButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>mCharSelectButtonBox</sender>
<signal>accepted()</signal>
<receiver>QgsCharacterSelectorBase</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>mCharSelectButtonBox</sender>
<signal>rejected()</signal>
<receiver>QgsCharacterSelectorBase</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
250 changes: 221 additions & 29 deletions src/ui/qgslabelingguibase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-448</y>
<width>686</width>
<height>714</height>
<height>834</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_17">
Expand All @@ -461,7 +461,7 @@
<property name="verticalSpacing">
<number>20</number>
</property>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QgsCollapsibleGroupBox" name="chkFormattedNumbers">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
Expand Down Expand Up @@ -1398,7 +1398,7 @@
</layout>
</widget>
</item>
<item row="11" column="0">
<item row="12" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
Expand Down Expand Up @@ -1495,31 +1495,6 @@
</property>
</widget>
</item>
<item row="0" column="2" colspan="2">
<widget class="QLabel" name="mFontLimitPixelLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(243, 243, 243);</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="text">
<string> Label in Map Units </string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>1</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="mFontLimitPixelLabel_2">
<property name="sizePolicy">
Expand All @@ -1546,6 +1521,31 @@
</property>
</spacer>
</item>
<item row="0" column="2" colspan="2">
<widget class="QLabel" name="mFontLimitPixelLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(243, 243, 243);</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="text">
<string> Label in Map Units </string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>1</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -1690,6 +1690,198 @@
</layout>
</widget>
</item>
<item row="8" column="0">
<widget class="QgsCollapsibleGroupBox" name="mDirectSymbGroupBox">
<property name="title">
<string>Line direction symbols</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item>
<widget class="QLabel" name="mDirectSymbLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Symbol(s)</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="mDirectSymbLeftToolBtn">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mDirectSymbLeftLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="mDirectSymbLabel_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(243, 243, 243);</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="text">
<string> Label </string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>1</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mDirectSymbRightLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="mDirectSymbRightToolBtn">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>22</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="mDirectSymbLabel_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Placement</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="mDirectSymbRadioBtnLR">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>left/right</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="mDirectSymbRadioBtnAbove">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>above</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="mDirectSymbRadioBtnBelow">
<property name="text">
<string>below</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="mDirectSymbRevChkBx">
<property name="text">
<string>Reverse direction</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
Expand Down