Added logic to make focus policy configurable for Qt PPU viewer window.

This commit is contained in:
mjbudd77 2021-01-31 21:27:05 -05:00
parent 2940f1da66
commit 8161e3d80b
2 changed files with 44 additions and 1 deletions

View File

@ -116,7 +116,8 @@ ppuViewerDialog_t::ppuViewerDialog_t(QWidget *parent)
QVBoxLayout *patternVbox[2];
QHBoxLayout *hbox;
QGridLayout *grid;
QMenu *viewMenu, *colorMenu;
QActionGroup *group;
QMenu *viewMenu, *colorMenu, *optMenu, *subMenu;
QAction *act;
char stmp[64];
int useNativeMenuBar;
@ -296,6 +297,28 @@ ppuViewerDialog_t::ppuViewerDialog_t(QWidget *parent)
colorMenu->addAction(act);
// Options
optMenu = menuBar->addMenu(tr("Options"));
// Options -> Focus
subMenu = optMenu->addMenu(tr("Focus Policy"));
group = new QActionGroup(this);
group->setExclusive(true);
act = new QAction(tr("Click"), this);
act->setCheckable(true);
act->setChecked(true);
group->addAction(act);
subMenu->addAction(act);
connect(act, SIGNAL(triggered()), this, SLOT(setClickFocus(void)) );
act = new QAction(tr("Hover"), this);
act->setCheckable(true);
act->setChecked(false);
group->addAction(act);
subMenu->addAction(act);
connect(act, SIGNAL(triggered()), this, SLOT(setHoverFocus(void)) );
//-----------------------------------------------------------------------
// End Menu
//-----------------------------------------------------------------------
@ -372,6 +395,18 @@ void ppuViewerDialog_t::refreshSliderChanged(int value)
PPUViewRefresh = value;
}
//----------------------------------------------------
void ppuViewerDialog_t::setClickFocus(void)
{
patternView[0]->setHoverFocus(false);
patternView[1]->setHoverFocus(false);
}
//----------------------------------------------------
void ppuViewerDialog_t::setHoverFocus(void)
{
patternView[0]->setHoverFocus(true);
patternView[1]->setHoverFocus(true);
}
//----------------------------------------------------
ppuPatternView_t::ppuPatternView_t( int patternIndexID, QWidget *parent)
: QWidget(parent)
{
@ -404,6 +439,11 @@ void ppuPatternView_t::setTileLabel( QLabel *l )
tileLabel = l;
}
//----------------------------------------------------
void ppuPatternView_t::setHoverFocus( bool h )
{
hover2Focus = h;
}
//----------------------------------------------------
void ppuPatternView_t::setTileCoord( int x, int y )
{
selTile.setX(x);

View File

@ -52,6 +52,7 @@ class ppuPatternView_t : public QWidget
void setPattern( ppuPatternTable_t *p );
void setTileLabel( QLabel *l );
void setTileCoord( int x, int y );
void setHoverFocus( bool h );
QPoint convPixToTile( QPoint p );
bool getDrawTileGrid(void){ return drawTileGrid; };
@ -275,6 +276,8 @@ class ppuViewerDialog_t : public QDialog
void sprite8x16Changed1(int state);
void refreshSliderChanged(int value);
void scanLineChanged( const QString &s );
void setClickFocus(void);
void setHoverFocus(void);
};
int openPPUViewWindow( QWidget *parent );