qgscomposerlabelwidget.cpp
1 |
/***************************************************************************
|
---|---|
2 |
qgscomposerlabelwidget.cpp
|
3 |
--------------------------
|
4 |
begin : June 10, 2008
|
5 |
copyright : (C) 2008 by Marco Hugentobler
|
6 |
email : marco dot hugentobler at karto dot baug dot ethz dot ch
|
7 |
***************************************************************************/
|
8 |
|
9 |
/***************************************************************************
|
10 |
* *
|
11 |
* This program is free software; you can redistribute it and/or modify *
|
12 |
* it under the terms of the GNU General Public License as published by *
|
13 |
* the Free Software Foundation; either version 2 of the License, or *
|
14 |
* (at your option) any later version. *
|
15 |
* *
|
16 |
***************************************************************************/
|
17 |
|
18 |
#include "qgscomposerlabelwidget.h" |
19 |
#include "qgscomposerlabel.h" |
20 |
#include "qgscomposeritemwidget.h" |
21 |
#include <QFontDialog> |
22 |
#include <QWidget> |
23 |
|
24 |
QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel* label ): QWidget(), mComposerLabel( label ) |
25 |
{ |
26 |
setupUi( this );
|
27 |
|
28 |
//add widget for general composer item properties
|
29 |
QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, label ); |
30 |
gridLayout->addWidget( itemPropertiesWidget, 5, 0, 1, 2 ); |
31 |
|
32 |
if ( mComposerLabel )
|
33 |
{ |
34 |
mTextEdit->setText( mComposerLabel->text() ); |
35 |
mMarginDoubleSpinBox->setValue( mComposerLabel->margin() ); |
36 |
} |
37 |
} |
38 |
|
39 |
void QgsComposerLabelWidget::on_mTextEdit_textChanged()
|
40 |
{ |
41 |
if ( mComposerLabel )
|
42 |
{ |
43 |
mComposerLabel->setText( mTextEdit->toPlainText() ); |
44 |
mComposerLabel->update(); |
45 |
} |
46 |
} |
47 |
|
48 |
void QgsComposerLabelWidget::on_mFontButton_clicked()
|
49 |
{ |
50 |
if ( mComposerLabel )
|
51 |
{ |
52 |
bool ok;
|
53 |
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && !defined(__LP64__) |
54 |
// Native Mac dialog works only for 64 bit Cocoa (observed in Qt 4.5.2, probably a Qt bug)
|
55 |
QFont newFont = QFontDialog::getFont( &ok, mComposerLabel->font(), this, QString(), QFontDialog::DontUseNativeDialog );
|
56 |
#else
|
57 |
QFont newFont = QFontDialog::getFont( &ok, mComposerLabel->font(), this );
|
58 |
#endif
|
59 |
if ( ok )
|
60 |
{ |
61 |
mComposerLabel->setFont( newFont ); |
62 |
mComposerLabel->update(); |
63 |
} |
64 |
} |
65 |
} |
66 |
|
67 |
void QgsComposerLabelWidget::on_mMarginDoubleSpinBox_valueChanged( double d ) |
68 |
{ |
69 |
if ( mComposerLabel )
|
70 |
{ |
71 |
mComposerLabel->setMargin( d ); |
72 |
mComposerLabel->update(); |
73 |
} |
74 |
} |
75 |
|