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"
44 mRenderingFpsLabel(new QLabel(this)),
45 mGrabbingInfoLabel(new QLabel(this)),
46 mRecordFullscreenLabel(new QLabel(this)),
47 mTpsLabel(new QLabel(this)),
48 mTrackingService(trackingService)
59 connect(trackingService.get(), SIGNAL(activeToolChanged(
const QString&)),
this, SLOT(updateToolButtons()));
61 connect(viewService.get(), SIGNAL(fps(
int)),
this, SLOT(renderingFpsSlot(
int)));
63 connect(videoService.get(), SIGNAL(fps(
int)),
this, SLOT(grabbingFpsSlot(
int)));
64 connect(videoService.get(), SIGNAL(connected(
bool)),
this, SLOT(grabberConnectedSlot(
bool)));
70 this->addPermanentWidget(mRenderingFpsLabel);
77 void StatusBar::fixFlickeringBar()
82 QLabel* emptyLabel =
new QLabel(
this);
83 QFont font = emptyLabel->font();
84 font.setPointSize(font.pointSize()+5);
85 emptyLabel->setFont(font);
86 this->addWidget(emptyLabel);
89 void StatusBar::resetToolManagerConnection()
91 this->disconnectFromToolSignals();
93 this->connectToToolSignals();
94 this->updateToolButtons();
97 void StatusBar::connectToToolSignals()
99 this->disconnectFromToolSignals();
101 this->addPermanentWidget(mTpsLabel);
105 for (TrackingService::ToolMap::iterator it = tools.begin(); it != tools.end(); ++it)
110 if (tool == mTrackingService->getManualTool())
112 connect(tool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
115 current.mTool = tool;
116 current.mAction.reset(
new QAction(tool->getName(), NULL));
117 current.mAction->setToolTip(
"Press to set active");
119 QtSignalAdapters::connect0<void()>(
120 current.mAction.get(),
122 boost::bind(&StatusBar::activateTool,
this, tool->getUid()));
124 current.mButton.reset(
new QToolButton);
125 current.mButton->setDefaultAction(current.mAction.get());
126 this->addPermanentWidget(current.mButton.get());
127 mToolData.push_back(current);
130 this->updateToolButtons();
133 void StatusBar::disconnectFromToolSignals()
135 this->removeWidget(mTpsLabel);
137 for (
unsigned i = 0; i < mToolData.size(); ++i)
139 ToolData current = mToolData[i];
141 disconnect(current.mTool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
142 this->removeWidget(current.mButton.get());
148 void StatusBar::activateTool(QString uid)
150 ToolPtr activeTool = mTrackingService->getActiveTool();
152 if (!activeTool || activeTool->getUid() != uid)
153 mTrackingService->setActiveTool(uid);
155 mTrackingService->clearActiveTool();
158 void StatusBar::updateToolButtons()
160 ToolPtr activeTool = mTrackingService->getActiveTool();
162 bool autoSelectActiveTool =
settings()->
value(
"Automation/autoSelectActiveTool").toBool();
164 for (
unsigned i = 0; i < mToolData.size(); ++i)
166 ToolData current = mToolData[i];
168 QString color = this->getToolStyle(tool->getVisible(), tool->isInitialized(), activeTool == tool);
169 current.mButton->setStyleSheet(QString(
"QToolButton { %1; }").arg(color));
171 if (!tool->isInitialized())
172 current.mAction->setToolTip(
"Tool is not Initialized");
173 else if (activeTool == tool)
174 current.mAction->setToolTip(
"Active Tool");
175 else if (!tool->getVisible())
176 current.mAction->setToolTip(
"Tool not visible/not tracking");
179 if(autoSelectActiveTool)
180 current.mAction->setToolTip(
"Tool visible - Other tool is auto active");
182 current.mAction->setToolTip(
"Tool visible - Press to set as active");
187 QString StatusBar::getToolStyle(
bool visible,
bool initialized,
bool active)
190 return QString(
"background-color: silver");
195 return QString(
"background-color: lime");
197 return QString(
"background-color: green");
200 return QString(
"background-color: orangered");
203 void StatusBar::renderingFpsSlot(
int numFps)
205 QString fpsString =
"FPS: " + QString::number(numFps);
206 mRenderingFpsLabel->setText(fpsString);
209 void StatusBar::tpsSlot(
int numTps)
211 QString tpsString =
"TPS: " + QString::number(numTps);
212 mTpsLabel->setText(tpsString);
215 void StatusBar::grabbingFpsSlot(
int numFps)
217 QString infoString =
"VideoConnection-FPS: " + QString::number(numFps);
218 mGrabbingInfoLabel->setText(infoString);
221 void StatusBar::grabberConnectedSlot(
bool connected)
225 this->addPermanentWidget(mGrabbingInfoLabel);
226 mGrabbingInfoLabel->show();
229 this->removeWidget(mGrabbingInfoLabel);
232 void StatusBar::onRecordFullscreenChanged()
234 QLabel* label = mRecordFullscreenLabel;
236 if (
vlc()->isRecording())
239 int size = this->height()*0.75;
241 map.load(
":/icons/Video-icon_green.png");
242 label->setPixmap(map.scaled(size, size, Qt::KeepAspectRatio));
244 this->addPermanentWidget(mRecordFullscreenLabel);
245 mRecordFullscreenLabel->show();
249 this->removeWidget(mRecordFullscreenLabel);
253 void StatusBar::showMessageSlot(
Message message)
255 QString text = QString(
"[%1] %4")
259 this->showMessage(text, message.
getTimeout());