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:
Christian Stenger
2022-12-05 22:04:57 +01:00
parent c7b60e7d6b
commit 511dc801b5
6 changed files with 62 additions and 50 deletions

View File

@@ -1,12 +1,11 @@
// Copyright (C) 2022 The Qt Company Ltd
// 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>
namespace Squish {
namespace Constants {
namespace Squish::Constants {
const char SQUISH_ID[] = "SquishPlugin.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 OBJECTSMAP_EDITOR_ID[] = "Squish.ObjectsMapEditor";
} // namespace Constants
} // namespace Squish
} // namespace Squish::Constants
#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

View File

@@ -238,9 +238,15 @@ void SquishPerspective::initPerspective()
addWindow(mainWidget, Perspective::AddToTab, nullptr, true, Qt::RightDockWidgetArea);
connect(m_pausePlayAction, &QAction::triggered, this, &SquishPerspective::onPausePlayTriggered);
connect(m_stepInAction, &QAction::triggered, this, [this] { emit runRequested(StepIn); });
connect(m_stepOverAction, &QAction::triggered, this, [this] { emit runRequested(StepOver); });
connect(m_stepOutAction, &QAction::triggered, this, [this] { emit runRequested(StepOut); });
connect(m_stepInAction, &QAction::triggered, this, [this] {
emit runRequested(StepMode::StepIn);
});
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_stopRecordAction, &QAction::triggered,
this, &SquishPerspective::onStopRecordTriggered);
@@ -279,7 +285,7 @@ void SquishPerspective::onStopRecordTriggered()
void SquishPerspective::onPausePlayTriggered()
{
if (m_mode == Interrupted)
emit runRequested(Continue);
emit runRequested(StepMode::Continue);
else if (m_mode == Running)
emit interruptRequested();
else

View File

@@ -3,6 +3,8 @@
#pragma once
#include "squishconstants.h"
#include <debugger/debuggermainwindow.h>
#include <utils/treemodel.h>
@@ -29,7 +31,6 @@ class SquishPerspective : public Utils::Perspective
Q_OBJECT
public:
enum PerspectiveMode { NoMode, Interrupted, Running, Recording, Querying };
enum StepMode { Continue, StepIn, StepOver, StepOut };
SquishPerspective();
void initPerspective();
@@ -45,7 +46,7 @@ signals:
void stopRequested();
void stopRecordRequested();
void interruptRequested();
void runRequested(SquishPerspective::StepMode mode);
void runRequested(StepMode mode);
private:
void onStopTriggered();

View File

@@ -3,14 +3,14 @@
#pragma once
#include "squishconstants.h"
#include <utils/qtcprocess.h>
#include <QObject>
namespace Squish::Internal {
enum SquishProcessState { Idle, Starting, Started, StartFailed, Stopped, StopFailed };
class SquishProcessBase : public QObject
{
Q_OBJECT

View File

@@ -43,20 +43,20 @@ using namespace Utils;
namespace Squish {
namespace Internal {
static QString runnerStateName(SquishTools::RunnerState state)
static QString runnerStateName(RunnerState state)
{
switch (state) {
case SquishTools::RunnerState::None: return "None";
case SquishTools::RunnerState::Starting: return "Starting";
case SquishTools::RunnerState::Running: return "Running";
case SquishTools::RunnerState::RunRequested: return "RunRequested";
case SquishTools::RunnerState::Interrupted: return "Interrupted";
case SquishTools::RunnerState::InterruptRequested: return "InterruptedRequested";
case SquishTools::RunnerState::Canceling: return "Canceling";
case SquishTools::RunnerState::Canceled: return "Canceled";
case SquishTools::RunnerState::CancelRequested: return "CancelRequested";
case SquishTools::RunnerState::CancelRequestedWhileInterrupted: return "CancelRequestedWhileInterrupted";
case SquishTools::RunnerState::Finished: return "Finished";
case RunnerState::None: return "None";
case RunnerState::Starting: return "Starting";
case RunnerState::Running: return "Running";
case RunnerState::RunRequested: return "RunRequested";
case RunnerState::Interrupted: return "Interrupted";
case RunnerState::InterruptRequested: return "InterruptedRequested";
case RunnerState::Canceling: return "Canceling";
case RunnerState::Canceled: return "Canceled";
case RunnerState::CancelRequested: return "CancelRequested";
case RunnerState::CancelRequestedWhileInterrupted: return "CancelRequestedWhileInterrupted";
case RunnerState::Finished: return "Finished";
}
return "ThouShallNotBeHere";
}
@@ -78,7 +78,7 @@ static QString toolsStateName(SquishTools::State state)
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);
}
@@ -995,7 +995,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
switch (m_squishRunnerState) {
case RunnerState::Starting:
setupAndStartRecorder();
onRunnerRunRequested(SquishPerspective::Continue);
onRunnerRunRequested(StepMode::Continue);
break;
case RunnerState::CancelRequested:
case RunnerState::CancelRequestedWhileInterrupted:
@@ -1016,7 +1016,7 @@ void SquishTools::handlePrompt(const QString &fileName, int line, int column)
case RunnerState::Starting: {
const Utils::Links setBPs = setBreakpoints();
if (!setBPs.contains({Utils::FilePath::fromString(fileName), line})) {
onRunnerRunRequested(SquishPerspective::Continue);
onRunnerRunRequested(StepMode::Continue);
} else {
m_perspective.setPerspectiveMode(SquishPerspective::Interrupted);
logRunnerStateChange(m_squishRunnerState, RunnerState::Interrupted);
@@ -1180,7 +1180,7 @@ void SquishTools::clearLocationMarker()
m_locationMarker = nullptr;
}
void SquishTools::onRunnerRunRequested(SquishPerspective::StepMode step)
void SquishTools::onRunnerRunRequested(StepMode step)
{
if (m_requestVarsTimer) {
delete m_requestVarsTimer;
@@ -1189,13 +1189,13 @@ void SquishTools::onRunnerRunRequested(SquishPerspective::StepMode step)
logRunnerStateChange(m_squishRunnerState, RunnerState::RunRequested);
m_squishRunnerState = RunnerState::RunRequested;
if (step == SquishPerspective::Continue)
if (step == StepMode::Continue)
m_runnerProcess.write("continue\n");
else if (step == SquishPerspective::StepIn)
else if (step == StepMode::StepIn)
m_runnerProcess.write("step\n");
else if (step == SquishPerspective::StepOver)
else if (step == StepMode::StepOver)
m_runnerProcess.write("next\n");
else if (step == SquishPerspective::StepOut)
else if (step == StepMode::StepOut)
m_runnerProcess.write("return\n");
clearLocationMarker();

View File

@@ -48,20 +48,6 @@ public:
RunnerStopped
};
enum class RunnerState {
None,
Starting,
Running,
RunRequested,
Interrupted,
InterruptRequested,
Canceling,
Canceled,
CancelRequested,
CancelRequestedWhileInterrupted,
Finished
};
using QueryCallback = std::function<void(const QString &, const QString &)>;
State state() const { return m_state; }
@@ -129,7 +115,7 @@ private:
void restoreQtCreatorWindows();
void updateLocationMarker(const Utils::FilePath &file, int line);
void clearLocationMarker();
void onRunnerRunRequested(SquishPerspective::StepMode step);
void onRunnerRunRequested(StepMode step);
void interruptRunner();
void terminateRunner();
bool isValidToStartRunner();