Class: RuGUI::FrameworkAdapters::Qt4::BaseView

Inherits:
BaseFrameworkAdapter::BaseView show all
Defined in:
lib/rugui/framework_adapters/Qt4.rb

Instance Attribute Summary

Attributes inherited from BaseFrameworkAdapter::Base

#adapted_object

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseFrameworkAdapter::Base

#initialize

Constructor Details

This class inherits a constructor from RuGUI::FrameworkAdapters::BaseFrameworkAdapter::Base

Class Method Details

.builder_file_extensionObject

Returns the builder file extension to be used for this view class.



99
100
101
# File 'lib/rugui/framework_adapters/Qt4.rb', line 99

def builder_file_extension
  'ui'
end

Instance Method Details

#add_widget_to_container(widget, container_widget) ⇒ Object

Adds a widget to the given container widget.



42
43
44
# File 'lib/rugui/framework_adapters/Qt4.rb', line 42

def add_widget_to_container(widget, container_widget)
  widget.parent = container_widget
end

#autoconnect_signals(view, other_target = nil) ⇒ Object

Autoconnects signals handlers for the view. If other_target is given it is used instead of the view itself.



65
66
67
# File 'lib/rugui/framework_adapters/Qt4.rb', line 65

def autoconnect_signals(view, other_target = nil)
  # Qt4 doesn't provides a method for autoconnecting signals.
end

#build_widgets_from(filename) ⇒ Object

Builds widgets from the given filename, using the proper builder.



85
86
87
88
89
90
# File 'lib/rugui/framework_adapters/Qt4.rb', line 85

def build_widgets_from(filename)
  ui_file_root_widget = load_ui_file(filename)
  @view_root_widget = root_widget_from(ui_file_root_widget)
  create_attributes_for_widget_and_children(@view_root_widget)
  @view_root_widget.show if self.adapted_object.display_root?
end

#connect_declared_signal(widget, signal, receiver, method) ⇒ Object

Connects the signal from the widget to the given receiver method.



78
79
80
81
82
# File 'lib/rugui/framework_adapters/Qt4.rb', line 78

def connect_declared_signal(widget, signal, receiver, method)
  widget.connect(SIGNAL(signal)) do |*args|
    receiver.send(method, *args)
  end
end

#connect_declared_signal_block(widget, signal, receiver, block) ⇒ Object

Connects the signal from the widget to the given receiver block. The block is executed in the context of the receiver.



71
72
73
74
75
# File 'lib/rugui/framework_adapters/Qt4.rb', line 71

def connect_declared_signal_block(widget, signal, receiver, block)
  widget.connect(SIGNAL(signal)) do |*args|
    receiver.instance_exec(*args, &block)
  end
end

#queue(&block) ⇒ Object

Queues the block call, so that it is only gets executed in the main thread.



37
38
39
# File 'lib/rugui/framework_adapters/Qt4.rb', line 37

def queue(&block)
  block.call
end

#register_widgetsObject

Registers widgets as attributes of the view class.



93
94
95
# File 'lib/rugui/framework_adapters/Qt4.rb', line 93

def register_widgets
  register_widget_and_children(@view_root_widget)
end

#remove_all_children(container_widget) ⇒ Object

Removes all children from the given container widget.



52
53
54
55
56
# File 'lib/rugui/framework_adapters/Qt4.rb', line 52

def remove_all_children(container_widget)
  container_widget.children.each do |child|
    child.parent = nil
  end
end

#remove_widget_from_container(widget, container_widget) ⇒ Object

Removes a widget from the given container widget.



47
48
49
# File 'lib/rugui/framework_adapters/Qt4.rb', line 47

def remove_widget_from_container(widget, container_widget)
  widget.parent = nil
end

#set_widget_name(widget, widget_name) ⇒ Object

Sets the widget name for the given widget if given.



59
60
61
# File 'lib/rugui/framework_adapters/Qt4.rb', line 59

def set_widget_name(widget, widget_name)
  widget.object_name = widget_name
end