Move selection rectangle from widget to scene
This commit is contained in:
@@ -73,6 +73,7 @@ void TeletextDocument::selectSubPageIndex(int newSubPageIndex, bool forceRefresh
|
|||||||
emit aboutToChangeSubPage();
|
emit aboutToChangeSubPage();
|
||||||
m_currentSubPageIndex = newSubPageIndex;
|
m_currentSubPageIndex = newSubPageIndex;
|
||||||
emit subPageSelected();
|
emit subPageSelected();
|
||||||
|
emit selectionMoved();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,6 +84,7 @@ void TeletextDocument::selectSubPageNext()
|
|||||||
emit aboutToChangeSubPage();
|
emit aboutToChangeSubPage();
|
||||||
m_currentSubPageIndex++;
|
m_currentSubPageIndex++;
|
||||||
emit subPageSelected();
|
emit subPageSelected();
|
||||||
|
emit selectionMoved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,6 +94,7 @@ void TeletextDocument::selectSubPagePrevious()
|
|||||||
emit aboutToChangeSubPage();
|
emit aboutToChangeSubPage();
|
||||||
m_currentSubPageIndex--;
|
m_currentSubPageIndex--;
|
||||||
emit subPageSelected();
|
emit subPageSelected();
|
||||||
|
emit selectionMoved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,6 +227,7 @@ void TeletextDocument::setSelection(int topRow, int leftColumn, int bottomRow, i
|
|||||||
void TeletextDocument::cancelSelection()
|
void TeletextDocument::cancelSelection()
|
||||||
{
|
{
|
||||||
m_selectionSubPage = nullptr;
|
m_selectionSubPage = nullptr;
|
||||||
|
emit selectionMoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TeletextDocument::levelRequired() const
|
int TeletextDocument::levelRequired() const
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ TeletextWidget::TeletextWidget(QFrame *parent) : QFrame(parent)
|
|||||||
connect(m_teletextDocument, &TeletextDocument::subPageSelected, this, &TeletextWidget::subPageSelected);
|
connect(m_teletextDocument, &TeletextDocument::subPageSelected, this, &TeletextWidget::subPageSelected);
|
||||||
connect(m_teletextDocument, &TeletextDocument::contentsChange, this, &TeletextWidget::refreshRow);
|
connect(m_teletextDocument, &TeletextDocument::contentsChange, this, &TeletextWidget::refreshRow);
|
||||||
connect(m_teletextDocument, &TeletextDocument::refreshNeeded, this, &TeletextWidget::refreshPage);
|
connect(m_teletextDocument, &TeletextDocument::refreshNeeded, this, &TeletextWidget::refreshPage);
|
||||||
connect(m_teletextDocument, &TeletextDocument::selectionMoved, this, QOverload<>::of(&TeletextWidget::update));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TeletextWidget::~TeletextWidget()
|
TeletextWidget::~TeletextWidget()
|
||||||
@@ -109,11 +108,6 @@ void TeletextWidget::paintEvent(QPaintEvent *event)
|
|||||||
widgetPainter.drawPixmap(0, 0, *m_pageRender.pagePixmap(m_flashPhase), 864-m_pageRender.leftSidePanelColumns()*12, 0, m_pageRender.leftSidePanelColumns()*12, 250);
|
widgetPainter.drawPixmap(0, 0, *m_pageRender.pagePixmap(m_flashPhase), 864-m_pageRender.leftSidePanelColumns()*12, 0, m_pageRender.leftSidePanelColumns()*12, 250);
|
||||||
if (m_pageRender.rightSidePanelColumns())
|
if (m_pageRender.rightSidePanelColumns())
|
||||||
widgetPainter.drawPixmap(480+m_pageRender.leftSidePanelColumns()*12, 0, *m_pageRender.pagePixmap(m_flashPhase), 480, 0, m_pageRender.rightSidePanelColumns()*12, 250);
|
widgetPainter.drawPixmap(480+m_pageRender.leftSidePanelColumns()*12, 0, *m_pageRender.pagePixmap(m_flashPhase), 480, 0, m_pageRender.rightSidePanelColumns()*12, 250);
|
||||||
if (m_teletextDocument->selectionActive()) {
|
|
||||||
widgetPainter.setPen(QPen(QColor(192, 192, 192, 224), 1, Qt::DashLine));
|
|
||||||
widgetPainter.setBrush(QBrush(QColor(255, 255, 255, 64)));
|
|
||||||
widgetPainter.drawRect((m_teletextDocument->selectionLeftColumn()+m_pageRender.leftSidePanelColumns())*12, m_teletextDocument->selectionTopRow()*10, m_teletextDocument->selectionWidth()*12-1, m_teletextDocument->selectionHeight()*10-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TeletextWidget::updateFlashTimer(int newFlashTimer)
|
void TeletextWidget::updateFlashTimer(int newFlashTimer)
|
||||||
@@ -496,6 +490,13 @@ LevelOneScene::LevelOneScene(QWidget *levelOneWidget, QObject *parent) : QGraphi
|
|||||||
m_levelOneProxyWidget->setPos(60, 19);
|
m_levelOneProxyWidget->setPos(60, 19);
|
||||||
m_levelOneProxyWidget->setAutoFillBackground(false);
|
m_levelOneProxyWidget->setAutoFillBackground(false);
|
||||||
|
|
||||||
|
// Selection
|
||||||
|
m_selectionRectItem = new QGraphicsRectItem(0, 0, 12, 10);
|
||||||
|
m_selectionRectItem->setVisible(false);
|
||||||
|
m_selectionRectItem->setPen(QPen(QColor(192, 192, 192), 1, Qt::DashLine));
|
||||||
|
m_selectionRectItem->setBrush(QBrush(QColor(255, 255, 255, 64)));
|
||||||
|
addItem(m_selectionRectItem);
|
||||||
|
|
||||||
// Cursor
|
// Cursor
|
||||||
m_cursorRectItem = new QGraphicsRectItem(0, 0, 12, 10);
|
m_cursorRectItem = new QGraphicsRectItem(0, 0, 12, 10);
|
||||||
m_cursorRectItem->setPen(Qt::NoPen);
|
m_cursorRectItem->setPen(Qt::NoPen);
|
||||||
@@ -545,6 +546,7 @@ void LevelOneScene::setBorderDimensions(int sceneWidth, int sceneHeight, int wid
|
|||||||
m_mainGridItemGroup->setPos(leftRightBorders + leftSidePanelColumns*12, topBottomBorders);
|
m_mainGridItemGroup->setPos(leftRightBorders + leftSidePanelColumns*12, topBottomBorders);
|
||||||
|
|
||||||
updateCursor();
|
updateCursor();
|
||||||
|
updateSelection();
|
||||||
|
|
||||||
// Grid for right side panel
|
// Grid for right side panel
|
||||||
for (int c=0; c<16; c++)
|
for (int c=0; c<16; c++)
|
||||||
@@ -582,6 +584,18 @@ void LevelOneScene::updateCursor()
|
|||||||
m_cursorRectItem->setPos(m_mainGridItemGroup->pos().x() + static_cast<TeletextWidget *>(m_levelOneProxyWidget->widget())->document()->cursorColumn()*12, m_mainGridItemGroup->pos().y() + static_cast<TeletextWidget *>(m_levelOneProxyWidget->widget())->document()->cursorRow()*10);
|
m_cursorRectItem->setPos(m_mainGridItemGroup->pos().x() + static_cast<TeletextWidget *>(m_levelOneProxyWidget->widget())->document()->cursorColumn()*12, m_mainGridItemGroup->pos().y() + static_cast<TeletextWidget *>(m_levelOneProxyWidget->widget())->document()->cursorRow()*10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LevelOneScene::updateSelection()
|
||||||
|
{
|
||||||
|
if (!static_cast<TeletextWidget *>(m_levelOneProxyWidget->widget())->document()->selectionActive()) {
|
||||||
|
m_selectionRectItem->setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_selectionRectItem->setRect(m_mainGridItemGroup->pos().x() + static_cast<TeletextWidget *>(m_levelOneProxyWidget->widget())->document()->selectionLeftColumn()*12, m_mainGridItemGroup->pos().y() + static_cast<TeletextWidget *>(m_levelOneProxyWidget->widget())->document()->selectionTopRow()*10, static_cast<TeletextWidget *>(m_levelOneProxyWidget->widget())->document()->selectionWidth()*12-1, static_cast<TeletextWidget *>(m_levelOneProxyWidget->widget())->document()->selectionHeight()*10-1);
|
||||||
|
|
||||||
|
m_selectionRectItem->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
void LevelOneScene::toggleGrid(bool gridOn)
|
void LevelOneScene::toggleGrid(bool gridOn)
|
||||||
{
|
{
|
||||||
m_grid = gridOn;
|
m_grid = gridOn;
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateCursor();
|
void updateCursor();
|
||||||
|
void updateSelection();
|
||||||
void toggleGrid(bool);
|
void toggleGrid(bool);
|
||||||
void setFullScreenColour(const QColor &);
|
void setFullScreenColour(const QColor &);
|
||||||
void setFullRowColour(int, const QColor &);
|
void setFullRowColour(int, const QColor &);
|
||||||
@@ -118,7 +119,7 @@ private:
|
|||||||
QGraphicsRectItem *m_fullScreenTopRectItem, *m_fullScreenBottomRectItem;
|
QGraphicsRectItem *m_fullScreenTopRectItem, *m_fullScreenBottomRectItem;
|
||||||
QGraphicsRectItem *m_fullRowLeftRectItem[25], *m_fullRowRightRectItem[25];
|
QGraphicsRectItem *m_fullRowLeftRectItem[25], *m_fullRowRightRectItem[25];
|
||||||
QGraphicsProxyWidget *m_levelOneProxyWidget;
|
QGraphicsProxyWidget *m_levelOneProxyWidget;
|
||||||
QGraphicsRectItem *m_cursorRectItem;
|
QGraphicsRectItem *m_cursorRectItem, *m_selectionRectItem;
|
||||||
QGraphicsItemGroup *m_mainGridItemGroup, *m_sidePanelGridItemGroup[32];
|
QGraphicsItemGroup *m_mainGridItemGroup, *m_sidePanelGridItemGroup[32];
|
||||||
bool m_grid, m_sidePanelGridNeeded[32];
|
bool m_grid, m_sidePanelGridNeeded[32];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ void MainWindow::init()
|
|||||||
setCentralWidget(m_textView);
|
setCentralWidget(m_textView);
|
||||||
|
|
||||||
connect(m_textWidget->document(), &TeletextDocument::cursorMoved, this, &MainWindow::updateCursorPosition);
|
connect(m_textWidget->document(), &TeletextDocument::cursorMoved, this, &MainWindow::updateCursorPosition);
|
||||||
|
connect(m_textWidget->document(), &TeletextDocument::selectionMoved, m_textScene, &LevelOneScene::updateSelection);
|
||||||
connect(m_textWidget->document()->undoStack(), &QUndoStack::cleanChanged, this, [=]() { setWindowModified(!m_textWidget->document()->undoStack()->isClean()); } );
|
connect(m_textWidget->document()->undoStack(), &QUndoStack::cleanChanged, this, [=]() { setWindowModified(!m_textWidget->document()->undoStack()->isClean()); } );
|
||||||
connect(m_textWidget->document(), &TeletextDocument::aboutToChangeSubPage, m_x26DockWidget, &X26DockWidget::unloadX26List);
|
connect(m_textWidget->document(), &TeletextDocument::aboutToChangeSubPage, m_x26DockWidget, &X26DockWidget::unloadX26List);
|
||||||
connect(m_textWidget->document(), &TeletextDocument::subPageSelected, this, &MainWindow::updatePageWidgets);
|
connect(m_textWidget->document(), &TeletextDocument::subPageSelected, this, &MainWindow::updatePageWidgets);
|
||||||
|
|||||||
Reference in New Issue
Block a user