2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2010-06-30 16:39:32 +02:00
|
|
|
|
|
|
|
|
#include "showoutputtaskhandler.h"
|
|
|
|
|
|
|
|
|
|
#include "task.h"
|
|
|
|
|
|
2021-11-25 12:31:14 +01:00
|
|
|
#include <coreplugin/ioutputpane.h>
|
|
|
|
|
#include <coreplugin/outputwindow.h>
|
|
|
|
|
#include <utils/algorithm.h>
|
2022-02-09 18:00:59 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2010-06-30 16:39:32 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
2010-06-30 16:39:32 +02:00
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
namespace Internal {
|
2010-06-30 16:39:32 +02:00
|
|
|
|
2022-02-09 18:00:59 +01:00
|
|
|
ShowOutputTaskHandler::ShowOutputTaskHandler(Core::IOutputPane *window, const QString &text,
|
|
|
|
|
const QString &tooltip, const QString &shortcut)
|
|
|
|
|
: m_window(window), m_text(text), m_tooltip(tooltip), m_shortcut(shortcut)
|
2010-06-30 16:39:32 +02:00
|
|
|
{
|
2022-02-09 18:00:59 +01:00
|
|
|
QTC_CHECK(m_window);
|
|
|
|
|
QTC_CHECK(!m_text.isEmpty());
|
2010-06-30 16:39:32 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
bool ShowOutputTaskHandler::canHandle(const Task &task) const
|
2010-06-30 16:39:32 +02:00
|
|
|
{
|
2021-11-25 12:31:14 +01:00
|
|
|
return Utils::anyOf(m_window->outputWindows(), [task](const Core::OutputWindow *ow) {
|
|
|
|
|
return ow->knowsPositionOf(task.taskId);
|
|
|
|
|
});
|
2010-06-30 16:39:32 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void ShowOutputTaskHandler::handle(const Task &task)
|
2010-06-30 16:39:32 +02:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(canHandle(task));
|
2012-09-13 15:50:06 +02:00
|
|
|
// popup first as this does move the visible area!
|
|
|
|
|
m_window->popup(Core::IOutputPane::Flags(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus));
|
2021-11-25 12:31:14 +01:00
|
|
|
for (Core::OutputWindow * const ow : m_window->outputWindows()) {
|
|
|
|
|
if (ow->knowsPositionOf(task.taskId)) {
|
2021-11-25 13:57:38 +01:00
|
|
|
m_window->ensureWindowVisible(ow);
|
2021-11-25 12:31:14 +01:00
|
|
|
ow->showPositionOf(task.taskId);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-06-30 16:39:32 +02:00
|
|
|
}
|
|
|
|
|
|
2012-05-04 20:10:01 +02:00
|
|
|
QAction *ShowOutputTaskHandler::createAction(QObject *parent) const
|
2010-06-30 16:39:32 +02:00
|
|
|
{
|
2022-02-09 18:00:59 +01:00
|
|
|
QAction * const outputAction = new QAction(m_text, parent);
|
|
|
|
|
if (!m_tooltip.isEmpty())
|
|
|
|
|
outputAction->setToolTip(m_tooltip);
|
|
|
|
|
if (!m_shortcut.isEmpty())
|
|
|
|
|
outputAction->setShortcut(QKeySequence(m_shortcut));
|
2012-10-05 14:37:05 +02:00
|
|
|
outputAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
2010-06-30 16:39:32 +02:00
|
|
|
return outputAction;
|
|
|
|
|
}
|
2014-10-13 22:37:28 +03:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ProjectExplorer
|