2 // File : SALOMEGUI_ViewChoiceDlg.cxx
3 // Created : Mon Jul 29 22:16:49 2002
4 // Author : Nicolas REJNERI
8 // Copyright : Open CASCADE 2002
11 #include "SALOMEGUI_ViewChoiceDlg.h"
12 #include "QAD_Config.h"
13 #include "QAD_StudyFrame.h"
15 #include <qcombobox.h>
16 #include <qgroupbox.h>
18 #include <qpushbutton.h>
22 #include <qwhatsthis.h>
25 * Constructs a SALOMEGUI_ViewChoiceDlg which is a child of 'parent', with the
26 * name 'name' and widget flags set to 'f'
28 * The dialog will by default be modeless, unless you set 'modal' to
29 * TRUE to construct a modal dialog.
31 SALOMEGUI_ViewChoiceDlg::SALOMEGUI_ViewChoiceDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
32 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
35 setName( "SALOMEGUI_ViewChoiceDlg" );
36 setCaption( tr( "MEN_CHOICE" ) );
37 setSizeGripEnabled( true );
39 QGridLayout* theBaseLayout = new QGridLayout( this, 2, 1, 11, 6);
41 GroupBox1 = new QGroupBox(0, Qt::Vertical, tr("MEN_VIEW"), this);
42 theBaseLayout->addWidget(GroupBox1, 0, 0);
44 QHBoxLayout* aBoxLayout = new QHBoxLayout(GroupBox1->layout());
46 QHBoxLayout* aInternalLayout = new QHBoxLayout(6);
48 TextLabel1 = new QLabel(tr("MEN_VIEWER_TYPE"), GroupBox1);
49 aInternalLayout->addWidget(TextLabel1);
51 ComboBox1 = new QComboBox( false, GroupBox1);
52 ComboBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
53 ComboBox1->setMinimumWidth( 200 );
55 ComboBox1->insertItem(tr("MEN_VIEWER_OCC"));
56 myViewers.append(VIEW_OCC);
57 if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_OCC )
58 ComboBox1->setCurrentItem( ComboBox1->count()-1 );
60 ComboBox1->insertItem(tr("MEN_VIEWER_VTK"));
61 myViewers.append(VIEW_VTK);
62 if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_VTK )
63 ComboBox1->setCurrentItem( ComboBox1->count()-1 );
65 // ComboBox1->insertItem(tr("MEN_VIEWER_GRAPH"));
66 // myViewers.append(VIEW_GRAPHSUPERV);
67 // if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_GRAPHSUPERV )
68 // ComboBox1->setCurrentItem( ComboBox1->count()-1 );
70 ComboBox1->insertItem(tr("MEN_VIEWER_PLOT2D"));
71 myViewers.append(VIEW_PLOT2D);
72 if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_PLOT2D )
73 ComboBox1->setCurrentItem( ComboBox1->count()-1 );
74 TextLabel1->setBuddy(ComboBox1);
75 aInternalLayout->addWidget(ComboBox1);
77 aBoxLayout->addLayout(aInternalLayout);
79 QFrame* aButtonFrame = new QFrame( this );
80 theBaseLayout->addWidget(aButtonFrame, 1, 0);
82 QHBoxLayout* aButtLayout = new QHBoxLayout(aButtonFrame);
84 buttonOk = new QPushButton(tr("BUT_OK"), aButtonFrame);
85 buttonOk->setAutoDefault(true);
86 buttonOk->setDefault(true);
87 aButtLayout->addWidget(buttonOk);
89 QSpacerItem* aSpacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding);
90 aButtLayout->addItem(aSpacer);
92 buttonCancel = new QPushButton(tr( "BUT_CANCEL" ), aButtonFrame);
93 buttonCancel->setAutoDefault(true);
94 aButtLayout->addWidget(buttonCancel);
96 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
97 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
101 * Destroys the object and frees any allocated resources
103 SALOMEGUI_ViewChoiceDlg::~SALOMEGUI_ViewChoiceDlg()
105 // no need to delete child widgets, Qt does it all for us
111 int SALOMEGUI_ViewChoiceDlg::getSelectedViewer()
113 return myViewers[ ComboBox1->currentItem() ];