Class: Ruber::ComponentLoadingErrorDialog

Inherits:
ExceptionDialog show all
Defined in:
lib/ruber/exception_widgets.rb

Overview

ExceptionDialog specialized to display failures when loading plugins and components.

It differs from ExceptionDialog in the following aspects:

  • it provides different buttons

  • it provides a check box to decide whether or not to warn of subsequent errors while loading plugins

  • its ##exec method provides values suitable to be returned from a block passed to Ruber::ComponentManager#load_plugins

  • it provides an appropriate text

The buttons on the dialog are:

  • Go on::= ignore the failure and attempt to load the remaining plugins, hoping everything goes well

  • Quit::= immediately quit Ruber

  • Skip remaining::= ignore the failure, but don’t attempt to load any other plugin

If the exception was raised while loading a core component, the dialog will behave exactly as an ExceptionDialog (since you can’t start Ruber without one of the core components, the other buttons and the checkbox would be useless).

Instance Method Summary collapse

Methods inherited from ExceptionDialog

#show, #sizeHint

Constructor Details

#initialize(plugin, ex, parent = nil, core = false) ⇒ ComponentLoadingErrorDialog

Returns a new instance of ComponentLoadingErrorDialog.

Parameters:

  • plugin (Symbol, String)

    the name of the component which caused the exception

  • ex (Exception)

    the exception which was raised

  • the (Qt::Widget, nil)

    parent widget

  • core (Boolean) (defaults to: false)

    whether the component which caused the failure is a core component or a plugin



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/ruber/exception_widgets.rb', line 188

def initialize plugin, ex, parent = nil, core = false
  msg = "An error occurred while loading the #{core ? 'component' : 'plugin' } #{plugin}. The error was:"
  super ex, parent, true, msg
  unless core
    label = main_widget
    w = Qt::Widget.new self
    self.main_widget = w
    w.layout = Qt::VBoxLayout.new w
    label.parent = w
    w.layout.add_widget label
    @silent = Qt::CheckBox.new "&Don't report other errors", w
    w.layout.add_widget @silent
    self.buttons = Yes|No|Cancel|Details
    self.set_button_text KDE::Dialog::Yes, "&Go on"
    self.set_button_text KDE::Dialog::No, "&Quit Ruber"
    self.set_button_text KDE::Dialog::Cancel, "&Skip remaining plugins"
    self.escape_button = KDE::Dialog::No
  end
end

Instance Method Details

#execBoolean, Symbol

Override of ExceptionDialog#exec

It returns a different value according to the button pressed by the user and to whether he checked the “Don’t report other errors” checkbox. The returned values are suitable for use by a block passed to Ruber::ComponentManager#load_plugins.

  • true:= if the user pressed the “Go on” button without checking the checkbox

  • @:silent@:= if the user pressed the “Go on” button and checked the checkbox

  • false:= if the user pressed the “Quit” button

  • @:skip@:= if the user pressed the “Skip” button

Returns:



233
234
235
236
237
238
239
240
241
# File 'lib/ruber/exception_widgets.rb', line 233

def exec
  res = super
  case res
  when KDE::Dialog::Yes then silently? ? :silent : true
  when KDE::Dialog::No then false
  when KDE::Dialog::Cancel then :skip
  else res
  end
end

#silently?Boolean?

Whether or not the user checked to ignore subsequent errors

Returns:

  • (Boolean, nil)

    true if the user checked the “Don’t report other errors” check box and false otherwise. If the dialog is shown for a core component, this method always returns nil



215
216
217
# File 'lib/ruber/exception_widgets.rb', line 215

def silently?
  @silent.checked? rescue nil
end