15 #include <QToolButton> 16 #include <QGridLayout> 17 #include <QFileDialog> 23 #include <QInputDialog> 33 mViewService(viewService),
34 mPatientModelService(patientModelService)
36 this->setObjectName(
"preferences_general_widget");
37 mPatientDataFolderComboBox = NULL;
38 mVLCPathComboBox = NULL;
39 mToolConfigFolderComboBox = NULL;
45 mGlobalPatientDataFolder =
profile()->getSessionRootFolder();
47 if(!QFile::exists(mVLCPath))
53 QLabel* patientDataFolderLabel =
new QLabel(tr(
"Patient data folder:"));
54 mPatientDataFolderComboBox =
new QComboBox;
55 mPatientDataFolderComboBox->addItem( mGlobalPatientDataFolder);
56 QAction* browsePatientFolderAction =
new QAction(QIcon(
":/icons/open.png"), tr(
"B&rowse..."),
this);
57 connect(browsePatientFolderAction, SIGNAL(triggered()),
this, SLOT(browsePatientDataFolderSlot()));
58 QToolButton* browsePatientFolderButton =
new QToolButton(
this);
59 browsePatientFolderButton->setDefaultAction(browsePatientFolderAction);
62 QLabel* vlcPathLabel =
new QLabel(tr(
"VLC path:"));
63 mVLCPathComboBox =
new QComboBox();
64 mVLCPathComboBox->addItem( mVLCPath);
65 QAction* browseVLCPathAction =
new QAction(QIcon(
":/icons/open.png"), tr(
"Browse for VLC..."),
this);
66 connect(browseVLCPathAction, SIGNAL(triggered()),
this, SLOT(browseVLCPathSlot()));
67 QToolButton* browseVLCPathButton =
new QToolButton(
this);
68 browseVLCPathButton->setDefaultAction(browseVLCPathAction);
80 bool filterToolPositions =
settings()->
value(
"TrackingPositionFilter/enabled").value<
bool>();
82 "Smooth the tool tracking positions using a low-pass filter.",
86 double filterToolPositionsCutoff =
settings()->
value(
"TrackingPositionFilter/cutoffFrequency").value<
double>();
87 mFilterToolPositionsCutoff
89 "If filtering enabled,\nfilter out tool movements faster than this frequency (Hz)",
90 filterToolPositionsCutoff,
DoubleRange(0.1, 10, 0.1), 1);
92 QToolButton* addProfileButton = this->createAddProfileButton();
95 QGridLayout *mainLayout =
new QGridLayout;
96 mainLayout->addWidget(patientDataFolderLabel, 0, 0);
97 mainLayout->addWidget(mPatientDataFolderComboBox, 0, 1);
98 mainLayout->addWidget(browsePatientFolderButton, 0, 2);
102 createDataWidget(mViewService, mPatientModelService,
this, profileSelector, mainLayout, 1);
103 mainLayout->addWidget(addProfileButton, 1, 2);
105 mainLayout->addWidget(vlcPathLabel, 2, 0);
106 mainLayout->addWidget(mVLCPathComboBox, 2, 1);
107 mainLayout->addWidget(browseVLCPathButton, 2, 2);
109 QGroupBox* filterToolPositionsGroupBox =
new QGroupBox(
"Filter Tool Positions");
110 QGridLayout* filterToolPositionsLayout =
new QGridLayout(filterToolPositionsGroupBox);
111 createDataWidget(mViewService, mPatientModelService,
this, mFilterToolPositions, filterToolPositionsLayout, 0);
112 createDataWidget(mViewService, mPatientModelService,
this, mFilterToolPositionsCutoff, filterToolPositionsLayout, 1);
113 mainLayout->addWidget(filterToolPositionsGroupBox, 3, 0, 1, 3 );
121 QToolButton* GeneralTab::createAddProfileButton()
123 QString tip =
"Create a new profile based on the current";
124 QAction* action =
new QAction(QIcon(
":/icons/preset_save.png"),
"Add",
this);
125 action->setStatusTip(tip);
126 action->setWhatsThis(tip);
127 action->setToolTip(tip);
128 connect(action, &QAction::triggered,
this, &GeneralTab::onAddProfile);
130 QToolButton* button =
new QToolButton();
131 button->setDefaultAction(action);
135 void GeneralTab::onAddProfile()
142 name = QString(
"%1(%2)").arg(current).arg(i);
143 if (!profiles.contains(name, Qt::CaseInsensitive))
148 QString text = QInputDialog::getText(
this,
"Select profile name",
149 "Name", QLineEdit::Normal, name, &ok);
150 if (!ok || text.isEmpty())
153 this->selectProfile(text);
156 void GeneralTab::browsePatientDataFolderSlot()
158 mGlobalPatientDataFolder = QFileDialog::getExistingDirectory(
this,
159 tr(
"Find Patient Data Folder"),
160 mGlobalPatientDataFolder,
161 QFileDialog::ShowDirsOnly);
162 if( !mGlobalPatientDataFolder.isEmpty() ) {
163 mPatientDataFolderComboBox->addItem( mGlobalPatientDataFolder );
164 mPatientDataFolderComboBox->setCurrentIndex( mPatientDataFolderComboBox->currentIndex() + 1 );
168 void GeneralTab::browseVLCPathSlot()
170 mVLCPath = QFileDialog::getOpenFileName(
this, tr(
"Find VLC executable"));
172 if(!mVLCPath.isEmpty())
174 mVLCPathComboBox->addItem( mVLCPath );
175 mVLCPathComboBox->setCurrentIndex( mVLCPathComboBox->currentIndex() + 1 );
184 QString defaultValue =
profile()->getUid();
186 "Choose profile, containing settings and configuration",
196 void GeneralTab::onProfileChanged()
199 mSelector->setValue(
profile()->getUid());
202 void GeneralTab::onProfileSelected()
204 this->selectProfile(mSelector->getValue());
207 void GeneralTab::selectProfile(QString uid)
209 this->rejectDialog();
213 void GeneralTab::rejectDialog()
215 QObject* item =
this;
218 QDialog* dialog =
dynamic_cast<QDialog*
>(item);
224 item = item->parent();
228 void GeneralTab::searchForVLC(QStringList searchPaths)
231 if(
vlc()->hasVLCApplication())
237 profile()->setSessionRootFolder(mGlobalPatientDataFolder);
239 settings()->
setValue(
"TrackingPositionFilter/enabled", mFilterToolPositions->getValue());
240 settings()->
setValue(
"TrackingPositionFilter/cutoffFrequency", mFilterToolPositionsCutoff->getValue());
cxResource_EXPORT ProfilePtr profile()
void activeProfileChanged()
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
ProfilePtr activeProfile()
Utility class for describing a bounded numeric range.
static ProfileManager * getInstance(QString defaultProfile=QString("Laboratory"))
returns the only instance of this class
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
QStringList getProfiles()
QWidget * createDataWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
void setValue(const QString &key, const QVariant &value)
boost::shared_ptr< class StringProperty > StringPropertyPtr
void findVLCApplication(QStringList suggestedVLCLocations=QStringList())
GeneralTab(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent=0)
static LogicManager * getInstance()
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void saveParametersSlot()
Settings * settings()
Shortcut for accessing the settings instance.
void restartWithNewProfile(QString uid)
static StringPropertyPtr initialize(const QString &uid, QString name, QString help, QString value, QStringList range, QDomNode root=QDomNode())
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
VLCRecorder * vlc()
Shortcut for accessing the vlc recorder.
Namespace for all CustusX production code.