Created a custom read only QCheckBox whose state cannot be changed via mouse button clicks. The widget is for boolean state display purposes only.

This commit is contained in:
mjbudd77 2021-08-14 16:54:48 -04:00
parent d8a1425715
commit 911e903ecb
4 changed files with 47 additions and 6 deletions

View File

@ -641,6 +641,28 @@ QValidator::State fceuHexIntValidtor::validate(QString &input, int &pos) const
return QValidator::Invalid; return QValidator::Invalid;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
//--- Read Only Checkbox
//---------------------------------------------------------------------------
QCheckBoxRO::QCheckBoxRO( const QString &text, QWidget *parent )
: QCheckBox( text, parent )
{
}
//---------------------------------------------------------------------------
QCheckBoxRO::QCheckBoxRO( QWidget *parent )
: QCheckBox( parent )
{
}
//---------------------------------------------------------------------------
// Hijack mouse events so that the checkbox is not clickable
void QCheckBoxRO::mousePressEvent( QMouseEvent *event )
{
event->accept();
}
void QCheckBoxRO::mouseReleaseEvent( QMouseEvent *event )
{
event->accept();
}
//---------------------------------------------------------------------------
//--- Opcode Tool Tip Description //--- Opcode Tool Tip Description
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
QString fceuGetOpcodeToolTip( uint8_t *opcode, int size ) QString fceuGetOpcodeToolTip( uint8_t *opcode, int size )

View File

@ -7,6 +7,7 @@
#include <QValidator> #include <QValidator>
#include <QDialog> #include <QDialog>
#include <QHelpEvent> #include <QHelpEvent>
#include <QCheckBox>
int getDirFromFile( const char *path, char *dir ); int getDirFromFile( const char *path, char *dir );
@ -48,6 +49,8 @@ class fceuHexIntValidtor : public QValidator
class fceuCustomToolTip : public QDialog class fceuCustomToolTip : public QDialog
{ {
Q_OBJECT
public: public:
fceuCustomToolTip( QWidget *parent = nullptr ); fceuCustomToolTip( QWidget *parent = nullptr );
~fceuCustomToolTip( void ); ~fceuCustomToolTip( void );
@ -70,6 +73,21 @@ class fceuCustomToolTip : public QDialog
void hideTimerExpired(void); void hideTimerExpired(void);
}; };
// Read Only Checkbox for state display only.
class QCheckBoxRO : public QCheckBox
{
Q_OBJECT
public:
QCheckBoxRO( const QString &text, QWidget *parent = nullptr );
QCheckBoxRO( QWidget *parent = nullptr );
protected:
void mousePressEvent( QMouseEvent *event ) override;
void mouseReleaseEvent( QMouseEvent *event ) override;
};
QString fceuGetOpcodeToolTip( uint8_t *opcode, int size ); QString fceuGetOpcodeToolTip( uint8_t *opcode, int size );
QDialog *fceuCustomToolTipShow( QHelpEvent *helpEvent, QDialog *popup ); QDialog *fceuCustomToolTipShow( QHelpEvent *helpEvent, QDialog *popup );

View File

@ -2993,13 +2993,13 @@ spriteViewerDialog_t::spriteViewerDialog_t(QWidget *parent)
cpuPagIdx->setEnabled(false); cpuPagIdx->setEnabled(false);
useCpuPag->setEnabled(false); useCpuPag->setEnabled(false);
hFlipBox = new QCheckBox( tr("Horizontal Flip") ); hFlipBox = new QCheckBoxRO( tr("Horizontal Flip") );
hFlipBox->setFocusPolicy(Qt::NoFocus); hFlipBox->setFocusPolicy(Qt::NoFocus);
vFlipBox = new QCheckBox( tr("Vertical Flip") ); vFlipBox = new QCheckBoxRO( tr("Vertical Flip") );
vFlipBox->setFocusPolicy(Qt::NoFocus); vFlipBox->setFocusPolicy(Qt::NoFocus);
bgPrioBox = new QCheckBox( tr("Background Priority") ); bgPrioBox = new QCheckBoxRO( tr("Background Priority") );
bgPrioBox->setFocusPolicy(Qt::NoFocus); bgPrioBox->setFocusPolicy(Qt::NoFocus);
spriteIndexBox = new QLineEdit(); spriteIndexBox = new QLineEdit();

View File

@ -22,6 +22,7 @@
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include "Qt/main.h" #include "Qt/main.h"
#include "Qt/ConsoleUtilities.h"
struct ppuPatternTable_t struct ppuPatternTable_t
{ {
@ -475,9 +476,9 @@ class spriteViewerDialog_t : public QDialog
QLineEdit *tileAddrBox; QLineEdit *tileAddrBox;
QLineEdit *palAddrBox; QLineEdit *palAddrBox;
QLineEdit *posBox; QLineEdit *posBox;
QCheckBox *hFlipBox; QCheckBoxRO *hFlipBox;
QCheckBox *vFlipBox; QCheckBoxRO *vFlipBox;
QCheckBox *bgPrioBox; QCheckBoxRO *bgPrioBox;
QCheckBox *showPosHex; QCheckBox *showPosHex;
QGroupBox *previewFrame; QGroupBox *previewFrame;