Skip to content

Commit

Permalink
Don't visualize default actions, if nameless (#331)
Browse files Browse the repository at this point in the history
No empty button, no empty combo-box item.
  • Loading branch information
Yuubi-san authored Oct 12, 2022
1 parent c3229fe commit 14164ad
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/notificationwidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,16 @@ NotificationActionsButtonsWidget::NotificationActionsButtonsWidget(const QString

for (const auto &action : qAsConst(m_actions))
{
QPushButton *b = new QPushButton(action.second, this);
b->setObjectName(action.first);
auto &id = action.first;
auto &label = action.second;

if (id == m_defaultAction && label.isEmpty())
{
continue;
}

QPushButton *b = new QPushButton(label, this);
b->setObjectName(id);
// Notifications do not have focus, and if they get focus under Wayland,
// we do not want to have a focus widget.
b->setFocusPolicy(Qt::NoFocus);
Expand Down Expand Up @@ -125,15 +133,19 @@ NotificationActionsComboWidget::NotificationActionsComboWidget(const QStringList
m_comboBox->setFocusPolicy(Qt::NoFocus);
int currentIndex = -1;

for (int i = 0; i < m_actions.count(); ++i)
for (const auto &action : qAsConst(m_actions))
{
auto const & action = m_actions[i];
auto &id = action.first;
auto &label = action.second;

m_comboBox->addItem(action.second, action.first);
if (action.first == m_defaultAction)
if (id == m_defaultAction)
{
currentIndex = i;
if (label.isEmpty())
continue;
currentIndex = m_comboBox->count();
}

m_comboBox->addItem(label, id);
}
l->addWidget(m_comboBox);

Expand Down

0 comments on commit 14164ad

Please sign in to comment.