1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // GEOM GEOMGUI : GUI for Geometry component
21 // File : GEOMToolsGUI_LineWidthDlg.cxx
24 #include "GEOMToolsGUI_LineWidthDlg.h"
25 #include <GeometryGUI.h>
26 #include <GEOM_Constants.h>
27 #include <LightApp_Application.h>
28 #include <SalomeApp_IntSpinBox.h>
30 #include <SUIT_MessageBox.h>
31 #include <SUIT_ResourceMgr.h>
32 #include <SUIT_Session.h>
33 #include <SUIT_Tools.h>
37 #include <QPushButton>
39 #include <QGridLayout>
42 //=================================================================================
43 // class : GEOMToolsGUI_LineWidthDlg()
44 // purpose : Constructs a GEOMToolsGUI_LineWidthDlg which is a child of 'parent', with the
45 // name 'name' and widget flags set to 'f'.
46 // The dialog will by default be modeless, unless you set 'modal' to
47 // true to construct a modal dialog.
48 //=================================================================================
50 GEOMToolsGUI_LineWidthDlg::GEOMToolsGUI_LineWidthDlg (QWidget* parent, const QString& title)
51 : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
53 setObjectName("GEOMToolsGUI_LineWidthDlg");
56 setWindowTitle(tr(title.toLatin1().constData()));
57 setSizeGripEnabled(true);
58 QGridLayout* MyDialogLayout = new QGridLayout(this);
59 MyDialogLayout->setSpacing(6);
60 MyDialogLayout->setMargin(11);
63 /***************************************************************/
64 QGroupBox* GroupC1 = new QGroupBox (this);
65 GroupC1->setObjectName("GroupC1");
66 QGridLayout* GroupC1Layout = new QGridLayout (GroupC1);
67 GroupC1Layout->setAlignment(Qt::AlignTop);
68 GroupC1Layout->setSpacing(6);
69 GroupC1Layout->setMargin(11);
71 QLabel* TextLabel1 = new QLabel (GroupC1);
72 TextLabel1->setObjectName("TextLabel1");
73 TextLabel1->setText(tr("GEOM_LINE_WIDTH"));
74 GroupC1Layout->addWidget(TextLabel1, 0, 0);
77 mySpinBox = new SalomeApp_IntSpinBox (GroupC1);
78 mySpinBox->setRange( 1, 5 );
79 mySpinBox->setSingleStep( 1 );
81 mySpinBox->setObjectName("SpinBoxU");
82 mySpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
83 mySpinBox->setValue(1);
84 GroupC1Layout->addWidget(mySpinBox, 0, 1);
87 /***************************************************************/
88 QGroupBox* GroupButtons = new QGroupBox (this);
89 GroupButtons->setObjectName("GroupButtons");
90 QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons);
91 GroupButtonsLayout->setAlignment(Qt::AlignTop);
92 GroupButtonsLayout->setSpacing(6);
93 GroupButtonsLayout->setMargin(11);
95 QPushButton* buttonOk = new QPushButton (GroupButtons);
96 buttonOk->setObjectName("buttonOk");
97 buttonOk->setText(tr("GEOM_BUT_OK"));
98 buttonOk->setAutoDefault(true);
99 buttonOk->setDefault(true);
100 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
102 GroupButtonsLayout->addItem(new QSpacerItem (20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
104 QPushButton* buttonCancel = new QPushButton (GroupButtons);
105 buttonCancel->setObjectName("buttonCancel");
106 buttonCancel->setText(tr("GEOM_BUT_CANCEL"));
107 buttonCancel->setAutoDefault(true);
108 GroupButtonsLayout->addWidget(buttonCancel, 0, 1);
110 QPushButton* buttonHelp = new QPushButton (GroupButtons);
111 buttonHelp->setObjectName("buttonHelp");
112 buttonHelp->setText(tr("GEOM_BUT_HELP"));
113 buttonHelp->setAutoDefault(true);
114 GroupButtonsLayout->addWidget(buttonHelp, 0, 2);
115 /***************************************************************/
117 MyDialogLayout->addWidget(GroupC1, 0, 0);
118 MyDialogLayout->addWidget(GroupButtons, 1, 0);
120 myHelpFileName = "line_width_page.html";
122 // signals and slots connections
123 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
124 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
125 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
127 // Move widget on the botton right corner of main widget
128 SUIT_Tools::centerWidget(this, parent);
132 //=================================================================================
133 // function : ~GEOMToolsGUI_LineWidthDlg()
134 // purpose : Destroys the object and frees any allocated resources
135 //=================================================================================
136 GEOMToolsGUI_LineWidthDlg::~GEOMToolsGUI_LineWidthDlg()
138 // no need to delete child widgets, Qt does it all for us
141 int GEOMToolsGUI_LineWidthDlg::getTheLW() const
143 return mySpinBox->text().toInt();
146 void GEOMToolsGUI_LineWidthDlg::setTheLW (const int v)
148 mySpinBox->setValue(v);
152 //=================================================================================
153 // function : ClickOnHelp()
155 //=================================================================================
156 void GEOMToolsGUI_LineWidthDlg::ClickOnHelp()
158 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
160 GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>(app->module("Geometry"));
161 app->onHelpContextModule(aGeomGUI ? app->moduleName(aGeomGUI->moduleName()) : QString(""), myHelpFileName);
166 platform = "winapplication";
168 platform = "application";
170 SUIT_MessageBox::warning
171 (0, QObject::tr("WRN_WARNING"),
172 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
173 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
174 QObject::tr("BUT_OK"));
178 //=================================================================================
179 // function : keyPressEvent()
181 //=================================================================================
182 void GEOMToolsGUI_LineWidthDlg::keyPressEvent (QKeyEvent* e)
184 QDialog::keyPressEvent(e);
188 if (e->key() == Qt::Key_F1) {