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)));
69 this->addPermanentWidget(mRenderingFpsLabel);
76 void StatusBar::resetToolManagerConnection()
78 this->disconnectFromToolSignals();
80 this->connectToToolSignals();
81 this->updateToolButtons();
84 void StatusBar::connectToToolSignals()
86 this->disconnectFromToolSignals();
88 this->addPermanentWidget(mTpsLabel);
92 for (TrackingService::ToolMap::iterator it = tools.begin(); it != tools.end(); ++it)
97 if (tool == mTrackingService->getManualTool())
99 connect(tool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
102 current.mTool = tool;
103 current.mAction.reset(
new QAction(tool->getName(), NULL));
104 current.mAction->setToolTip(
"Press to set active");
106 QtSignalAdapters::connect0<void()>(
107 current.mAction.get(),
109 boost::bind(&StatusBar::activateTool,
this, tool->getUid()));
111 current.mButton.reset(
new QToolButton);
112 current.mButton->setDefaultAction(current.mAction.get());
113 this->addPermanentWidget(current.mButton.get());
114 mToolData.push_back(current);
117 this->updateToolButtons();
120 void StatusBar::disconnectFromToolSignals()
122 this->removeWidget(mTpsLabel);
124 for (
unsigned i = 0; i < mToolData.size(); ++i)
126 ToolData current = mToolData[i];
128 disconnect(current.mTool.get(), SIGNAL(toolVisible(
bool)),
this, SLOT(updateToolButtons()));
129 this->removeWidget(current.mButton.get());
135 void StatusBar::activateTool(QString uid)
137 mTrackingService->setActiveTool(uid);
140 void StatusBar::updateToolButtons()
142 ToolPtr activeTool = mTrackingService->getActiveTool();
144 for (
unsigned i = 0; i < mToolData.size(); ++i)
146 ToolData current = mToolData[i];
148 QString color = this->getToolStyle(tool->getVisible(), tool->isInitialized(), activeTool == tool);
149 current.mButton->setStyleSheet(QString(
"QToolButton { %1; }").arg(color));
151 if (!tool->isInitialized())
152 current.mAction->setToolTip(
"Tool is not Initialized");
153 else if (activeTool == tool)
154 current.mAction->setToolTip(
"Active Tool");
155 else if (!tool->getVisible())
156 current.mAction->setToolTip(
"Tool not visible/not tracking");
158 current.mAction->setToolTip(
"Tool visible. Press to set as active");
162 QString StatusBar::getToolStyle(
bool visible,
bool initialized,
bool active)
165 return QString(
"background-color: silver");
170 return QString(
"background-color: lime");
172 return QString(
"background-color: green");
175 return QString(
"background-color: orangered");
178 void StatusBar::renderingFpsSlot(
int numFps)
180 QString fpsString =
"FPS: " + QString::number(numFps);
181 mRenderingFpsLabel->setText(fpsString);
184 void StatusBar::tpsSlot(
int numTps)
186 QString tpsString =
"TPS: " + QString::number(numTps);
187 mTpsLabel->setText(tpsString);
190 void StatusBar::grabbingFpsSlot(
int numFps)
192 QString infoString =
"VideoConnection-FPS: " + QString::number(numFps);
193 mGrabbingInfoLabel->setText(infoString);
196 void StatusBar::grabberConnectedSlot(
bool connected)
200 this->addPermanentWidget(mGrabbingInfoLabel);
201 mGrabbingInfoLabel->show();
204 this->removeWidget(mGrabbingInfoLabel);
207 void StatusBar::onRecordFullscreenChanged()
209 QLabel* label = mRecordFullscreenLabel;
211 if (
vlc()->isRecording())
214 int size = this->height()*0.75;
216 map.load(
":/icons/Video-icon_green.png");
217 label->setPixmap(map.scaled(size, size, Qt::KeepAspectRatio));
219 this->addPermanentWidget(mRecordFullscreenLabel);
220 mRecordFullscreenLabel->show();
224 this->removeWidget(mRecordFullscreenLabel);
228 void StatusBar::showMessageSlot(
Message message)
230 QString text = QString(
"[%1] %4")
234 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