Added logic to Qt GUI to allow for the shape of the viewport cursor to be selectable between an arrow, cross, or blank. Also added a viewport cursor visibility configuration parameter. Cursor visibility and shape can be set via the video config option window.

This commit is contained in:
mjbudd77 2021-03-14 14:02:10 -04:00
parent b1c0c4447f
commit ffd5de60aa
5 changed files with 156 additions and 0 deletions

View File

@ -363,6 +363,30 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
grid->addWidget( winSizeReadout, 0, 1, Qt::AlignLeft);
grid->addWidget( vpSizeReadout, 1, 1, Qt::AlignLeft);
gbox = new QGroupBox( tr("Viewport Cursor") );
grid = new QGridLayout();
cursorSelect = new QComboBox();
cursorSelect->addItem( tr("Arrow"), 0 );
cursorSelect->addItem( tr("Cross"), 1 );
cursorSelect->addItem( tr("Blank"), 2 );
setComboBoxFromProperty( cursorSelect, "SDL.CursorType" );
connect(cursorSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(cursorShapeChanged(int)) );
vbox2->addWidget( gbox, 1 );
gbox->setLayout(grid);
grid->addWidget( new QLabel( tr("Shape:") ), 0, 0, Qt::AlignLeft);
grid->addWidget( cursorSelect, 0, 1, Qt::AlignLeft);
cursorVisCbx = new QCheckBox( tr("Visible") );
setCheckBoxFromProperty( cursorVisCbx, "SDL.CursorVis" );
grid->addWidget( cursorVisCbx, 1, 0, 2, 1, Qt::AlignLeft);
connect(cursorVisCbx, SIGNAL(stateChanged(int)), this, SLOT(cursorVisChanged(int)) );
vbox2->addStretch( 5 );
setLayout( main_vbox );
@ -724,6 +748,73 @@ void ConsoleVideoConfDialog_t::regionChanged(int index)
}
}
//----------------------------------------------------
void ConsoleVideoConfDialog_t::cursorShapeChanged(int index)
{
int cursorSel;
Qt::CursorShape s;
//printf("Scaler: %i : %i \n", index, scalerSelect->itemData(index).toInt() );
cursorSel = cursorSelect->itemData(index).toInt();
switch ( cursorSel )
{
case 2:
s = Qt::BlankCursor;
break;
case 1:
s = Qt::CrossCursor;
break;
default:
case 0:
s = Qt::ArrowCursor;
cursorSel = 0;
break;
}
consoleWindow->setViewerCursor( s );
g_config->setOption ("SDL.CursorType", cursorSel);
g_config->save ();
}
//----------------------------------------------------
void ConsoleVideoConfDialog_t::cursorVisChanged( int value )
{
int vis;
vis = (value != Qt::Unchecked);
//printf("Value:%i \n", value );
g_config->setOption("SDL.CursorVis", vis );
g_config->save ();
if ( vis )
{
int opt;
Qt::CursorShape s;
g_config->getOption("SDL.CursorType", &opt );
switch ( opt )
{
case 2:
s = Qt::BlankCursor;
break;
case 1:
s = Qt::CrossCursor;
break;
default:
case 0:
s = Qt::ArrowCursor;
break;
}
consoleWindow->setViewerCursor( s );
}
else
{
consoleWindow->setViewerCursor( Qt::BlankCursor );
}
}
//----------------------------------------------------
QSize ConsoleVideoConfDialog_t::calcNewScreenSize(void)
{
QSize out( GL_NES_WIDTH, GL_NES_HEIGHT );

View File

@ -33,6 +33,7 @@ class ConsoleVideoConfDialog_t : public QDialog
QComboBox *driverSelect;
QComboBox *scalerSelect;
QComboBox *regionSelect;
QComboBox *cursorSelect;
QCheckBox *autoRegion;
QCheckBox *gl_LF_chkBox;
QCheckBox *new_PPU_ena;
@ -42,6 +43,7 @@ class ConsoleVideoConfDialog_t : public QDialog
QCheckBox *showFPS_cbx;
QCheckBox *autoScaleCbx;
QCheckBox *sqrPixCbx;
QCheckBox *cursorVisCbx;
QDoubleSpinBox *xScaleBox;
QDoubleSpinBox *yScaleBox;
QLabel *xScaleLabel;
@ -78,6 +80,8 @@ class ConsoleVideoConfDialog_t : public QDialog
void regionChanged(int index);
void driverChanged(int index);
void scalerChanged(int index);
void cursorShapeChanged(int index);
void cursorVisChanged(int value);
void applyChanges( void );
void ntscStartScanLineChanged(const QString &);
void ntscEndScanLineChanged(const QString &);

View File

@ -90,6 +90,7 @@ consoleWin_t::consoleWin_t(QWidget *parent)
int opt, xWinSize = 256, yWinSize = 240;
int use_SDL_video = false;
int setFullScreen = false;
int cursorVis = true;
//QString libpath = QLibraryInfo::location(QLibraryInfo::PluginsPath);
//printf("LibPath: '%s'\n", libpath.toStdString().c_str() );
@ -190,6 +191,34 @@ consoleWin_t::consoleWin_t(QWidget *parent)
updateCounter = 0;
recentRomMenuReset = false;
// Viewport Cursor Type and Visibility
g_config->getOption("SDL.CursorVis", &cursorVis );
if ( cursorVis )
{
int cursorType;
g_config->getOption("SDL.CursorType", &cursorType );
switch ( cursorType )
{
case 2:
setViewerCursor( Qt::BlankCursor );
break;
case 1:
setViewerCursor( Qt::CrossCursor );
break;
default:
case 0:
setViewerCursor( Qt::ArrowCursor );
break;
}
}
else
{
setViewerCursor( Qt::BlankCursor );
}
}
consoleWin_t::~consoleWin_t(void)
@ -323,6 +352,33 @@ QSize consoleWin_t::calcRequiredSize(void)
return out;
}
void consoleWin_t::setViewerCursor( Qt::CursorShape s )
{
if ( viewport_GL )
{
viewport_GL->setCursor(s);
}
else if ( viewport_SDL )
{
viewport_SDL->setCursor(s);
}
}
Qt::CursorShape consoleWin_t::getViewerCursor(void)
{
Qt::CursorShape s;
if ( viewport_GL )
{
s = viewport_GL->cursor().shape();
}
else if ( viewport_SDL )
{
s = viewport_SDL->cursor().shape();
}
return s;
}
void consoleWin_t::resizeEvent(QResizeEvent *event)
{
if ( firstResize )

View File

@ -19,6 +19,7 @@
#include <QTimer>
#include <QThread>
#include <QMutex>
#include <QCursor>
#include "Qt/ConsoleViewerGL.h"
#include "Qt/ConsoleViewerSDL.h"
@ -118,6 +119,8 @@ class consoleWin_t : public QMainWindow
QSize calcRequiredSize(void);
void setViewerCursor( Qt::CursorShape s );
Qt::CursorShape getViewerCursor(void);
protected:
consoleMenuBar *menubar;

View File

@ -270,6 +270,8 @@ InitConfig()
config->addOption("special", "SDL.SpecialFilter", 0);
config->addOption("showfps", "SDL.ShowFPS", 0);
config->addOption("togglemenu", "SDL.ToggleMenu", 0);
config->addOption("cursorType", "SDL.CursorType", 0);
config->addOption("cursorVis" , "SDL.CursorVis", 1);
// OpenGL options
config->addOption("opengl", "SDL.OpenGL", 1);