From 90825e2392b2d70e43c7a25b8a3752299a933894 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../examples/qt-examples/chart/optionsform.rb | 127 +++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 qtruby/rubylib/examples/qt-examples/chart/optionsform.rb (limited to 'qtruby/rubylib/examples/qt-examples/chart/optionsform.rb') diff --git a/qtruby/rubylib/examples/qt-examples/chart/optionsform.rb b/qtruby/rubylib/examples/qt-examples/chart/optionsform.rb new file mode 100644 index 00000000..6b2eeac4 --- /dev/null +++ b/qtruby/rubylib/examples/qt-examples/chart/optionsform.rb @@ -0,0 +1,127 @@ +class OptionsForm < Qt::Dialog + slots 'chooseFont()' + + attr_reader :chartTypeComboBox, + :noRadioButton, + :yesRadioButton, + :asPercentageRadioButton, + :decimalPlacesSpinBox, + :font + + def initialize( parent = nil, name = "options form", + modal = false, f = 0 ) + super( parent, name, modal, f ) + setCaption( "Chart -- Options" ) + resize( 320, 290 ) + + @optionsFormLayout = Qt::VBoxLayout.new( self, 11, 6 ) + + @chartTypeLayout = Qt::HBoxLayout.new( nil, 0, 6 ) + + @chartTypeTextLabel = Qt::Label.new( "&Chart Type", self ) + @chartTypeLayout.addWidget( @chartTypeTextLabel ) + + @chartTypeComboBox = Qt::ComboBox.new( false, self ) + @chartTypeComboBox.insertItem( Qt::Pixmap.new( "images/options_piechart.xpm" ), "Pie Chart" ) + @chartTypeComboBox.insertItem( Qt::Pixmap.new( "images/options_verticalbarchart.xpm" ), + "Vertical Bar Chart" ) + @chartTypeComboBox.insertItem( Qt::Pixmap.new( "images/options_horizontalbarchart.xpm" ), + "Horizontal Bar Chart" ) + @chartTypeLayout.addWidget( @chartTypeComboBox ) + @optionsFormLayout.addLayout( @chartTypeLayout ) + + @fontLayout = Qt::HBoxLayout.new( nil, 0, 6 ) + + @fontPushButton = Qt::PushButton.new( "&Font...", self ) + @fontLayout.addWidget( @fontPushButton ) + @spacer = Qt::SpacerItem.new( 0, 0, Qt::SizePolicy::Expanding, + Qt::SizePolicy::Minimum ) + @fontLayout.addItem( @spacer ) + + @fontTextLabel = Qt::Label.new( self ) # Must be set by caller via setFont() + @fontLayout.addWidget( @fontTextLabel ) + @optionsFormLayout.addLayout( @fontLayout ) + + @addValuesFrame = Qt::Frame.new( self ) + @addValuesFrame.setFrameShape( Qt::Frame::StyledPanel ) + @addValuesFrame.setFrameShadow( Qt::Frame::Sunken ) + @addValuesFrameLayout = Qt::VBoxLayout.new( @addValuesFrame, 11, 6 ) + + @addValuesButtonGroup = Qt::ButtonGroup.new( "Show Values", @addValuesFrame ) + @addValuesButtonGroup.setColumnLayout(0, Qt::Vertical ) + @addValuesButtonGroup.layout().setSpacing( 6 ) + @addValuesButtonGroup.layout().setMargin( 11 ) + @addValuesButtonGroupLayout = Qt::VBoxLayout.new( + @addValuesButtonGroup.layout() ) + @addValuesButtonGroupLayout.setAlignment( Qt::AlignTop ) + + @noRadioButton = Qt::RadioButton.new( "&No", @addValuesButtonGroup ) + @noRadioButton.setChecked( true ) + @addValuesButtonGroupLayout.addWidget( @noRadioButton ) + + @yesRadioButton = Qt::RadioButton.new( "&Yes", @addValuesButtonGroup ) + @addValuesButtonGroupLayout.addWidget( @yesRadioButton ) + + @asPercentageRadioButton = Qt::RadioButton.new( "As &Percentage", + @addValuesButtonGroup ) + @addValuesButtonGroupLayout.addWidget( @asPercentageRadioButton ) + @addValuesFrameLayout.addWidget( @addValuesButtonGroup ) + + @decimalPlacesLayout = Qt::HBoxLayout.new( nil, 0, 6 ) + + @decimalPlacesTextLabel = Qt::Label.new( "&Decimal Places", @addValuesFrame ) + @decimalPlacesLayout.addWidget( @decimalPlacesTextLabel ) + + @decimalPlacesSpinBox = Qt::SpinBox.new( @addValuesFrame ) + @decimalPlacesSpinBox.setMinValue( 0 ) + @decimalPlacesSpinBox.setMaxValue( 9 ) + @decimalPlacesLayout.addWidget( @decimalPlacesSpinBox ) + + @addValuesFrameLayout.addLayout( @decimalPlacesLayout ) + + @optionsFormLayout.addWidget( @addValuesFrame ) + + @buttonsLayout = Qt::HBoxLayout.new( nil, 0, 6 ) + @spacer = Qt::SpacerItem.new( 0, 0, + Qt::SizePolicy::Expanding, Qt::SizePolicy::Minimum ) + @buttonsLayout.addItem( @spacer ) + + @okPushButton = Qt::PushButton.new( "OK", self ) + @okPushButton.setDefault( true ) + @buttonsLayout.addWidget( @okPushButton ) + + @cancelPushButton = Qt::PushButton.new( "Cancel", self ) + @buttonsLayout.addWidget( @cancelPushButton ) + @optionsFormLayout.addLayout( @buttonsLayout ) + + connect( @fontPushButton, SIGNAL( 'clicked()' ), self, SLOT( 'chooseFont()' ) ) + connect( @okPushButton, SIGNAL( 'clicked()' ), self, SLOT( 'accept()' ) ) + connect( @cancelPushButton, SIGNAL( 'clicked()' ), self, SLOT( 'reject()' ) ) + + @chartTypeTextLabel.setBuddy( @chartTypeComboBox ) + @decimalPlacesTextLabel.setBuddy( @decimalPlacesSpinBox ) + end + + + def chooseFont() + ok = Qt::Boolean.new + font = Qt::FontDialog.getFont( ok, @font, self ) + if !ok.nil? + setFont( font ) + end + end + + + def font=( font ) + label = font.family() + " " + font.pointSize().to_s + "pt" + if font.bold() + label += " Bold" + end + if font.italic() + label += " Italic" + end + @fontTextLabel.setText( label ) + @font = font + end + +end -- cgit v1.2.3