From 71df641046f4d0b708ace17aa0f98846b2e89049 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 20 Jun 2014 15:02:34 +0200 Subject: [PATCH] TaskHandler: Add task handler that let's you jump into the configuration ... wire it up so that "No compiler found in kit" gets you to the kits page. Change-Id: Ie7b34d285a6d2eef81ccd5fdc86d91bcd0254515 Reviewed-by: Eike Ziller --- .../projectexplorer/configtaskhandler.cpp | 66 +++++++++++++++++++ .../projectexplorer/configtaskhandler.h | 61 +++++++++++++++++ .../projectexplorer/projectexplorer.cpp | 4 ++ .../projectexplorer/projectexplorer.pro | 2 + .../projectexplorer/projectexplorer.qbs | 1 + 5 files changed, 134 insertions(+) create mode 100644 src/plugins/projectexplorer/configtaskhandler.cpp create mode 100644 src/plugins/projectexplorer/configtaskhandler.h diff --git a/src/plugins/projectexplorer/configtaskhandler.cpp b/src/plugins/projectexplorer/configtaskhandler.cpp new file mode 100644 index 00000000000..30c7c58b60d --- /dev/null +++ b/src/plugins/projectexplorer/configtaskhandler.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "configtaskhandler.h" + +#include "task.h" +#include "taskhub.h" + +#include + +#include + +#include + +using namespace ProjectExplorer::Internal; + +ConfigTaskHandler::ConfigTaskHandler(const Task &pattern, Core::Id group, Core::Id page) : + m_pattern(pattern), + m_targetGroup(group), + m_targetPage(page) +{ } + +bool ConfigTaskHandler::canHandle(const ProjectExplorer::Task &task) const +{ + return task.description == m_pattern.description + && task.category == m_pattern.category; +} + +void ConfigTaskHandler::handle(const ProjectExplorer::Task &task) +{ + Q_UNUSED(task); + Core::ICore::showOptionsDialog(m_targetGroup, m_targetPage); +} + +QAction *ConfigTaskHandler::createAction(QObject *parent) const +{ + QAction *action = new QAction(Core::ICore::msgShowOptionsDialog(), parent); + action->setToolTip(Core::ICore::msgShowOptionsDialogToolTip()); + return action; +} diff --git a/src/plugins/projectexplorer/configtaskhandler.h b/src/plugins/projectexplorer/configtaskhandler.h new file mode 100644 index 00000000000..bed4fb837a5 --- /dev/null +++ b/src/plugins/projectexplorer/configtaskhandler.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef PROJECTEXPLORER_CONFIGTASKHANDLER_H +#define PROJECTEXPLORER_CONFIGTASKHANDLER_H + +#include "itaskhandler.h" + +#include "task.h" + +namespace ProjectExplorer { +namespace Internal { + +class ConfigTaskHandler : public ITaskHandler +{ + Q_OBJECT + +public: + ConfigTaskHandler(const Task &pattern, Core::Id group, Core::Id page); + + bool canHandle(const Task &task) const; + void handle(const Task &task); + QAction *createAction(QObject *parent) const; + +private: + const Task m_pattern; + + const Core::Id m_targetGroup; + const Core::Id m_targetPage; +}; + +} // namespace Internal +} // namespace ProjectExplorer + +#endif // PROJECTEXPLORER_CONFIGTASKHANDLER_H diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index a8d5222bbda..9c166eb1527 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -30,6 +30,7 @@ #include "projectexplorer.h" #include "buildsteplist.h" +#include "configtaskhandler.h" #include "customwizard/customwizard.h" #include "deployablefile.h" #include "deployconfiguration.h" @@ -418,6 +419,9 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er addAutoReleasedObject(new ShowInEditorTaskHandler); addAutoReleasedObject(new VcsAnnotateTaskHandler); addAutoReleasedObject(new RemoveTaskHandler); + addAutoReleasedObject(new ConfigTaskHandler(Task::compilerMissingTask(), + Constants::PROJECTEXPLORER_SETTINGS_CATEGORY, + Constants::KITS_SETTINGS_PAGE_ID)); addAutoReleasedObject(new CoreListener); d->m_outputPane = new AppOutputPane; diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index c9702aef035..c8c0b03c4ed 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -8,6 +8,7 @@ HEADERS += projectexplorer.h \ ansifilterparser.h \ buildinfo.h \ clangparser.h \ + configtaskhandler.h \ environmentaspect.h \ environmentaspectwidget.h \ gcctoolchain.h \ @@ -154,6 +155,7 @@ SOURCES += projectexplorer.cpp \ abiwidget.cpp \ ansifilterparser.cpp \ clangparser.cpp \ + configtaskhandler.cpp \ environmentaspect.cpp \ environmentaspectwidget.cpp \ gcctoolchain.cpp \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 2837bb3f586..ef21d10fb8b 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -49,6 +49,7 @@ QtcPlugin { "clangparser.cpp", "clangparser.h", "codestylesettingspropertiespage.cpp", "codestylesettingspropertiespage.h", "codestylesettingspropertiespage.ui", "compileoutputwindow.cpp", "compileoutputwindow.h", + "configtaskhandler.cpp", "configtaskhandler.h", "copytaskhandler.cpp", "copytaskhandler.h", "corelistenercheckingforrunningbuild.cpp", "corelistenercheckingforrunningbuild.h", "currentprojectfilter.cpp", "currentprojectfilter.h",