36 #include <QToolButton>
37 #include <QGridLayout>
38 #include <QFileDialog>
44 #include <QInputDialog>
53 mViewService(viewService),
54 mPatientModelService(patientModelService)
56 this->setObjectName(
"preferences_general_widget");
57 mPatientDataFolderComboBox = NULL;
58 mVLCPathComboBox = NULL;
59 mToolConfigFolderComboBox = NULL;
65 mGlobalPatientDataFolder =
profile()->getSessionRootFolder();
67 if(!QFile::exists(mVLCPath))
73 QLabel* patientDataFolderLabel =
new QLabel(tr(
"Patient data folder:"));
74 mPatientDataFolderComboBox =
new QComboBox;
75 mPatientDataFolderComboBox->addItem( mGlobalPatientDataFolder);
76 QAction* browsePatientFolderAction =
new QAction(QIcon(
":/icons/open.png"), tr(
"B&rowse..."),
this);
77 connect(browsePatientFolderAction, SIGNAL(triggered()),
this, SLOT(browsePatientDataFolderSlot()));
78 QToolButton* browsePatientFolderButton =
new QToolButton(
this);
79 browsePatientFolderButton->setDefaultAction(browsePatientFolderAction);
82 QLabel* vlcPathLabel =
new QLabel(tr(
"VLC path:"));
83 mVLCPathComboBox =
new QComboBox();
84 mVLCPathComboBox->addItem( mVLCPath);
85 QAction* browseVLCPathAction =
new QAction(QIcon(
":/icons/open.png"), tr(
"Browse for VLC..."),
this);
86 connect(browseVLCPathAction, SIGNAL(triggered()),
this, SLOT(browseVLCPathSlot()));
87 QToolButton* browseVLCPathButton =
new QToolButton(
this);
88 browseVLCPathButton->setDefaultAction(browseVLCPathAction);
100 bool filterToolPositions =
settings()->
value(
"TrackingPositionFilter/enabled").value<
bool>();
102 "Smooth the tool tracking positions using a low-pass filter.",
103 filterToolPositions);
105 QToolButton* addProfileButton = this->createAddProfileButton();
108 QGridLayout *mainLayout =
new QGridLayout;
109 mainLayout->addWidget(patientDataFolderLabel, 0, 0);
110 mainLayout->addWidget(mPatientDataFolderComboBox, 0, 1);
111 mainLayout->addWidget(browsePatientFolderButton, 0, 2);
115 createDataWidget(mViewService, mPatientModelService,
this, profileSelector, mainLayout, 1);
116 mainLayout->addWidget(addProfileButton, 1, 2);
118 mainLayout->addWidget(vlcPathLabel, 2, 0);
119 mainLayout->addWidget(mVLCPathComboBox, 2, 1);
120 mainLayout->addWidget(browseVLCPathButton, 2, 2);
122 createDataWidget(mViewService, mPatientModelService,
this, mFilterToolPositions, mainLayout, 3);
131 QToolButton* GeneralTab::createAddProfileButton()
133 QString tip =
"Create a new profile based on the current";
134 QAction* action =
new QAction(QIcon(
":/icons/preset_save.png"),
"Add",
this);
135 action->setStatusTip(tip);
136 action->setWhatsThis(tip);
137 action->setToolTip(tip);
138 connect(action, &QAction::triggered,
this, &GeneralTab::onAddProfile);
140 QToolButton* button =
new QToolButton();
141 button->setDefaultAction(action);
145 void GeneralTab::onAddProfile()
152 name = QString(
"%1(%2)").arg(current).arg(i);
153 if (!profiles.contains(name, Qt::CaseInsensitive))
158 QString text = QInputDialog::getText(
this,
"Select profile name",
159 "Name", QLineEdit::Normal, name, &ok);
160 if (!ok || text.isEmpty())
163 this->selectProfile(text);
166 void GeneralTab::browsePatientDataFolderSlot()
168 mGlobalPatientDataFolder = QFileDialog::getExistingDirectory(
this,
169 tr(
"Find Patient Data Folder"),
170 mGlobalPatientDataFolder,
171 QFileDialog::ShowDirsOnly);
172 if( !mGlobalPatientDataFolder.isEmpty() ) {
173 mPatientDataFolderComboBox->addItem( mGlobalPatientDataFolder );
174 mPatientDataFolderComboBox->setCurrentIndex( mPatientDataFolderComboBox->currentIndex() + 1 );
178 void GeneralTab::browseVLCPathSlot()
180 mVLCPath = QFileDialog::getOpenFileName(
this, tr(
"Find VLC executable"));
182 if(!mVLCPath.isEmpty())
184 mVLCPathComboBox->addItem( mVLCPath );
185 mVLCPathComboBox->setCurrentIndex( mVLCPathComboBox->currentIndex() + 1 );
194 QString defaultValue =
profile()->getUid();
196 "Choose profile, containing settings and configuration",
197 defaultValue, manager->getProfiles(), QDomNode());
206 void GeneralTab::onProfileChanged()
209 mSelector->setValue(
profile()->getUid());
212 void GeneralTab::onProfileSelected()
214 this->selectProfile(mSelector->getValue());
217 void GeneralTab::selectProfile(QString uid)
219 this->rejectDialog();
223 void GeneralTab::rejectDialog()
225 QObject* item =
this;
228 QDialog* dialog =
dynamic_cast<QDialog*
>(item);
234 item = item->parent();
238 void GeneralTab::searchForVLC(QStringList searchPaths)
241 if(
vlc()->hasVLCApplication())
247 profile()->setSessionRootFolder(mGlobalPatientDataFolder);
249 settings()->
setValue(
"TrackingPositionFilter/enabled", mFilterToolPositions->getValue());
cxResource_EXPORT ProfilePtr profile()
void activeProfileChanged()
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
ProfilePtr activeProfile()
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())
cxLogicManager_EXPORT ViewServicePtr viewService()
VLCRecorder * vlc()
Shortcut for accessing the vlc recorder.