37 #include <QHBoxLayout> 39 #include <QToolButton> 41 #include <QMetaObject> 47 #include "boost/bind.hpp" 48 #include <QMetaMethod> 49 #include "libQtSignalAdapters/Qt2Func.h" 50 #include "libQtSignalAdapters/ConnectionFactories.h" 65 mRenderingFpsLabel(new QLabel(this)),
66 mGrabbingInfoLabel(new QLabel(this)),
67 mRecordFullscreenLabel(new QLabel(this)),
68 mTpsLabel(new QLabel(this)),
69 mTrackingService(trackingService)
80 connect(trackingService.get(), SIGNAL(activeToolChanged(
const QString&)),
this, SLOT(updateToolButtons()));
82 connect(viewService.get(), SIGNAL(fps(
int)),
this, SLOT(renderingFpsSlot(
int)));
84 connect(videoService.get(), SIGNAL(fps(
int)),
this, SLOT(grabbingFpsSlot(
int)));
85 connect(videoService.get(), SIGNAL(connected(
bool)),
this, SLOT(grabberConnectedSlot(
bool)));
90 this->addPermanentWidget(mRenderingFpsLabel);
97 void StatusBar::resetToolManagerConnection()
99 this->disconnectFromToolSignals();
101 this->connectToToolSignals();
102 this->updateToolButtons();
105 void StatusBar::connectToToolSignals()
107 this->disconnectFromToolSignals();
109 this->addPermanentWidget(mTpsLabel);
113 for (TrackingService::ToolMap::iterator it = tools.begin(); it != tools.end(); ++it)
118 if (tool == mTrackingService->getManualTool())
120 connect(tool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
123 current.mTool = tool;
124 current.mAction.reset(
new QAction(tool->getName(), NULL));
125 current.mAction->setToolTip(
"Press to set active");
127 QtSignalAdapters::connect0<void()>(
128 current.mAction.get(),
130 boost::bind(&StatusBar::activateTool,
this, tool->getUid()));
132 current.mButton.reset(
new QToolButton);
133 current.mButton->setDefaultAction(current.mAction.get());
134 this->addPermanentWidget(current.mButton.get());
135 mToolData.push_back(current);
138 this->updateToolButtons();
141 void StatusBar::disconnectFromToolSignals()
143 this->removeWidget(mTpsLabel);
145 for (
unsigned i = 0; i < mToolData.size(); ++i)
147 ToolData current = mToolData[i];
149 disconnect(current.mTool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
150 this->removeWidget(current.mButton.get());
156 void StatusBar::activateTool(QString uid)
158 mTrackingService->setActiveTool(uid);
161 void StatusBar::updateToolButtons()
163 ToolPtr activeTool = mTrackingService->getActiveTool();
165 for (
unsigned i = 0; i < mToolData.size(); ++i)
167 ToolData current = mToolData[i];
169 QString color = this->getToolStyle(tool->getVisible(), tool->isInitialized(), activeTool == tool);
170 current.mButton->setStyleSheet(QString(
"QToolButton { %1; }").arg(color));
172 if (!tool->isInitialized())
173 current.mAction->setToolTip(
"Tool is not Initialized");
174 else if (activeTool == tool)
175 current.mAction->setToolTip(
"Active Tool");
176 else if (!tool->getVisible())
177 current.mAction->setToolTip(
"Tool not visible/not tracking");
179 current.mAction->setToolTip(
"Tool visible. Press to set as active");
183 QString StatusBar::getToolStyle(
bool visible,
bool initialized,
bool active)
186 return QString(
"background-color: silver");
191 return QString(
"background-color: lime");
193 return QString(
"background-color: green");
196 return QString(
"background-color: orangered");
199 void StatusBar::renderingFpsSlot(
int numFps)
201 QString fpsString =
"FPS: " + QString::number(numFps);
202 mRenderingFpsLabel->setText(fpsString);
205 void StatusBar::tpsSlot(
int numTps)
207 QString tpsString =
"TPS: " + QString::number(numTps);
208 mTpsLabel->setText(tpsString);
211 void StatusBar::grabbingFpsSlot(
int numFps)
213 QString infoString =
"VideoConnection-FPS: " + QString::number(numFps);
214 mGrabbingInfoLabel->setText(infoString);
217 void StatusBar::grabberConnectedSlot(
bool connected)
221 this->addPermanentWidget(mGrabbingInfoLabel);
222 mGrabbingInfoLabel->show();
225 this->removeWidget(mGrabbingInfoLabel);
228 void StatusBar::onRecordFullscreenChanged()
230 QLabel* label = mRecordFullscreenLabel;
232 if (
vlc()->isRecording())
235 int size = this->height()*0.75;
237 map.load(
":/icons/Video-icon_green.png");
238 label->setPixmap(map.scaled(size, size, Qt::KeepAspectRatio));
240 this->addPermanentWidget(mRecordFullscreenLabel);
241 mRecordFullscreenLabel->show();
245 this->removeWidget(mRecordFullscreenLabel);
249 void StatusBar::showMessageSlot(
Message message)
251 QString text = QString(
"[%1] %4")
255 this->showMessage(text, message.
getTimeout());
QString qstring_cast(const T &val)
static MessageListenerPtr create(LogPtr log=LogPtr())
boost::shared_ptr< class VideoService > VideoServicePtr
boost::shared_ptr< class TrackingService > TrackingServicePtr
StatusBar(TrackingServicePtr trackingService, ViewServicePtr viewService, VideoServicePtr videoService)
connects signals and slots
QString getText() const
The raw message.
static MessageFilterStatusBarPtr create()
int getTimeout() const
Timout tells the statusbar how long it should be displayed, this depends on the message level...
std::map< QString, ToolPtr > ToolMap
void newMessage(Message message)
MESSAGE_LEVEL getMessageLevel() const
The category of the message.
virtual ~StatusBar()
empty
VLCRecorder * vlc()
Shortcut for accessing the vlc recorder.
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr