| 106 | } |
| 107 | |
| 108 | void Runner::handleEvents(const dpf::Event &event) |
| 109 | { |
| 110 | QString topic = event.topic(); |
| 111 | QString data = event.data().toString(); |
| 112 | if (topic == T_BUILDER) { |
| 113 | if (data == D_BUILD_STATE) { |
| 114 | int state = event.property(P_STATE).toInt(); |
| 115 | BuildCommandInfo commandInfo = qvariant_cast<BuildCommandInfo>(event.property(P_ORIGINCMD)); |
| 116 | if (commandInfo.uuid == d->currentBuildUuid) { |
| 117 | int buildSuccess = 0; |
| 118 | if (state == buildSuccess) { |
| 119 | running(); |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | } else if (event.data() == editor.switchedFile.name) { |
| 124 | QString filePath = event.property(editor.switchedFile.pKeys[0]).toString(); |
| 125 | if (d->currentOpenedFilePath != filePath) { |
| 126 | d->currentOpenedFilePath = filePath; |
| 127 | } |
| 128 | } else if (event.data() == editor.fileOpened.name) { |
| 129 | QString filePath = event.property(editor.switchedFile.pKeys[0]).toString(); |
| 130 | d->currentOpenedFilePath = filePath; |
| 131 | } else if (event.data() == editor.fileClosed.name) { |
| 132 | QString filePath = event.property(editor.switchedFile.pKeys[0]).toString(); |
| 133 | if (d->currentOpenedFilePath == filePath) { |
| 134 | d->currentOpenedFilePath.clear(); |
| 135 | } |
| 136 | } else if (event.data() == project.activatedProject.name) { |
| 137 | QVariant proInfoVar = event.property("projectInfo"); |
| 138 | dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar); |
| 139 | auto programs = projectInfo.exePrograms(); |
| 140 | d->runProgram->clear(); |
| 141 | for (auto program : programs) |
| 142 | d->runProgram->addItem(QIcon::fromTheme("executable"), program); |
| 143 | d->runProgram->setCurrentText(projectInfo.currentProgram()); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | void Runner::running() |
| 148 | { |