From a0dd98144a0871d0c685924f175a48f3b73ef02c Mon Sep 17 00:00:00 2001 From: "G.K.MacGregor" Date: Sun, 9 Jun 2024 22:13:24 +0100 Subject: [PATCH] Show blast-through alphanumerics in G1 character selection --- x26dockwidget.cpp | 28 +++++++++++++++++++++++----- x26dockwidget.h | 2 ++ x26menus.cpp | 6 ++++-- x26menus.h | 2 +- x26model.cpp | 13 ++++++++++--- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/x26dockwidget.cpp b/x26dockwidget.cpp index d31fe9d..7b44432 100644 --- a/x26dockwidget.cpp +++ b/x26dockwidget.cpp @@ -43,6 +43,7 @@ CharacterListModel::CharacterListModel(QObject *parent): QAbstractListModel(parent) { m_characterSet = 0; + m_mosaic = true; } int CharacterListModel::rowCount(const QModelIndex & /*parent*/) const @@ -58,16 +59,30 @@ QVariant CharacterListModel::data(const QModelIndex &index, int role) const if (role == Qt::DisplayRole) return QString("0x%1").arg(index.row()+0x20, 2, 16); - if (role == Qt::DecorationRole) - return m_fontBitmap.charBitmap(index.row()+32, m_characterSet); + if (role == Qt::DecorationRole) { + if (m_mosaic && (index.row()+32) & 0x20) + return m_fontBitmap.charBitmap(index.row()+32, 24); + else + return m_fontBitmap.charBitmap(index.row()+32, m_characterSet); + } return QVariant(); } void CharacterListModel::setCharacterSet(int characterSet) { - if (characterSet != m_characterSet) { + if (characterSet != m_characterSet || m_mosaic) { m_characterSet = characterSet; + m_mosaic = false; + emit dataChanged(createIndex(0, 0), createIndex(95, 0), QVector(Qt::DecorationRole)); + } +} + +void CharacterListModel::setG1AndBlastCharacterSet(int characterSet) +{ + if (characterSet != m_characterSet || !m_mosaic) { + m_characterSet = characterSet; + m_mosaic = true; emit dataChanged(createIndex(0, 0), createIndex(95, 0), QVector(Qt::DecorationRole)); } } @@ -693,7 +708,7 @@ void X26DockWidget::updateAllCookedTripletWidgets(const QModelIndex &index) case 0x3f: // G0 character with diacritical m_characterCodeComboBox->blockSignals(true); if (modeExt == 0x21) - m_characterListModel.setCharacterSet(24); + m_characterListModel.setG1AndBlastCharacterSet(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+3).toInt()); else if (modeExt == 0x22 || modeExt == 0x2b) m_characterListModel.setCharacterSet(26); else @@ -1142,6 +1157,8 @@ void X26DockWidget::customMenuRequested(QPoint pos) connect(static_cast(customMenu)->rowsAction(i), &QAction::triggered, [=]() { updateModelFromCookedWidget(i, Qt::UserRole+4); updateAllCookedTripletWidgets(index); }); break; case 0x21: // G1 mosaic character + customMenu = new TripletCharacterQMenu(m_x26Model->data(index.model()->index(index.row(), 2), Qt::UserRole+3).toInt(), true, this); + // fall-through case 0x22: // G3 mosaic character at level 1.5 case 0x2b: // G3 mosaic character at level >=2.5 case 0x29: // G0 character @@ -1162,7 +1179,8 @@ void X26DockWidget::customMenuRequested(QPoint pos) case 0x3d: case 0x3e: case 0x3f: // G0 character with diacritical - customMenu = new TripletCharacterQMenu(m_x26Model->data(index.model()->index(index.row(), 2), Qt::UserRole+2).toInt(), this); + if (!customMenu) + customMenu = new TripletCharacterQMenu(m_x26Model->data(index.model()->index(index.row(), 2), Qt::UserRole+2).toInt(), false, this); for (int i=0; i<96; i++) connect(static_cast(customMenu)->action(i), &QAction::triggered, [=]() { updateModelFromCookedWidget(i+32, Qt::UserRole+1); updateAllCookedTripletWidgets(index); }); diff --git a/x26dockwidget.h b/x26dockwidget.h index b684755..695fc89 100644 --- a/x26dockwidget.h +++ b/x26dockwidget.h @@ -48,10 +48,12 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; void setCharacterSet(int characterSet); + void setG1AndBlastCharacterSet(int characterSet); private: TeletextFontBitmap m_fontBitmap; int m_characterSet; + bool m_mosaic; }; class X26DockWidget : public QDockWidget diff --git a/x26menus.cpp b/x26menus.cpp index 1c7f08d..7c98d97 100644 --- a/x26menus.cpp +++ b/x26menus.cpp @@ -130,15 +130,17 @@ void TripletCLUTQMenu::setColour(int i, QColor c) } -TripletCharacterQMenu::TripletCharacterQMenu(int charSet, QWidget *parent): QMenu(parent) +TripletCharacterQMenu::TripletCharacterQMenu(int charSet, bool mosaic, QWidget *parent): QMenu(parent) { QMenu *charRange[6]; for (int r=0; r<6; r++) { charRange[r] = this->addMenu(QString("0x%010-0x%01f").arg(r+2)); + const int charSetInColumn = (mosaic && ((r & 0x2) == 0)) ? 24 : charSet; + for (int c=0; c<16; c++) - m_actions[r*16+c] = charRange[r]->addAction(QIcon(m_fontBitmap.charBitmap(r*16+c+32, charSet)), QString("0x%1").arg(r*16+c+32, 2, 16, QChar('0'))); + m_actions[r*16+c] = charRange[r]->addAction(QIcon(m_fontBitmap.charBitmap(r*16+c+32, charSetInColumn)), QString("0x%1").arg(r*16+c+32, 2, 16, QChar('0'))); } } diff --git a/x26menus.h b/x26menus.h index 6a1221b..b3f723b 100644 --- a/x26menus.h +++ b/x26menus.h @@ -148,7 +148,7 @@ class TripletCharacterQMenu : public QMenu Q_OBJECT public: - TripletCharacterQMenu(int charSet, QWidget *parent = nullptr); + TripletCharacterQMenu(int charSet, bool mosaic, QWidget *parent = nullptr); QAction *action(int n) const { return m_actions[n]; }; private: diff --git a/x26model.cpp b/x26model.cpp index 043719e..58ad8b7 100644 --- a/x26model.cpp +++ b/x26model.cpp @@ -379,6 +379,9 @@ QVariant X26Model::data(const QModelIndex &index, int role) const // Returning the bitmap as-is doesn't seem to work here // but putting it inside a QIcon... does? return QIcon(m_fontBitmap.charBitmap(triplet.data(), 24)); + else if (triplet.data() >= 0x20) + // Blast-through + return QIcon(m_fontBitmap.charBitmap(triplet.data(), m_parentMainWidget->pageDecode()->cellG0CharacterSet(triplet.activePositionRow(), triplet.activePositionColumn()))); break; case 0x22: // G3 mosaic character at level 1.5 case 0x2b: // G3 mosaic character at level >=2.5 @@ -472,13 +475,17 @@ QVariant X26Model::data(const QModelIndex &index, int role) const break; case 0x21: // G1 character // Qt::UserRole+1 is character number, returned by default below - if (role == Qt::UserRole+2) // Character set - return 24; + switch (role) { + case Qt::UserRole+2: // G1 character set + return 24; + case Qt::UserRole+3: // G0 character set for blast-through + return m_parentMainWidget->pageDecode()->cellG0CharacterSet(triplet.activePositionRow(), triplet.activePositionColumn()); + } break; case 0x22: // G3 character at Level 1.5 case 0x2b: // G3 character at Level 2.5 // Qt::UserRole+1 is character number, returned by default below - if (role == Qt::UserRole+2) // Character set + if (role == Qt::UserRole+2) // G3 character set return 26; break; case 0x27: // Flash functions