Engauge Digitizer 2
Loading...
Searching...
No Matches
StatusBar Class Reference

Wrapper around QStatusBar to manage permanent widgets. More...

#include <StatusBar.h>

Inheritance diagram for StatusBar:
Inheritance graph
Collaboration diagram for StatusBar:
Collaboration graph

Public Slots

void slotZoom (int)
 Receive zoom selection from MainWindow.

Signals

void signalZoom (int)
 Send zoom factor, that was just selected in the status bar, to MainWindow.

Public Member Functions

 StatusBar (QStatusBar &statusBar)
 Single constructor that accepts the previously-constructed standard QStatusBar.
 ~StatusBar ()
void setCoordinates (const QString &coordsScreen, const QString &coordsGraph, const QString &resolutionGraph)
 Populate the coordinates fields. Unavailable values are empty. Html-encoding to highlight with colors is supported.
void setStatusBarMode (StatusBarMode statusBarMode)
 Set the status bar visibility mode.
void showTemporaryMessage (const QString &message)
 Show temporary message in status bar. After a short interval the message will disappear.
StatusBarMode statusBarMode () const
 Current mode for status bar visibility. This is tracked locally so this class knows when to hide/show the status bar.
void wakeUp ()
 Enable all widgets in the status bar. This is called just after a Document becomes active.

Detailed Description

Wrapper around QStatusBar to manage permanent widgets.

This class does not inherit from QStatusBar since QApplication automatically sets up its own QStatusBar

Definition at line 24 of file StatusBar.h.

Constructor & Destructor Documentation

◆ StatusBar()

StatusBar::StatusBar ( QStatusBar & statusBar)

Single constructor that accepts the previously-constructed standard QStatusBar.

Definition at line 28 of file StatusBar.cpp.

28 :
29 m_statusBar (statusBar),
30 m_statusBarMode (STATUS_BAR_MODE_ALWAYS),
31 m_timer (nullptr)
32{
33 createZoomLabels ();
34 createZoom ();
35 createZoomMaps ();
36 createGroupUnits ();
37
38 connect (&m_statusBar, SIGNAL (messageChanged (const QString &)), this, SLOT (slotStatusBarChanged (const QString &)));
39
40 m_statusBar.setMaximumHeight (60);
41 m_statusBar.hide();
42}
@ STATUS_BAR_MODE_ALWAYS

◆ ~StatusBar()

StatusBar::~StatusBar ( )

Definition at line 44 of file StatusBar.cpp.

45{
46 delete m_timer;
47}

Member Function Documentation

◆ setCoordinates()

void StatusBar::setCoordinates ( const QString & coordsScreen,
const QString & coordsGraph,
const QString & resolutionGraph )

Populate the coordinates fields. Unavailable values are empty. Html-encoding to highlight with colors is supported.

Definition at line 239 of file StatusBar.cpp.

242{
243// LOG4CPP_DEBUG_S ((*mainCat)) << "StatusBar::setCoordinates"
244// << " screen=" << coordsScreen.toLatin1 ().data ()
245// << " graph=" << coordsGraph.toLatin1 ().data ()
246// << " resolution=" << resolutionGraph.toLatin1 ().data ();
247
248 if (m_cmbUnits->isEnabled ()) {
249
250 m_coordsScreen = coordsScreen;
251 m_coordsGraph = coordsGraph;
252 m_resolutionGraph = resolutionGraph;
253
254 updateCoordsText();
255 }
256}

◆ setStatusBarMode()

void StatusBar::setStatusBarMode ( StatusBarMode statusBarMode)

Set the status bar visibility mode.

Definition at line 258 of file StatusBar.cpp.

259{
260 m_statusBarMode = statusBarMode;
261 if (m_statusBarMode == STATUS_BAR_MODE_ALWAYS) {
262 m_statusBar.show();
263 } else {
264 m_statusBar.hide();
265 }
266}
StatusBarMode statusBarMode() const
Current mode for status bar visibility. This is tracked locally so this class knows when to hide/show...
Definition StatusBar.h:45

◆ showTemporaryMessage()

void StatusBar::showTemporaryMessage ( const QString & message)

Show temporary message in status bar. After a short interval the message will disappear.

Definition at line 268 of file StatusBar.cpp.

269{
270 LOG4CPP_DEBUG_S ((*mainCat)) << "StatusBar::showTemporaryMessage"
271 << " mode=" << statusBarModeToString (m_statusBarMode).toLatin1 ().data ()
272 << " message=" << message.toLatin1 ().data ();
273
274 if (m_statusBarMode != STATUS_BAR_MODE_NEVER) {
275 if (m_statusBarMode == STATUS_BAR_MODE_TEMPORARY) {
276 // Calling m_statusBar.show here will have no effect since this is called while processing a signal. Use a timer to
277 // show the status bar as soon as possible
278 m_timer = new QTimer;
279 connect (m_timer, SIGNAL (timeout ()), this, SLOT (slotTimeout()));
280 m_timer->setSingleShot(true);
281 m_timer->start (0);
282 }
283 m_statusBar.showMessage (message, TEMPORARY_MESSAGE_LIFETIME);
284 }
285}
log4cpp::Category * mainCat
Definition Logger.cpp:14
QString statusBarModeToString(StatusBarMode statusBarMode)
@ STATUS_BAR_MODE_TEMPORARY
@ STATUS_BAR_MODE_NEVER
const int TEMPORARY_MESSAGE_LIFETIME
Definition StatusBar.cpp:21
#define LOG4CPP_DEBUG_S(logger)
Definition convenience.h:20

◆ signalZoom

void StatusBar::signalZoom ( int )
signal

Send zoom factor, that was just selected in the status bar, to MainWindow.

◆ slotZoom

void StatusBar::slotZoom ( int zoom)
slot

Receive zoom selection from MainWindow.

Definition at line 322 of file StatusBar.cpp.

323{
324 LOG4CPP_INFO_S ((*mainCat)) << "StatusBar::slotZoom zoom=" << zoom;
325
326 // Show string for the numeric zoom value
327 ZoomFactor zoomFactor = static_cast<ZoomFactor> (zoom);
328 ENGAUGE_ASSERT (m_zoomMapToLabel.contains (zoomFactor));
329 m_cmbZoom->setCurrentText (m_zoomMapToLabel [zoomFactor]);
330}
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
ZoomFactor
Zoom factors ordered by zoom level so next one above/below is the next zoom level.
Definition ZoomFactor.h:11
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ statusBarMode()

StatusBarMode StatusBar::statusBarMode ( ) const
inline

Current mode for status bar visibility. This is tracked locally so this class knows when to hide/show the status bar.

Definition at line 45 of file StatusBar.h.

45{ return m_statusBarMode; }

◆ wakeUp()

void StatusBar::wakeUp ( )

Enable all widgets in the status bar. This is called just after a Document becomes active.

Definition at line 343 of file StatusBar.cpp.

344{
345 if (!m_cmbUnits->isEnabled ()) {
346
347 // First file has just been read in, so enable the widgets
348 m_cmbZoom->setEnabled (true);
349 m_cmbUnits->setEnabled (true);
350 m_editCoords->setEnabled (true);
351 }
352}

The documentation for this class was generated from the following files: