mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
disable input method in QuickSelector
This commit is contained in:
parent
f92e1a9791
commit
7fc7481cfb
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QInputMethod>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
#include <utils/widgetutils.h>
|
#include <utils/widgetutils.h>
|
||||||
|
|
||||||
@ -98,3 +100,24 @@ void LineEdit::selectBaseName(QLineEdit *p_lineEdit)
|
|||||||
int dotIndex = name.lastIndexOf('.');
|
int dotIndex = name.lastIndexOf('.');
|
||||||
p_lineEdit->setSelection(0, (dotIndex == -1) ? name.size() : dotIndex);
|
p_lineEdit->setSelection(0, (dotIndex == -1) ? name.size() : dotIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant LineEdit::inputMethodQuery(Qt::InputMethodQuery p_query) const
|
||||||
|
{
|
||||||
|
if (p_query == Qt::ImEnabled) {
|
||||||
|
return m_inputMethodEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QLineEdit::inputMethodQuery(p_query);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineEdit::setInputMethodEnabled(bool p_enabled)
|
||||||
|
{
|
||||||
|
if (m_inputMethodEnabled != p_enabled) {
|
||||||
|
m_inputMethodEnabled = p_enabled;
|
||||||
|
|
||||||
|
QInputMethod *im = QGuiApplication::inputMethod();
|
||||||
|
im->reset();
|
||||||
|
// Ask input method to query current state, which will call inputMethodQuery().
|
||||||
|
im->update(Qt::ImEnabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,10 +14,18 @@ namespace vnotex
|
|||||||
|
|
||||||
LineEdit(const QString &p_contents, QWidget *p_parent = nullptr);
|
LineEdit(const QString &p_contents, QWidget *p_parent = nullptr);
|
||||||
|
|
||||||
|
QVariant inputMethodQuery(Qt::InputMethodQuery p_query) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void setInputMethodEnabled(bool p_enabled);
|
||||||
|
|
||||||
static void selectBaseName(QLineEdit *p_lineEdit);
|
static void selectBaseName(QLineEdit *p_lineEdit);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE;
|
void keyPressEvent(QKeyEvent *p_event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Whether enable input method.
|
||||||
|
bool m_inputMethodEnabled = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,8 @@ void QuickSelector::setupUI(const QString &p_title)
|
|||||||
mainLayout->addWidget(new QLabel(p_title, this));
|
mainLayout->addWidget(new QLabel(p_title, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_searchLineEdit = WidgetsFactory::createLineEdit(this);
|
m_searchLineEdit = dynamic_cast<LineEdit *>(WidgetsFactory::createLineEdit(this));
|
||||||
|
m_searchLineEdit->setInputMethodEnabled(false);
|
||||||
connect(m_searchLineEdit, &QLineEdit::textEdited,
|
connect(m_searchLineEdit, &QLineEdit::textEdited,
|
||||||
this, &QuickSelector::searchAndFilter);
|
this, &QuickSelector::searchAndFilter);
|
||||||
mainLayout->addWidget(m_searchLineEdit);
|
mainLayout->addWidget(m_searchLineEdit);
|
||||||
|
@ -6,12 +6,13 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
class QLineEdit;
|
|
||||||
class QListWidget;
|
class QListWidget;
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
|
|
||||||
namespace vnotex
|
namespace vnotex
|
||||||
{
|
{
|
||||||
|
class LineEdit;
|
||||||
|
|
||||||
struct QuickSelectorItem
|
struct QuickSelectorItem
|
||||||
{
|
{
|
||||||
QuickSelectorItem() = default;
|
QuickSelectorItem() = default;
|
||||||
@ -63,7 +64,7 @@ namespace vnotex
|
|||||||
|
|
||||||
QVector<QuickSelectorItem> m_items;
|
QVector<QuickSelectorItem> m_items;
|
||||||
|
|
||||||
QLineEdit *m_searchLineEdit = nullptr;
|
LineEdit *m_searchLineEdit = nullptr;
|
||||||
|
|
||||||
QListWidget *m_itemList = nullptr;
|
QListWidget *m_itemList = nullptr;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user