Skip to content

Commit

Permalink
fix #943
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Jun 22, 2023
1 parent 64b33e3 commit 057738a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/librssguard/gui/toolbars/messagestoolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "miscellaneous/settings.h"

#include <QMenu>
#include <QPainter>
#include <QTimer>
#include <QToolButton>
#include <QWidgetAction>
Expand Down Expand Up @@ -146,10 +147,32 @@ void MessagesToolBar::handleMessageHighlighterChange(QAction* action) {

m_btnMessageHighlighter->setDefaultAction(checked_tasks_std.empty() ? m_menuMessageHighlighter->actions().constFirst()
: checked_tasks_std.front());
saveToolButtonSelection(HIGHLIGHTER_ACTION_NAME, FROM_STD_LIST(QList<QAction*>, checked_tasks_std));

if (checked_tasks_std.size() > 1) {
drawNumberOfCriterias(m_btnMessageHighlighter, checked_tasks_std.size());
}

saveToolButtonSelection(QSL(HIGHLIGHTER_ACTION_NAME), FROM_STD_LIST(QList<QAction*>, checked_tasks_std));
emit messageHighlighterChanged(task);
}

void MessagesToolBar::drawNumberOfCriterias(QToolButton* btn, int count) {
QPixmap px(128, 128);
px.fill(Qt::GlobalColor::transparent);

QPainter p(&px);

auto fon = p.font();

fon.setPixelSize(40);
p.setFont(fon);

p.drawPixmap(0, 0, 80, 80, btn->defaultAction()->icon().pixmap(128, 128));
p.drawText(65, 65, 50, 50, Qt::AlignmentFlag::AlignCenter, QString::number(count));

btn->setIcon(px);
}

void MessagesToolBar::handleMessageFilterChange(QAction* action) {
MessagesProxyModel::MessageListFilter task = action->data().value<MessagesProxyModel::MessageListFilter>();
std::list<QAction*> checked_tasks_std = boolinq::from(m_menuMessageFilter->actions())
Expand Down Expand Up @@ -180,7 +203,12 @@ void MessagesToolBar::handleMessageFilterChange(QAction* action) {

m_btnMessageFilter->setDefaultAction(checked_tasks_std.empty() ? m_menuMessageFilter->actions().constFirst()
: checked_tasks_std.front());
saveToolButtonSelection(FILTER_ACTION_NAME, FROM_STD_LIST(QList<QAction*>, checked_tasks_std));

if (checked_tasks_std.size() > 1) {
drawNumberOfCriterias(m_btnMessageFilter, checked_tasks_std.size());
}

saveToolButtonSelection(QSL(FILTER_ACTION_NAME), FROM_STD_LIST(QList<QAction*>, checked_tasks_std));
emit messageFilterChanged(task);
}

Expand Down
1 change: 1 addition & 0 deletions src/librssguard/gui/toolbars/messagestoolbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class MessagesToolBar : public BaseToolBar {
void initializeHighlighter();
void activateAction(const QString& action_name, QWidgetAction* widget_action);
void saveToolButtonSelection(const QString& button_name, const QList<QAction*>& actions) const;
void drawNumberOfCriterias(QToolButton* btn, int count);

private:
QWidgetAction* m_actionMessageHighlighter;
Expand Down

0 comments on commit 057738a

Please sign in to comment.