QtDcmDcm2niiSettingsWidget.cpp
Go to the documentation of this file.
1 /*
2  QtDcm is a C++ Qt based library for communication and conversion of Dicom images.
3  Copyright (C) 2011 Alexandre Abadie <Alexandre.Abadie@univ-rennes1.fr>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
21 
22 #include <QFileDialog>
23 
24 #include <QtDcmPreferences.h>
25 
27  : QWidget(parent)
28 {
29  this->setupUi(this);
30 
31  QObject::connect(browseDcm2niiButton, SIGNAL(clicked()), this, SLOT(onBrowseDcm2niiPathClicked()));
32  QObject::connect(dcm2niiCheckBox, SIGNAL(stateChanged(int)), this, SLOT(onUseDcm2niiCheckChanged(int)));
33 }
34 
36 {
37 }
38 
40 {
41  dcm2niiCheckBox->setChecked(QtDcmPreferences::instance()->useDcm2nii());
42  dcm2niiLineEdit->setText( QtDcmPreferences::instance()->dcm2niiPath());
43 }
44 
46 {
47  QtDcmPreferences::instance()->setDcm2niiPath(dcm2niiLineEdit->text());
48  QtDcmPreferences::instance()->setUseDcm2nii(dcm2niiCheckBox->isChecked());
49 }
50 
52 {
53  // Open aa QFileDialog in directory mode.
54  QFileDialog * dialog = new QFileDialog(this);
55  dialog->setFileMode(QFileDialog::ExistingFile);
56 #ifdef Q_OS_UNIX
57  dialog->setNameFilter(tr("Dcm2nii (dcm2nii)"));
58 #else
59  dialog->setNameFilter(tr("Dcm2nii (dcm2nii.exe)"));
60 #endif
61  dialog->setDirectory(QDir::home().dirName());
62  dialog->setWindowTitle("Choose dcm2nii path");
63  QString filename;
64  if (dialog->exec())
65  {
66  filename = dialog->selectedFiles()[0];
67  }
68  dialog->close();
69  if (!filename.isEmpty()) // A file has been chosen
70  {
71  // The the output directory to the manager and launch the conversion process
73  dcm2niiLineEdit->setText(filename);
74  }
75 }
76 
78 {
79  dcm2niiPathFrame->setEnabled((state == Qt::Checked));
80  QtDcmPreferences::instance()->setUseDcm2nii((state == Qt::Checked));
81 }
82 
83 
84 
static QtDcmPreferences * instance()
void setUseDcm2nii(bool use)
void setDcm2niiPath(const QString &path)