forked from qt-creator/qt-creator
Squish: Move some enums to a more central place
Change-Id: I86d57675fb92b650f3d3ab52c990b4b87f1790d5 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
// Copyright (C) 2022 The Qt Company Ltd
|
// Copyright (C) 2022 The Qt Company Ltd
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
#ifndef SQUISHCONSTANTS_H
|
|
||||||
#define SQUISHCONSTANTS_H
|
#pragma once
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
namespace Squish {
|
namespace Squish::Constants {
|
||||||
namespace Constants {
|
|
||||||
|
|
||||||
const char SQUISH_ID[] = "SquishPlugin.Squish";
|
const char SQUISH_ID[] = "SquishPlugin.Squish";
|
||||||
const char SQUISH_CONTEXT[] = "Squish";
|
const char SQUISH_CONTEXT[] = "Squish";
|
||||||
@@ -16,7 +15,27 @@ const char SQUISH_SETTINGS_CATEGORY[] = "ZYY.Squish";
|
|||||||
const char SQUISH_OBJECTSMAP_MIMETYPE[] = "text/squish-objectsmap";
|
const char SQUISH_OBJECTSMAP_MIMETYPE[] = "text/squish-objectsmap";
|
||||||
const char OBJECTSMAP_EDITOR_ID[] = "Squish.ObjectsMapEditor";
|
const char OBJECTSMAP_EDITOR_ID[] = "Squish.ObjectsMapEditor";
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Squish::Constants
|
||||||
} // namespace Squish
|
|
||||||
|
|
||||||
#endif // SQUISHCONSTANTS_H
|
namespace Squish::Internal {
|
||||||
|
|
||||||
|
// SquishProcess related enums
|
||||||
|
enum SquishProcessState { Idle, Starting, Started, StartFailed, Stopped, StopFailed };
|
||||||
|
|
||||||
|
enum class RunnerState {
|
||||||
|
None,
|
||||||
|
Starting,
|
||||||
|
Running,
|
||||||
|
RunRequested,
|
||||||
|
Interrupted,
|
||||||
|
InterruptRequested,
|
||||||
|
Canceling,
|
||||||
|
Canceled,
|
||||||
|
CancelRequested,
|
||||||
|
CancelRequestedWhileInterrupted,
|
||||||
|
Finished
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class StepMode { Continue, StepIn, StepOver, StepOut };
|
||||||
|
|
||||||
|
} // namespace Squish::Internal
|
||||||
|
@@ -238,9 +238,15 @@ void SquishPerspective::initPerspective()
|
|||||||
addWindow(mainWidget, Perspective::AddToTab, nullptr, true, Qt::RightDockWidgetArea);
|
addWindow(mainWidget, Perspective::AddToTab, nullptr, true, Qt::RightDockWidgetArea);
|
||||||
|
|
||||||
connect(m_pausePlayAction, &QAction::triggered, this, &SquishPerspective::onPausePlayTriggered);
|
connect(m_pausePlayAction, &QAction::triggered, this, &SquishPerspective::onPausePlayTriggered);
|
||||||
connect(m_stepInAction, &QAction::triggered, this, [this] { emit runRequested(StepIn); });
|
connect(m_stepInAction, &QAction::triggered, this, [this] {
|
||||||
connect(m_stepOverAction, &QAction::triggered, this, [this] { emit runRequested(StepOver); });
|
emit runRequested(StepMode::StepIn);
|
||||||
connect(m_stepOutAction, &QAction::triggered, this, [this] { emit runRequested(StepOut); });
|
});
|
||||||
|
connect(m_stepOverAction, &QAction::triggered, this, [this] {
|
||||||
|
emit runRequested(StepMode::StepOver);
|
||||||
|
});
|
||||||
|
connect(m_stepOutAction, &QAction::triggered, this, [this] {
|
||||||
|
emit runRequested(StepMode::StepOut);
|
||||||
|
});
|
||||||
connect(m_stopAction, &QAction::triggered, this, &SquishPerspective::onStopTriggered);
|
connect(m_stopAction, &QAction::triggered, this, &SquishPerspective::onStopTriggered);
|
||||||
connect(m_stopRecordAction, &QAction::triggered,
|
connect(m_stopRecordAction, &QAction::triggered,
|
||||||
this, &SquishPerspective::onStopRecordTriggered);
|
this, &SquishPerspective::onStopRecordTriggered);
|
||||||
@@ -279,7 +285,7 @@ void SquishPerspective::onStopRecordTriggered()
|
|||||||
void SquishPerspective::onPausePlayTriggered()
|
void SquishPerspective::onPausePlayTriggered()
|
||||||
{
|
{
|
||||||
if (m_mode == Interrupted)
|
if (m_mode == Interrupted)
|
||||||
emit runRequested(Continue);
|
emit runRequested(StepMode::Continue);
|
||||||
else if (m_mode == Running)
|
else if (m_mode == Running)
|
||||||
emit interruptRequested();
|
emit interruptRequested();
|
||||||
else
|
else
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "squishconstants.h"
|
||||||
|
|
||||||
#include <debugger/debuggermainwindow.h>
|
#include <debugger/debuggermainwindow.h>
|
||||||
|
|
||||||
#include <utils/treemodel.h>
|
#include <utils/treemodel.h>
|
||||||
@@ -29,7 +31,6 @@ class SquishPerspective : public Utils::Perspective
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum PerspectiveMode { NoMode, Interrupted, Running, Recording, Querying };
|
enum PerspectiveMode { NoMode, Interrupted, Running, Recording, Querying };
|
||||||
enum StepMode { Continue, StepIn, StepOver, StepOut };
|
|
||||||
|
|
||||||
SquishPerspective();
|
SquishPerspective();
|
||||||
void initPerspective();
|
void initPerspective();
|
||||||
@@ -45,7 +46,7 @@ signals:
|
|||||||
void stopRequested();
|
void stopRequested();
|
||||||
void stopRecordRequested();
|
void stopRecordRequested();
|
||||||
void interruptRequested();
|
void interruptRequested();
|
||||||
void runRequested(SquishPerspective::StepMode mode);
|
void runRequested(StepMode mode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onStopTriggered();
|
void onStopTriggered();
|
||||||
|
@@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "squishconstants.h"
|
||||||
|
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace Squish::Internal {
|
namespace Squish::Internal {
|
||||||
|
|
||||||
enum SquishProcessState { Idle, Starting, Started, StartFailed, Stopped, StopFailed };
|
|
||||||
|
|
||||||
class SquishProcessBase : public QObject
|
class SquishProcessBase : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@@ -43,20 +43,20 @@ using namespace Utils;
|
|||||||
namespace Squish {
|
namespace Squish {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static QString runnerStateName(SquishTools::RunnerState state)
|
static QString runnerStateName(RunnerState state)
|
||||||
{
|
{
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SquishTools::RunnerState::None: return "None";
|
case RunnerState::None: return "None";
|
||||||
case SquishTools::RunnerState::Starting: return "Starting";
|
case RunnerState::Starting: return "Starting";
|
||||||
case SquishTools::RunnerState::Running: return "Running";
|
case RunnerState::Running: return "Running";
|
||||||
case SquishTools::RunnerState::RunRequested: return "RunRequested";
|
case RunnerState::RunRequested: return "RunRequested";
|
||||||
case SquishTools::RunnerState::Interrupted: return "Interrupted";
|
case RunnerState::Interrupted: return "Interrupted";
|
||||||
case SquishTools::RunnerState::InterruptRequested: return "InterruptedRequested";
|
case RunnerState::InterruptRequested: return "InterruptedRequested";
|
||||||
case SquishTools::RunnerState::Canceling: return "Canceling";
|
case RunnerState::Canceling: return "Canceling";
|
||||||
case SquishTools::RunnerState::Canceled: return "Canceled";
|
case RunnerState::Canceled: return "Canceled";
|
||||||
case SquishTools::RunnerState::CancelRequested: return "CancelRequested";
|
case RunnerState::CancelRequested: return "CancelRequested";
|
||||||
case SquishTools::RunnerState::CancelRequestedWhileInterrupted: return "CancelRequestedWhileInterrupted";
|
case RunnerState::CancelRequestedWhileInterrupted: return "CancelRequestedWhileInterrupted";
|
||||||
case SquishTools::RunnerState::Finished: return "Finished";
|
case RunnerState::Finished: return "Finished";
|
||||||
}
|
}
|
||||||
return "ThouShallNotBeHere";
|
return "ThouShallNotBeHere";
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ static QString toolsStateName(SquishTools::State state)
|
|||||||
return "UnexpectedState";
|
return "UnexpectedState";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void logRunnerStateChange(SquishTools::RunnerState from, SquishTools::RunnerState to)
|
static void logRunnerStateChange(RunnerState from, RunnerState to)
|
||||||
{
|
{
|
||||||
qCInfo(LOG) << "Runner state change:" << runnerStateName(from) << ">" << runnerStateName(to);
|
qCInfo(LOG) << "Runner state change:" << runnerStateName(from) << ">" << runnerStateName(to);
|
||||||
}
|
}
|
||||||
@@ -995,7 +995,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
|||||||
switch (m_squishRunnerState) {
|
switch (m_squishRunnerState) {
|
||||||
case RunnerState::Starting:
|
case RunnerState::Starting:
|
||||||
setupAndStartRecorder();
|
setupAndStartRecorder();
|
||||||
onRunnerRunRequested(SquishPerspective::Continue);
|
onRunnerRunRequested(StepMode::Continue);
|
||||||
break;
|
break;
|
||||||
case RunnerState::CancelRequested:
|
case RunnerState::CancelRequested:
|
||||||
case RunnerState::CancelRequestedWhileInterrupted:
|
case RunnerState::CancelRequestedWhileInterrupted:
|
||||||
@@ -1016,7 +1016,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
|
|||||||
case RunnerState::Starting: {
|
case RunnerState::Starting: {
|
||||||
const Utils::Links setBPs = setBreakpoints();
|
const Utils::Links setBPs = setBreakpoints();
|
||||||
if (!setBPs.contains({Utils::FilePath::fromString(fileName), line})) {
|
if (!setBPs.contains({Utils::FilePath::fromString(fileName), line})) {
|
||||||
onRunnerRunRequested(SquishPerspective::Continue);
|
onRunnerRunRequested(StepMode::Continue);
|
||||||
} else {
|
} else {
|
||||||
m_perspective.setPerspectiveMode(SquishPerspective::Interrupted);
|
m_perspective.setPerspectiveMode(SquishPerspective::Interrupted);
|
||||||
logRunnerStateChange(m_squishRunnerState, RunnerState::Interrupted);
|
logRunnerStateChange(m_squishRunnerState, RunnerState::Interrupted);
|
||||||
@@ -1180,7 +1180,7 @@ void SquishTools::clearLocationMarker()
|
|||||||
m_locationMarker = nullptr;
|
m_locationMarker = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SquishTools::onRunnerRunRequested(SquishPerspective::StepMode step)
|
void SquishTools::onRunnerRunRequested(StepMode step)
|
||||||
{
|
{
|
||||||
if (m_requestVarsTimer) {
|
if (m_requestVarsTimer) {
|
||||||
delete m_requestVarsTimer;
|
delete m_requestVarsTimer;
|
||||||
@@ -1189,13 +1189,13 @@ void SquishTools::onRunnerRunRequested(SquishPerspective::StepMode step)
|
|||||||
logRunnerStateChange(m_squishRunnerState, RunnerState::RunRequested);
|
logRunnerStateChange(m_squishRunnerState, RunnerState::RunRequested);
|
||||||
m_squishRunnerState = RunnerState::RunRequested;
|
m_squishRunnerState = RunnerState::RunRequested;
|
||||||
|
|
||||||
if (step == SquishPerspective::Continue)
|
if (step == StepMode::Continue)
|
||||||
m_runnerProcess.write("continue\n");
|
m_runnerProcess.write("continue\n");
|
||||||
else if (step == SquishPerspective::StepIn)
|
else if (step == StepMode::StepIn)
|
||||||
m_runnerProcess.write("step\n");
|
m_runnerProcess.write("step\n");
|
||||||
else if (step == SquishPerspective::StepOver)
|
else if (step == StepMode::StepOver)
|
||||||
m_runnerProcess.write("next\n");
|
m_runnerProcess.write("next\n");
|
||||||
else if (step == SquishPerspective::StepOut)
|
else if (step == StepMode::StepOut)
|
||||||
m_runnerProcess.write("return\n");
|
m_runnerProcess.write("return\n");
|
||||||
|
|
||||||
clearLocationMarker();
|
clearLocationMarker();
|
||||||
|
@@ -48,20 +48,6 @@ public:
|
|||||||
RunnerStopped
|
RunnerStopped
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class RunnerState {
|
|
||||||
None,
|
|
||||||
Starting,
|
|
||||||
Running,
|
|
||||||
RunRequested,
|
|
||||||
Interrupted,
|
|
||||||
InterruptRequested,
|
|
||||||
Canceling,
|
|
||||||
Canceled,
|
|
||||||
CancelRequested,
|
|
||||||
CancelRequestedWhileInterrupted,
|
|
||||||
Finished
|
|
||||||
};
|
|
||||||
|
|
||||||
using QueryCallback = std::function<void(const QString &, const QString &)>;
|
using QueryCallback = std::function<void(const QString &, const QString &)>;
|
||||||
|
|
||||||
State state() const { return m_state; }
|
State state() const { return m_state; }
|
||||||
@@ -129,7 +115,7 @@ private:
|
|||||||
void restoreQtCreatorWindows();
|
void restoreQtCreatorWindows();
|
||||||
void updateLocationMarker(const Utils::FilePath &file, int line);
|
void updateLocationMarker(const Utils::FilePath &file, int line);
|
||||||
void clearLocationMarker();
|
void clearLocationMarker();
|
||||||
void onRunnerRunRequested(SquishPerspective::StepMode step);
|
void onRunnerRunRequested(StepMode step);
|
||||||
void interruptRunner();
|
void interruptRunner();
|
||||||
void terminateRunner();
|
void terminateRunner();
|
||||||
bool isValidToStartRunner();
|
bool isValidToStartRunner();
|
||||||
|
Reference in New Issue
Block a user