add all dropdown filters to keyboard shortcuts subsystem
This commit is contained in:
parent
f81f06ca3d
commit
4e9dc137f1
9 changed files with 99 additions and 36 deletions
|
@ -11,7 +11,9 @@ void DynamicShortcuts::save(const QList<QAction*>& actions) {
|
|||
Settings* settings = qApp->settings();
|
||||
|
||||
for (const QAction* action : actions) {
|
||||
settings->setValue(GROUP(Keyboard), action->objectName(), action->shortcut().toString(QKeySequence::PortableText));
|
||||
settings->setValue(GROUP(Keyboard),
|
||||
action->objectName(),
|
||||
action->shortcut().toString(QKeySequence::SequenceFormat::PortableText));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,10 +21,12 @@ void DynamicShortcuts::load(const QList<QAction*>& actions) {
|
|||
Settings* settings = qApp->settings();
|
||||
|
||||
for (QAction* action : actions) {
|
||||
QString shortcut_for_action =
|
||||
settings->value(GROUP(Keyboard), action->objectName(), action->shortcut().toString(QKeySequence::PortableText))
|
||||
QString shortcut_for_action = settings
|
||||
->value(GROUP(Keyboard),
|
||||
action->objectName(),
|
||||
action->shortcut().toString(QKeySequence::SequenceFormat::PortableText))
|
||||
.toString();
|
||||
|
||||
action->setShortcut(QKeySequence::fromString(shortcut_for_action, QKeySequence::PortableText));
|
||||
action->setShortcut(QKeySequence::fromString(shortcut_for_action, QKeySequence::SequenceFormat::PortableText));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,11 +73,12 @@ void DynamicShortcutsWidget::populate(QList<QAction*> actions) {
|
|||
auto act_text = action->text().remove(QSL("&"));
|
||||
auto act_toolt = action->toolTip();
|
||||
|
||||
if (act_text == act_toolt) {
|
||||
if (act_toolt.isEmpty() || act_text == act_toolt) {
|
||||
action_label->setText(act_text);
|
||||
}
|
||||
else {
|
||||
action_label->setText(QSL("%1 (%2)").arg(act_text, act_toolt));
|
||||
action_label->setText(act_toolt);
|
||||
// action_label->setText(QSL("%1 (%2)").arg(act_text, act_toolt));
|
||||
}
|
||||
|
||||
action_label->setToolTip(action->toolTip());
|
||||
|
|
|
@ -94,11 +94,12 @@ FormMain::FormMain(QWidget* parent, Qt::WindowFlags f)
|
|||
m_ui->m_menuWebBrowserTabs->addAction(qApp->web()->engineSettingsAction());
|
||||
#endif
|
||||
|
||||
setStatusBar(m_statusBar = new StatusBar(this));
|
||||
|
||||
// Add these actions to the list of actions of the main window.
|
||||
// This allows to use actions via shortcuts
|
||||
// even if main menu is not visible.
|
||||
addActions(qApp->userActions());
|
||||
setStatusBar(m_statusBar = new StatusBar(this));
|
||||
|
||||
// Prepare main window and tabs.
|
||||
prepareMenus();
|
||||
|
@ -243,6 +244,10 @@ QList<QAction*> FormMain::allActions() const {
|
|||
actions << m_ui->m_actionBrowserScrollDown;
|
||||
actions << m_actionToolbarMainMenu;
|
||||
|
||||
actions << m_ui->m_tabWidget->feedMessageViewer()->feedsToolBar()->extraActions();
|
||||
actions << m_ui->m_tabWidget->feedMessageViewer()->messagesToolBar()->extraActions();
|
||||
actions << m_statusBar->extraActions();
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ BaseToolBar::~BaseToolBar() {
|
|||
qDebugNN << LOGSEC_GUI << "Destroying BaseToolBar instance.";
|
||||
}
|
||||
|
||||
QList<QAction*> BaseBar::extraActions() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
void BaseBar::loadSavedActions() {
|
||||
loadSpecificActions(convertActions(savedActions()), true);
|
||||
}
|
||||
|
@ -39,13 +43,15 @@ QAction* BaseBar::findMatchingAction(const QString& action, const QList<QAction*
|
|||
void BaseToolBar::addActionToMenu(QMenu* menu,
|
||||
const QIcon& icon,
|
||||
const QString& title,
|
||||
const QString& tooltip_suffix,
|
||||
const QVariant& value,
|
||||
const QString& name) {
|
||||
const QString& object_name) {
|
||||
QAction* action = menu->addAction(icon, title);
|
||||
|
||||
action->setToolTip(title + tooltip_suffix);
|
||||
action->setCheckable(true);
|
||||
action->setData(value);
|
||||
action->setObjectName(name);
|
||||
action->setObjectName(object_name);
|
||||
}
|
||||
|
||||
void BaseToolBar::activateAction(const QString& action_name, QWidgetAction* widget_action) {
|
||||
|
|
|
@ -30,6 +30,11 @@ class BaseBar {
|
|||
// Loads the toolbar state from settings.
|
||||
virtual void loadSavedActions();
|
||||
|
||||
// Returns list of actions which are created solely by this toolbar.
|
||||
// NOTE: These actions are added to global list of actions which can be
|
||||
// bound to keyboard shortcuts.
|
||||
virtual QList<QAction*> extraActions() const;
|
||||
|
||||
// Converts action names to actions.
|
||||
virtual QList<QAction*> convertActions(const QStringList& actions) = 0;
|
||||
|
||||
|
@ -60,8 +65,9 @@ class BaseToolBar : public QToolBar, public BaseBar {
|
|||
void addActionToMenu(QMenu* menu,
|
||||
const QIcon& icon,
|
||||
const QString& title,
|
||||
const QString& tooltip_suffix,
|
||||
const QVariant& value,
|
||||
const QString& name);
|
||||
const QString& object_name);
|
||||
void drawNumberOfCriterias(QToolButton* btn, int count);
|
||||
};
|
||||
|
||||
|
|
|
@ -172,6 +172,10 @@ QStringList FeedsToolBar::savedActions() const {
|
|||
#endif
|
||||
}
|
||||
|
||||
QList<QAction*> FeedsToolBar::extraActions() const {
|
||||
return m_menuMessageFilter->actions();
|
||||
}
|
||||
|
||||
void FeedsToolBar::initializeSearchBox() {
|
||||
m_txtSearchMessages =
|
||||
new SearchLineEdit(QSL("feed_list_searcher"),
|
||||
|
@ -200,46 +204,56 @@ SearchLineEdit* FeedsToolBar::searchBox() const {
|
|||
void FeedsToolBar::initializeFilter() {
|
||||
m_menuMessageFilter = new NonClosableMenu(tr("Menu for filtering feeds"), this);
|
||||
|
||||
QString fl = QSL(" ") + tr("(feed list)");
|
||||
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("No extra filtering"),
|
||||
fl,
|
||||
QVariant::fromValue(FeedsProxyModel::FeedListFilter::NoFiltering),
|
||||
QSL("no_filtering"));
|
||||
QSL("feedlist_no_filtering"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show unread feeds"),
|
||||
tr("Show unread items"),
|
||||
fl,
|
||||
QVariant::fromValue(FeedsProxyModel::FeedListFilter::ShowUnread),
|
||||
QSL("show_unread"));
|
||||
QSL("feedlist_show_unread"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show non-empty feeds"),
|
||||
tr("Show non-empty items"),
|
||||
fl,
|
||||
QVariant::fromValue(FeedsProxyModel::FeedListFilter::ShowNonEmpty),
|
||||
QSL("non_empty"));
|
||||
QSL("feedlist_non_empty"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show feeds with new articles"),
|
||||
fl,
|
||||
QVariant::fromValue(FeedsProxyModel::FeedListFilter::ShowWithNewArticles),
|
||||
QSL("new_articles"));
|
||||
QSL("feedlist_new_articles"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show feeds with error"),
|
||||
fl,
|
||||
QVariant::fromValue(FeedsProxyModel::FeedListFilter::ShowWithError),
|
||||
QSL("with_error"));
|
||||
QSL("feedlist_with_error"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show switched off feeds"),
|
||||
fl,
|
||||
QVariant::fromValue(FeedsProxyModel::FeedListFilter::ShowSwitchedOff),
|
||||
QSL("switched_off"));
|
||||
QSL("feedlist_switched_off"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show quiet feeds"),
|
||||
fl,
|
||||
QVariant::fromValue(FeedsProxyModel::FeedListFilter::ShowQuiet),
|
||||
QSL("quiet"));
|
||||
QSL("feedlist_quiet"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show feeds with article filters"),
|
||||
fl,
|
||||
QVariant::fromValue(FeedsProxyModel::FeedListFilter::ShowWithArticleFilters),
|
||||
QSL("with_filters"));
|
||||
QSL("feedlist_with_filters"));
|
||||
|
||||
m_btnMessageFilter = new QToolButton(this);
|
||||
m_btnMessageFilter->setToolTip(tr("Display all feeds"));
|
||||
|
|
|
@ -22,6 +22,7 @@ class FeedsToolBar : public BaseToolBar {
|
|||
virtual void loadSpecificActions(const QList<QAction*>& actions, bool initial_load = false);
|
||||
virtual QStringList defaultActions() const;
|
||||
virtual QStringList savedActions() const;
|
||||
virtual QList<QAction*> extraActions() const;
|
||||
|
||||
SearchLineEdit* searchBox() const;
|
||||
|
||||
|
|
|
@ -224,84 +224,101 @@ void MessagesToolBar::initializeSearchBox() {
|
|||
void MessagesToolBar::initializeHighlighter() {
|
||||
m_menuMessageHighlighter = new NonClosableMenu(tr("Menu for highlighting articles"), this);
|
||||
|
||||
QString al = QSL(" ") + tr("(article list)");
|
||||
|
||||
addActionToMenu(m_menuMessageHighlighter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("No extra highlighting"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesModel::MessageHighlighter::NoHighlighting),
|
||||
QSL("no_highlighting"));
|
||||
QSL("articlelist_no_highlighting"));
|
||||
addActionToMenu(m_menuMessageHighlighter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-unread")),
|
||||
tr("Highlight unread articles"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesModel::MessageHighlighter::HighlightUnread),
|
||||
QSL("highlight_unread"));
|
||||
QSL("articlelist_highlight_unread"));
|
||||
addActionToMenu(m_menuMessageHighlighter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-important")),
|
||||
tr("Highlight important articles"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesModel::MessageHighlighter::HighlightImportant),
|
||||
QSL("highlight_important"));
|
||||
QSL("articlelist_highlight_important"));
|
||||
|
||||
m_menuMessageFilter = new NonClosableMenu(tr("Menu for filtering articles"), this);
|
||||
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("No extra filtering"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::NoFiltering),
|
||||
QSL("no_filtering"));
|
||||
QSL("articlelist_no_filtering"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-unread")),
|
||||
tr("Show unread articles"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowUnread),
|
||||
QSL("show_unread"));
|
||||
QSL("articlelist_show_unread"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show read articles"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowRead),
|
||||
QSL("show_read"));
|
||||
QSL("articlelist_show_read"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-important")),
|
||||
tr("Show important articles"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowImportant),
|
||||
QSL("show_important"));
|
||||
QSL("articlelist_show_important"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show today's articles"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowToday),
|
||||
QSL("show_today"));
|
||||
QSL("articlelist_show_today"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show yesterday's articles"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowYesterday),
|
||||
QSL("show_yesterday"));
|
||||
QSL("articlelist_show_yesterday"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show articles in last 24 hours"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowLast24Hours),
|
||||
QSL("show_last24hours"));
|
||||
QSL("articlelist_show_last24hours"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show articles in last 48 hours"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowLast48Hours),
|
||||
QSL("show_last48hours"));
|
||||
QSL("articlelist_show_last48hours"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show this week's articles"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowThisWeek),
|
||||
QSL("show_this_week"));
|
||||
QSL("articlelist_show_this_week"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-mark-read")),
|
||||
tr("Show last week's articles"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowLastWeek),
|
||||
QSL("show_last_week"));
|
||||
QSL("articlelist_show_last_week"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
qApp->icons()->fromTheme(QSL("mail-attachment")),
|
||||
tr("Show articles with attachments"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowOnlyWithAttachments),
|
||||
QSL("show_with_attachments"));
|
||||
QSL("articlelist_show_with_attachments"));
|
||||
addActionToMenu(m_menuMessageFilter,
|
||||
MessagesModel::generateIconForScore(MSG_SCORE_MAX / 2.0),
|
||||
tr("Show articles with some score"),
|
||||
al,
|
||||
QVariant::fromValue(MessagesProxyModel::MessageListFilter::ShowOnlyWithScore),
|
||||
QSL("show_with_score"));
|
||||
QSL("articlelist_show_with_score"));
|
||||
|
||||
m_btnMessageHighlighter = new QToolButton(this);
|
||||
m_btnMessageHighlighter->setToolTip(tr("Display all articles"));
|
||||
|
@ -362,3 +379,11 @@ QStringList MessagesToolBar::savedActions() const {
|
|||
QString::SplitBehavior::SkipEmptyParts);
|
||||
#endif
|
||||
}
|
||||
|
||||
QList<QAction*> MessagesToolBar::extraActions() const {
|
||||
QList<QAction*> act;
|
||||
|
||||
act << m_menuMessageHighlighter->actions() << m_menuMessageFilter->actions();
|
||||
|
||||
return act;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ class MessagesToolBar : public BaseToolBar {
|
|||
virtual QList<QAction*> convertActions(const QStringList& actions);
|
||||
virtual QStringList defaultActions() const;
|
||||
virtual QStringList savedActions() const;
|
||||
virtual QList<QAction*> extraActions() const;
|
||||
|
||||
SearchLineEdit* searchBox() const;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue