2 // File : SALOMEGUI_OpenWith.cxx
3 // Created : Wed Oct 24 12:19:34 2001
4 // Author : Nicolas REJNERI
7 // Copyright : Open CASCADE
11 #include "SALOMEGUI_OpenWith.h"
14 #include <qcheckbox.h>
15 #include <qpushbutton.h>
19 #define SPACING_SIZE 6
20 #define MARGIN_SIZE 11
21 #define MIN_LISTBOX_WIDTH 150
22 #define MIN_LISTBOX_HEIGHT 100
25 * Constructs modal SALOMEGUI_OpenWith which is a child of 'parent', with the
28 SALOMEGUI_OpenWith::SALOMEGUI_OpenWith(QWidget* parent, const char* name)
29 : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
32 setName( "SALOMEGUI_OpenWith" );
33 setCaption( tr("OPEN_WITH_TLT") );
34 setSizeGripEnabled( TRUE );
36 QGridLayout* aTopLayout = new QGridLayout(this);
37 aTopLayout->setMargin(MARGIN_SIZE);
38 aTopLayout->setSpacing(SPACING_SIZE);
42 AllwaysCheckBox = new QCheckBox( this, "AllwaysCheckBox" );
43 AllwaysCheckBox->setText( tr( "MEN_COMPONENT_CHOICE1" ) );
45 QHBoxLayout* aBtnLayout = new QHBoxLayout;
46 aBtnLayout->setSpacing( SPACING_SIZE );
47 aBtnLayout->setMargin( 0 );
49 buttonOk = new QPushButton( this, "buttonOk" );
50 buttonOk->setText( tr( "BUT_OK" ) );
51 buttonOk->setAutoDefault( true );
52 buttonOk->setDefault( true );
54 buttonCancel = new QPushButton( this, "buttonCancel" );
55 buttonCancel->setText( tr( "BUT_CANCEL" ) );
56 buttonCancel->setAutoDefault( true );
58 aBtnLayout->addWidget( buttonOk );
59 aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
60 aBtnLayout->addWidget( buttonCancel );
62 ListComponent = new QListBox( this, "ListComponent" );
63 ListComponent->setVScrollBarMode(QListBox::AlwaysOn);
64 ListComponent->setMinimumSize(MIN_LISTBOX_WIDTH, MIN_LISTBOX_HEIGHT);
65 ListComponent->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
66 ListComponent->setSelectionMode(QListBox::Single);
68 aTopLayout->addWidget(ListComponent, 0, 0);
69 // aTopLayout->addWidget(AllwaysCheckBox, 1, 0);
70 aTopLayout->addLayout(aBtnLayout, 1, 0);
72 // signals and slots connections
73 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
74 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
75 connect( ListComponent, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ));
81 * Destroys the object and frees any allocated resources
83 SALOMEGUI_OpenWith::~SALOMEGUI_OpenWith()
88 Inserts new component into component list
90 void SALOMEGUI_OpenWith::addComponent(const QString& aComp)
92 ListComponent->insertItem(aComp);
96 Returns choosen component
98 QString SALOMEGUI_OpenWith::getComponent()
100 return ListComponent->currentText();
103 bool SALOMEGUI_OpenWith::getAlwaysFlag()
105 if ( AllwaysCheckBox )
106 return AllwaysCheckBox->isChecked();
109 void SALOMEGUI_OpenWith::onSelectionChanged()
114 void SALOMEGUI_OpenWith:: updateButtonState()
116 buttonOk->setEnabled( ListComponent->currentItem() >=0 &&
117 ListComponent->currentItem() < ListComponent->count() ) ;