diff --git a/src/plugins/coreplugin/ioutputpane.h b/src/plugins/coreplugin/ioutputpane.h index d219e2aefff..b7800a65c84 100644 --- a/src/plugins/coreplugin/ioutputpane.h +++ b/src/plugins/coreplugin/ioutputpane.h @@ -41,6 +41,8 @@ class QWidget; QT_END_NAMESPACE namespace Core { +class CommandButton; +class IContext; class CORE_EXPORT IOutputPane : public QObject { @@ -93,6 +95,7 @@ signals: void setBadgeNumber(int number); void zoomIn(int range); void zoomOut(int range); + void resetZoom(); void wheelZoomEnabledChanged(bool enabled); void fontChanged(const QFont &font); @@ -103,7 +106,7 @@ protected: Qt::CaseSensitivity filterCaseSensitivity() const { return m_filterCaseSensitivity; } void setFilteringEnabled(bool enable); QWidget *filterWidget() const { return m_filterOutputLineEdit; } - + void setupContext(const char *context, QWidget *widget); void setZoomButtonsEnabled(bool enabled); private: @@ -115,11 +118,12 @@ private: Id filterRegexpActionId() const; Id filterCaseSensitivityActionId() const; - QToolButton * const m_zoomInButton = nullptr; - QToolButton * const m_zoomOutButton = nullptr; + Core::CommandButton * const m_zoomInButton; + Core::CommandButton * const m_zoomOutButton; QAction *m_filterActionRegexp = nullptr; QAction *m_filterActionCaseSensitive = nullptr; Utils::FancyLineEdit *m_filterOutputLineEdit = nullptr; + IContext *m_context = nullptr; bool m_filterRegexp = false; Qt::CaseSensitivity m_filterCaseSensitivity = Qt::CaseInsensitive; }; diff --git a/src/plugins/coreplugin/messageoutputwindow.cpp b/src/plugins/coreplugin/messageoutputwindow.cpp index 7aabaefbbc9..c7c752e1556 100644 --- a/src/plugins/coreplugin/messageoutputwindow.cpp +++ b/src/plugins/coreplugin/messageoutputwindow.cpp @@ -56,6 +56,7 @@ MessageOutputWindow::MessageOutputWindow() connect(this, &IOutputPane::zoomIn, m_widget, &Core::OutputWindow::zoomIn); connect(this, &IOutputPane::zoomOut, m_widget, &Core::OutputWindow::zoomOut); + connect(this, &IOutputPane::resetZoom, m_widget, &Core::OutputWindow::resetZoom); connect(this, &IOutputPane::fontChanged, m_widget, &OutputWindow::setBaseFont); connect(this, &IOutputPane::wheelZoomEnabledChanged, m_widget, &OutputWindow::setWheelZoomEnabled); @@ -65,6 +66,7 @@ MessageOutputWindow::MessageOutputWindow() setupFilterUi("MessageOutputPane.Filter"); setFilteringEnabled(true); + setupContext(Constants::C_GENERAL_OUTPUT_PANE, m_widget); } MessageOutputWindow::~MessageOutputWindow() diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index 951fed419b0..7cf2ec2c90a 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -90,24 +91,27 @@ static bool g_managerConstructed = false; // For debugging reasons. IOutputPane::IOutputPane(QObject *parent) : QObject(parent), - m_zoomInButton(new QToolButton), - m_zoomOutButton(new QToolButton) + m_zoomInButton(new Core::CommandButton), + m_zoomOutButton(new Core::CommandButton) { // We need all pages first. Ignore latecomers and shout. QTC_ASSERT(!g_managerConstructed, return); g_outputPanes.append(OutputPaneData(this)); - m_zoomInButton->setToolTip(tr("Increase Font Size")); m_zoomInButton->setIcon(Utils::Icons::PLUS_TOOLBAR.icon()); + m_zoomInButton->setCommandId(Constants::ZOOM_IN); connect(m_zoomInButton, &QToolButton::clicked, this, [this] { emit zoomIn(1); }); - m_zoomOutButton->setToolTip(tr("Decrease Font Size")); m_zoomOutButton->setIcon(Utils::Icons::MINUS.icon()); + m_zoomOutButton->setCommandId(Constants::ZOOM_OUT); connect(m_zoomOutButton, &QToolButton::clicked, this, [this] { emit zoomOut(1); }); } IOutputPane::~IOutputPane() { + if (m_context) + ICore::removeContextObject(m_context); + const int i = Utils::indexOf(g_outputPanes, Utils::equal(&OutputPaneData::pane, this)); QTC_ASSERT(i >= 0, return); delete g_outputPanes.at(i).button; @@ -174,6 +178,26 @@ void IOutputPane::setFilteringEnabled(bool enable) m_filterOutputLineEdit->setEnabled(enable); } +void IOutputPane::setupContext(const char *context, QWidget *widget) +{ + QTC_ASSERT(!m_context, return); + m_context = new IContext(this); + m_context->setContext(Context(context)); + m_context->setWidget(widget); + ICore::addContextObject(m_context); + + const auto zoomInAction = new QAction(this); + Core::ActionManager::registerAction(zoomInAction, Constants::ZOOM_IN, m_context->context()); + connect(zoomInAction, &QAction::triggered, this, [this] { emit zoomIn(1); }); + const auto zoomOutAction = new QAction(this); + Core::ActionManager::registerAction(zoomOutAction, Constants::ZOOM_OUT, m_context->context()); + connect(zoomOutAction, &QAction::triggered, this, [this] { emit zoomOut(1); }); + const auto resetZoomAction = new QAction(this); + Core::ActionManager::registerAction(resetZoomAction, Constants::ZOOM_RESET, + m_context->context()); + connect(resetZoomAction, &QAction::triggered, this, &IOutputPane::resetZoom); +} + void IOutputPane::setZoomButtonsEnabled(bool enabled) { m_zoomInButton->setEnabled(enabled); diff --git a/src/plugins/coreplugin/outputwindow.h b/src/plugins/coreplugin/outputwindow.h index 88692d5ab74..204a1106a93 100644 --- a/src/plugins/coreplugin/outputwindow.h +++ b/src/plugins/coreplugin/outputwindow.h @@ -75,6 +75,7 @@ public: void setBaseFont(const QFont &newFont); float fontZoom() const; void setFontZoom(float zoom); + void resetZoom() { setFontZoom(0); } void setWheelZoomEnabled(bool enabled); void updateFilterProperties(const QString &filterText, Qt::CaseSensitivity caseSensitivity, bool regexp); diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index 7631f26cac6..df9fd503ba0 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -213,6 +213,7 @@ AppOutputPane::AppOutputPane() : connect(this, &Core::IOutputPane::zoomIn, this, &AppOutputPane::zoomIn); connect(this, &Core::IOutputPane::zoomOut, this, &AppOutputPane::zoomOut); + connect(this, &IOutputPane::resetZoom, this, &AppOutputPane::resetZoom); m_settingsButton->setToolTip(tr("Open Settings Page")); m_settingsButton->setIcon(Utils::Icons::SETTINGS_TOOLBAR.icon()); @@ -247,6 +248,7 @@ AppOutputPane::AppOutputPane() : setupFilterUi("AppOutputPane.Filter"); setFilteringEnabled(false); setZoomButtonsEnabled(false); + setupContext("Core.AppOutputPane", m_mainWidget); } AppOutputPane::~AppOutputPane() @@ -662,6 +664,12 @@ void AppOutputPane::zoomOut(int range) tab.window->zoomOut(range); } +void AppOutputPane::resetZoom() +{ + for (const RunControlTab &tab : qAsConst(m_runControlTabs)) + tab.window->resetZoom(); +} + void AppOutputPane::enableButtons(const RunControl *rc) { if (rc) { diff --git a/src/plugins/projectexplorer/appoutputpane.h b/src/plugins/projectexplorer/appoutputpane.h index 5fc88219fcb..6d7936042ee 100644 --- a/src/plugins/projectexplorer/appoutputpane.h +++ b/src/plugins/projectexplorer/appoutputpane.h @@ -120,6 +120,7 @@ private: void zoomIn(int range); void zoomOut(int range); + void resetZoom(); void enableButtons(const RunControl *rc); diff --git a/src/plugins/projectexplorer/compileoutputwindow.cpp b/src/plugins/projectexplorer/compileoutputwindow.cpp index 91cc2fb22cc..d92bcc4bbe0 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.cpp +++ b/src/plugins/projectexplorer/compileoutputwindow.cpp @@ -177,6 +177,7 @@ CompileOutputWindow::CompileOutputWindow(QAction *cancelBuildAction) : connect(this, &IOutputPane::zoomIn, m_outputWindow, &Core::OutputWindow::zoomIn); connect(this, &IOutputPane::zoomOut, m_outputWindow, &Core::OutputWindow::zoomOut); + connect(this, &IOutputPane::resetZoom, m_outputWindow, &Core::OutputWindow::resetZoom); connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::fontSettingsChanged, this, updateFontSettings); connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::behaviorSettingsChanged, @@ -194,6 +195,7 @@ CompileOutputWindow::CompileOutputWindow(QAction *cancelBuildAction) : m_handler = new ShowOutputTaskHandler(this); ExtensionSystem::PluginManager::addObject(m_handler); + setupContext(C_COMPILE_OUTPUT, m_outputWindow); loadSettings(); updateFromSettings(); } diff --git a/src/plugins/vcsbase/vcsoutputwindow.cpp b/src/plugins/vcsbase/vcsoutputwindow.cpp index 4c559a9c742..76ffdf46ea5 100644 --- a/src/plugins/vcsbase/vcsoutputwindow.cpp +++ b/src/plugins/vcsbase/vcsoutputwindow.cpp @@ -302,9 +302,11 @@ VcsOutputWindow::VcsOutputWindow() updateFontSettings(); updateBehaviorSettings(); + setupContext(Internal::C_VCS_OUTPUT_PANE, &d->widget); connect(this, &IOutputPane::zoomIn, &d->widget, &Core::OutputWindow::zoomIn); connect(this, &IOutputPane::zoomOut, &d->widget, &Core::OutputWindow::zoomOut); + connect(this, &IOutputPane::resetZoom, &d->widget, &Core::OutputWindow::resetZoom); connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::fontSettingsChanged, this, updateFontSettings); connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::behaviorSettingsChanged,