Class: Ruber::StatusBar

Inherits:
KDE::StatusBar
  • Object
show all
Defined in:
lib/ruber/main_window/status_bar.rb

Overview

The Ruber status bar

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ StatusBar

Creates a new StatusBar. parent is the status bar’s parent widget



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ruber/main_window/status_bar.rb', line 35

def initialize parent
  super parent
  @view = nil
  @cursor_position_label = Qt::Label.new(self){self.margin = 3}
  @status_label = Qt::Label.new self
  @mode_label = Qt::Label.new(self){self.margin = 3}
  @selection_mode_label = Qt::Label.new(self){self.margin = 3}
#       @cursor_position_label.margin = 3
#       @status_label.margin = 3
#       @mode_label.margin = 3
#       @selection_mode_label.margin = 3
#       @status_label.margin = 3
  add_widget @cursor_position_label
  add_widget @status_label
  add_widget @mode_label
  add_widget @selection_mode_label
  update
end

Instance Method Details

#clear_widgetsObject

Empties all the widgets in the status bar (it doesn’t hide messages, though)



83
84
85
86
87
88
# File 'lib/ruber/main_window/status_bar.rb', line 83

def clear_widgets
  @cursor_position_label.text = ''
  @status_label.pixmap = Qt::Pixmap.new
  @mode_label.text = ''
  @selection_mode_label.text= ''
end

#view=(v) ⇒ Object

Associates an editor view with the status bar. This means that the status bar will display information about that view.

v can be the view to associate with the status bar or nil. If it’s nil, the status bar won’t show anything



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/ruber/main_window/status_bar.rb', line 61

def view= v
  return if @view == v
  if @view 
    disconnect @view, nil, self, nil 
    disconnect @view.document, nil, self, nil
    clear_widgets
  end
  @view = v
  if v
    connect @view, SIGNAL('information_message(QString, QWidget*)'), self, SLOT('display_information(const QString &)')
    connect @view, SIGNAL('cursor_position_changed(KTextEditor::Cursor, QWidget*)'), self, SLOT('update_cursor_position(KTextEditor::Cursor)')
    connect @view, SIGNAL('view_mode_changed(QString, QWidget*)'), self, SLOT('update_view_mode(const QString &)')
    connect @view, SIGNAL('selection_mode_changed(bool, QWidget*)'), self, SLOT('update_selection_mode(bool)')
    connect @view.document, SIGNAL('modified_changed(bool, QObject*)'), self, SLOT('update_state()')
    connect @view.document, SIGNAL('modified_on_disk(QObject*, bool, KTextEditor::ModificationInterface::ModifiedOnDiskReason)'), self, SLOT('update_state()')
    update
  end
end