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;
}
//---------------------------------------------------------------------------
//--- 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
//---------------------------------------------------------------------------
QString fceuGetOpcodeToolTip( uint8_t *opcode, int size )

View File

@ -7,6 +7,7 @@
#include <QValidator>
#include <QDialog>
#include <QHelpEvent>
#include <QCheckBox>
int getDirFromFile( const char *path, char *dir );
@ -48,6 +49,8 @@ class fceuHexIntValidtor : public QValidator
class fceuCustomToolTip : public QDialog
{
Q_OBJECT
public:
fceuCustomToolTip( QWidget *parent = nullptr );
~fceuCustomToolTip( void );
@ -70,6 +73,21 @@ class fceuCustomToolTip : public QDialog
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 );
QDialog *fceuCustomToolTipShow( QHelpEvent *helpEvent, QDialog *popup );

View File

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

View File

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