36 #include <QToolButton> 37 #include <QGridLayout> 38 #include <QFileDialog> 44 #include <QInputDialog> 54 mViewService(viewService),
55 mPatientModelService(patientModelService)
57 this->setObjectName(
"preferences_general_widget");
58 mPatientDataFolderComboBox = NULL;
59 mVLCPathComboBox = NULL;
60 mToolConfigFolderComboBox = NULL;
66 mGlobalPatientDataFolder =
profile()->getSessionRootFolder();
68 if(!QFile::exists(mVLCPath))
74 QLabel* patientDataFolderLabel =
new QLabel(tr(
"Patient data folder:"));
75 mPatientDataFolderComboBox =
new QComboBox;
76 mPatientDataFolderComboBox->addItem( mGlobalPatientDataFolder);
77 QAction* browsePatientFolderAction =
new QAction(QIcon(
":/icons/open.png"), tr(
"B&rowse..."),
this);
78 connect(browsePatientFolderAction, SIGNAL(triggered()),
this, SLOT(browsePatientDataFolderSlot()));
79 QToolButton* browsePatientFolderButton =
new QToolButton(
this);
80 browsePatientFolderButton->setDefaultAction(browsePatientFolderAction);
83 QLabel* vlcPathLabel =
new QLabel(tr(
"VLC path:"));
84 mVLCPathComboBox =
new QComboBox();
85 mVLCPathComboBox->addItem( mVLCPath);
86 QAction* browseVLCPathAction =
new QAction(QIcon(
":/icons/open.png"), tr(
"Browse for VLC..."),
this);
87 connect(browseVLCPathAction, SIGNAL(triggered()),
this, SLOT(browseVLCPathSlot()));
88 QToolButton* browseVLCPathButton =
new QToolButton(
this);
89 browseVLCPathButton->setDefaultAction(browseVLCPathAction);
101 bool filterToolPositions =
settings()->
value(
"TrackingPositionFilter/enabled").value<
bool>();
103 "Smooth the tool tracking positions using a low-pass filter.",
104 filterToolPositions);
107 double filterToolPositionsCutoff =
settings()->
value(
"TrackingPositionFilter/cutoffFrequency").value<
double>();
108 mFilterToolPositionsCutoff
110 "If filtering enabled,\nfilter out tool movements faster than this frequency (Hz)",
111 filterToolPositionsCutoff,
DoubleRange(0.1, 10, 0.1), 1);
113 QToolButton* addProfileButton = this->createAddProfileButton();
116 QGridLayout *mainLayout =
new QGridLayout;
117 mainLayout->addWidget(patientDataFolderLabel, 0, 0);
118 mainLayout->addWidget(mPatientDataFolderComboBox, 0, 1);
119 mainLayout->addWidget(browsePatientFolderButton, 0, 2);
123 createDataWidget(mViewService, mPatientModelService,
this, profileSelector, mainLayout, 1);
124 mainLayout->addWidget(addProfileButton, 1, 2);
126 mainLayout->addWidget(vlcPathLabel, 2, 0);
127 mainLayout->addWidget(mVLCPathComboBox, 2, 1);
128 mainLayout->addWidget(browseVLCPathButton, 2, 2);
130 QGroupBox* filterToolPositionsGroupBox =
new QGroupBox(
"Filter Tool Positions");
131 QGridLayout* filterToolPositionsLayout =
new QGridLayout(filterToolPositionsGroupBox);
132 createDataWidget(mViewService, mPatientModelService,
this, mFilterToolPositions, filterToolPositionsLayout, 0);
133 createDataWidget(mViewService, mPatientModelService,
this, mFilterToolPositionsCutoff, filterToolPositionsLayout, 1);
134 mainLayout->addWidget(filterToolPositionsGroupBox, 3, 0, 1, 3 );
142 QToolButton* GeneralTab::createAddProfileButton()
144 QString tip =
"Create a new profile based on the current";
145 QAction* action =
new QAction(QIcon(
":/icons/preset_save.png"),
"Add",
this);
146 action->setStatusTip(tip);
147 action->setWhatsThis(tip);
148 action->setToolTip(tip);
149 connect(action, &QAction::triggered,
this, &GeneralTab::onAddProfile);
151 QToolButton* button =
new QToolButton();
152 button->setDefaultAction(action);
156 void GeneralTab::onAddProfile()
163 name = QString(
"%1(%2)").arg(current).arg(i);
164 if (!profiles.contains(name, Qt::CaseInsensitive))
169 QString text = QInputDialog::getText(
this,
"Select profile name",
170 "Name", QLineEdit::Normal, name, &ok);
171 if (!ok || text.isEmpty())
174 this->selectProfile(text);
177 void GeneralTab::browsePatientDataFolderSlot()
179 mGlobalPatientDataFolder = QFileDialog::getExistingDirectory(
this,
180 tr(
"Find Patient Data Folder"),
181 mGlobalPatientDataFolder,
182 QFileDialog::ShowDirsOnly);
183 if( !mGlobalPatientDataFolder.isEmpty() ) {
184 mPatientDataFolderComboBox->addItem( mGlobalPatientDataFolder );
185 mPatientDataFolderComboBox->setCurrentIndex( mPatientDataFolderComboBox->currentIndex() + 1 );
189 void GeneralTab::browseVLCPathSlot()
191 mVLCPath = QFileDialog::getOpenFileName(
this, tr(
"Find VLC executable"));
193 if(!mVLCPath.isEmpty())
195 mVLCPathComboBox->addItem( mVLCPath );
196 mVLCPathComboBox->setCurrentIndex( mVLCPathComboBox->currentIndex() + 1 );
205 QString defaultValue =
profile()->getUid();
207 "Choose profile, containing settings and configuration",
217 void GeneralTab::onProfileChanged()
220 mSelector->setValue(
profile()->getUid());
223 void GeneralTab::onProfileSelected()
225 this->selectProfile(mSelector->getValue());
228 void GeneralTab::selectProfile(QString uid)
230 this->rejectDialog();
234 void GeneralTab::rejectDialog()
236 QObject* item =
this;
239 QDialog* dialog =
dynamic_cast<QDialog*
>(item);
245 item = item->parent();
249 void GeneralTab::searchForVLC(QStringList searchPaths)
252 if(
vlc()->hasVLCApplication())
258 profile()->setSessionRootFolder(mGlobalPatientDataFolder);
260 settings()->
setValue(
"TrackingPositionFilter/enabled", mFilterToolPositions->getValue());
261 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.