Merge pull request #1246 from manongjohn/fix_broken_column_toggle_shortcuts

Fix broken column toggle shortcuts
This commit is contained in:
manongjohn 2023-10-22 07:18:03 -04:00 committed by GitHub
commit fc36cd170c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 19 deletions

View file

@ -1437,7 +1437,9 @@ public:
TApp::instance()->getCurrentSelection()->getSelection());
TXsheet *xsh = TApp::instance()->getCurrentXsheet()->getXsheet();
XsheetViewer *xviewer = TApp::instance()->getCurrentXsheetViewer();
int cc = xviewer->getClickedColumn();
int mc = xviewer->getMenuColumnTarget();
int cc =
mc >= -1 ? mc : TApp::instance()->getCurrentColumn()->getColumnIndex();
bool sound_changed = false;
TTool *tool = TApp::instance()->getCurrentTool()->getTool();
TTool::Viewer *viewer = tool ? tool->getViewer() : nullptr;

View file

@ -1591,7 +1591,9 @@ ColumnArea::ColumnArea(XsheetViewer *parent, Qt::WindowFlags flags)
, m_columnTransparencyPopup(0)
, m_transparencyPopupTimer(0)
, m_isPanning(false)
, m_soundColumnPopup(0) {
, m_soundColumnPopup(0)
, m_menuCol(-999)
, m_menuTimer(0) {
TXsheetHandle *xsheetHandle = TApp::instance()->getCurrentXsheet();
TObjectHandle *objectHandle = TApp::instance()->getCurrentObject();
m_changeObjectParent = new ChangeObjectParent(m_viewer);
@ -3119,19 +3121,22 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
#endif
const Orientation *o = m_viewer->orientation();
int col = m_viewer->xyToPosition(event->pos()).layer();
m_menuCol = m_viewer->xyToPosition(event->pos()).layer();
bool isCamera = col < 0;
bool isCamera = m_menuCol < 0;
TXsheet *xsh = m_viewer->getXsheet();
QPoint topLeft = m_viewer->positionToXY(CellPosition(0, col));
QPoint topLeft = m_viewer->positionToXY(CellPosition(0, m_menuCol));
QPoint mouseInCell = event->pos() - topLeft;
QMenu menu(this);
connect(&menu, SIGNAL(aboutToHide()), this, SLOT(onMenuAboutToHide()));
CommandManager *cmdManager = CommandManager::instance();
//---- Preview
if (((isCamera && !o->isVerticalTimeline()) || !xsh->isColumnEmpty(col)) &&
if (((isCamera && !o->isVerticalTimeline()) ||
!xsh->isColumnEmpty(m_menuCol)) &&
o->rect(PredefinedRect::EYE_AREA).contains(mouseInCell)) {
menu.setObjectName("xsheetColumnAreaMenu_Preview");
@ -3143,7 +3148,7 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
menu.addAction(cmdManager->getAction("MI_SwapEnabledColumns"));
}
//---- Lock
else if ((isCamera || !xsh->isColumnEmpty(col)) &&
else if ((isCamera || !xsh->isColumnEmpty(m_menuCol)) &&
o->rect((isCamera) ? PredefinedRect::CAMERA_LOCK_AREA
: PredefinedRect::LOCK_AREA)
.contains(mouseInCell)) {
@ -3158,7 +3163,7 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
}
//---- Camstand
else if (((isCamera && !o->isVerticalTimeline()) ||
!xsh->isColumnEmpty(col)) &&
!xsh->isColumnEmpty(m_menuCol)) &&
o->rect(PredefinedRect::PREVIEW_LAYER_AREA).contains(mouseInCell)) {
menu.setObjectName("xsheetColumnAreaMenu_Camstand");
@ -3175,8 +3180,8 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
else {
if (!isCamera) {
int r0, r1;
xsh->getCellRange(col, r0, r1);
TXshCell cell = xsh->getCell(r0, col);
xsh->getCellRange(m_menuCol, r0, r1);
TXshCell cell = xsh->getCell(r0, m_menuCol);
menu.addAction(cmdManager->getAction(MI_Cut));
menu.addAction(cmdManager->getAction(MI_Copy));
menu.addAction(cmdManager->getAction(MI_Paste));
@ -3191,7 +3196,7 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
menu.addAction(cmdManager->getAction(MI_RemoveEmptyColumns));
}
menu.addSeparator();
if (m_viewer->getXsheet()->isColumnEmpty(col) ||
if (m_viewer->getXsheet()->isColumnEmpty(m_menuCol) ||
(cell.m_level && cell.m_level->getChildLevel()))
menu.addAction(cmdManager->getAction(MI_OpenChild));
@ -3240,7 +3245,7 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
}
// force the selected cells placed in n-steps
if (!xsh->isColumnEmpty(col)) {
if (!xsh->isColumnEmpty(m_menuCol)) {
menu.addSeparator();
QMenu *reframeSubMenu = new QMenu(tr("Reframe"), this);
{
@ -3267,7 +3272,7 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
menu.addMenu(subsampleSubMenu);
}
if (!xsh->isColumnEmpty(col)) {
if (!xsh->isColumnEmpty(m_menuCol)) {
menu.addAction(cmdManager->getAction(MI_ReplaceLevel));
menu.addAction(cmdManager->getAction(MI_ReplaceParentDirectory));
}
@ -3309,6 +3314,8 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
act4->setText(tr("&Paste Insert Below"));
}
if (m_menuTimer) m_menuTimer->stop();
menu.exec(event->globalPos());
act->setText(actText);
@ -3319,6 +3326,25 @@ void ColumnArea::contextMenuEvent(QContextMenuEvent *event) {
//-----------------------------------------------------------------------------
void ColumnArea::onMenuAboutToHide() {
if (!m_menuTimer) {
m_menuTimer = new QTimer(this);
connect(m_menuTimer, SIGNAL(timeout()), this,
SLOT(onResetContextMenuTarget()));
m_menuTimer->setSingleShot(true);
}
m_menuTimer->start(300);
}
//-----------------------------------------------------------------------------
void ColumnArea::onResetContextMenuTarget() {
if (m_menuTimer) m_menuTimer->stop();
m_menuCol = -999;
}
//-----------------------------------------------------------------------------
void ColumnArea::onSubSampling(QAction *action) {
int subsampling;
if (action == m_subsampling1)

View file

@ -325,6 +325,9 @@ class ColumnArea final : public QWidget {
QAction *m_subsampling3;
QAction *m_subsampling4;
int m_menuCol;
QTimer *m_menuTimer;
DragTool *getDragTool() const;
void setDragTool(DragTool *dragTool);
void startTransparencyPopupTimer(QMouseEvent *e);
@ -384,7 +387,7 @@ public:
QPixmap getColumnIcon(int columnIndex);
int getClickedColumn() { return m_col; }
int getMenuColumnTarget() { return m_menuCol; }
class Pixmaps {
public:
@ -412,6 +415,8 @@ protected slots:
void onCameraColumnChangedTriggered();
void onCameraColumnLockToggled(bool);
void onXsheetCameraChange(int);
void onMenuAboutToHide();
void onResetContextMenuTarget();
};
//-----------------------------------------------------------------------------

View file

@ -500,10 +500,9 @@ int XsheetViewer::getCurrentColumn() const {
//-----------------------------------------------------------------------------
int XsheetViewer::getClickedColumn() const {
if (!m_columnArea) return -1;
return m_columnArea->getClickedColumn();
int XsheetViewer::getMenuColumnTarget() const {
if (!m_columnArea) return -999;
return m_columnArea->getMenuColumnTarget();
}
//-----------------------------------------------------------------------------

View file

@ -683,7 +683,7 @@ public:
TXsheet *getXsheet() const;
int getCurrentColumn() const;
int getClickedColumn() const;
int getMenuColumnTarget() const;
int getCurrentRow() const;
//! Restituisce la \b objectId corrispondente alla colonna \b col
TStageObjectId getObjectId(int col) const;