Qt: add fallback path for older versions

This commit is contained in:
Brad Parker 2018-09-17 23:12:08 -04:00
parent 132faf3bf2
commit dd2e73d664
2 changed files with 11 additions and 0 deletions

View File

@ -199,6 +199,11 @@ TableWidget::TableWidget(QWidget *parent) :
{
}
bool TableWidget::isEditorOpen()
{
return (state() == QAbstractItemView::EditingState);
}
void TableWidget::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
@ -1587,8 +1592,13 @@ QTabWidget* MainWindow::browserAndPlaylistTabWidget()
void MainWindow::onTableWidgetEnterPressed()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
/* entry is being renamed, ignore this enter press */
if (m_tableWidget->isPersistentEditorOpen(m_tableWidget->currentIndex()))
#else
/* we can only check if any editor at all is open */
if (m_tableWidget->isEditorOpen())
#endif
return;
onRunClicked();
}

View File

@ -169,6 +169,7 @@ class TableWidget : public QTableWidget
Q_OBJECT
public:
TableWidget(QWidget *parent = 0);
bool isEditorOpen();
signals:
void enterPressed();
void deletePressed();