~ubuntu-branches/ubuntu/maverick/qgis/maverick

« back to all changes in this revision

Viewing changes to src/app/composer/qgscomposerlabelwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 <QColorDialog>
 
22
#include <QFontDialog>
 
23
#include <QWidget>
 
24
 
 
25
QgsComposerLabelWidget::QgsComposerLabelWidget( QgsComposerLabel* label ): QWidget(), mComposerLabel( label )
 
26
{
 
27
  setupUi( this );
 
28
 
 
29
  //add widget for general composer item properties
 
30
  QgsComposerItemWidget* itemPropertiesWidget = new QgsComposerItemWidget( this, label );
 
31
  toolBox->addItem( itemPropertiesWidget, tr( "General options" ) );
 
32
 
 
33
  if ( mComposerLabel )
 
34
  {
 
35
    mTextEdit->setText( mComposerLabel->text() );
 
36
    mMarginDoubleSpinBox->setValue( mComposerLabel->margin() );
 
37
  }
 
38
}
 
39
 
 
40
void QgsComposerLabelWidget::on_mTextEdit_textChanged()
 
41
{
 
42
  if ( mComposerLabel )
 
43
  {
 
44
    mComposerLabel->setText( mTextEdit->toPlainText() );
 
45
    mComposerLabel->update();
 
46
  }
 
47
}
 
48
 
 
49
void QgsComposerLabelWidget::on_mFontButton_clicked()
 
50
{
 
51
  if ( mComposerLabel )
 
52
  {
 
53
    bool ok;
 
54
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && !defined(__LP64__)
 
55
    // Native Mac dialog works only for 64 bit Cocoa (observed in Qt 4.5.2, probably a Qt bug)
 
56
    QFont newFont = QFontDialog::getFont( &ok, mComposerLabel->font(), this, QString(), QFontDialog::DontUseNativeDialog );
 
57
#else
 
58
    QFont newFont = QFontDialog::getFont( &ok, mComposerLabel->font(), this );
 
59
#endif
 
60
    if ( ok )
 
61
    {
 
62
      mComposerLabel->setFont( newFont );
 
63
      mComposerLabel->update();
 
64
    }
 
65
  }
 
66
}
 
67
 
 
68
void QgsComposerLabelWidget::on_mMarginDoubleSpinBox_valueChanged( double d )
 
69
{
 
70
  if ( mComposerLabel )
 
71
  {
 
72
    mComposerLabel->setMargin( d );
 
73
    mComposerLabel->update();
 
74
  }
 
75
}
 
76
 
 
77
void QgsComposerLabelWidget::on_mFontColorButton_clicked()
 
78
{
 
79
  if ( !mComposerLabel )
 
80
  {
 
81
    return;
 
82
  }
 
83
  QColor newColor = QColorDialog::getColor( mComposerLabel->fontColor() );
 
84
  if ( !newColor.isValid() )
 
85
  {
 
86
    return;
 
87
  }
 
88
  mComposerLabel->setFontColor( newColor );
 
89
}
 
90