From 329d1cd9f459855be75d80a18af28351269e0593 Mon Sep 17 00:00:00 2001 From: "G.K.MacGregor" Date: Sun, 13 Dec 2020 15:46:23 +0000 Subject: [PATCH] Add statusbar widgets to flip between subpages --- README.md | 2 -- mainwindow.cpp | 37 +++++++++++++++++++++++++++++++------ mainwindow.h | 4 +++- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 593a5a6..c89abd8 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,6 @@ At the moment QTeletextMaker is in pre-alpha status so many features are not fin Spacing attributes are only accessible through an "Insert" menu. A toolbar to insert spacing attributes may be added in the future. -There is no visible widget for switching between subpages, use the `PageUp` and `PageDown` keys for this. - Keymapping between ASCII and Teletext character sets is not yet implemented e.g. in English pressing the hash key will type a pound sign instead, and in other languages the square and curly brackets keys need to be pressed to obtain the accented characters. The following X/26 enhancement triplets are not rendered by the editor, although the list is fully aware of them. diff --git a/mainwindow.cpp b/mainwindow.cpp index 6aa4532..eea154d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include "mainwindow.h" @@ -589,10 +590,32 @@ void MainWindow::zoomReset() void MainWindow::createStatusBar() { - m_cursorStatus = new QLabel("Subpage 1/1 row 1 column 1"); - statusBar()->insertWidget(0, m_cursorStatus); - m_levelSelect = new QLabel("Level"); - statusBar()->addPermanentWidget(m_levelSelect); + QLabel *subPageLabel = new QLabel("Subpage"); + statusBar()->insertWidget(0, subPageLabel); + + m_previousSubPageButton = new QToolButton; + m_previousSubPageButton->setMinimumSize(subPageLabel->height(), subPageLabel->height()); + m_previousSubPageButton->setMaximumSize(subPageLabel->height(), subPageLabel->height()); + m_previousSubPageButton->setAutoRaise(true); + m_previousSubPageButton->setArrowType(Qt::LeftArrow); + statusBar()->insertWidget(1, m_previousSubPageButton); + connect(m_previousSubPageButton, &QToolButton::clicked, m_textWidget->document(), &TeletextDocument::selectSubPagePrevious); + + m_subPageLabel = new QLabel("1/1"); + statusBar()->insertWidget(2, m_subPageLabel); + + m_nextSubPageButton = new QToolButton; + m_nextSubPageButton->setMinimumSize(subPageLabel->height(), subPageLabel->height()); + m_nextSubPageButton->setMaximumSize(subPageLabel->height(), subPageLabel->height()); + m_nextSubPageButton->setAutoRaise(true); + m_nextSubPageButton->setArrowType(Qt::RightArrow); + statusBar()->insertWidget(3, m_nextSubPageButton); + connect(m_nextSubPageButton, &QToolButton::clicked, m_textWidget->document(), &TeletextDocument::selectSubPageNext); + + m_cursorPositionLabel = new QLabel("Row 1 Column 1"); + statusBar()->insertWidget(4, m_cursorPositionLabel); + + statusBar()->addPermanentWidget(new QLabel("Level")); QRadioButton *level1 = new QRadioButton("1"); QRadioButton *level15 = new QRadioButton("1.5"); @@ -838,12 +861,14 @@ MainWindow *MainWindow::findMainWindow(const QString &fileName) const void MainWindow::updateCursorPosition() { - m_cursorStatus->setText(QString("Subpage %1/%2 row %3 column %4").arg(m_textWidget->document()->currentSubPageIndex()+1).arg(m_textWidget->document()->numberOfSubPages()).arg(m_textWidget->document()->cursorRow()).arg(m_textWidget->document()->cursorColumn())); + m_cursorPositionLabel->setText(QString("Row %1 Column %2").arg(m_textWidget->document()->cursorRow()).arg(m_textWidget->document()->cursorColumn())); } void MainWindow::updatePageWidgets() { - updateCursorPosition(); + m_subPageLabel->setText(QString("%1/%2").arg(m_textWidget->document()->currentSubPageIndex()+1).arg(m_textWidget->document()->numberOfSubPages())); + m_previousSubPageButton->setEnabled(!(m_textWidget->document()->currentSubPageIndex() == 0)); + m_nextSubPageButton->setEnabled(!(m_textWidget->document()->currentSubPageIndex() == (m_textWidget->document()->numberOfSubPages()) - 1)); m_pageOptionsDockWidget->updateWidgets(); m_pageEnhancementsDockWidget->updateWidgets(); m_x26DockWidget->loadX26List(); diff --git a/mainwindow.h b/mainwindow.h index f0a5df1..b6136fc 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -27,6 +27,7 @@ #include #include #include +#include #include "mainwidget.h" #include "pageenhancementsdockwidget.h" @@ -110,7 +111,8 @@ private: QAction *m_borderActs[3]; QAction *m_aspectRatioActs[4]; - QLabel *m_cursorStatus, *m_levelSelect; + QLabel *m_subPageLabel, *m_cursorPositionLabel; + QToolButton *m_previousSubPageButton, *m_nextSubPageButton; QString m_curFile; bool m_isUntitled;