2020-09-06 16:47:38 +01:00
|
|
|
/*
|
2024-01-01 00:12:17 +00:00
|
|
|
* Copyright (C) 2020-2024 Gavin MacGregor
|
2020-09-06 16:47:38 +01:00
|
|
|
*
|
|
|
|
|
* This file is part of QTeletextMaker.
|
|
|
|
|
*
|
|
|
|
|
* QTeletextMaker is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* QTeletextMaker is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QGridLayout>
|
2020-09-19 19:34:41 +01:00
|
|
|
#include <QGroupBox>
|
2020-09-06 16:47:38 +01:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QSpinBox>
|
|
|
|
|
|
2020-09-08 12:12:24 +01:00
|
|
|
#include "pageenhancementsdockwidget.h"
|
2020-09-06 16:47:38 +01:00
|
|
|
|
2023-08-13 21:39:25 +01:00
|
|
|
#include "levelonecommands.h"
|
|
|
|
|
|
2020-09-08 12:12:24 +01:00
|
|
|
PageEnhancementsDockWidget::PageEnhancementsDockWidget(TeletextWidget *parent): QDockWidget(parent)
|
2020-09-06 16:47:38 +01:00
|
|
|
{
|
2020-09-19 19:34:41 +01:00
|
|
|
QVBoxLayout *pageEnhancementsLayout = new QVBoxLayout;
|
2020-09-08 12:12:24 +01:00
|
|
|
QWidget *pageEnhancementsWidget = new QWidget;
|
2020-09-06 16:47:38 +01:00
|
|
|
|
|
|
|
|
m_parentMainWidget = parent;
|
|
|
|
|
|
2020-09-08 12:12:24 +01:00
|
|
|
this->setObjectName("PageEnhancementsDockWidget");
|
2022-05-01 12:55:08 +01:00
|
|
|
this->setWindowTitle("X/28 page enhancements");
|
2020-09-19 19:34:41 +01:00
|
|
|
|
2022-05-01 12:55:08 +01:00
|
|
|
// Colour group box and layout
|
|
|
|
|
QGroupBox *colourGroupBox = new QGroupBox(tr("Colours"));
|
|
|
|
|
QGridLayout *colourLayout = new QGridLayout;
|
2020-09-19 19:34:41 +01:00
|
|
|
|
|
|
|
|
// Default screen and default row colours
|
2022-05-01 12:55:08 +01:00
|
|
|
colourLayout->addWidget(new QLabel(tr("Default screen colour")), 0, 0, 1, 1);
|
|
|
|
|
colourLayout->addWidget(new QLabel(tr("Default row colour")), 1, 0, 1, 1);
|
2020-09-06 16:47:38 +01:00
|
|
|
m_defaultScreenColourCombo = new QComboBox;
|
2021-07-18 21:39:41 +01:00
|
|
|
m_defaultScreenColourCombo->setModel(m_parentMainWidget->document()->clutModel());
|
2020-09-06 16:47:38 +01:00
|
|
|
m_defaultRowColourCombo = new QComboBox;
|
2021-07-18 21:39:41 +01:00
|
|
|
m_defaultRowColourCombo->setModel(m_parentMainWidget->document()->clutModel());
|
2022-05-01 12:55:08 +01:00
|
|
|
colourLayout->addWidget(m_defaultScreenColourCombo, 0, 1, 1, 1, Qt::AlignTop);
|
2023-08-13 21:39:25 +01:00
|
|
|
connect(m_defaultScreenColourCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index){ m_parentMainWidget->document()->undoStack()->push(new SetFullScreenColourCommand(m_parentMainWidget->document(), index)); });
|
2022-05-01 12:55:08 +01:00
|
|
|
colourLayout->addWidget(m_defaultRowColourCombo, 1, 1, 1, 1, Qt::AlignTop);
|
2023-08-13 21:39:25 +01:00
|
|
|
connect(m_defaultRowColourCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index){ m_parentMainWidget->document()->undoStack()->push(new SetFullRowColourCommand(m_parentMainWidget->document(), index)); });
|
2020-09-19 19:34:41 +01:00
|
|
|
|
|
|
|
|
// CLUT remapping
|
2022-05-01 12:55:08 +01:00
|
|
|
colourLayout->addWidget(new QLabel(tr("CLUT remapping")), 2, 0, 1, 1);
|
2020-09-06 16:47:38 +01:00
|
|
|
m_colourTableCombo = new QComboBox;
|
|
|
|
|
m_colourTableCombo->addItem("Fore 0 Back 0");
|
|
|
|
|
m_colourTableCombo->addItem("Fore 0 Back 1");
|
|
|
|
|
m_colourTableCombo->addItem("Fore 0 Back 2");
|
|
|
|
|
m_colourTableCombo->addItem("Fore 1 Back 1");
|
|
|
|
|
m_colourTableCombo->addItem("Fore 1 Back 2");
|
|
|
|
|
m_colourTableCombo->addItem("Fore 2 Back 1");
|
|
|
|
|
m_colourTableCombo->addItem("Fore 2 Back 2");
|
|
|
|
|
m_colourTableCombo->addItem("Fore 2 Back 3");
|
2022-05-01 12:55:08 +01:00
|
|
|
colourLayout->addWidget(m_colourTableCombo, 2, 1, 1, 1, Qt::AlignTop);
|
2023-08-13 21:39:25 +01:00
|
|
|
connect(m_colourTableCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](int index){ m_parentMainWidget->document()->undoStack()->push(new SetCLUTRemapCommand(m_parentMainWidget->document(), index)); });
|
2020-09-19 19:34:41 +01:00
|
|
|
|
|
|
|
|
// Black background colour substitution
|
2020-09-06 16:47:38 +01:00
|
|
|
m_blackBackgroundSubstAct = new QCheckBox("Black background colour substitution");
|
2022-05-01 12:55:08 +01:00
|
|
|
colourLayout->addWidget(m_blackBackgroundSubstAct, 3, 0, 1, 2, Qt::AlignTop);
|
2023-08-13 21:39:25 +01:00
|
|
|
connect(m_blackBackgroundSubstAct, &QCheckBox::stateChanged, [=](int state){ m_parentMainWidget->document()->undoStack()->push(new SetBlackBackgroundSubstCommand(m_parentMainWidget->document(), state)); });
|
2020-09-06 16:47:38 +01:00
|
|
|
|
2022-05-01 12:55:08 +01:00
|
|
|
// Add group box to the main layout
|
|
|
|
|
colourGroupBox->setLayout(colourLayout);
|
|
|
|
|
pageEnhancementsLayout->addWidget(colourGroupBox);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Side panels group box and layout
|
|
|
|
|
QGroupBox *sidePanelsGroupBox = new QGroupBox(tr("Side panels"));
|
|
|
|
|
QGridLayout *sidePanelsLayout = new QGridLayout;
|
|
|
|
|
|
2020-09-19 19:34:41 +01:00
|
|
|
// Side panel columns
|
2022-05-01 12:55:08 +01:00
|
|
|
sidePanelsLayout->addWidget(new QLabel(tr("Left side panel columns")), 0, 0, 1, 1);
|
2020-09-06 16:47:38 +01:00
|
|
|
m_leftSidePanelSpinBox = new QSpinBox(this);
|
|
|
|
|
m_leftSidePanelSpinBox->setMaximum(16);
|
2022-05-01 12:55:08 +01:00
|
|
|
sidePanelsLayout->addWidget(m_leftSidePanelSpinBox, 0, 1, 1, 1, Qt::AlignTop);
|
2020-09-06 16:47:38 +01:00
|
|
|
connect(m_leftSidePanelSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), [=](int index){ setLeftSidePanelWidth(index); });
|
|
|
|
|
|
2022-05-01 12:55:08 +01:00
|
|
|
sidePanelsLayout->addWidget(new QLabel(tr("Right side panel columns")), 1, 0, 1, 1);
|
2020-09-06 16:47:38 +01:00
|
|
|
m_rightSidePanelSpinBox = new QSpinBox(this);
|
|
|
|
|
m_rightSidePanelSpinBox->setMaximum(16);
|
2022-05-01 12:55:08 +01:00
|
|
|
sidePanelsLayout->addWidget(m_rightSidePanelSpinBox, 1, 1, 1, 1, Qt::AlignTop);
|
2020-09-06 16:47:38 +01:00
|
|
|
connect(m_rightSidePanelSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), [=](int index){ setRightSidePanelWidth(index); });
|
|
|
|
|
|
2020-09-19 19:34:41 +01:00
|
|
|
// Side panels status
|
2020-09-06 16:47:38 +01:00
|
|
|
m_sidePanelStatusAct = new QCheckBox("Side panels at level 3.5 only");
|
2022-05-01 12:55:08 +01:00
|
|
|
sidePanelsLayout->addWidget(m_sidePanelStatusAct, 2, 0, 1, 2, Qt::AlignTop);
|
2020-09-06 16:47:38 +01:00
|
|
|
connect(m_sidePanelStatusAct, &QCheckBox::stateChanged, m_parentMainWidget, &TeletextWidget::setSidePanelAtL35Only);
|
|
|
|
|
|
2022-05-01 12:55:08 +01:00
|
|
|
// Add group box to the main layout
|
|
|
|
|
sidePanelsGroupBox->setLayout(sidePanelsLayout);
|
|
|
|
|
pageEnhancementsLayout->addWidget(sidePanelsGroupBox);
|
2020-09-19 19:34:41 +01:00
|
|
|
|
|
|
|
|
pageEnhancementsLayout->addStretch(1);
|
|
|
|
|
|
2020-09-08 12:12:24 +01:00
|
|
|
pageEnhancementsWidget->setLayout(pageEnhancementsLayout);
|
|
|
|
|
this->setWidget(pageEnhancementsWidget);
|
2020-09-06 16:47:38 +01:00
|
|
|
}
|
|
|
|
|
|
2020-09-08 12:12:24 +01:00
|
|
|
void PageEnhancementsDockWidget::setLeftSidePanelWidth(int newLeftPanelSize)
|
2020-09-06 16:47:38 +01:00
|
|
|
{
|
|
|
|
|
if (newLeftPanelSize && m_rightSidePanelSpinBox->value()) {
|
|
|
|
|
int newRightPanelSize = 16-newLeftPanelSize;
|
|
|
|
|
m_rightSidePanelSpinBox->blockSignals(true);
|
|
|
|
|
m_rightSidePanelSpinBox->setValue(newRightPanelSize);
|
|
|
|
|
m_rightSidePanelSpinBox->blockSignals(false);
|
|
|
|
|
}
|
|
|
|
|
m_parentMainWidget->setSidePanelWidths(newLeftPanelSize, m_rightSidePanelSpinBox->value());
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-08 12:12:24 +01:00
|
|
|
void PageEnhancementsDockWidget::setRightSidePanelWidth(int newRightPanelSize)
|
2020-09-06 16:47:38 +01:00
|
|
|
{
|
|
|
|
|
if (newRightPanelSize && m_leftSidePanelSpinBox->value()) {
|
|
|
|
|
int newLeftPanelSize = 16-newRightPanelSize;
|
|
|
|
|
m_leftSidePanelSpinBox->blockSignals(true);
|
|
|
|
|
m_leftSidePanelSpinBox->setValue(newLeftPanelSize);
|
|
|
|
|
m_leftSidePanelSpinBox->blockSignals(false);
|
|
|
|
|
}
|
|
|
|
|
m_parentMainWidget->setSidePanelWidths(m_leftSidePanelSpinBox->value(), newRightPanelSize);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-08 12:12:24 +01:00
|
|
|
void PageEnhancementsDockWidget::updateWidgets()
|
2020-09-06 16:47:38 +01:00
|
|
|
{
|
|
|
|
|
int leftSidePanelColumnsResult = 0;
|
|
|
|
|
int rightSidePanelColumnsResult = 0;
|
|
|
|
|
|
|
|
|
|
m_defaultScreenColourCombo->blockSignals(true);
|
|
|
|
|
m_defaultScreenColourCombo->setCurrentIndex(m_parentMainWidget->document()->currentSubPage()->defaultScreenColour());
|
|
|
|
|
m_defaultScreenColourCombo->blockSignals(false);
|
|
|
|
|
m_defaultRowColourCombo->blockSignals(true);
|
|
|
|
|
m_defaultRowColourCombo->setCurrentIndex(m_parentMainWidget->document()->currentSubPage()->defaultRowColour());
|
|
|
|
|
m_defaultRowColourCombo->blockSignals(false);
|
|
|
|
|
m_colourTableCombo->blockSignals(true);
|
|
|
|
|
m_colourTableCombo->setCurrentIndex(m_parentMainWidget->document()->currentSubPage()->colourTableRemap());
|
|
|
|
|
m_colourTableCombo->blockSignals(false);
|
|
|
|
|
m_blackBackgroundSubstAct->blockSignals(true);
|
|
|
|
|
m_blackBackgroundSubstAct->setChecked(m_parentMainWidget->document()->currentSubPage()->blackBackgroundSubst());
|
|
|
|
|
m_blackBackgroundSubstAct->blockSignals(false);
|
|
|
|
|
|
|
|
|
|
if (m_parentMainWidget->document()->currentSubPage()->leftSidePanelDisplayed())
|
|
|
|
|
leftSidePanelColumnsResult = (m_parentMainWidget->document()->currentSubPage()->sidePanelColumns() == 0) ? 16 : m_parentMainWidget->document()->currentSubPage()->sidePanelColumns();
|
|
|
|
|
|
|
|
|
|
if (m_parentMainWidget->document()->currentSubPage()->rightSidePanelDisplayed())
|
|
|
|
|
rightSidePanelColumnsResult = 16-m_parentMainWidget->document()->currentSubPage()->sidePanelColumns();
|
|
|
|
|
|
|
|
|
|
m_leftSidePanelSpinBox->blockSignals(true);
|
|
|
|
|
m_leftSidePanelSpinBox->setValue(leftSidePanelColumnsResult);
|
|
|
|
|
m_leftSidePanelSpinBox->blockSignals(false);
|
|
|
|
|
m_rightSidePanelSpinBox->blockSignals(true);
|
|
|
|
|
m_rightSidePanelSpinBox->setValue(rightSidePanelColumnsResult);
|
|
|
|
|
m_rightSidePanelSpinBox->blockSignals(false);
|
|
|
|
|
m_sidePanelStatusAct->blockSignals(true);
|
|
|
|
|
m_sidePanelStatusAct->setChecked(!m_parentMainWidget->document()->currentSubPage()->sidePanelStatusL25());
|
|
|
|
|
m_sidePanelStatusAct->blockSignals(false);
|
|
|
|
|
}
|