fixed #889
This commit is contained in:
parent
a96024aebd
commit
92c00c0c8a
3 changed files with 64 additions and 11 deletions
|
@ -99,6 +99,17 @@ FormMessageFiltersManager::FormMessageFiltersManager(FeedReader* reader,
|
|||
this,
|
||||
&FormMessageFiltersManager::showMessageContextMenu);
|
||||
|
||||
connect(m_ui.m_searchWidget, &SearchTextWidget::searchCancelled, this, [this]() {
|
||||
m_ui.m_txtScript->find(QString());
|
||||
});
|
||||
connect(m_ui.m_searchWidget, &SearchTextWidget::searchForText, this, [this](const QString& text, bool backwards) {
|
||||
m_ui.m_txtScript->find(text, backwards ? QTextDocument::FindFlag::FindBackward : QTextDocument::FindFlags());
|
||||
m_ui.m_searchWidget->setFocus();
|
||||
});
|
||||
|
||||
m_ui.m_txtScript->installEventFilter(this);
|
||||
m_ui.m_searchWidget->hide();
|
||||
|
||||
initializeTestingMessage();
|
||||
initializePremadeFilters();
|
||||
loadFilters();
|
||||
|
@ -119,6 +130,30 @@ MessageFilter* FormMessageFiltersManager::selectedFilter() const {
|
|||
}
|
||||
}
|
||||
|
||||
bool FormMessageFiltersManager::eventFilter(QObject* watched, QEvent* event) {
|
||||
Q_UNUSED(watched)
|
||||
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent* key_event = static_cast<QKeyEvent*>(event);
|
||||
|
||||
// Find text.
|
||||
if (key_event->matches(QKeySequence::StandardKey::Find)) {
|
||||
m_ui.m_searchWidget->clear();
|
||||
m_ui.m_searchWidget->show();
|
||||
m_ui.m_searchWidget->setFocus();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Hide visible search box.
|
||||
if (key_event->key() == Qt::Key::Key_Escape && m_ui.m_searchWidget->isVisible()) {
|
||||
m_ui.m_searchWidget->hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ServiceRoot* FormMessageFiltersManager::selectedAccount() const {
|
||||
auto dat = m_ui.m_cmbAccounts->currentData(Qt::ItemDataRole::UserRole);
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ class FormMessageFiltersManager : public QDialog {
|
|||
MessageFilter* selectedFilter() const;
|
||||
ServiceRoot* selectedAccount() const;
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject* watched, QEvent* event);
|
||||
|
||||
private slots:
|
||||
void filterMessagesLikeThis(const Message& msg);
|
||||
void showMessageContextMenu(QPoint pos);
|
||||
|
|
|
@ -179,17 +179,24 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPlainTextEdit" name="m_txtScript">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Your JavaScript-based article filtering logic</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="m_txtScript">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Your JavaScript-based article filtering logic</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="SearchTextWidget" name="m_searchWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
|
@ -445,6 +452,14 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>SearchTextWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>searchtextwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>m_listFilters</tabstop>
|
||||
<tabstop>m_btnAddNew</tabstop>
|
||||
|
|
Loading…
Add table
Reference in a new issue