fix #545 and also clear lineedits on ESC
This commit is contained in:
parent
ae189db85f
commit
0d9521a33c
@ -16,6 +16,7 @@
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/messagepreviewer.h"
|
||||
#include "gui/messagesview.h"
|
||||
#include "gui/reusable/baselineedit.h"
|
||||
#include "gui/reusable/plaintoolbutton.h"
|
||||
#include "gui/systemtrayicon.h"
|
||||
#include "gui/tabbar.h"
|
||||
@ -209,6 +210,8 @@ QList<QAction*> FormMain::allActions() const {
|
||||
actions << m_ui->m_actionEditSelectedItem;
|
||||
actions << m_ui->m_actionCopyUrlSelectedFeed;
|
||||
actions << m_ui->m_actionCopyUrlSelectedArticles;
|
||||
actions << m_ui->m_actionFocusSearchFeeds;
|
||||
actions << m_ui->m_actionFocusSearchArticles;
|
||||
actions << m_ui->m_actionDeleteSelectedItem;
|
||||
actions << m_ui->m_actionServiceAdd;
|
||||
actions << m_ui->m_actionServiceEdit;
|
||||
@ -792,6 +795,18 @@ void FormMain::createConnections() {
|
||||
connect(qApp->feedReader(), &FeedReader::feedUpdatesFinished, this, &FormMain::onFeedUpdatesFinished);
|
||||
|
||||
// Toolbar forwardings.
|
||||
connect(m_ui->m_actionFocusSearchFeeds,
|
||||
&QAction::triggered,
|
||||
tabWidget()->feedMessageViewer()->feedsToolBar()->searchBox(),
|
||||
[this]() {
|
||||
tabWidget()->feedMessageViewer()->feedsToolBar()->searchBox()->setFocus();
|
||||
});
|
||||
connect(m_ui->m_actionFocusSearchArticles,
|
||||
&QAction::triggered,
|
||||
tabWidget()->feedMessageViewer()->messagesToolBar()->searchBox(),
|
||||
[this]() {
|
||||
tabWidget()->feedMessageViewer()->messagesToolBar()->searchBox()->setFocus();
|
||||
});
|
||||
connect(m_ui->m_actionAddFeedIntoSelectedItem,
|
||||
&QAction::triggered,
|
||||
tabWidget()->feedMessageViewer()->feedsView(),
|
||||
|
@ -146,6 +146,8 @@
|
||||
<addaction name="m_actionMarkSelectedItemsAsRead"/>
|
||||
<addaction name="m_actionMarkSelectedItemsAsUnread"/>
|
||||
<addaction name="m_actionClearSelectedItems"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_actionFocusSearchFeeds"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="m_menuMessages">
|
||||
<property name="title">
|
||||
@ -169,6 +171,8 @@
|
||||
<addaction name="m_actionRestoreSelectedMessages"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_actionMessageFilters"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="m_actionFocusSearchArticles"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="m_menuRecycleBin">
|
||||
<property name="title">
|
||||
@ -890,6 +894,16 @@
|
||||
<string>Display application &log</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionFocusSearchFeeds">
|
||||
<property name="text">
|
||||
<string>Focus feeds search box</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="m_actionFocusSearchArticles">
|
||||
<property name="text">
|
||||
<string>Focus articles search box</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -14,9 +14,8 @@ BaseLineEdit::BaseLineEdit(QWidget* parent)
|
||||
this)) {
|
||||
|
||||
connect(m_actShowPassword, &QAction::triggered, this, [this]() {
|
||||
setEchoMode(echoMode() == QLineEdit::EchoMode::Password
|
||||
? QLineEdit::EchoMode::Normal
|
||||
: QLineEdit::EchoMode::Password);
|
||||
setEchoMode(echoMode() == QLineEdit::EchoMode::Password ? QLineEdit::EchoMode::Normal
|
||||
: QLineEdit::EchoMode::Password);
|
||||
});
|
||||
connect(this, &QLineEdit::textChanged, this, [this](const QString& text) {
|
||||
if (actions().contains(m_actShowPassword)) {
|
||||
@ -48,9 +47,13 @@ void BaseLineEdit::submit(const QString& text) {
|
||||
}
|
||||
|
||||
void BaseLineEdit::keyPressEvent(QKeyEvent* event) {
|
||||
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
|
||||
if (event->key() == Qt::Key::Key_Enter || event->key() == Qt::Key::Key_Return) {
|
||||
emit submitted(text());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key::Key_Escape) {
|
||||
submit(QString());
|
||||
event->accept();
|
||||
}
|
||||
|
||||
|
@ -93,27 +93,31 @@ void FeedsToolBar::loadSpecificActions(const QList<QAction*>& actions, bool init
|
||||
}
|
||||
|
||||
QStringList FeedsToolBar::defaultActions() const {
|
||||
return QString(GUI::FeedsToolbarActionsDef).split(',',
|
||||
return QString(GUI::FeedsToolbarActionsDef)
|
||||
.split(',',
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SplitBehavior::SkipEmptyParts);
|
||||
QString::SplitBehavior::SkipEmptyParts);
|
||||
#endif
|
||||
}
|
||||
|
||||
QStringList FeedsToolBar::savedActions() const {
|
||||
return qApp->settings()->value(GROUP(GUI),
|
||||
SETTING(GUI::FeedsToolbarActions)).toString().split(',',
|
||||
return qApp->settings()
|
||||
->value(GROUP(GUI), SETTING(GUI::FeedsToolbarActions))
|
||||
.toString()
|
||||
.split(',',
|
||||
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
Qt::SplitBehaviorFlags::SkipEmptyParts);
|
||||
#else
|
||||
QString::SplitBehavior::SkipEmptyParts);
|
||||
QString::SplitBehavior::SkipEmptyParts);
|
||||
#endif
|
||||
}
|
||||
|
||||
void FeedsToolBar::initializeSearchBox() {
|
||||
m_txtSearchMessages = new BaseLineEdit(this);
|
||||
m_txtSearchMessages->setSizePolicy(QSizePolicy::Policy::Expanding, m_txtSearchMessages->sizePolicy().verticalPolicy());
|
||||
m_txtSearchMessages->setSizePolicy(QSizePolicy::Policy::Expanding,
|
||||
m_txtSearchMessages->sizePolicy().verticalPolicy());
|
||||
m_txtSearchMessages->setPlaceholderText(tr("Search feeds (regex only)"));
|
||||
|
||||
// Setup wrapping action for search box.
|
||||
@ -126,3 +130,7 @@ void FeedsToolBar::initializeSearchBox() {
|
||||
|
||||
connect(m_txtSearchMessages, &BaseLineEdit::textChanged, this, &FeedsToolBar::feedsFilterPatternChanged);
|
||||
}
|
||||
|
||||
BaseLineEdit* FeedsToolBar::searchBox() const {
|
||||
return m_txtSearchMessages;
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ class FeedsToolBar : public BaseToolBar {
|
||||
virtual QStringList defaultActions() const;
|
||||
virtual QStringList savedActions() const;
|
||||
|
||||
BaseLineEdit *searchBox() const;
|
||||
|
||||
signals:
|
||||
void feedsFilterPatternChanged(const QString& pattern);
|
||||
|
||||
|
@ -305,6 +305,10 @@ void MessagesToolBar::saveToolButtonSelection(const QString& button_name, const
|
||||
qApp->settings()->setValue(GROUP(GUI), GUI::MessagesToolbarDefaultButtons, action_names.join(QSL(",")));
|
||||
}
|
||||
|
||||
BaseLineEdit* MessagesToolBar::searchBox() const {
|
||||
return m_txtSearchMessages;
|
||||
}
|
||||
|
||||
void MessagesToolBar::activateAction(const QString& action_name, QWidgetAction* widget_action) {
|
||||
const int start = action_name.indexOf('[');
|
||||
const int end = action_name.indexOf(']');
|
||||
|
@ -28,6 +28,8 @@ class MessagesToolBar : public BaseToolBar {
|
||||
virtual QStringList defaultActions() const;
|
||||
virtual QStringList savedActions() const;
|
||||
|
||||
BaseLineEdit *searchBox() const;
|
||||
|
||||
signals:
|
||||
void messageSearchPatternChanged(const QString& pattern);
|
||||
void messageHighlighterChanged(MessagesModel::MessageHighlighter highlighter);
|
||||
|
Loading…
x
Reference in New Issue
Block a user