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"
66 mRenderingFpsLabel(new QLabel(this)),
67 mGrabbingInfoLabel(new QLabel(this)),
68 mRecordFullscreenLabel(new QLabel(this)),
69 mTpsLabel(new QLabel(this))
81 connect(
trackingService().
get(), SIGNAL(activeToolChanged(
const QString&)),
this, SLOT(updateToolButtons()));
83 connect(
viewService().
get(), SIGNAL(fps(
int)),
this, SLOT(renderingFpsSlot(
int)));
85 connect(
videoService().
get(), SIGNAL(fps(
int)),
this, SLOT(grabbingFpsSlot(
int)));
86 connect(
videoService().
get(), SIGNAL(connected(
bool)),
this, SLOT(grabberConnectedSlot(
bool)));
91 this->addPermanentWidget(mRenderingFpsLabel);
98 void StatusBar::resetToolManagerConnection()
100 this->disconnectFromToolSignals();
102 this->connectToToolSignals();
103 this->updateToolButtons();
106 void StatusBar::connectToToolSignals()
108 this->disconnectFromToolSignals();
110 this->addPermanentWidget(mTpsLabel);
114 for (TrackingService::ToolMap::iterator it = tools.begin(); it != tools.end(); ++it)
121 connect(tool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
124 current.mTool = tool;
125 current.mAction.reset(
new QAction(tool->getName(), NULL));
126 current.mAction->setToolTip(
"Press to set active");
128 QtSignalAdapters::connect0<void()>(
129 current.mAction.get(),
131 boost::bind(&StatusBar::activateTool,
this, tool->getUid()));
133 current.mButton.reset(
new QToolButton);
134 current.mButton->setDefaultAction(current.mAction.get());
135 this->addPermanentWidget(current.mButton.get());
136 mToolData.push_back(current);
139 this->updateToolButtons();
142 void StatusBar::disconnectFromToolSignals()
144 this->removeWidget(mTpsLabel);
146 for (
unsigned i = 0; i < mToolData.size(); ++i)
148 ToolData current = mToolData[i];
150 disconnect(current.mTool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
151 this->removeWidget(current.mButton.get());
157 void StatusBar::activateTool(QString uid)
162 void StatusBar::updateToolButtons()
166 for (
unsigned i = 0; i < mToolData.size(); ++i)
168 ToolData current = mToolData[i];
170 QString color = this->getToolStyle(tool->getVisible(), tool->isInitialized(), activeTool == tool);
171 current.mButton->setStyleSheet(QString(
"QToolButton { %1; }").arg(color));
173 if (!tool->isInitialized())
174 current.mAction->setToolTip(
"Tool is not Initialized");
175 else if (activeTool == tool)
176 current.mAction->setToolTip(
"Active Tool");
177 else if (tool->getVisible())
178 current.mAction->setToolTip(
"Tool not visible/not tracking");
180 current.mAction->setToolTip(
"Tool visible. Press to set as active");
184 QString StatusBar::getToolStyle(
bool visible,
bool initialized,
bool active)
187 return QString(
"background-color: silver");
192 return QString(
"background-color: lime");
194 return QString(
"background-color: green");
197 return QString(
"background-color: orangered");
200 void StatusBar::renderingFpsSlot(
int numFps)
202 QString fpsString =
"FPS: " + QString::number(numFps);
203 mRenderingFpsLabel->setText(fpsString);
206 void StatusBar::tpsSlot(
int numTps)
208 QString tpsString =
"TPS: " + QString::number(numTps);
209 mTpsLabel->setText(tpsString);
212 void StatusBar::grabbingFpsSlot(
int numFps)
214 QString infoString =
"VideoConnection-FPS: " + QString::number(numFps);
215 mGrabbingInfoLabel->setText(infoString);
218 void StatusBar::grabberConnectedSlot(
bool connected)
222 this->addPermanentWidget(mGrabbingInfoLabel);
223 mGrabbingInfoLabel->show();
226 this->removeWidget(mGrabbingInfoLabel);
229 void StatusBar::onRecordFullscreenChanged()
231 QLabel* label = mRecordFullscreenLabel;
233 if (
vlc()->isRecording())
236 int size = this->height()*0.75;
238 map.load(
":/icons/Video-icon_green.png");
239 label->setPixmap(map.scaled(size, size, Qt::KeepAspectRatio));
241 this->addPermanentWidget(mRecordFullscreenLabel);
242 mRecordFullscreenLabel->show();
246 this->removeWidget(mRecordFullscreenLabel);
250 void StatusBar::showMessageSlot(
Message message)
252 QString text = QString(
"[%1] %4")
256 this->showMessage(text, message.
getTimeout());
QString qstring_cast(const T &val)
static MessageListenerPtr create(LogPtr log=LogPtr())
boost::shared_ptr< class TrackingService > TrackingServicePtr
TrackingServicePtr getTrackingService()
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...
LogicManager * logicManager()
std::map< QString, ToolPtr > ToolMap
cxLogicManager_EXPORT ViewServicePtr viewService()
cxLogicManager_EXPORT VideoServicePtr videoService()
cxLogicManager_EXPORT TrackingServicePtr trackingService()
void newMessage(Message message)
MESSAGE_LEVEL getMessageLevel() const
The category of the message.
virtual ~StatusBar()
empty
VLCRecorder * vlc()
Shortcut for accessing the vlc recorder.
StatusBar()
connects signals and slots
boost::shared_ptr< class Tool > ToolPtr