36 #include <QToolButton>
37 #include <QGridLayout>
38 #include <QFileDialog>
44 #include <QInputDialog>
53 mVisualizationService(visualizationService),
54 mPatientModelService(patientModelService)
56 mPatientDataFolderComboBox = NULL;
57 mVLCPathComboBox = NULL;
58 mToolConfigFolderComboBox = NULL;
64 mGlobalPatientDataFolder =
settings()->
value(
"globalPatientDataFolder").toString();
66 if(!QFile::exists(mVLCPath))
72 QLabel* patientDataFolderLabel =
new QLabel(tr(
"Patient data folder:"));
73 mPatientDataFolderComboBox =
new QComboBox;
74 mPatientDataFolderComboBox->addItem( mGlobalPatientDataFolder);
75 QAction* browsePatientFolderAction =
new QAction(QIcon(
":/icons/open.png"), tr(
"B&rowse..."),
this);
76 connect(browsePatientFolderAction, SIGNAL(triggered()),
this, SLOT(browsePatientDataFolderSlot()));
77 QToolButton* browsePatientFolderButton =
new QToolButton(
this);
78 browsePatientFolderButton->setDefaultAction(browsePatientFolderAction);
81 QLabel* vlcPathLabel =
new QLabel(tr(
"VLC path:"));
82 mVLCPathComboBox =
new QComboBox();
83 mVLCPathComboBox->addItem( mVLCPath);
84 QAction* browseVLCPathAction =
new QAction(QIcon(
":/icons/open.png"), tr(
"Browse for VLC..."),
this);
85 connect(browseVLCPathAction, SIGNAL(triggered()),
this, SLOT(browseVLCPathSlot()));
86 QToolButton* browseVLCPathButton =
new QToolButton(
this);
87 browseVLCPathButton->setDefaultAction(browseVLCPathAction);
99 bool filterToolPositions =
settings()->
value(
"TrackingPositionFilter/enabled").value<
bool>();
101 "Smooth the tool tracking positions using a low-pass filter.",
102 filterToolPositions);
104 QToolButton* addProfileButton = this->createAddProfileButton();
107 QGridLayout *mainLayout =
new QGridLayout;
108 mainLayout->addWidget(patientDataFolderLabel, 0, 0);
109 mainLayout->addWidget(mPatientDataFolderComboBox, 0, 1);
110 mainLayout->addWidget(browsePatientFolderButton, 0, 2);
114 createDataWidget(mVisualizationService, mPatientModelService,
this, profileSelector, mainLayout, 1);
115 mainLayout->addWidget(addProfileButton, 1, 2);
117 mainLayout->addWidget(vlcPathLabel, 2, 0);
118 mainLayout->addWidget(mVLCPathComboBox, 2, 1);
119 mainLayout->addWidget(browseVLCPathButton, 2, 2);
121 createDataWidget(mVisualizationService, mPatientModelService,
this, mFilterToolPositions, mainLayout, 3);
130 QToolButton* GeneralTab::createAddProfileButton()
132 QString tip =
"Create a new profile based on the current";
133 QAction* action =
new QAction(QIcon(
":/icons/preset_save.png"),
"Add",
this);
134 action->setStatusTip(tip);
135 action->setWhatsThis(tip);
136 action->setToolTip(tip);
137 connect(action, &QAction::triggered,
this, &GeneralTab::onAddProfile);
139 QToolButton* button =
new QToolButton();
140 button->setDefaultAction(action);
144 void GeneralTab::onAddProfile()
151 name = QString(
"%1(%2)").arg(current).arg(i);
152 if (!profiles.contains(name, Qt::CaseInsensitive))
157 QString text = QInputDialog::getText(
this,
"Select profile name",
158 "Name", QLineEdit::Normal, name, &ok);
159 if (!ok || text.isEmpty())
162 this->selectProfile(text);
165 void GeneralTab::browsePatientDataFolderSlot()
167 mGlobalPatientDataFolder = QFileDialog::getExistingDirectory(
this,
168 tr(
"Find Patient Data Folder"),
169 mGlobalPatientDataFolder,
170 QFileDialog::ShowDirsOnly);
171 if( !mGlobalPatientDataFolder.isEmpty() ) {
172 mPatientDataFolderComboBox->addItem( mGlobalPatientDataFolder );
173 mPatientDataFolderComboBox->setCurrentIndex( mPatientDataFolderComboBox->currentIndex() + 1 );
177 void GeneralTab::browseVLCPathSlot()
179 mVLCPath = QFileDialog::getOpenFileName(
this, tr(
"Find VLC executable"));
181 if(!mVLCPath.isEmpty())
183 mVLCPathComboBox->addItem( mVLCPath );
184 mVLCPathComboBox->setCurrentIndex( mVLCPathComboBox->currentIndex() + 1 );
193 QString defaultValue =
profile()->getUid();
195 "Choose profile, containing settings and configuration",
196 defaultValue, manager->getProfiles(), QDomNode());
205 void GeneralTab::onProfileChanged()
208 mSelector->setValue(
profile()->getUid());
211 void GeneralTab::onProfileSelected()
213 this->selectProfile(mSelector->getValue());
216 void GeneralTab::selectProfile(QString uid)
218 this->rejectDialog();
222 void GeneralTab::rejectDialog()
224 QObject* item =
this;
227 QDialog* dialog =
dynamic_cast<QDialog*
>(item);
233 item = item->parent();
237 void GeneralTab::searchForVLC(QStringList searchPaths)
240 if(
vlc()->hasVLCApplication())
248 settings()->
setValue(
"TrackingPositionFilter/enabled", mFilterToolPositions->getValue());
GeneralTab(VisualizationServicePtr visualizationService, PatientModelServicePtr patientModelService, QWidget *parent=0)
cxResource_EXPORT ProfilePtr profile()
void activeProfileChanged()
static BoolPropertyPtr initialize(const QString &uid, QString name, QString help, bool value, QDomNode root=QDomNode())
ProfilePtr activeProfile()
QWidget * createDataWidget(VisualizationServicePtr visualizationService, PatientModelServicePtr patientModelService, QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
QStringList getProfiles()
void setValue(const QString &key, const QVariant &value)
boost::shared_ptr< class StringProperty > StringPropertyPtr
void findVLCApplication(QStringList suggestedVLCLocations=QStringList())
static ProfileManager * getInstance()
returns the only instance of this class
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())
VLCRecorder * vlc()
Shortcut for accessing the vlc recorder.