#include <QmitkInputDevicesPrefPage.h>


Public Member Functions | |
| QmitkInputDevicesPrefPage () | |
| void | Init (berry::IWorkbench::Pointer workbench) |
| void | CreateQtControl (QWidget *widget) |
| QWidget * | GetQtControl () const |
| virtual bool | PerformOk () |
| virtual void | PerformCancel () |
| virtual void | Update () |
Protected Attributes | |
| QWidget * | m_MainControl |
| QHash< QCheckBox *, std::string > | m_InputDevices |
| berry::IPreferences::Pointer | m_InputDevicesPrefNode |
Definition at line 29 of file QmitkInputDevicesPrefPage.h.
| QmitkInputDevicesPrefPage::QmitkInputDevicesPrefPage | ( | ) |
Default constructor
Definition at line 35 of file QmitkInputDevicesPrefPage.cpp.
References berry::Platform::GetServiceRegistry(), ID, mitk::CoreExtConstants::INPUTDEVICE_PREFERENCES, and m_InputDevicesPrefNode.
: m_MainControl(0) { // gets the old setting of the preferences and loads them into the preference node berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById<berry::IPreferencesService>(berry::IPreferencesService::ID); this->m_InputDevicesPrefNode = prefService->GetSystemPreferences()->Node(mitk::CoreExtConstants::INPUTDEVICE_PREFERENCES); }
| void QmitkInputDevicesPrefPage::CreateQtControl | ( | QWidget * | widget ) | [virtual] |
Implements berry::IQtPreferencePage.
Definition at line 49 of file QmitkInputDevicesPrefPage.cpp.
References berry::Platform::GetServiceRegistry(), mitk::CoreExtConstants::INPUTDEVICE_SERVICE, m_InputDevices, m_MainControl, and Update().
{
m_MainControl = new QWidget(parent);
QVBoxLayout *layout = new QVBoxLayout;
mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry =
berry::Platform::GetServiceRegistry().GetServiceById<mitk::IInputDeviceRegistry>(mitk::CoreExtConstants::INPUTDEVICE_SERVICE);
std::vector<mitk::IInputDeviceDescriptor::Pointer> temp(inputDeviceRegistry->GetInputDevices());
for(std::vector<mitk::IInputDeviceDescriptor::Pointer>::const_iterator it = temp.begin(); it != temp.end();++it)
{
QCheckBox* checkBox = new QCheckBox(QString::fromStdString((*it)->GetName()),m_MainControl);
layout->addWidget(checkBox);
m_InputDevices.insert(checkBox,(*it)->GetID());
}
layout->addStretch();
m_MainControl->setLayout(layout);
this->Update();
}
| QWidget * QmitkInputDevicesPrefPage::GetQtControl | ( | ) | const [virtual] |
Implements berry::IQtPreferencePage.
Definition at line 70 of file QmitkInputDevicesPrefPage.cpp.
References m_MainControl.
{
return m_MainControl;
}
| void QmitkInputDevicesPrefPage::Init | ( | berry::IWorkbench::Pointer | workbench ) | [virtual] |
| void QmitkInputDevicesPrefPage::PerformCancel | ( | ) | [virtual] |
Implements berry::IPreferencePage.
Definition at line 119 of file QmitkInputDevicesPrefPage.cpp.
{
}
| bool QmitkInputDevicesPrefPage::PerformOk | ( | ) | [virtual] |
Implements berry::IPreferencePage.
Definition at line 75 of file QmitkInputDevicesPrefPage.cpp.
References berry::Platform::GetServiceRegistry(), mitk::CoreExtConstants::INPUTDEVICE_SERVICE, m_InputDevices, and m_InputDevicesPrefNode.
{
bool result = true;
mitk::IInputDeviceRegistry::Pointer inputDeviceRegistry =
berry::Platform::GetServiceRegistry().GetServiceById<mitk::IInputDeviceRegistry>(mitk::CoreExtConstants::INPUTDEVICE_SERVICE);
QHashIterator<QCheckBox*, std::string> it(m_InputDevices);
while (it.hasNext())
{
it.next();
mitk::IInputDeviceDescriptor::Pointer inputdevice(inputDeviceRegistry->Find(it.value()));
if(it.key()->isChecked())
{
result &= inputdevice->CreateInputDevice()->RegisterInputDevice();
}
else
{
result &= inputdevice->CreateInputDevice()->UnRegisterInputDevice();
// temporary fix, unclean solution:
// e.g. user activates SpaceNavigator and leaves the
// the wiimote deactivated, the user will get the warning
// despite the fact that it has never been activated
if(it.value() == "org.mitk.inputdevices.wiimote")
{
// until now 2010-09-06 there were some unfixed problems
// with reconnecting the wiimote after disconnecting it.
// It was suggested that it might have something to do
// with the type of stack, that is used for the pairing.
// MS-Stack for example does not work properly.
QMessageBox::information(NULL,"WiiMote supportproblem",
"A reconnect of the WiiMote is not yet supported! "
"Please restart the application, if you want to "
"activate the Wii remote/s again.");
}
}
if(result)
{
this->m_InputDevicesPrefNode->PutBool(it.value(),it.key()->isChecked());
}
}
return result;
}
| void QmitkInputDevicesPrefPage::Update | ( | ) | [virtual] |
Implements berry::IPreferencePage.
Definition at line 124 of file QmitkInputDevicesPrefPage.cpp.
References m_InputDevices, and m_InputDevicesPrefNode.
Referenced by CreateQtControl().
{
QHashIterator<QCheckBox*, std::string> it(m_InputDevices);
while (it.hasNext())
{
it.next();
it.key()->setChecked(this->m_InputDevicesPrefNode->GetBool(it.value(), false));
}
}
QHash<QCheckBox*,std::string> QmitkInputDevicesPrefPage::m_InputDevices [protected] |
Definition at line 74 of file QmitkInputDevicesPrefPage.h.
Referenced by CreateQtControl(), PerformOk(), and Update().
Definition at line 76 of file QmitkInputDevicesPrefPage.h.
Referenced by PerformOk(), QmitkInputDevicesPrefPage(), and Update().
QWidget* QmitkInputDevicesPrefPage::m_MainControl [protected] |
Definition at line 72 of file QmitkInputDevicesPrefPage.h.
Referenced by CreateQtControl(), and GetQtControl().
1.7.2