| 804 | } |
| 805 | |
| 806 | void DialogAgent::onBuildMessage(const QString &msg) |
| 807 | { |
| 808 | if (msg.isEmpty()) |
| 809 | return; |
| 810 | |
| 811 | QJsonParseError parseError; |
| 812 | QJsonDocument doc = QJsonDocument::fromJson(msg.toUtf8(), &parseError); |
| 813 | |
| 814 | if (parseError.error != QJsonParseError::NoError || !doc.isObject()) { |
| 815 | buildLogOutput->append(msg.toHtmlEscaped()); |
| 816 | return; |
| 817 | } |
| 818 | |
| 819 | QJsonObject obj = doc.object(); |
| 820 | int status = obj.value("status").toInt(0); |
| 821 | QString message = obj.value("message").toString(); |
| 822 | |
| 823 | if (status != 4 && message.isEmpty()) |
| 824 | return; |
| 825 | |
| 826 | QString htmlMsg = message.toHtmlEscaped(); |
| 827 | htmlMsg.replace("\\n", "<br>"); |
| 828 | |
| 829 | switch (status) { |
| 830 | case 0: // BUILD_LOG_NONE |
| 831 | buildLogOutput->append(htmlMsg); |
| 832 | break; |
| 833 | case 1: // BUILD_LOG_INFO |
| 834 | buildLogOutput->append(QString("<span style='color: #569cd6;'>[*]</span> %1").arg(htmlMsg)); |
| 835 | break; |
| 836 | case 2: // BUILD_LOG_ERROR |
| 837 | buildLogOutput->append(QString("<span style='color: #f14c4c;'>[-]</span> %1").arg(htmlMsg)); |
| 838 | break; |
| 839 | case 3: // BUILD_LOG_SUCCESS |
| 840 | buildLogOutput->append(QString("<span style='color: #dcdcaa;'>[+]</span> %1").arg(htmlMsg)); |
| 841 | break; |
| 842 | case 4: { // BUILD_LOG_SAVE_FILE |
| 843 | QString filename = obj.value("filename").toString(); |
| 844 | QString contentBase64 = obj.value("content").toString(); |
| 845 | QByteArray content = QByteArray::fromBase64(contentBase64.toUtf8()); |
| 846 | |
| 847 | if (filename.isEmpty() || content.isEmpty()) |
| 848 | return; |
| 849 | |
| 850 | QString baseDir = authProfile.GetProjectDir(); |
| 851 | QString initialPath = QDir(baseDir).filePath(filename); |
| 852 | |
| 853 | QPointer<DialogAgent> safeThis = this; |
| 854 | NonBlockingDialogs::getSaveFileName(this, "Save File", initialPath, "All Files (*.*)", |
| 855 | [safeThis, content](const QString& filePath) { |
| 856 | if (filePath.isEmpty()) |
| 857 | return; |
| 858 | |
| 859 | QFile file(filePath); |
| 860 | if (!file.open(QIODevice::WriteOnly)) { |
| 861 | MessageError("Failed to open file for writing"); |
| 862 | return; |
| 863 | } |
nothing calls this directly
no test coverage detected