1
0
Fork 0

temporary

This commit is contained in:
torusrxxx 2016-08-20 20:18:16 +08:00
parent 5a04cc70f3
commit 1c6c1583d2
2 changed files with 35 additions and 9 deletions

View File

@ -33,7 +33,6 @@ void ThreadView::contextMenuSlot(const QPoint & pos)
wMenu.addMenu(&wCopyMenu);
}
foreach(QAction * action, mSetPriority->actions())
{
action->setCheckable(true);
@ -135,21 +134,18 @@ void ThreadView::SetPriorityTimeCriticalSlot()
void ThreadView::setupContextMenu()
{
mMenuBuilder = new MenuBuilder(this);
//Switch thread menu
mSwitchThread = new QAction(tr("Switch Thread"), this);
connect(mSwitchThread, SIGNAL(triggered()), this, SLOT(SwitchThread()));
mMenuBuilder->addAction(makeAction(tr("Switch Thread"), SLOT(SwitchThread())));
//Suspend thread menu
mSuspendThread = new QAction(tr("Suspend Thread"), this);
connect(mSuspendThread, SIGNAL(triggered()), this, SLOT(SuspendThread()));
mMenuBuilder->addAction(makeAction(tr("Suspend Thread"), SLOT(SuspendThread())));
//Resume thread menu
mResumeThread = new QAction(tr("Resume Thread"), this);
connect(mResumeThread, SIGNAL(triggered()), this, SLOT(ResumeThread()));
mMenuBuilder->addAction(makeAction(tr("Resume Thread"), SLOT(ResumeThread())));
//Kill thread menu
mKillThread = new QAction(tr("Kill Thread"), this);
connect(mKillThread, SIGNAL(triggered()), this, SLOT(KillThread()));
mMenuBuilder->addAction(makeAction(tr("Kill Thread"), SLOT(KillThread())));
// Set priority
mSetPriority = new QMenu(tr("Set Priority"), this);
@ -191,6 +187,33 @@ void ThreadView::setupContextMenu()
connect(mSetName, SIGNAL(triggered()), this, SLOT(SetNameSlot()));
}
/**
* @brief ThreadView::makeCommandAction Make action to execute the command. $ will be replaced with thread id at runtime.
* @param action The action to bind
* @param command The command to execute when the action is triggered.
* @return action
*/
QAction* ThreadView::makeCommandAction(QAction* action, const QString & command)
{
action->setData(QVariant(command));
connect(action, SIGNAL(triggered()), this, SLOT(execCommandSlot()));
return action;
}
/**
* @brief ThreadView::ExecCommand execute command slot for menus. Only used by command that reference thread id.
*/
void ThreadView::ExecCommand()
{
QAction* action = qobject_cast<QAction*>(sender());
if(action)
{
QString command = action->data().toString();
command.replace(QChar('$'), getCellContent(getInitialSelection(), 1)); // $ -> Thread Id
DbgCmdExec(command.toUtf8().constData());
}
}
ThreadView::ThreadView(StdTable* parent) : StdTable(parent)
{
int charwidth = getCharWidth();

View File

@ -18,6 +18,7 @@ public slots:
void SwitchThread();
void SuspendThread();
void ResumeThread();
void ExecCommand();
void KillThread();
void GoToThreadEntry();
void contextMenuSlot(const QPoint & pos);
@ -34,7 +35,9 @@ signals:
void showCpu();
private:
QAction* makeCommandAction(QAction* action, const QString & command);
QString mCurrentThreadId;
MenuBuilder* mMenuBuilder;
QAction* mSwitchThread;
QAction* mSuspendThread;
QAction* mGoToThreadEntry;