Skip to content

Commit

Permalink
OutputPane: Show "manage" menu as context menu for the buttons too
Browse files Browse the repository at this point in the history
Simply makes sense.

Change-Id: I2f68b0bfdea66185c0c70d8e888fe0965276a7ab
Reviewed-by: Marcus Tillmanns <[email protected]>
  • Loading branch information
e4z9 committed Sep 19, 2023
1 parent 8a72318 commit ea47e6c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/plugins/coreplugin/outputpanemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ void OutputPaneManager::initialize()
outPane->displayName(),
cmd->action());
data.button = button;
connect(button, &OutputPaneToggleButton::contextMenuRequested, m_instance, [] {
m_instance->popupMenu();
});

connect(outPane, &IOutputPane::flashButton, button, [button] { button->flash(); });
connect(outPane,
Expand Down Expand Up @@ -562,7 +565,7 @@ void OutputPaneManager::initialize()
m_instance->m_titleLabel->setText(g_outputPanes[currentIdx].pane->displayName());
m_instance->m_buttonsWidget->layout()->addWidget(m_instance->m_manageButton);
connect(m_instance->m_manageButton,
&QAbstractButton::clicked,
&OutputPaneManageButton::menuRequested,
m_instance,
&OutputPaneManager::popupMenu);

Expand Down Expand Up @@ -1004,6 +1007,10 @@ bool OutputPaneToggleButton::isPaneVisible() const
return isVisibleTo(parentWidget());
}

void OutputPaneToggleButton::contextMenuEvent(QContextMenuEvent *)
{
emit contextMenuRequested();
}

///////////////////////////////////////////////////////////////////////
//
Expand All @@ -1016,6 +1023,7 @@ OutputPaneManageButton::OutputPaneManageButton()
setFocusPolicy(Qt::NoFocus);
setCheckable(true);
setFixedWidth(StyleHelper::toolbarStyle() == Utils::StyleHelper::ToolbarStyleCompact ? 17 : 21);
connect(this, &QToolButton::clicked, this, &OutputPaneManageButton::menuRequested);
}

void OutputPaneManageButton::paintEvent(QPaintEvent*)
Expand All @@ -1037,6 +1045,11 @@ void OutputPaneManageButton::paintEvent(QPaintEvent*)
s->drawPrimitive(QStyle::PE_IndicatorArrowDown, &arrowOpt, &p, this);
}

void OutputPaneManageButton::contextMenuEvent(QContextMenuEvent *)
{
emit menuRequested();
}

BadgeLabel::BadgeLabel()
{
m_font = QApplication::font();
Expand Down
12 changes: 11 additions & 1 deletion src/plugins/coreplugin/outputpanemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ class OutputPaneToggleButton : public QToolButton
void setIconBadgeNumber(int number);
bool isPaneVisible() const;

void contextMenuEvent(QContextMenuEvent *e) override;

signals:
void contextMenuRequested();

private:
void updateToolTip();
void checkStateSet() override;
Expand All @@ -124,7 +129,12 @@ class OutputPaneManageButton : public QToolButton
Q_OBJECT
public:
OutputPaneManageButton();
void paintEvent(QPaintEvent*) override;
void paintEvent(QPaintEvent *) override;

void contextMenuEvent(QContextMenuEvent *e) override;

signals:
void menuRequested();
};

} // namespace Internal
Expand Down

0 comments on commit ea47e6c

Please sign in to comment.