Class: Cosmos::AboutDialog
- Inherits:
-
Qt::Dialog
- Object
- Qt::Dialog
- Cosmos::AboutDialog
- Defined in:
- lib/cosmos/gui/dialogs/about_dialog.rb
Constant Summary collapse
- ABOUT_COSMOS =
''
- @@pry_dialogs =
[]
Instance Method Summary collapse
-
#initialize(parent, about_string) ⇒ AboutDialog
constructor
A new instance of AboutDialog.
- #keyPressEvent(event) ⇒ Object
Methods inherited from Qt::Dialog
Constructor Details
#initialize(parent, about_string) ⇒ AboutDialog
Returns a new instance of AboutDialog.
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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/cosmos/gui/dialogs/about_dialog.rb', line 40 def initialize (parent, about_string) super(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) @saved_text = '' setWindowTitle('About') # Get Word Icon filename = File.join(::Cosmos::USERPATH, 'config', 'data', 'cosmos_word.gif') filename = File.join(::Cosmos::PATH, 'data', 'cosmos_word.gif') unless File.exist?(filename) word_icon = Qt::Label.new word_icon.setPixmap(Qt::Pixmap.new(filename)) copyright = Qt::Label.new("Copyright 2014 - Ball Aerospace & Technologies Corp.") = Qt::Label.new("Created by Ryan Melton (ryanmelt) and Jason Thomas (jmthomas)") ver = Qt::Label.new("Version: " + COSMOS_VERSION) user_ver = nil user_ver = Qt::Label.new("User Version: " + USER_VERSION) if defined? USER_VERSION and USER_VERSION != 'Unofficial' icon_layout = Qt::VBoxLayout.new do addWidget(word_icon) addWidget(copyright) addWidget() addWidget(ver) addWidget(user_ver) if user_ver addStretch end # Get COSMOS Configurable About Text filename = File.join(Cosmos::USERPATH, 'config', 'data', 'about.txt') filename = File.join(Cosmos::PATH, 'data', 'about.txt') unless File.exist?(filename) configurable_about_text = File.read(filename) configurable_about_text.gsub!("\r", '') unless Kernel.is_windows? if Kernel.is_windows? configurable_about_text << "\n" + "Main Application x:#{parent.x} y:#{parent.y} width:#{parent.frameGeometry.width + 16} height:#{parent.frameGeometry.height + 38}\n\n" + ABOUT_COSMOS else configurable_about_text << "\n" + "Main Application x:#{parent.x} y:#{parent.y} width:#{parent.frameGeometry.width} height:#{parent.frameGeometry.height}\n\n" + ABOUT_COSMOS end # Set the application about text about = Qt::Label.new(about_string + "\n\n" + configurable_about_text) about.setAlignment(Qt::AlignTop) about.setWordWrap(true) dialog = self ok = Qt::PushButton.new('Ok') do connect(SIGNAL('clicked()')) { dialog.done(0) } end = Qt::HBoxLayout.new do addStretch addWidget(ok) addStretch end self.layout = Qt::VBoxLayout.new do scroll_area = Qt::ScrollArea.new scroll_area.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff) addWidget(scroll_area) = Qt::Widget.new scroll_area.setWidget() interior_layout = Qt::VBoxLayout.new interior_layout.addLayout(icon_layout) interior_layout.addWidget(about) .setLayout(interior_layout) scroll_area.setMinimumWidth(.minimumSizeHint.width + 20) .adjustSize addLayout() end setMaximumWidth(800) self.raise() exec() dispose() end |
Instance Method Details
#keyPressEvent(event) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/cosmos/gui/dialogs/about_dialog.rb', line 112 def keyPressEvent(event) @saved_text << event.text.to_s if @saved_text[0] == 'p' if @saved_text[1] if @saved_text[1] == 'r' if @saved_text[2] if @saved_text[2] == 'y' self.done(0) @@pry_dialogs << PryDialog.new(nil, binding) return end @saved_text = '' end else @saved_text = '' end end else @saved_text = '' end super(event) end |