Class: Cosmos::TextDialog

Inherits:
Qt::Dialog show all
Defined in:
lib/cosmos/tools/table_manager/table_manager.rb

Overview

A dialog box containing a text field and ok button

Instance Method Summary collapse

Methods inherited from Qt::Dialog

#exec

Constructor Details

#initialize(parent) ⇒ TextDialog

Returns a new instance of TextDialog.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/cosmos/tools/table_manager/table_manager.rb', line 92

def initialize(parent)
  super(parent)

  layout = Qt::VBoxLayout.new

  @text = Qt::PlainTextEdit.new
  if Kernel.is_windows?
    @text.setFont(Cosmos.getFont('courier', 10))
  else
    @text.setFont(Cosmos.getFont('courier', 14))
  end
  @text.setReadOnly(true)

  layout.addWidget(@text)

  button_layout = Qt::HBoxLayout.new
  ok_button = Qt::PushButton.new('OK')
  ok_button.connect(SIGNAL('clicked()')) { self.accept }
  button_layout.addStretch
  button_layout.addWidget(ok_button)
  button_layout.addStretch

  layout.addLayout(button_layout)
  setLayout(layout)
end

Instance Method Details

#set_size(width, height) ⇒ Object

Set the size of the dialog box



125
126
127
# File 'lib/cosmos/tools/table_manager/table_manager.rb', line 125

def set_size(width, height)
  resize(width, height)
end

#set_title_and_text(title, text) ⇒ Object

Set the title of the dialog box and the text contents



119
120
121
122
# File 'lib/cosmos/tools/table_manager/table_manager.rb', line 119

def set_title_and_text(title, text)
  self.setWindowTitle(title)
  @text.setPlainText(text)
end