class Object

Constants

FontDialog

Public Class Methods

new(*args,&block) click to toggle source
# File lib/qt_connect/qt_sugar.rb, line 217
def new(*args,&block)
  setup_qt_signals
  new_before_signals(*args,&block)
end
Also aliased as: new_before_signals
new_before_signals(*args,&block)
Alias for: new
setup_qt_signals() click to toggle source
# File lib/qt_connect/qt_sugar.rb, line 222
def setup_qt_signals
    return if @not_first_instance
    @not_first_instance=true
    associates=[]
    printf("\n%-30s (first instance at %s)\n" ,"#{self.name}","#{caller[0].split('/')[-1]}") if $VERB && ($VERB>1)
    signals={}
    begin
      ancestors.each{ |klass| 
        next unless klass.name.start_with?('Qt::')
        begin ; metaobject=klass.staticMetaObject ; rescue ; next ; end
        metaobject.signalNames.each{ |signalname|
          next unless md=signalname.match(/([^ ]+)\ ([^(]+)\(([^)]*)/)  #<returntype><space<methodname>(<args>)
          signature=md[2]+'('+md[3]+')'
          methodname=if (h=Qt::Internal::Signature2Signal[klass.name]) && (mr=h[signature]) ; mr ; else ; md[2] end
          next if methodname.size==0
          next if self.method_defined?(methodname.to_sym)
          printf("  %-30s  =>  %s\n",methodname,signature) if $VERB && ($VERB > 1)
          uscore_name = if (methodname =~ /\A[A-Z]+\z/)
            methodname.downcase
          else
              methodname.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-","_").downcase
            end
          #puts "defining #{methodname} for #{self.name} #{self.method_defined? :new} (inherited from #{klass.name})"
          self.class_eval(%Q[
            def #{methodname}(&block)
              return super(*yield) if block_given?
              return @_#{methodname} ||=Qt::Signal.new(self,'#{signature}')
            end
            #{(uscore_name==methodname) ? '' : "alias :#{uscore_name} :#{methodname}"}
          ])
        }
        (0...metaobject.propertyCount).each{ |i| associates |= [metaobject.property(i).typeName]}
        (0...metaobject.methodCount).each{ |m| method=metaobject.method(m)
          case method.methodType
          when Qt::MetaMethod::Signal
            if md=method.signature.match(/([^(]+)\(([^)]*)/)
              associates |= md[2].split(',').map{ |s| s.delete('*&<>')}
            end
          else
            associates |= [method.typeName] if method.typeName.size>0
          end
        }
      }
    rescue => e
      puts e if $VERB
    end
    x=associates.map{|c| Qt::Internal::normalize_classname(c)}.                 #normalized names e.g. QWebFrame => Qt::WebFrame
        select{ |c| c.start_with?('Qt::')}.                                      #remove non-Qt classes
        each{ |klassname| eval("#{klassname}.setup_qt_signals") rescue next }   #recursive call to setup associates signals
    #(Internal::EmbeddedClasses["#{self.name}"] || []).each{ |klassname| eval("#{klassname}.setup_qt_signals")}
  end

Public Instance Methods

connect(a1=nil,a2=nil,&block) click to toggle source
# File lib/qt_connect/qt_jbindings.rb, line 96
def connect(a1=nil,a2=nil,&block)
  if a1
    if QtJambi::SIGNALEMITTERS[a1.class]
      orig_connect(a1)                                       #connecting [D]
      return
    end
    
    if a1.kind_of?(Qt::Signal)
      @action=Qt::RubySignalAction.new{ |*a| a1.emit(*a)}
      orig_connect(@action,'signal0()')                       #connecting [C]
      return
    end
  end
  #
  if signature=QtJambi::SIGNALEMITTERS[self.class]
    @action=Qt::RubySignalAction.new(a1,a2,&block)
    orig_connect(@action,signature)                            #connecting  [A,B]
    return
  else
    raise "cannot connect signal #{self} to #{a1}"
    return
  end
end
Also aliased as: orig_connect
orig_connect(a1=nil,a2=nil,&block)
Alias for: connect