Class: MetaBuilder::Qt4MB::GenericDialog

Inherits:
Qt::Dialog
  • Object
show all
Defined in:
lib/MetaBuilder/Qt4/parameter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, type, title, label, val, target) ⇒ GenericDialog

Creates a generic input dialog for the type type.



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/MetaBuilder/Qt4/parameter.rb', line 125

def initialize(parent, type, title, label, val, target)
  super(parent)
  self.window_title = title
  vbox = Qt::VBoxLayout.new(self)

  hbox = Qt::HBoxLayout.new
  @label = Qt::Label.new(label)
  hbox.add_widget(@label)
  @widget = type.qt4_create_input_widget(nil, target)
  hbox.add_widget(@widget)
  @widget.value = val
  vbox.add_layout(hbox)

  hbox = Qt::HBoxLayout.new
  # OK and Cancel buttons
  button  = Qt::PushButton.new("OK")
  connect(button, SIGNAL('clicked()'),
          SLOT('accept()'))
  hbox.add_widget(button)
  button  = Qt::PushButton.new("Cancel")
  connect(button, SIGNAL('clicked()'),
          SLOT('reject()'))
  hbox.add_widget(button)
  vbox.add_layout(hbox)
  # and that's all ! 
end

Class Method Details

.get_type(parent, type, title, label, val, target) ⇒ Object

A convenience wrapper around the functionnality. Creates a GenericDialog and executes it.



163
164
165
166
# File 'lib/MetaBuilder/Qt4/parameter.rb', line 163

def self.get_type(parent, type, title, label, val, target)
  dialog = new(parent, type, title, label, val, target)
  return dialog.exec
end

Instance Method Details

#execObject



152
153
154
155
156
157
158
159
# File 'lib/MetaBuilder/Qt4/parameter.rb', line 152

def exec
  res = super
  if res > 0
    return @widget.value
  else
    raise CancelInput,  "User cancelled input"
  end
end