diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/autotest/autotestplugin.cpp | 27 | ||||
-rw-r--r-- | src/plugins/autotest/autotestplugin.h | 2 | ||||
-rw-r--r-- | src/plugins/autotest/testresultspane.cpp | 55 | ||||
-rw-r--r-- | src/plugins/autotest/testresultspane.h | 2 |
4 files changed, 25 insertions, 61 deletions
diff --git a/src/plugins/autotest/autotestplugin.cpp b/src/plugins/autotest/autotestplugin.cpp index 316667ddf3a..eb1079e4b53 100644 --- a/src/plugins/autotest/autotestplugin.cpp +++ b/src/plugins/autotest/autotestplugin.cpp @@ -25,6 +25,7 @@ #include "autotestplugin.h" #include "autotestconstants.h" +#include "autotesticons.h" #include "testcodeparser.h" #include "testframeworkmanager.h" #include "testrunner.h" @@ -42,12 +43,14 @@ #include <coreplugin/icore.h> #include <coreplugin/icontext.h> +#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/command.h> -#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/coreconstants.h> #include <extensionsystem/pluginmanager.h> #include <projectexplorer/buildmanager.h> +#include <projectexplorer/projectexplorer.h> +#include <utils/utilsicons.h> #include <QAction> #include <QMessageBox> @@ -98,18 +101,23 @@ void AutotestPlugin::initializeMenuEntries() menu->setOnAllDisabledBehavior(ActionContainer::Show); QAction *action = new QAction(tr("Run &All Tests"), this); + action->setIcon(Utils::Icons::RUN_SMALL_TOOLBAR.icon()); + action->setToolTip(tr("Run All Tests")); Command *command = ActionManager::registerAction(action, Constants::ACTION_RUN_ALL_ID); command->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+T,Alt+A"))); - connect(action, &QAction::triggered, - this, &AutotestPlugin::onRunAllTriggered); + connect(action, &QAction::triggered, this, &AutotestPlugin::onRunAllTriggered); action->setEnabled(false); menu->addAction(command); action = new QAction(tr("&Run Selected Tests"), this); + Utils::Icon runSelectedIcon = Utils::Icons::RUN_SMALL_TOOLBAR; + for (const Utils::IconMaskAndColor &maskAndColor : Icons::RUN_SELECTED_OVERLAY) + runSelectedIcon.append(maskAndColor); + action->setIcon(runSelectedIcon.icon()); + action->setToolTip(tr("Run Selected Tests")); command = ActionManager::registerAction(action, Constants::ACTION_RUN_SELECTED_ID); command->setDefaultKeySequence(QKeySequence(tr("Alt+Shift+T,Alt+R"))); - connect(action, &QAction::triggered, - this, &AutotestPlugin::onRunSelectedTriggered); + connect(action, &QAction::triggered, this, &AutotestPlugin::onRunSelectedTriggered); action->setEnabled(false); menu->addAction(command); @@ -128,6 +136,8 @@ void AutotestPlugin::initializeMenuEntries() this, &AutotestPlugin::updateMenuItemsEnabledState); connect(BuildManager::instance(), &BuildManager::buildQueueFinished, this, &AutotestPlugin::updateMenuItemsEnabledState); + connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions, + this, &AutotestPlugin::updateMenuItemsEnabledState); connect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged, this, &AutotestPlugin::updateMenuItemsEnabledState); } @@ -137,9 +147,8 @@ bool AutotestPlugin::initialize(const QStringList &arguments, QString *errorStri Q_UNUSED(arguments) Q_UNUSED(errorString) - initializeMenuEntries(); - m_frameworkManager = TestFrameworkManager::instance(); + initializeMenuEntries(); m_frameworkManager->registerTestFramework(new QtTestFramework); m_frameworkManager->registerTestFramework(new QuickTestFramework); m_frameworkManager->registerTestFramework(new GTestFramework); @@ -185,7 +194,9 @@ void AutotestPlugin::updateMenuItemsEnabledState() { const bool enabled = !ProjectExplorer::BuildManager::isBuilding() && !TestRunner::instance()->isTestRunning() - && TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle; + && TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle + && ProjectExplorer::ProjectExplorerPlugin::canRunStartupProject( + ProjectExplorer::Constants::NORMAL_RUN_MODE); const bool hasTests = TestTreeModel::instance()->hasTests(); ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()->setEnabled(enabled && hasTests); diff --git a/src/plugins/autotest/autotestplugin.h b/src/plugins/autotest/autotestplugin.h index 7c3f0712d48..f8769a2a12a 100644 --- a/src/plugins/autotest/autotestplugin.h +++ b/src/plugins/autotest/autotestplugin.h @@ -51,13 +51,13 @@ public: bool initialize(const QStringList &arguments, QString *errorString) override; void extensionsInitialized() override; ShutdownFlag aboutToShutdown() override; + void updateMenuItemsEnabledState(); private: bool checkLicense(); void initializeMenuEntries(); void onRunAllTriggered(); void onRunSelectedTriggered(); - void updateMenuItemsEnabledState(); QList<QObject *> createTestObjects() const override; const QSharedPointer<TestSettings> m_settings; TestFrameworkManager *m_frameworkManager = nullptr; diff --git a/src/plugins/autotest/testresultspane.cpp b/src/plugins/autotest/testresultspane.cpp index 6324770ca89..cbe0a61eadd 100644 --- a/src/plugins/autotest/testresultspane.cpp +++ b/src/plugins/autotest/testresultspane.cpp @@ -155,9 +155,6 @@ TestResultsPane::TestResultsPane(QObject *parent) : this, &TestResultsPane::onTestRunFinished); connect(TestRunner::instance(), &TestRunner::testResultReady, this, &TestResultsPane::addTestResult); - connect(ProjectExplorer::ProjectExplorerPlugin::instance(), - &ProjectExplorer::ProjectExplorerPlugin::updateRunActions, - this, &TestResultsPane::updateRunActions); } void TestResultsPane::createToolButtons() @@ -175,19 +172,10 @@ void TestResultsPane::createToolButtons() }); m_runAll = new QToolButton(m_treeView); - m_runAll->setIcon(Utils::Icons::RUN_SMALL_TOOLBAR.icon()); - m_runAll->setToolTip(tr("Run All Tests")); - m_runAll->setEnabled(false); - connect(m_runAll, &QToolButton::clicked, this, &TestResultsPane::onRunAllTriggered); + m_runAll->setDefaultAction(Core::ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()); m_runSelected = new QToolButton(m_treeView); - Utils::Icon runSelectedIcon = Utils::Icons::RUN_SMALL_TOOLBAR; - for (const Utils::IconMaskAndColor &maskAndColor : Icons::RUN_SELECTED_OVERLAY) - runSelectedIcon.append(maskAndColor); - m_runSelected->setIcon(runSelectedIcon.icon()); - m_runSelected->setToolTip(tr("Run Selected Tests")); - m_runSelected->setEnabled(false); - connect(m_runSelected, &QToolButton::clicked, this, &TestResultsPane::onRunSelectedTriggered); + m_runSelected->setDefaultAction(Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action()); m_stopTestRun = new QToolButton(m_treeView); m_stopTestRun->setIcon(Utils::Icons::STOP_SMALL_TOOLBAR.icon()); @@ -286,20 +274,8 @@ void TestResultsPane::clearContents() m_textOutput->clear(); } -void TestResultsPane::visibilityChanged(bool visible) +void TestResultsPane::visibilityChanged(bool /*visible*/) { - if (visible == m_wasVisibleBefore) - return; - if (visible) { - connect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged, - this, &TestResultsPane::updateRunActions); - // make sure run/run all are in correct state - updateRunActions(); - } else { - disconnect(TestTreeModel::instance(), &TestTreeModel::testTreeModelChanged, - this, &TestResultsPane::updateRunActions); - } - m_wasVisibleBefore = visible; } void TestResultsPane::setFocus() @@ -514,10 +490,7 @@ void TestResultsPane::onTestRunStarted() { m_testRunning = true; m_stopTestRun->setEnabled(true); - m_runAll->setEnabled(false); - Core::ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()->setEnabled(false); - m_runSelected->setEnabled(false); - Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action()->setEnabled(false); + AutotestPlugin::instance()->updateMenuItemsEnabledState(); m_summaryWidget->setVisible(false); } @@ -526,13 +499,7 @@ void TestResultsPane::onTestRunFinished() m_testRunning = false; m_stopTestRun->setEnabled(false); - const bool runEnabled = !ProjectExplorer::BuildManager::isBuilding() - && TestTreeModel::instance()->hasTests() - && TestTreeModel::instance()->parser()->state() == TestCodeParser::Idle; - m_runAll->setEnabled(runEnabled); // TODO unify Run* actions - Core::ActionManager::command(Constants::ACTION_RUN_ALL_ID)->action()->setEnabled(runEnabled); - m_runSelected->setEnabled(runEnabled); - Core::ActionManager::command(Constants::ACTION_RUN_SELECTED_ID)->action()->setEnabled(runEnabled); + AutotestPlugin::instance()->updateMenuItemsEnabledState(); updateSummaryLabel(); m_summaryWidget->setVisible(true); m_model->removeCurrentTestMessage(); @@ -548,18 +515,6 @@ void TestResultsPane::onScrollBarRangeChanged(int, int max) m_treeView->verticalScrollBar()->setValue(max); } -void TestResultsPane::updateRunActions() -{ - QString whyNot; - TestTreeModel *model = TestTreeModel::instance(); - const bool enable = !m_testRunning && !model->parser()->isParsing() && model->hasTests() - && !ProjectExplorer::BuildManager::isBuilding() - && ProjectExplorer::ProjectExplorerPlugin::canRunStartupProject( - ProjectExplorer::Constants::NORMAL_RUN_MODE, &whyNot); - m_runAll->setEnabled(enable); - m_runSelected->setEnabled(enable); -} - void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos) { const bool resultsAvailable = m_filterModel->hasResults(); diff --git a/src/plugins/autotest/testresultspane.h b/src/plugins/autotest/testresultspane.h index 911396b1939..12a3720091c 100644 --- a/src/plugins/autotest/testresultspane.h +++ b/src/plugins/autotest/testresultspane.h @@ -108,7 +108,6 @@ private: void onTestRunStarted(); void onTestRunFinished(); void onScrollBarRangeChanged(int, int max); - void updateRunActions(); void onCustomContextMenuRequested(const QPoint &pos); const TestResult *getTestResult(const QModelIndex &idx); void onCopyItemTriggered(const TestResult *result); @@ -133,7 +132,6 @@ private: QToolButton *m_outputToggleButton; QPlainTextEdit *m_textOutput; QMenu *m_filterMenu; - bool m_wasVisibleBefore = false; bool m_autoScroll = false; bool m_atEnd = false; bool m_testRunning = false; |