Class: Cosmos::CalendarDialog
- Inherits:
-
Qt::Dialog
- Object
- Qt::Dialog
- Cosmos::CalendarDialog
- Defined in:
- lib/cosmos/gui/dialogs/calendar_dialog.rb
Overview
CalendarDialog class
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
The selected time.
Instance Method Summary collapse
-
#initialize(parent, title, initial_time = nil, show_time = true) ⇒ CalendarDialog
constructor
Constructor.
Methods inherited from Qt::Dialog
Constructor Details
#initialize(parent, title, initial_time = nil, show_time = true) ⇒ CalendarDialog
Constructor
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cosmos/gui/dialogs/calendar_dialog.rb', line 26 def initialize (parent, title, initial_time = nil, show_time = true) # Call base class constructor super(parent) setWindowTitle(title) @layout = Qt::VBoxLayout.new if initial_time @time = initial_time else time_now = Time.now @time = Time.local(time_now.year, time_now.mon, time_now.day) end @show_time = show_time @calendar = Qt::CalendarWidget.new @date = Qt::Date.new(@time.year, @time.mon, @time.day) @calendar.setSelectedDate(@date) @calendar.setVerticalHeaderFormat(Qt::CalendarWidget::NoVerticalHeader) @calendar.connect(SIGNAL('selectionChanged()')) { handle_calendar_select() } @layout.addWidget(@calendar) @date_layout = Qt::HBoxLayout.new @date_label = Qt::Label.new('Date:') @date_layout.addWidget(@date_label) @date_layout.addStretch @year_month_day = Qt::Label.new(sprintf("%04u/%02u/%02u", @time.year, @time.mon, @time.day)) @date_layout.addWidget(@year_month_day) @layout.addLayout(@date_layout) if @show_time @time_layout = Qt::HBoxLayout.new @time_label = Qt::Label.new('Time:') @time_layout.addWidget(@time_label) @time_layout.addStretch @hour = Qt::LineEdit.new(sprintf("%02u", @time.hour)) @hour.setMaximumWidth(20) @time_layout.addWidget(@hour) @colon_label = Qt::Label.new(':') @time_layout.addWidget(@colon_label) @minute = Qt::LineEdit.new(sprintf("%02u", @time.min)) @minute.setMaximumWidth(20) @time_layout.addWidget(@minute) @colon_label2 = Qt::Label.new(':') @time_layout.addWidget(@colon_label2) @second = Qt::LineEdit.new(sprintf("%02u", @time.sec)) @second.setMaximumWidth(20) @time_layout.addWidget(@second) @period_label = Qt::Label.new('.') @time_layout.addWidget(@period_label) @microsecond = Qt::LineEdit.new(sprintf("%06u", @time.tv_usec)) @microsecond.setMaximumWidth(45) @time_layout.addWidget(@microsecond) @layout.addLayout(@time_layout) end # Create OK and Cancel buttons @button_layout = Qt::HBoxLayout.new @ok_button = Qt::PushButton.new('OK') @ok_button.connect(SIGNAL('clicked()')) { () } @button_layout.addWidget(@ok_button) @cancel_button = Qt::PushButton.new('Cancel') @cancel_button.connect(SIGNAL('clicked()')) { self.reject } @button_layout.addWidget(@cancel_button) @layout.addLayout(@button_layout) setLayout(@layout) end |
Instance Attribute Details
#time ⇒ Object (readonly)
The selected time
23 24 25 |
# File 'lib/cosmos/gui/dialogs/calendar_dialog.rb', line 23 def time @time end |