1 // Copyright (C) 2015-2016 CEA/DEN, EDF R&D
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 #include "DlgImageToMed.hxx"
21 #include "SALOME_GuiServices.hxx"
23 #include <SUIT_FileDlg.h>
24 #include <SUIT_Desktop.h>
27 #include <QStringList>
31 DlgImageToMed::DlgImageToMed(QDialog *parent) : GenericDialog(parent)
33 ui.setupUi(this->getPanel());
35 QString moduleName = "MED";
36 QPixmap aPixmap = GUI::getResourcesManager()->loadPixmap( moduleName, tr("ICO_FOLDER") );
38 ui.btnImageFileChooser->setIcon(icon);
39 ui.btnMedFileChooser->setIcon(icon);
41 connect(ui.btnImageFileChooser,SIGNAL(clicked()),
42 this, SLOT(OnBtnImageFileChooser()));
43 connect(ui.btnMedFileChooser,SIGNAL(clicked()),
44 this, SLOT(OnBtnMedFileChooser()));
46 this->setWindowTitle("Créer un champ à partir d'une image");
49 QString DlgImageToMed::getImageFilepath() {
50 return ui.txtImageFile->text().trimmed();
53 QString DlgImageToMed::getMedFilepath() {
54 return ui.txtMedFile->text().trimmed();
57 void DlgImageToMed::setAutoLoaded(bool autoloaded) {
59 ui.chkAutoLoad->setCheckState(Qt::Checked);
62 ui.chkAutoLoad->setCheckState(Qt::Unchecked);
66 bool DlgImageToMed::isAutoLoaded() {
67 Qt::CheckState state = ui.chkAutoLoad->checkState();
68 if ( state == Qt::Checked ) {
74 void DlgImageToMed::OnBtnImageFileChooser() {
76 filter.append(tr("FILE_FILTER_PNG"));
77 filter.append(tr("FILE_FILTER_JPG"));
78 filter.append(tr("FILE_FILTER_PGM"));
79 filter.append(tr("FILE_FILTER_ALL"));
80 QString filename = SUIT_FileDlg::getFileName(ui.btnImageFileChooser,
83 tr("SELECT_IMAGE_FILE"),
85 if ( filename.isEmpty() ) return;
86 ui.txtImageFile->setText(filename);
88 QString medFilename = (filename.remove(filename.size()-3,3))+"med";
89 ui.txtMedFile->setText(medFilename);
92 void DlgImageToMed::OnBtnMedFileChooser() {
94 filter.append(tr("FILE_FILTER_MED"));
95 QString filename = SUIT_FileDlg::getFileName(ui.btnMedFileChooser,
98 tr("SPECIFY_MED_FILE"),
100 if ( filename.isEmpty() ) return;
101 ui.txtMedFile->setText(filename);