Changeset View
Standalone View
addons/katebuild-plugin/plugin_katebuild.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
57 | 57 | | |||
58 | K_PLUGIN_FACTORY_WITH_JSON (KateBuildPluginFactory, "katebuildplugin.json", registerPlugin<KateBuildPlugin>();) | 58 | K_PLUGIN_FACTORY_WITH_JSON (KateBuildPluginFactory, "katebuildplugin.json", registerPlugin<KateBuildPlugin>();) | ||
59 | 59 | | |||
60 | static const QString DefConfigCmd = QStringLiteral("cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr/local ../"); | 60 | static const QString DefConfigCmd = QStringLiteral("cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr/local ../"); | ||
61 | static const QString DefConfClean; | 61 | static const QString DefConfClean; | ||
62 | static const QString DefTargetName = QStringLiteral("all"); | 62 | static const QString DefTargetName = QStringLiteral("all"); | ||
63 | static const QString DefBuildCmd = QStringLiteral("make"); | 63 | static const QString DefBuildCmd = QStringLiteral("make"); | ||
64 | static const QString DefCleanCmd = QStringLiteral("make clean"); | 64 | static const QString DefCleanCmd = QStringLiteral("make clean"); | ||
65 | 65 | static const bool OnlyUpdateMessageText = true; | |||
66 | static const int NeverHide = 60 * 60 * 1000; // 1hour delay, quirk to avoid forced "Close" button | ||||
66 | 67 | | |||
67 | /******************************************************************/ | 68 | /******************************************************************/ | ||
sars: Please increase the time, in case we have really long builds that progress slowly ;) | |||||
68 | KateBuildPlugin::KateBuildPlugin(QObject *parent, const VariantList&): | 69 | KateBuildPlugin::KateBuildPlugin(QObject *parent, const VariantList&): | ||
69 | KTextEditor::Plugin(parent) | 70 | KTextEditor::Plugin(parent) | ||
70 | { | 71 | { | ||
71 | // KF5 FIXME KGlobal::locale()->insertCatalog("katebuild-plugin"); | 72 | // KF5 FIXME KGlobal::locale()->insertCatalog("katebuild-plugin"); | ||
72 | } | 73 | } | ||
73 | 74 | | |||
74 | /******************************************************************/ | 75 | /******************************************************************/ | ||
75 | QObject *KateBuildPlugin::createView (KTextEditor::MainWindow *mainWindow) | 76 | QObject *KateBuildPlugin::createView (KTextEditor::MainWindow *mainWindow) | ||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Line(s) | |||||
482 | 483 | | |||
483 | 484 | | |||
484 | /******************************************************************/ | 485 | /******************************************************************/ | ||
485 | void KateBuildView::clearBuildResults() | 486 | void KateBuildView::clearBuildResults() | ||
486 | { | 487 | { | ||
487 | m_buildUi.plainTextEdit->clear(); | 488 | m_buildUi.plainTextEdit->clear(); | ||
488 | m_buildUi.errTreeWidget->clear(); | 489 | m_buildUi.errTreeWidget->clear(); | ||
489 | m_stdOut.clear(); | 490 | m_stdOut.clear(); | ||
490 | m_stdErr.clear(); | 491 | m_stdErr.clear(); | ||
Why would we not want to have a tooltip? with really long error messages you would not get the error. The What's this is much harder to find... If we keep this I think the option should be: Use "What's this" for long error messages or something similar. sars: Why would we not want to have a tooltip? with really long error messages you would not get the… | |||||
491 | m_numErrors = 0; | 492 | m_numErrors = 0; | ||
492 | m_numWarnings = 0; | 493 | m_numWarnings = 0; | ||
493 | m_make_dir_stack.clear(); | 494 | m_make_dir_stack.clear(); | ||
494 | } | 495 | } | ||
495 | 496 | | |||
496 | /******************************************************************/ | 497 | /******************************************************************/ | ||
497 | bool KateBuildView::startProcess(const QString &dir, const QString &command) | 498 | bool KateBuildView::startProcess(const QString &dir, const QString &command) | ||
498 | { | 499 | { | ||
499 | if (m_proc.state() != QProcess::NotRunning) { | 500 | if (m_proc.state() != QProcess::NotRunning) { | ||
500 | return false; | 501 | return false; | ||
501 | } | 502 | } | ||
502 | 503 | | |||
503 | // clear previous runs | 504 | // clear previous runs | ||
504 | clearBuildResults(); | 505 | clearBuildResults(); | ||
505 | 506 | | |||
506 | // activate the output tab | 507 | // activate the output tab | ||
507 | m_buildUi.u_tabWidget->setCurrentIndex(1); | 508 | m_buildUi.u_tabWidget->setCurrentIndex(1); | ||
508 | m_displayModeBeforeBuild = m_buildUi.displayModeSlider->value(); | 509 | m_displayModeBeforeBuild = m_buildUi.displayModeSlider->value(); | ||
509 | m_buildUi.displayModeSlider->setValue(0); | 510 | m_buildUi.displayModeSlider->setValue(0); | ||
510 | m_win->showToolView(m_toolView); | | |||
511 | 511 | | |||
512 | // set working directory | 512 | // set working directory | ||
513 | m_make_dir = dir; | 513 | m_make_dir = dir; | ||
514 | m_make_dir_stack.push(m_make_dir); | 514 | m_make_dir_stack.push(m_make_dir); | ||
515 | 515 | | |||
516 | if (!QFile::exists(m_make_dir)) { | 516 | if (!QFile::exists(m_make_dir)) { | ||
517 | KMessageBox::error(nullptr, i18n("Cannot run command: %1\nWork path does not exist: %2", command, m_make_dir)); | 517 | KMessageBox::error(nullptr, i18n("Cannot run command: %1\nWork path does not exist: %2", command, m_make_dir)); | ||
518 | return false; | 518 | return false; | ||
Show All 17 Lines | |||||
536 | return true; | 536 | return true; | ||
537 | } | 537 | } | ||
538 | 538 | | |||
539 | /******************************************************************/ | 539 | /******************************************************************/ | ||
540 | bool KateBuildView::slotStop() | 540 | bool KateBuildView::slotStop() | ||
541 | { | 541 | { | ||
542 | if (m_proc.state() != QProcess::NotRunning) { | 542 | if (m_proc.state() != QProcess::NotRunning) { | ||
543 | m_buildCancelled = true; | 543 | m_buildCancelled = true; | ||
544 | QString msg = i18n("Building <b>%1</b> cancelled", m_currentlyBuildingTarget); | | |||
545 | m_buildUi.buildStatusLabel->setText(msg); | | |||
546 | m_buildUi.buildStatusLabel2->setText(msg); | | |||
547 | m_proc.terminate(); | 544 | m_proc.terminate(); | ||
548 | return true; | 545 | return true; | ||
549 | } | 546 | } | ||
550 | return false; | 547 | return false; | ||
551 | } | 548 | } | ||
552 | 549 | | |||
553 | /******************************************************************/ | 550 | /******************************************************************/ | ||
554 | void KateBuildView::slotBuildActiveTarget() { | 551 | void KateBuildView::slotBuildActiveTarget() { | ||
Show All 16 Lines | 561 | void KateBuildView::slotBuildPreviousTarget() { | |||
571 | } | 568 | } | ||
572 | } | 569 | } | ||
573 | 570 | | |||
574 | 571 | | |||
575 | /******************************************************************/ | 572 | /******************************************************************/ | ||
576 | void KateBuildView::slotBuildDefaultTarget() { | 573 | void KateBuildView::slotBuildDefaultTarget() { | ||
577 | QModelIndex defaultTarget = m_targetsUi->targetsModel.defaultTarget(m_targetsUi->targetsView->currentIndex()); | 574 | QModelIndex defaultTarget = m_targetsUi->targetsModel.defaultTarget(m_targetsUi->targetsView->currentIndex()); | ||
578 | m_targetsUi->targetsView->setCurrentIndex(defaultTarget); | 575 | m_targetsUi->targetsView->setCurrentIndex(defaultTarget); | ||
576 | m_hideViewOnSuccess = 2; | ||||
579 | buildCurrentTarget(); | 577 | buildCurrentTarget(); | ||
580 | } | 578 | } | ||
581 | 579 | | |||
582 | 580 | | |||
583 | /******************************************************************/ | 581 | /******************************************************************/ | ||
584 | void KateBuildView::slotSelectTarget() { | 582 | void KateBuildView::slotSelectTarget() { | ||
585 | SelectTargetView *dialog = new SelectTargetView(&(m_targetsUi->targetsModel)); | 583 | SelectTargetView *dialog = new SelectTargetView(&(m_targetsUi->targetsModel)); | ||
586 | 584 | | |||
587 | dialog->setCurrentIndex(m_targetsUi->targetsView->currentIndex()); | 585 | dialog->setCurrentIndex(m_targetsUi->targetsView->currentIndex()); | ||
588 | 586 | | |||
589 | int result = dialog->exec(); | 587 | int result = dialog->exec(); | ||
590 | if (result == QDialog::Accepted) { | 588 | if (result == QDialog::Accepted) { | ||
591 | m_targetsUi->targetsView->setCurrentIndex(dialog->currentIndex()); | 589 | m_targetsUi->targetsView->setCurrentIndex(dialog->currentIndex()); | ||
sars: Why the type change? | |||||
loh.tar: Why not? Nothing happens which may cause trouble. | |||||
592 | buildCurrentTarget(); | 590 | buildCurrentTarget(); | ||
593 | } | 591 | } | ||
594 | delete dialog; | 592 | delete dialog; | ||
595 | dialog = nullptr; | 593 | dialog = nullptr; | ||
596 | } | 594 | } | ||
597 | 595 | | |||
598 | 596 | | |||
599 | /******************************************************************/ | 597 | /******************************************************************/ | ||
600 | bool KateBuildView::buildCurrentTarget() | 598 | bool KateBuildView::buildCurrentTarget() | ||
601 | { | 599 | { | ||
602 | if (m_proc.state() != QProcess::NotRunning) { | 600 | if (m_proc.state() == QProcess::Running) { | ||
603 | displayBuildResult(i18n("Already building..."), KTextEditor::Message::Warning); | 601 | m_win->showToolView(m_toolView); | ||
604 | return false; | 602 | return true; | ||
605 | } | 603 | } | ||
606 | 604 | | |||
607 | QFileInfo docFInfo = docUrl().toLocalFile(); // docUrl() saves the current document | 605 | QFileInfo docFInfo = docUrl().toLocalFile(); // docUrl() saves the current document | ||
608 | 606 | | |||
609 | QModelIndex ind = m_targetsUi->targetsView->currentIndex(); | 607 | QModelIndex ind = m_targetsUi->targetsView->currentIndex(); | ||
610 | m_previousIndex = ind; | 608 | m_previousIndex = ind; | ||
611 | if (!ind.isValid()) { | 609 | if (!ind.isValid()) { | ||
612 | KMessageBox::sorry(nullptr, i18n("No target available for building.")); | 610 | postMessage(i18n("No target available for building."), KTextEditor::Message::Error); | ||
613 | return false; | 611 | return false; | ||
614 | } | 612 | } | ||
615 | 613 | | |||
616 | QString buildCmd = m_targetsUi->targetsModel.command(ind); | 614 | QString buildCmd = m_targetsUi->targetsModel.command(ind); | ||
617 | QString cmdName = m_targetsUi->targetsModel.cmdName(ind); | 615 | QString cmdName = m_targetsUi->targetsModel.cmdName(ind); | ||
618 | QString workDir = m_targetsUi->targetsModel.workDir(ind); | 616 | QString workDir = m_targetsUi->targetsModel.workDir(ind); | ||
619 | QString targetSet = m_targetsUi->targetsModel.targetName(ind); | 617 | QString targetSet = m_targetsUi->targetsModel.targetName(ind); | ||
620 | 618 | | |||
621 | QString dir = workDir; | 619 | QString dir = workDir; | ||
622 | if (workDir.isEmpty()) { | 620 | if (workDir.isEmpty()) { | ||
623 | dir = docFInfo.absolutePath(); | 621 | dir = docFInfo.absolutePath(); | ||
624 | if (dir.isEmpty()) { | 622 | if (dir.isEmpty()) { | ||
This would work differently for building: default, previous and active target. How the build is invoked should not affect the behavior. sars: This would work differently for building: default, previous and active target.
How the build… | |||||
625 | KMessageBox::sorry(nullptr, i18n("There is no local file or directory specified for building.")); | 623 | postMessage(i18n("There is no local file or directory specified for building."), KTextEditor::Message::Error); | ||
626 | return false; | 624 | return false; | ||
627 | } | 625 | } | ||
628 | } | 626 | } | ||
629 | 627 | | |||
630 | // Check if the command contains the file name or directory | 628 | // Check if the command contains the file name or directory | ||
631 | if (buildCmd.contains(QStringLiteral("%f")) || | 629 | if (buildCmd.contains(QStringLiteral("%f")) || | ||
632 | buildCmd.contains(QStringLiteral("%d")) || | 630 | buildCmd.contains(QStringLiteral("%d")) || | ||
633 | buildCmd.contains(QStringLiteral("%n"))) | 631 | buildCmd.contains(QStringLiteral("%n"))) | ||
634 | { | 632 | { | ||
635 | 633 | | |||
636 | if (docFInfo.absoluteFilePath().isEmpty()) { | 634 | if (docFInfo.absoluteFilePath().isEmpty()) { | ||
637 | return false; | 635 | return false; | ||
638 | } | 636 | } | ||
639 | 637 | | |||
640 | buildCmd.replace(QStringLiteral("%n"), docFInfo.baseName()); | 638 | buildCmd.replace(QStringLiteral("%n"), docFInfo.baseName()); | ||
641 | buildCmd.replace(QStringLiteral("%f"), docFInfo.absoluteFilePath()); | 639 | buildCmd.replace(QStringLiteral("%f"), docFInfo.absoluteFilePath()); | ||
642 | buildCmd.replace(QStringLiteral("%d"), docFInfo.absolutePath()); | 640 | buildCmd.replace(QStringLiteral("%d"), docFInfo.absolutePath()); | ||
643 | } | 641 | } | ||
642 | | ||||
643 | --m_hideViewOnSuccess; | ||||
644 | m_filenameDetectorGccWorked = false; | 644 | m_filenameDetectorGccWorked = false; | ||
645 | m_currentlyBuildingTarget = QStringLiteral("%1: %2").arg(targetSet).arg(cmdName); | 645 | m_currentlyBuildingTarget = QStringLiteral("%1: %2").arg(targetSet).arg(cmdName); | ||
646 | m_buildCancelled = false; | 646 | m_buildCancelled = false; | ||
The state can also be QProcess::Starting. In some rare situations starting can be slow. I think its better to handle all cases. sars: The state can also be QProcess::Starting. In some rare situations starting can be slow. I think… | |||||
647 | QString msg = i18n("Building target <b>%1</b> ...", m_currentlyBuildingTarget); | 647 | QString msg = i18n("Building target <b>%1</b> ...", m_currentlyBuildingTarget); | ||
648 | m_buildUi.buildStatusLabel->setText(msg); | 648 | m_buildUi.buildStatusLabel->setText(msg); | ||
If the toolview is hidden we can open the toolview in stead of showing, the error message, but I would say that trying to start a new build should not effect whether or not the toolview is hidden at the end of the build. I also think we need to show the error message. The user might get the impression that a new build was already started. sars: If the toolview is hidden we can open the toolview in stead of showing, the error message, but… | |||||
649 | m_buildUi.buildStatusLabel2->setText(msg); | 649 | m_buildUi.buildStatusLabel2->setText(msg); | ||
650 | postMessage(i18n("Building target..."), KTextEditor::Message::Information, NeverHide); | ||||
651 | | ||||
650 | return startProcess(dir, buildCmd); | 652 | return startProcess(dir, buildCmd); | ||
651 | } | 653 | } | ||
652 | 654 | | |||
653 | /******************************************************************/ | 655 | /******************************************************************/ | ||
654 | void KateBuildView::displayBuildResult(const QString &msg, KTextEditor::Message::MessageType level) | 656 | void KateBuildView::postMessage(const QString &msg, KTextEditor::Message::MessageType type, int autoHideDelay/* = 0*/, bool updateOnly/* = false*/) | ||
655 | { | 657 | { | ||
656 | KTextEditor::View *kv = m_win->activeView(); | 658 | KTextEditor::View *kv = m_win->activeView(); | ||
657 | if (!kv) return; | 659 | if (!kv) return; | ||
658 | 660 | | |||
659 | delete m_infoMessage; | 661 | QString msgType; | ||
660 | m_infoMessage = new KTextEditor::Message(xi18nc("@info", "<title>Make Results:</title><nl/>%1", msg), level); | 662 | switch (type) { | ||
661 | m_infoMessage->setWordWrap(true); | 663 | // TODO KF6 How about a function in KTextEditor::Message to get these translated message type names? | ||
662 | m_infoMessage->setPosition(KTextEditor::Message::BottomInView); | 664 | case KTextEditor::Message::Positive: | ||
663 | m_infoMessage->setAutoHide(5000); | 665 | case KTextEditor::Message::Information: | ||
664 | m_infoMessage->setAutoHideMode(KTextEditor::Message::Immediate); | 666 | msgType = i18n("Info"); | ||
665 | m_infoMessage->setView(kv); | 667 | break; | ||
666 | kv->document()->postMessage(m_infoMessage); | 668 | case KTextEditor::Message::Warning: | ||
669 | msgType = i18n("Warning"); | ||||
670 | break; | ||||
671 | case KTextEditor::Message::Error: | ||||
672 | msgType = i18n("Error"); | ||||
673 | break; | ||||
674 | } | ||||
675 | | ||||
676 | if (updateOnly && m_infoMessage) { | ||||
677 | m_infoMessage->setText(xi18nc("@info", "<title>Make %1</title><nl/>%2", msgType, msg)); | ||||
678 | | ||||
679 | } else { | ||||
680 | delete m_infoMessage; | ||||
681 | // FIXME Add a minimum width to the message box, looks sometimes too titchy | ||||
682 | // m_infoMessage->setMinimumWidth(123) will not work, it's only an QOject | ||||
683 | // and attempts to add spaces failed | ||||
684 | m_infoMessage = new KTextEditor::Message(xi18nc("@info", "<title>Make %1</title><nl/>%2", msgType, msg), type); | ||||
685 | m_infoMessage->setWordWrap(true); | ||||
686 | m_infoMessage->setPosition(KTextEditor::Message::BottomInView); | ||||
687 | m_infoMessage->setAutoHide(autoHideDelay); | ||||
688 | m_infoMessage->setAutoHideMode(KTextEditor::Message::Immediate); | ||||
689 | m_infoMessage->setView(kv); | ||||
690 | kv->document()->postMessage(m_infoMessage); | ||||
691 | } | ||||
667 | } | 692 | } | ||
668 | 693 | | |||
669 | /******************************************************************/ | 694 | /******************************************************************/ | ||
670 | void KateBuildView::slotProcExited(int exitCode, QProcess::ExitStatus) | 695 | void KateBuildView::slotProcExited(int exitCode, QProcess::ExitStatus) | ||
671 | { | 696 | { | ||
672 | QApplication::restoreOverrideCursor(); | 697 | QApplication::restoreOverrideCursor(); | ||
673 | m_buildUi.cancelBuildButton->setEnabled(false); | 698 | m_buildUi.cancelBuildButton->setEnabled(false); | ||
674 | m_buildUi.cancelBuildButton2->setEnabled(false); | 699 | m_buildUi.cancelBuildButton2->setEnabled(false); | ||
675 | m_buildUi.buildAgainButton->setEnabled(true); | 700 | m_buildUi.buildAgainButton->setEnabled(true); | ||
676 | m_buildUi.buildAgainButton2->setEnabled(true); | 701 | m_buildUi.buildAgainButton2->setEnabled(true); | ||
677 | 702 | | |||
678 | QString buildStatus = i18n("Building <b>%1</b> completed.", m_currentlyBuildingTarget); | 703 | QString buildStatus = i18n("Building <b>%1</b> completed.", m_currentlyBuildingTarget); | ||
679 | 704 | | |||
680 | // did we get any errors? | 705 | // did we get any errors? | ||
681 | if (m_numErrors || m_numWarnings || (exitCode != 0)) { | 706 | if (m_numErrors || m_numWarnings || (exitCode != 0)) { | ||
682 | m_buildUi.u_tabWidget->setCurrentIndex(1); | 707 | m_buildUi.u_tabWidget->setCurrentIndex(1); | ||
683 | if (m_buildUi.displayModeSlider->value() == 0) { | 708 | if (m_buildUi.displayModeSlider->value() == 0) { | ||
684 | m_buildUi.displayModeSlider->setValue(m_displayModeBeforeBuild > 0 ? m_displayModeBeforeBuild: 1); | 709 | m_buildUi.displayModeSlider->setValue(m_displayModeBeforeBuild > 0 ? m_displayModeBeforeBuild: 1); | ||
685 | } | 710 | } | ||
Why would this be a KF6 thing? Can't we just add another constructor/functin? Anyways the comment can be removed or moved to KTextEditor::Message sars: Why would this be a KF6 thing? Can't we just add another constructor/functin?
Anyways the… | |||||
686 | m_buildUi.errTreeWidget->resizeColumnToContents(0); | 711 | m_buildUi.errTreeWidget->resizeColumnToContents(0); | ||
687 | m_buildUi.errTreeWidget->resizeColumnToContents(1); | 712 | m_buildUi.errTreeWidget->resizeColumnToContents(1); | ||
Why the type change? You get a exitCode != 0 also if you only have a warning. sars: Why the type change? You get a exitCode != 0 also if you only have a warning. | |||||
I guess, I have assumed that in case of a warning "m_numWarnings" was set. And on a compile error "m_numErrors", so that we here have some other ugly error. loh.tar: I guess, I have assumed that in case of a warning "m_numWarnings" was set. And on a compile… | |||||
688 | m_buildUi.errTreeWidget->resizeColumnToContents(2); | 713 | m_buildUi.errTreeWidget->resizeColumnToContents(2); | ||
689 | m_buildUi.errTreeWidget->horizontalScrollBar()->setValue(0); | 714 | m_buildUi.errTreeWidget->horizontalScrollBar()->setValue(0); | ||
690 | //m_buildUi.errTreeWidget->setSortingEnabled(true); | 715 | //m_buildUi.errTreeWidget->setSortingEnabled(true); | ||
691 | m_win->showToolView(m_toolView); | 716 | m_win->showToolView(m_toolView); | ||
692 | } | 717 | } | ||
693 | 718 | | |||
694 | if (m_numErrors || m_numWarnings) { | 719 | if (m_buildCancelled) { | ||
720 | buildStatus = i18n("Building <b>%1</b> cancelled", m_currentlyBuildingTarget); | ||||
721 | postMessage(i18n("Build cancelled"), KTextEditor::Message::Information); | ||||
722 | | ||||
723 | } else if (m_numErrors || m_numWarnings) { | ||||
695 | QStringList msgs; | 724 | QStringList msgs; | ||
696 | if (m_numErrors) { | 725 | if (m_numErrors) { | ||
697 | msgs << i18np("Found one error.", "Found %1 errors.", m_numErrors); | 726 | msgs << i18np("Found one error.", "Found %1 errors.", m_numErrors); | ||
698 | buildStatus = i18n("Building <b>%1</b> had errors.", m_currentlyBuildingTarget); | 727 | buildStatus = i18n("Building <b>%1</b> had errors.", m_currentlyBuildingTarget); | ||
699 | } | 728 | } | ||
700 | else if (m_numWarnings) { | 729 | else if (m_numWarnings) { | ||
701 | msgs << i18np("Found one warning.", "Found %1 warnings.", m_numWarnings); | 730 | msgs << i18np("Found one warning.", "Found %1 warnings.", m_numWarnings); | ||
702 | buildStatus = i18n("Building <b>%1</b> had warnings.", m_currentlyBuildingTarget); | 731 | buildStatus = i18n("Building <b>%1</b> had warnings.", m_currentlyBuildingTarget); | ||
703 | } | 732 | } | ||
704 | displayBuildResult(msgs.join(QLatin1Char('\n')), m_numErrors ? KTextEditor::Message::Error : KTextEditor::Message::Warning); | 733 | postMessage(msgs.join(QLatin1Char('\n')), m_numErrors ? KTextEditor::Message::Error : KTextEditor::Message::Warning); | ||
705 | } | | |||
706 | else if (exitCode != 0) { | | |||
707 | displayBuildResult(i18n("Build failed."), KTextEditor::Message::Warning); | | |||
708 | } | | |||
709 | else { | | |||
710 | displayBuildResult(i18n("Build completed without problems."), KTextEditor::Message::Positive); | | |||
711 | } | | |||
712 | 734 | | |||
713 | if (!m_buildCancelled) { | 735 | } else if (exitCode != 0) { | ||
714 | m_buildUi.buildStatusLabel->setText(buildStatus); | 736 | postMessage(i18n("Build failed."), KTextEditor::Message::Error); | ||
715 | m_buildUi.buildStatusLabel2->setText(buildStatus); | 737 | | ||
716 | m_buildCancelled = false; | 738 | } else { | ||
739 | postMessage(i18n("Build completed without problems."), KTextEditor::Message::Positive); | ||||
740 | if (m_hideViewOnSuccess > 0) { | ||||
The idea is good, but until it works it is best to not output debug messages. If it would be possible to use the same plasma integrated progress indication as dolphin it would be nice, but if it would be only in the toolview you kinda already have it there. sars: The idea is good, but until it works it is best to not output debug messages.
If it would be… | |||||
741 | m_win->hideToolView(m_toolView); | ||||
742 | } | ||||
717 | } | 743 | } | ||
718 | 744 | | |||
745 | m_buildUi.buildStatusLabel->setText(buildStatus); | ||||
746 | m_buildUi.buildStatusLabel2->setText(buildStatus); | ||||
747 | m_hideViewOnSuccess = 0; | ||||
719 | } | 748 | } | ||
yurchor: Typo: progess -> progress | |||||
720 | 749 | | |||
721 | 750 | | |||
722 | /******************************************************************/ | 751 | /******************************************************************/ | ||
723 | void KateBuildView::slotReadReadyStdOut() | 752 | void KateBuildView::slotReadReadyStdOut() | ||
724 | { | 753 | { | ||
725 | // read data from procs stdout and add | 754 | // read data from procs stdout and add | ||
726 | // the text to the end of the output | 755 | // the text to the end of the output | ||
727 | // FIXME This works for utf8 but not for all charsets | 756 | // FIXME This works for utf8 but not for all charsets | ||
728 | QString l = QString::fromUtf8(m_proc.readAllStandardOutput()); | 757 | QString l = QString::fromUtf8(m_proc.readAllStandardOutput()); | ||
729 | l.remove(QLatin1Char('\r')); | 758 | l.remove(QLatin1Char('\r')); | ||
730 | m_stdOut += l; | 759 | m_stdOut += l; | ||
731 | 760 | | |||
761 | QRegularExpression regExp = QRegularExpression(QStringLiteral("^\\[\\s?([\\d\\%]+)\\]")); | ||||
732 | // handle one line at a time | 762 | // handle one line at a time | ||
733 | do { | 763 | do { | ||
734 | const int end = m_stdOut.indexOf(QLatin1Char('\n')); | 764 | const int end = m_stdOut.indexOf(QLatin1Char('\n')); | ||
735 | if (end < 0) break; | 765 | if (end < 0) break; | ||
736 | 766 | | |||
737 | const QString line = m_stdOut.mid(0, end); | 767 | const QString line = m_stdOut.mid(0, end); | ||
738 | m_buildUi.plainTextEdit->appendPlainText(line); | 768 | m_buildUi.plainTextEdit->appendPlainText(line); | ||
739 | //qDebug() << line; | 769 | //qDebug() << line; | ||
740 | 770 | | |||
771 | QRegularExpressionMatch match = regExp.match(line); | ||||
772 | if (match.hasMatch()) { | ||||
773 | postMessage(i18n("Building target...") + QStringLiteral("%1").arg(match.captured(1), 4, QLatin1Char('.')) | ||||
774 | , KTextEditor::Message::Information, NeverHide, OnlyUpdateMessageText); | ||||
775 | } | ||||
776 | | ||||
741 | if (m_newDirDetector.match(line).hasMatch()) { | 777 | if (m_newDirDetector.match(line).hasMatch()) { | ||
742 | //qDebug() << "Enter/Exit dir found"; | 778 | //qDebug() << "Enter/Exit dir found"; | ||
743 | int open = line.indexOf(QLatin1Char('`')); | 779 | int open = line.indexOf(QLatin1Char('`')); | ||
744 | int close = line.indexOf(QLatin1Char('\'')); | 780 | int close = line.indexOf(QLatin1Char('\'')); | ||
745 | QString newDir = line.mid(open+1, close-open-1); | 781 | QString newDir = line.mid(open+1, close-open-1); | ||
746 | //qDebug () << "New dir = " << newDir; | 782 | //qDebug () << "New dir = " << newDir; | ||
747 | 783 | | |||
748 | if ((m_make_dir_stack.size() > 1) && (m_make_dir_stack.top() == newDir)) { | 784 | if ((m_make_dir_stack.size() > 1) && (m_make_dir_stack.top() == newDir)) { | ||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |
Please increase the time, in case we have really long builds that progress slowly ;)