Sha256: a62396f1bd1a27cece59e424527443713449995792f16ceb256c96fb7d2ccbf1

Contents?: true

Size: 1.46 KB

Versions: 25

Compression:

Stored size: 1.46 KB

Contents

# encoding: ascii-8bit

# Copyright 2014 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

require 'cosmos'
require 'cosmos/gui/qt'
require 'cosmos/gui/choosers/combobox_chooser'

module Cosmos

  class SelectDialog
    attr_accessor :result

    def initialize(parent, label_text, items, title = 'Select Item')
      @result = nil

      dialog = Qt::Dialog.new(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
      dialog.setWindowTitle(title)
      dialog_layout = Qt::VBoxLayout.new

      chooser = ComboboxChooser.new(dialog, label_text, items)
      dialog_layout.addWidget(chooser)

      button_layout = Qt::HBoxLayout.new
      ok = Qt::PushButton.new("Ok")
      ok.connect(SIGNAL('clicked()')) do
        dialog.accept()
      end
      button_layout.addWidget(ok)
      cancel = Qt::PushButton.new("Cancel")
      cancel.connect(SIGNAL('clicked()')) do
        dialog.reject()
      end
      button_layout.addWidget(cancel)
      dialog_layout.addLayout(button_layout)

      dialog.setLayout(dialog_layout)
      dialog.raise
      if dialog.exec == Qt::Dialog::Accepted
        @result = chooser.string
      else
        @result = nil
      end
      dialog.dispose
    end
  end # class TlmEditDialog

end # module Cosmos

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
cosmos-3.8.3 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.8.2 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.8.1 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.8.0 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.7.1 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.7.0 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.6.3 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.6.2 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.6.1 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.6.0 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.5.3 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.5.2 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.5.0 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.4.2 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.4.1 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.4.0 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.3.3 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.3.2 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.3.1 lib/cosmos/gui/dialogs/select_dialog.rb
cosmos-3.3.0 lib/cosmos/gui/dialogs/select_dialog.rb