Skip to content

Commit 4519471

Browse files
committed
changed tools
1 parent db314e4 commit 4519471

File tree

4 files changed

+855
-145
lines changed

4 files changed

+855
-145
lines changed

app/CanvasWidget.cpp

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
264296
void CanvasWidget::setBackgroundChecked(bool enabled)
265297
{
266298
if (!m_backgroundButton) {
@@ -306,20 +338,30 @@ void CanvasWidget::setHdButtonEnabled(bool enabled)
306338
void 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

app/CanvasWidget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ class CanvasWidget : public QWidget
3939
void setZoneButtonVisible(bool visible);
4040
void setRotateChecked(bool enabled);
4141
void setRotateEnabled(bool enabled);
42+
void setBackEnabled(bool enabled);
43+
void setForwardEnabled(bool enabled);
4244

4345
signals:
4446
void fitRequested();
47+
void backRequested();
48+
void forwardRequested();
4549
void gridToggled(bool enabled);
4650
void originalToggled(bool enabled);
4751
void backgroundToggled(bool enabled);
@@ -59,6 +63,8 @@ class CanvasWidget : public QWidget
5963
GLCanvasWidget* m_canvas;
6064
QLabel* m_label;
6165
QToolButton* m_fitButton;
66+
QToolButton* m_backButton;
67+
QToolButton* m_forwardButton;
6268
QToolButton* m_gridButton;
6369
QToolButton* m_originalButton;
6470
QToolButton* m_backgroundButton;

0 commit comments

Comments
 (0)