Class: Ruber::Autosave::ConfigWidget

Inherits:
Qt::Widget
  • Object
show all
Defined in:
plugins/autosave/autosave.rb

Overview

The configuration widget for the Autosave plugin

Constant Summary

REMOTE_FILES_MODE =

Associations between remote files behaviour and entries in the Remote files widget

{:normal => 0, :skip => 1, :ignore => 2}

Instance Method Summary (collapse)

API for feature autosave

Constructor Details

- (ConfigWidget) initialize(parent = nil)

Creates a new instance

Parameters:

  • the (Qt::Widget, nil)

    parent widget



369
370
371
372
373
374
375
376
377
378
379
380
# File 'plugins/autosave/autosave.rb', line 369

def initialize parent = nil
  super
  @ui = Ui::AutosaveConfigWidget.new
  @ui.setupUi self
  m = Qt::StandardItemModel.new @ui._autosave__plugins
  @ui._autosave__plugins.model = m
  fill_plugin_list
  @ui._autosave__plugins.enabled = false
  @ui._autosave__enable.connect(SIGNAL('toggled(bool)')) do |b|
    @ui._autosave__plugins.enabled = b
  end
end

Instance Method Details

- (nil) fill_plugin_list (private)

Fills the list view with the registered plugins

Returns:

  • (nil)


427
428
429
430
431
432
433
434
435
436
437
438
# File 'plugins/autosave/autosave.rb', line 427

def fill_plugin_list
  m = @ui._autosave__plugins.model
  Ruber[:autosave].registered_plugins.each_pair do |pl, val|
    obj = Ruber[pl.to_sym]
    it = Qt::StandardItem.new obj.plugin_description.about.human_name
    it.data = Qt::Variant.new(pl.to_s)
    it.flags = Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsUserCheckable
    it.checked = val
    m.append_row it
  end
  nil
end

- (Hash) plugins

The plugins for which autsave is enabled and those for which it’s disabled

autosave is enabled or not for a given plugin

Returns:

  • (Hash)

    a hash whose keys are the plugin names and whose values tell whether



412
413
414
415
416
417
418
# File 'plugins/autosave/autosave.rb', line 412

def plugins
  mod = @ui._autosave__plugins.model
  mod.inject({}) do |res, it|
    res[it.data.to_string.to_sym] = it.checked?
    res
  end
end

- (void) plugins=(val)

This method returns an undefined value.

Changes the status of the Plugins widget according to the given value

autosave should be enabled or not for the given plugin. Any entries corresponding to plugins without a corresponding entry in the wigdet are added

Parameters:

  • val (Hash)

    the keys are the names of the plugin, while the values tell whether



391
392
393
394
395
396
397
398
399
400
401
402
403
404
# File 'plugins/autosave/autosave.rb', line 391

def plugins= val
  mod = @ui._autosave__plugins.model
  val.each_pair do |k, v|
    name = v.to_s
    it = mod.find{|i| i.data.to_string == name}
    unless it
      it = Qt::StandardItem.new k.to_s
      it.data = Qt::Variant.new k.to_s
      it.flags = Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsUserCheckable
      mod.append_row it
    end
    it.checked = v
  end
end

- (Symbol) remote_files (private)

The symbol associated with the entry selected in the remote files widget according to REMOTE_FILES_MODE

Returns:

  • (Symbol)

    the symbol associated with the entry selected in the remote files widget according to REMOTE_FILES_MODE



457
458
459
# File 'plugins/autosave/autosave.rb', line 457

def remote_files
  REMOTE_FILES_MODE.invert[@ui._autosave__remote_files.current_index]
end

- (nil) remote_files=(val) (private)

Selects the appropriate entry from the remote file combo box

Parameters:

  • val (Symbol)

    the bheaviour with respect to remote files. It can be one of :normal, :skip or :ignore

Returns:

  • (nil)


447
448
449
450
451
# File 'plugins/autosave/autosave.rb', line 447

def remote_files= val
  mode = 
  @ui._autosave__remote_files.current_index = REMOTE_FILES_MODE[val]
  nil
end