| 1 | #include "optionsform.h"
|
|---|
| 2 |
|
|---|
| 3 | #include <qbuttongroup.h>
|
|---|
| 4 | #include <qcombobox.h>
|
|---|
| 5 | #include <qfontdialog.h>
|
|---|
| 6 | #include <qframe.h>
|
|---|
| 7 | #include <qimage.h>
|
|---|
| 8 | #include <qlabel.h>
|
|---|
| 9 | #include <qlayout.h>
|
|---|
| 10 | #include <qpushbutton.h>
|
|---|
| 11 | #include <qradiobutton.h>
|
|---|
| 12 | #include <qspinbox.h>
|
|---|
| 13 |
|
|---|
| 14 | #include "images/options_horizontalbarchart.xpm"
|
|---|
| 15 | #include "images/options_piechart.xpm"
|
|---|
| 16 | #include "images/options_verticalbarchart.xpm"
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | OptionsForm::OptionsForm( QWidget* parent, const char* name,
|
|---|
| 20 | bool modal, WFlags f )
|
|---|
| 21 | : QDialog( parent, name, modal, f )
|
|---|
| 22 | {
|
|---|
| 23 | setCaption( "Chart -- Options" );
|
|---|
| 24 | resize( 320, 290 );
|
|---|
| 25 |
|
|---|
| 26 | optionsFormLayout = new QVBoxLayout( this, 11, 6 );
|
|---|
| 27 |
|
|---|
| 28 | chartTypeLayout = new QHBoxLayout( 0, 0, 6 );
|
|---|
| 29 |
|
|---|
| 30 | chartTypeTextLabel = new QLabel( "&Chart Type", this );
|
|---|
| 31 | chartTypeLayout->addWidget( chartTypeTextLabel );
|
|---|
| 32 |
|
|---|
| 33 | chartTypeComboBox = new QComboBox( FALSE, this );
|
|---|
| 34 | chartTypeComboBox->insertItem( QPixmap( options_piechart ), "Pie Chart" );
|
|---|
| 35 | chartTypeComboBox->insertItem( QPixmap( options_verticalbarchart ),
|
|---|
| 36 | "Vertical Bar Chart" );
|
|---|
| 37 | chartTypeComboBox->insertItem( QPixmap( options_horizontalbarchart ),
|
|---|
| 38 | "Horizontal Bar Chart" );
|
|---|
| 39 | chartTypeLayout->addWidget( chartTypeComboBox );
|
|---|
| 40 | optionsFormLayout->addLayout( chartTypeLayout );
|
|---|
| 41 |
|
|---|
| 42 | fontLayout = new QHBoxLayout( 0, 0, 6 );
|
|---|
| 43 |
|
|---|
| 44 | fontPushButton = new QPushButton( "&Font...", this );
|
|---|
| 45 | fontLayout->addWidget( fontPushButton );
|
|---|
| 46 | QSpacerItem* spacer = new QSpacerItem( 0, 0,
|
|---|
| 47 | QSizePolicy::Expanding,
|
|---|
| 48 | QSizePolicy::Minimum );
|
|---|
| 49 | fontLayout->addItem( spacer );
|
|---|
| 50 |
|
|---|
| 51 | fontTextLabel = new QLabel( this ); // Must be set by caller via setFont()
|
|---|
| 52 | fontLayout->addWidget( fontTextLabel );
|
|---|
| 53 | optionsFormLayout->addLayout( fontLayout );
|
|---|
| 54 |
|
|---|
| 55 | addValuesFrame = new QFrame( this );
|
|---|
| 56 | addValuesFrame->setFrameShape( QFrame::StyledPanel );
|
|---|
| 57 | addValuesFrame->setFrameShadow( QFrame::Sunken );
|
|---|
| 58 | addValuesFrameLayout = new QVBoxLayout( addValuesFrame, 11, 6 );
|
|---|
| 59 |
|
|---|
| 60 | addValuesButtonGroup = new QButtonGroup( "Show Values", addValuesFrame );
|
|---|
| 61 | addValuesButtonGroup->setColumnLayout(0, Qt::Vertical );
|
|---|
| 62 | addValuesButtonGroup->layout()->setSpacing( 6 );
|
|---|
| 63 | addValuesButtonGroup->layout()->setMargin( 11 );
|
|---|
| 64 | addValuesButtonGroupLayout = new QVBoxLayout(
|
|---|
| 65 | addValuesButtonGroup->layout() );
|
|---|
| 66 | addValuesButtonGroupLayout->setAlignment( Qt::AlignTop );
|
|---|
| 67 |
|
|---|
| 68 | noRadioButton = new QRadioButton( "&No", addValuesButtonGroup );
|
|---|
| 69 | noRadioButton->setChecked( TRUE );
|
|---|
| 70 | addValuesButtonGroupLayout->addWidget( noRadioButton );
|
|---|
| 71 |
|
|---|
| 72 | yesRadioButton = new QRadioButton( "&Yes", addValuesButtonGroup );
|
|---|
| 73 | addValuesButtonGroupLayout->addWidget( yesRadioButton );
|
|---|
| 74 |
|
|---|
| 75 | asPercentageRadioButton = new QRadioButton( "As &Percentage",
|
|---|
| 76 | addValuesButtonGroup );
|
|---|
| 77 | addValuesButtonGroupLayout->addWidget( asPercentageRadioButton );
|
|---|
| 78 | addValuesFrameLayout->addWidget( addValuesButtonGroup );
|
|---|
| 79 |
|
|---|
| 80 | decimalPlacesLayout = new QHBoxLayout( 0, 0, 6 );
|
|---|
| 81 |
|
|---|
| 82 | decimalPlacesTextLabel = new QLabel( "&Decimal Places", addValuesFrame );
|
|---|
| 83 | decimalPlacesLayout->addWidget( decimalPlacesTextLabel );
|
|---|
| 84 |
|
|---|
| 85 | decimalPlacesSpinBox = new QSpinBox( addValuesFrame );
|
|---|
| 86 | decimalPlacesSpinBox->setMinValue( 0 );
|
|---|
| 87 | decimalPlacesSpinBox->setMaxValue( 9 );
|
|---|
| 88 | decimalPlacesLayout->addWidget( decimalPlacesSpinBox );
|
|---|
| 89 |
|
|---|
| 90 | addValuesFrameLayout->addLayout( decimalPlacesLayout );
|
|---|
| 91 |
|
|---|
| 92 | optionsFormLayout->addWidget( addValuesFrame );
|
|---|
| 93 |
|
|---|
| 94 | buttonsLayout = new QHBoxLayout( 0, 0, 6 );
|
|---|
| 95 | spacer = new QSpacerItem( 0, 0,
|
|---|
| 96 | QSizePolicy::Expanding, QSizePolicy::Minimum );
|
|---|
| 97 | buttonsLayout->addItem( spacer );
|
|---|
| 98 |
|
|---|
| 99 | okPushButton = new QPushButton( "OK", this );
|
|---|
| 100 | okPushButton->setDefault( TRUE );
|
|---|
| 101 | buttonsLayout->addWidget( okPushButton );
|
|---|
| 102 |
|
|---|
| 103 | cancelPushButton = new QPushButton( "Cancel", this );
|
|---|
| 104 | buttonsLayout->addWidget( cancelPushButton );
|
|---|
| 105 | optionsFormLayout->addLayout( buttonsLayout );
|
|---|
| 106 |
|
|---|
| 107 | connect( fontPushButton, SIGNAL( clicked() ), this, SLOT( chooseFont() ) );
|
|---|
| 108 | connect( okPushButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
|
|---|
| 109 | connect( cancelPushButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
|
|---|
| 110 |
|
|---|
| 111 | chartTypeTextLabel->setBuddy( chartTypeComboBox );
|
|---|
| 112 | decimalPlacesTextLabel->setBuddy( decimalPlacesSpinBox );
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 | void OptionsForm::chooseFont()
|
|---|
| 117 | {
|
|---|
| 118 | bool ok;
|
|---|
| 119 | QFont font = QFontDialog::getFont( &ok, m_font, this );
|
|---|
| 120 | if ( ok )
|
|---|
| 121 | setFont( font );
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 | void OptionsForm::setFont( QFont font )
|
|---|
| 126 | {
|
|---|
| 127 | QString label = font.family() + " " +
|
|---|
| 128 | QString::number( font.pointSize() ) + "pt";
|
|---|
| 129 | if ( font.bold() )
|
|---|
| 130 | label += " Bold";
|
|---|
| 131 | if ( font.italic() )
|
|---|
| 132 | label += " Italic";
|
|---|
| 133 | fontTextLabel->setText( label );
|
|---|
| 134 | m_font = font;
|
|---|
| 135 | }
|
|---|