mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-22 00:17:23 -06:00
Fix Enter key behavior in Add new torrent dialog
Prevent inappropriate default completer from being used by path edit. PR #20670. Closes #20663.
This commit is contained in:
committed by
Vladimir Golovnev (Glassez)
parent
684a561974
commit
a7dfefc2a5
@@ -164,6 +164,7 @@ QValidator::State Private::FileSystemPathValidator::validate(QString &input, int
|
|||||||
Private::FileLineEdit::FileLineEdit(QWidget *parent)
|
Private::FileLineEdit::FileLineEdit(QWidget *parent)
|
||||||
: QLineEdit(parent)
|
: QLineEdit(parent)
|
||||||
{
|
{
|
||||||
|
setCompleter(new QCompleter(this));
|
||||||
connect(this, &QLineEdit::textChanged, this, &FileLineEdit::validateText);
|
connect(this, &QLineEdit::textChanged, this, &FileLineEdit::validateText);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +223,7 @@ void Private::FileLineEdit::keyPressEvent(QKeyEvent *e)
|
|||||||
|
|
||||||
if ((e->key() == Qt::Key_Space) && (e->modifiers() == Qt::CTRL))
|
if ((e->key() == Qt::Key_Space) && (e->modifiers() == Qt::CTRL))
|
||||||
{
|
{
|
||||||
if (!m_completer)
|
if (!m_completerModel)
|
||||||
{
|
{
|
||||||
m_iconProvider = new QFileIconProvider;
|
m_iconProvider = new QFileIconProvider;
|
||||||
m_iconProvider->setOptions(QFileIconProvider::DontUseCustomDirectoryIcons);
|
m_iconProvider->setOptions(QFileIconProvider::DontUseCustomDirectoryIcons);
|
||||||
@@ -235,9 +236,7 @@ void Private::FileLineEdit::keyPressEvent(QKeyEvent *e)
|
|||||||
| (m_completeDirectoriesOnly ? QDir::Dirs : QDir::AllEntries);
|
| (m_completeDirectoriesOnly ? QDir::Dirs : QDir::AllEntries);
|
||||||
m_completerModel->setFilter(filters);
|
m_completerModel->setFilter(filters);
|
||||||
|
|
||||||
m_completer = new QCompleter(this);
|
completer()->setModel(m_completerModel);
|
||||||
m_completer->setModel(m_completerModel);
|
|
||||||
setCompleter(m_completer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_completerModel->setRootPath(Path(text()).data());
|
m_completerModel->setRootPath(Path(text()).data());
|
||||||
@@ -261,8 +260,8 @@ void Private::FileLineEdit::contextMenuEvent(QContextMenuEvent *event)
|
|||||||
|
|
||||||
void Private::FileLineEdit::showCompletionPopup()
|
void Private::FileLineEdit::showCompletionPopup()
|
||||||
{
|
{
|
||||||
m_completer->setCompletionPrefix(text());
|
completer()->setCompletionPrefix(text());
|
||||||
m_completer->complete();
|
completer()->complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Private::FileLineEdit::validateText()
|
void Private::FileLineEdit::validateText()
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
#include "base/pathfwd.h"
|
#include "base/pathfwd.h"
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class QCompleter;
|
|
||||||
class QContextMenuEvent;
|
class QContextMenuEvent;
|
||||||
class QFileIconProvider;
|
class QFileIconProvider;
|
||||||
class QFileSystemModel;
|
class QFileSystemModel;
|
||||||
@@ -141,7 +140,6 @@ namespace Private
|
|||||||
static QString warningText(FileSystemPathValidator::TestResult result);
|
static QString warningText(FileSystemPathValidator::TestResult result);
|
||||||
|
|
||||||
QFileSystemModel *m_completerModel = nullptr;
|
QFileSystemModel *m_completerModel = nullptr;
|
||||||
QCompleter *m_completer = nullptr;
|
|
||||||
QAction *m_browseAction = nullptr;
|
QAction *m_browseAction = nullptr;
|
||||||
QAction *m_warningAction = nullptr;
|
QAction *m_warningAction = nullptr;
|
||||||
QFileIconProvider *m_iconProvider = nullptr;
|
QFileIconProvider *m_iconProvider = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user