Implement display attributes context menu
This commit is contained in:
@@ -1096,6 +1096,16 @@ void X26DockWidget::customMenuRequested(QPoint pos)
|
||||
for (int i=0; i<6; i++)
|
||||
connect(static_cast<TripletFlashQMenu *>(customMenu)->ratePhaseAction(i), &QAction::triggered, [=]() { updateModelFromCookedWidget(i, Qt::UserRole+2); updateAllCookedTripletWidgets(index); });
|
||||
break;
|
||||
case 0x2c: // Display attributes
|
||||
customMenu = new TripletDisplayAttrsQMenu(this);
|
||||
|
||||
static_cast<TripletDisplayAttrsQMenu *>(customMenu)->setTextSizeChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toInt());
|
||||
for (int i=0; i<4; i++) {
|
||||
static_cast<TripletDisplayAttrsQMenu *>(customMenu)->setOtherAttrChecked(i, index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+i+2).toBool());
|
||||
connect(static_cast<TripletDisplayAttrsQMenu *>(customMenu)->textSizeAction(i), &QAction::triggered, [=]() { updateModelFromCookedWidget(i, Qt::UserRole+1); updateAllCookedTripletWidgets(index); });
|
||||
connect(static_cast<TripletDisplayAttrsQMenu *>(customMenu)->otherAttrAction(i), &QAction::toggled, [=](const int checked) { updateModelFromCookedWidget(checked, Qt::UserRole+i+2); updateAllCookedTripletWidgets(index); });
|
||||
}
|
||||
break;
|
||||
case 0x21: // G1 mosaic character
|
||||
case 0x22: // G3 mosaic character at level 1.5
|
||||
case 0x2b: // G3 mosaic character at level >=2.5
|
||||
|
||||
36
x26menus.cpp
36
x26menus.cpp
@@ -179,3 +179,39 @@ void TripletFlashQMenu::setRatePhaseChecked(int n)
|
||||
{
|
||||
m_actions[n+4]->setChecked(true);
|
||||
}
|
||||
|
||||
|
||||
TripletDisplayAttrsQMenu::TripletDisplayAttrsQMenu(QWidget *parent): QMenu(parent)
|
||||
{
|
||||
QMenu *sizeMenu = this->addMenu(tr("Text size"));
|
||||
m_actions[0] = sizeMenu->addAction(tr("Normal size"));
|
||||
m_actions[1] = sizeMenu->addAction(tr("Double height"));
|
||||
m_actions[2] = sizeMenu->addAction(tr("Double width"));
|
||||
m_actions[3] = sizeMenu->addAction(tr("Double size"));
|
||||
m_sizeActionGroup = new QActionGroup(this);
|
||||
for (int i=0; i<4; i++) {
|
||||
m_actions[i]->setCheckable(true);
|
||||
m_sizeActionGroup->addAction(m_actions[i]);
|
||||
}
|
||||
|
||||
m_actions[4] = this->addAction(tr("Boxing/Window"));
|
||||
m_actions[5] = this->addAction(tr("Conceal"));
|
||||
m_actions[6] = this->addAction(tr("Invert"));
|
||||
m_actions[7] = this->addAction(tr("Underline/Separated"));
|
||||
m_otherActionGroup = new QActionGroup(this);
|
||||
m_otherActionGroup->setExclusive(false);
|
||||
for (int i=4; i<8; i++) {
|
||||
m_actions[i]->setCheckable(true);
|
||||
m_otherActionGroup->addAction(m_actions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void TripletDisplayAttrsQMenu::setTextSizeChecked(int n)
|
||||
{
|
||||
m_actions[n]->setChecked(true);
|
||||
}
|
||||
|
||||
void TripletDisplayAttrsQMenu::setOtherAttrChecked(int n, bool b)
|
||||
{
|
||||
m_actions[n+4]->setChecked(b);
|
||||
}
|
||||
|
||||
16
x26menus.h
16
x26menus.h
@@ -172,4 +172,20 @@ private:
|
||||
QActionGroup *m_modeActionGroup, *m_ratePhaseActionGroup;
|
||||
};
|
||||
|
||||
class TripletDisplayAttrsQMenu : public QMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TripletDisplayAttrsQMenu(QWidget *parent = nullptr);
|
||||
QAction *textSizeAction(int n) const { return m_actions[n]; };
|
||||
QAction *otherAttrAction(int n) const { return m_actions[n+4]; };
|
||||
void setTextSizeChecked(int n);
|
||||
void setOtherAttrChecked(int n, bool b);
|
||||
|
||||
private:
|
||||
QAction *m_actions[8];
|
||||
QActionGroup *m_sizeActionGroup, *m_otherActionGroup;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user