mirror of
				https://github.com/bitcoin/bitcoin.git
				synced 2024-05-17 23:56:39 +00:00 
			
		
		
		
	gui: Add GUIUtil::ItemDelegate with keyEscapePressed signal
This commit is contained in:
		
							parent
							
								
									84d5a6210c
								
							
						
					
					
						commit
						f7a553177d
					
				@ -49,6 +49,7 @@
 | 
			
		||||
#include <QDoubleValidator>
 | 
			
		||||
#include <QFileDialog>
 | 
			
		||||
#include <QFont>
 | 
			
		||||
#include <QKeyEvent>
 | 
			
		||||
#include <QLineEdit>
 | 
			
		||||
#include <QSettings>
 | 
			
		||||
#include <QTextDocument> // for Qt::mightBeRichText
 | 
			
		||||
@ -927,4 +928,14 @@ void ClickableProgressBar::mouseReleaseEvent(QMouseEvent *event)
 | 
			
		||||
    Q_EMIT clicked(event->pos());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool ItemDelegate::eventFilter(QObject *object, QEvent *event)
 | 
			
		||||
{
 | 
			
		||||
    if (event->type() == QEvent::KeyPress) {
 | 
			
		||||
        if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape) {
 | 
			
		||||
            Q_EMIT keyEscapePressed();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return QItemDelegate::eventFilter(object, event);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace GUIUtil
 | 
			
		||||
 | 
			
		||||
@ -10,6 +10,7 @@
 | 
			
		||||
 | 
			
		||||
#include <QEvent>
 | 
			
		||||
#include <QHeaderView>
 | 
			
		||||
#include <QItemDelegate>
 | 
			
		||||
#include <QMessageBox>
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include <QProgressBar>
 | 
			
		||||
@ -232,6 +233,18 @@ namespace GUIUtil
 | 
			
		||||
 | 
			
		||||
    typedef ClickableProgressBar ProgressBar;
 | 
			
		||||
 | 
			
		||||
    class ItemDelegate : public QItemDelegate
 | 
			
		||||
    {
 | 
			
		||||
        Q_OBJECT
 | 
			
		||||
    public:
 | 
			
		||||
        ItemDelegate(QObject* parent) : QItemDelegate(parent) {}
 | 
			
		||||
 | 
			
		||||
    Q_SIGNALS:
 | 
			
		||||
        void keyEscapePressed();
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        bool eventFilter(QObject *object, QEvent *event);
 | 
			
		||||
    };
 | 
			
		||||
} // namespace GUIUtil
 | 
			
		||||
 | 
			
		||||
#endif // BITCOIN_QT_GUIUTIL_H
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user