@@ -13,6 +13,8 @@ CanvasWidget::CanvasWidget(const QString& title, QWidget* parent)
1313 , m_canvas(new GLCanvasWidget(this ))
1414 , m_label(new QLabel(title, this ))
1515 , m_fitButton(new QToolButton(m_canvas))
16+ , m_backButton(new QToolButton(m_canvas))
17+ , m_forwardButton(new QToolButton(m_canvas))
1618 , m_gridButton(new QToolButton(m_canvas))
1719 , m_originalButton(new QToolButton(m_canvas))
1820 , m_backgroundButton(new QToolButton(m_canvas))
@@ -36,6 +38,20 @@ CanvasWidget::CanvasWidget(const QString& title, QWidget* parent)
3638 m_fitButton->setCursor (Qt::PointingHandCursor);
3739 connect (m_fitButton, &QToolButton::clicked, this , &CanvasWidget::fitRequested);
3840
41+ m_backButton->setText (" <" );
42+ m_backButton->setAutoRaise (true );
43+ m_backButton->setToolTip (" Back" );
44+ m_backButton->setCursor (Qt::PointingHandCursor);
45+ m_backButton->setEnabled (false );
46+ connect (m_backButton, &QToolButton::clicked, this , &CanvasWidget::backRequested);
47+
48+ m_forwardButton->setText (" >" );
49+ m_forwardButton->setAutoRaise (true );
50+ m_forwardButton->setToolTip (" Forward" );
51+ m_forwardButton->setCursor (Qt::PointingHandCursor);
52+ m_forwardButton->setEnabled (false );
53+ connect (m_forwardButton, &QToolButton::clicked, this , &CanvasWidget::forwardRequested);
54+
3955 m_gridButton->setText (" Grid" );
4056 m_gridButton->setCheckable (true );
4157 m_gridButton->setChecked (true );
@@ -261,6 +277,22 @@ void CanvasWidget::setRotateEnabled(bool enabled)
261277 m_rotateButton->setEnabled (enabled);
262278}
263279
280+ void CanvasWidget::setBackEnabled (bool enabled)
281+ {
282+ if (!m_backButton) {
283+ return ;
284+ }
285+ m_backButton->setEnabled (enabled);
286+ }
287+
288+ void CanvasWidget::setForwardEnabled (bool enabled)
289+ {
290+ if (!m_forwardButton) {
291+ return ;
292+ }
293+ m_forwardButton->setEnabled (enabled);
294+ }
295+
264296void CanvasWidget::setBackgroundChecked (bool enabled)
265297{
266298 if (!m_backgroundButton) {
@@ -306,20 +338,30 @@ void CanvasWidget::setHdButtonEnabled(bool enabled)
306338void CanvasWidget::resizeEvent (QResizeEvent* event)
307339{
308340 QWidget::resizeEvent (event);
309- if (!m_fitButton || !m_gridButton || !m_originalButton || !m_backgroundButton ||
341+ if (!m_fitButton || !m_backButton || !m_forwardButton || ! m_gridButton || !m_originalButton || !m_backgroundButton ||
310342 !m_maskButton || !m_dynamicButton || !m_backgroundMaskButton || !m_zoneButton || !m_hdButton ||
311343 !m_rotateButton) {
312344 return ;
313345 }
314346 const int margin = 8 ;
315- const QSize buttonSize = m_fitButton ->sizeHint ();
316- const int x = m_canvas->width () - buttonSize .width () - margin;
347+ const QSize forwardSize = m_forwardButton ->sizeHint ();
348+ const int x = m_canvas->width () - forwardSize .width () - margin;
317349 const int y = margin;
318- m_fitButton->move (x, y);
350+ m_forwardButton->move (x, y);
351+ m_forwardButton->raise ();
352+
353+ const QSize backSize = m_backButton->sizeHint ();
354+ const int backX = x - backSize.width () - 6 ;
355+ m_backButton->move (backX, y);
356+ m_backButton->raise ();
357+
358+ const QSize fitSize = m_fitButton->sizeHint ();
359+ const int fitX = backX - fitSize.width () - 6 ;
360+ m_fitButton->move (fitX, y);
319361 m_fitButton->raise ();
320362
321363 const QSize gridSize = m_gridButton->sizeHint ();
322- const int gridX = x - gridSize.width () - 6 ;
364+ const int gridX = fitX - gridSize.width () - 6 ;
323365 m_gridButton->move (gridX, y);
324366 m_gridButton->raise ();
325367
0 commit comments