16 #include <QHBoxLayout> 18 #include <QToolButton> 20 #include <QMetaObject> 26 #include "boost/bind.hpp" 27 #include <QMetaMethod> 28 #include "libQtSignalAdapters/Qt2Func.h" 29 #include "libQtSignalAdapters/ConnectionFactories.h" 43 mRenderingFpsLabel(new QLabel(this)),
44 mGrabbingInfoLabel(new QLabel(this)),
45 mRecordFullscreenLabel(new QLabel(this)),
46 mTpsLabel(new QLabel(this)),
47 mTrackingService(trackingService)
58 connect(trackingService.get(), SIGNAL(activeToolChanged(
const QString&)),
this, SLOT(updateToolButtons()));
60 connect(viewService.get(), SIGNAL(fps(
int)),
this, SLOT(renderingFpsSlot(
int)));
62 connect(videoService.get(), SIGNAL(fps(
int)),
this, SLOT(grabbingFpsSlot(
int)));
63 connect(videoService.get(), SIGNAL(connected(
bool)),
this, SLOT(grabberConnectedSlot(
bool)));
68 this->addPermanentWidget(mRenderingFpsLabel);
75 void StatusBar::resetToolManagerConnection()
77 this->disconnectFromToolSignals();
79 this->connectToToolSignals();
80 this->updateToolButtons();
83 void StatusBar::connectToToolSignals()
85 this->disconnectFromToolSignals();
87 this->addPermanentWidget(mTpsLabel);
91 for (TrackingService::ToolMap::iterator it = tools.begin(); it != tools.end(); ++it)
96 if (tool == mTrackingService->getManualTool())
98 connect(tool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
101 current.mTool = tool;
102 current.mAction.reset(
new QAction(tool->getName(), NULL));
103 current.mAction->setToolTip(
"Press to set active");
105 QtSignalAdapters::connect0<void()>(
106 current.mAction.get(),
108 boost::bind(&StatusBar::activateTool,
this, tool->getUid()));
110 current.mButton.reset(
new QToolButton);
111 current.mButton->setDefaultAction(current.mAction.get());
112 this->addPermanentWidget(current.mButton.get());
113 mToolData.push_back(current);
116 this->updateToolButtons();
119 void StatusBar::disconnectFromToolSignals()
121 this->removeWidget(mTpsLabel);
123 for (
unsigned i = 0; i < mToolData.size(); ++i)
125 ToolData current = mToolData[i];
127 disconnect(current.mTool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
128 this->removeWidget(current.mButton.get());
134 void StatusBar::activateTool(QString uid)
136 mTrackingService->setActiveTool(uid);
139 void StatusBar::updateToolButtons()
141 ToolPtr activeTool = mTrackingService->getActiveTool();
143 for (
unsigned i = 0; i < mToolData.size(); ++i)
145 ToolData current = mToolData[i];
147 QString color = this->getToolStyle(tool->getVisible(), tool->isInitialized(), activeTool == tool);
148 current.mButton->setStyleSheet(QString(
"QToolButton { %1; }").arg(color));
150 if (!tool->isInitialized())
151 current.mAction->setToolTip(
"Tool is not Initialized");
152 else if (activeTool == tool)
153 current.mAction->setToolTip(
"Active Tool");
154 else if (!tool->getVisible())
155 current.mAction->setToolTip(
"Tool not visible/not tracking");
157 current.mAction->setToolTip(
"Tool visible. Press to set as active");
161 QString StatusBar::getToolStyle(
bool visible,
bool initialized,
bool active)
164 return QString(
"background-color: silver");
169 return QString(
"background-color: lime");
171 return QString(
"background-color: green");
174 return QString(
"background-color: orangered");
177 void StatusBar::renderingFpsSlot(
int numFps)
179 QString fpsString =
"FPS: " + QString::number(numFps);
180 mRenderingFpsLabel->setText(fpsString);
183 void StatusBar::tpsSlot(
int numTps)
185 QString tpsString =
"TPS: " + QString::number(numTps);
186 mTpsLabel->setText(tpsString);
189 void StatusBar::grabbingFpsSlot(
int numFps)
191 QString infoString =
"VideoConnection-FPS: " + QString::number(numFps);
192 mGrabbingInfoLabel->setText(infoString);
195 void StatusBar::grabberConnectedSlot(
bool connected)
199 this->addPermanentWidget(mGrabbingInfoLabel);
200 mGrabbingInfoLabel->show();
203 this->removeWidget(mGrabbingInfoLabel);
206 void StatusBar::onRecordFullscreenChanged()
208 QLabel* label = mRecordFullscreenLabel;
210 if (
vlc()->isRecording())
213 int size = this->height()*0.75;
215 map.load(
":/icons/Video-icon_green.png");
216 label->setPixmap(map.scaled(size, size, Qt::KeepAspectRatio));
218 this->addPermanentWidget(mRecordFullscreenLabel);
219 mRecordFullscreenLabel->show();
223 this->removeWidget(mRecordFullscreenLabel);
227 void StatusBar::showMessageSlot(
Message message)
229 QString text = QString(
"[%1] %4")
233 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