1 #include "pirmacrocommanditem.h"
3 #include "mainwindow.h"
4 #include "pirkeynames.h"
8 PIRKeynameMgr keynameMgr;
11 PIRMacroCommandItem::PIRMacroCommandItem(
13 : QListWidgetItem(displayName)
18 PIRKeyCommandItem::PIRKeyCommandItem(
19 PIRKeyName keyToExecute,
21 : PIRMacroCommandItem(keynameMgr.getKeynameString(keyToExecute)),
29 void PIRKeyCommandItem::executeCommand()
31 // First, make sure no other macro is running:
32 if (advanceTimer) delete advanceTimer;
35 advanceTimer = new QTimer();
36 connect(advanceTimer, SIGNAL(timeout()), this, SLOT(startRunningCommand()));
37 advanceTimer->start(50);
41 void PIRKeyCommandItem::startRunningCommand()
43 // Try to start running the command:
44 if (mainWindow->startRepeating(key))
46 // The command has successfully started, now wait for it to stop:
47 if (advanceTimer) delete advanceTimer;
48 advanceTimer = new QTimer();
49 connect(advanceTimer, SIGNAL(timeout()), this, SLOT(stopRunningCommand()));
50 advanceTimer->start(50);
55 void PIRKeyCommandItem::stopRunningCommand()
57 mainWindow->stopRepeating();
59 if (advanceTimer) delete advanceTimer;
62 emit commandCompleted();
66 PIRKeysetCommandItem::PIRKeysetCommandItem(
68 unsigned int keysetToChoose,
70 : PIRMacroCommandItem(displayName),
77 void PIRKeysetCommandItem::executeCommand()
79 mainWindow->updateKeysetSelection(id);
80 emit commandCompleted();
84 PIRPauseCommandItem::PIRPauseCommandItem(
86 unsigned int timeToWait)
87 : PIRMacroCommandItem(displayName),
88 timeInSeconds(timeToWait),
94 void PIRPauseCommandItem::executeCommand()
96 if (advanceTimer) delete advanceTimer;
98 advanceTimer = new QTimer();
99 connect(advanceTimer, SIGNAL(timeout()), this, SLOT(finishedWaiting()));
100 advanceTimer->start(timeInSeconds * 1000);
104 void PIRPauseCommandItem::finishedWaiting()
112 emit commandCompleted();