Class: Ruber::Plugin

Inherits:
Qt::Object
  • Object
show all
Includes:
PluginLike
Defined in:
lib/ruber/plugin.rb

Overview

Base class for all plugins

Most of its functionality comes from the included PluginLike module.

Direct Known Subclasses

GuiPlugin

Constant Summary collapse

LICENSES =

A map between the license symbols used in the PSF and the @KDE::AboutData@ licenses constants

{
:unknown => KDE::AboutData::License_Unknown,
:gpl => KDE::AboutData::License_GPL,
:gpl2 => KDE::AboutData::License_GPL_V2,
:lgpl => KDE::AboutData::License_LGPL,
:lgpl2 => KDE::AboutData::License_LGPL_V2,
:bsd => KDE::AboutData::License_BSD,
:artistic => KDE::AboutData::License_Artistic,
:qpl => KDE::AboutData::License_QPL,
:qpl1 => KDE::AboutData::License_QPL_V1_0,
:gpl3 => KDE::AboutData::License_GPL_V3,
:lgpl3 => KDE::AboutData::License_LGPL_V3
}

Instance Attribute Summary

Attributes included from PluginLike

#plugin_description

Instance Method Summary collapse

Methods included from PluginLike

#add_extensions_to_project, #add_options_to_project, #add_widgets_to_project, #plugin_name, #query_close, #register_with_project, #remove_extensions_from_project, #remove_from_project, #remove_options_from_project, #remove_widgets_from_project, #restore_session, #save_settings, #session_data, #shutdown, #unload, #update_project

Constructor Details

#initialize(psf) ⇒ Plugin

Creates a new instance

This method takes care of calling the Ruber::PluginLike#initialize_plugin method required by the Ruber::PluginLike module

with the plugin

Parameters:



87
88
89
90
# File 'lib/ruber/plugin.rb', line 87

def initialize psf
  super(Ruber[:app])
  initialize_plugin psf
end

Instance Method Details

#about_dataKDE::AboutData

Creates a @KDE::AboutData@ object for the plugin

Note: every time this method is called, a new @KDE::AboutData@ object is created

taken from the PSF

Returns:

  • (KDE::AboutData)

    a @KDE::AboutData@ containing information about the plugin,



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/ruber/plugin.rb', line 100

def about_data
  about = @plugin_description.about
  app_name = @plugin_description.name.to_s
  version = @plugin_description.version
  license = @plugin_description.about.license
  license_key, license_text =
  if about.license.is_a? String then [KDE::AboutData::License_Custom, about.license]
  else [LICENSES[about.license], nil]
  end
  res = KDE::AboutData.new app_name, '', KDE.ki18n(about.human_name), version, 
      KDE.ki18n(about.description), license_key
  res.license_text = KDE.ki18n(license_text) if license_text
  @plugin_description.about.authors.each do |a|
    res.add_author KDE.ki18n(a[0]), KDE.ki18n(''), Qt::ByteArray.new(a[1] || '')
  end
  res.bug_address = Qt::ByteArray.new(about.bug_address) unless about.bug_address.empty?
  res.copyright_statement = KDE.ki18n(about.copyright) unless about.copyright.empty?
  res.homepage = Qt::ByteArray.new(about.homepage) unless about.homepage.empty?
  res.program_icon_name = about.icon unless about.icon.empty?
  res
end