Changeset View
Changeset View
Standalone View
Standalone View
plugins/patchreview/patchreview.cpp
Show First 20 Lines • Show All 569 Lines • ▼ Show 20 Line(s) | |||||
570 | { | 570 | { | ||
571 | bool reviewing = area->objectName() == QLatin1String("review"); | 571 | bool reviewing = area->objectName() == QLatin1String("review"); | ||
572 | m_finishReview->setEnabled(reviewing); | 572 | m_finishReview->setEnabled(reviewing); | ||
573 | if(!reviewing) { | 573 | if(!reviewing) { | ||
574 | closeReview(); | 574 | closeReview(); | ||
575 | } | 575 | } | ||
576 | } | 576 | } | ||
577 | 577 | | |||
578 | KDevelop::ContextMenuExtension PatchReviewPlugin::contextMenuExtension( KDevelop::Context* context ) | 578 | KDevelop::ContextMenuExtension PatchReviewPlugin::contextMenuExtension(KDevelop::Context* context, QWidget* parent) | ||
579 | { | 579 | { | ||
580 | QList<QUrl> urls; | 580 | QList<QUrl> urls; | ||
581 | 581 | | |||
582 | if ( context->type() == KDevelop::Context::FileContext ) { | 582 | if ( context->type() == KDevelop::Context::FileContext ) { | ||
583 | KDevelop::FileContext* filectx = static_cast<KDevelop::FileContext*>(context); | 583 | KDevelop::FileContext* filectx = static_cast<KDevelop::FileContext*>(context); | ||
584 | urls = filectx->urls(); | 584 | urls = filectx->urls(); | ||
585 | } else if ( context->type() == KDevelop::Context::ProjectItemContext ) { | 585 | } else if ( context->type() == KDevelop::Context::ProjectItemContext ) { | ||
586 | KDevelop::ProjectItemContext* projctx = static_cast<KDevelop::ProjectItemContext*>(context); | 586 | KDevelop::ProjectItemContext* projctx = static_cast<KDevelop::ProjectItemContext*>(context); | ||
587 | foreach( KDevelop::ProjectBaseItem* item, projctx->items() ) { | 587 | foreach( KDevelop::ProjectBaseItem* item, projctx->items() ) { | ||
588 | if ( item->file() ) { | 588 | if ( item->file() ) { | ||
589 | urls << item->file()->path().toUrl(); | 589 | urls << item->file()->path().toUrl(); | ||
590 | } | 590 | } | ||
591 | } | 591 | } | ||
592 | } else if ( context->type() == KDevelop::Context::EditorContext ) { | 592 | } else if ( context->type() == KDevelop::Context::EditorContext ) { | ||
593 | KDevelop::EditorContext* econtext = static_cast<KDevelop::EditorContext*>(context); | 593 | KDevelop::EditorContext* econtext = static_cast<KDevelop::EditorContext*>(context); | ||
594 | urls << econtext->url(); | 594 | urls << econtext->url(); | ||
595 | } | 595 | } | ||
596 | 596 | | |||
597 | if (urls.size() == 1) { | 597 | if (urls.size() == 1) { | ||
598 | QAction* reviewAction = new QAction( QIcon::fromTheme(QStringLiteral("text-x-patch")), | 598 | QAction* reviewAction = new QAction( QIcon::fromTheme(QStringLiteral("text-x-patch")), | ||
599 | i18n( "Review Patch" ), this ); | 599 | i18n("Review Patch"), parent); | ||
600 | reviewAction->setData(QVariant(urls[0])); | 600 | reviewAction->setData(QVariant(urls[0])); | ||
601 | connect( reviewAction, &QAction::triggered, this, &PatchReviewPlugin::executeFileReviewAction ); | 601 | connect( reviewAction, &QAction::triggered, this, &PatchReviewPlugin::executeFileReviewAction ); | ||
602 | ContextMenuExtension cm; | 602 | ContextMenuExtension cm; | ||
603 | cm.addAction( KDevelop::ContextMenuExtension::VcsGroup, reviewAction ); | 603 | cm.addAction( KDevelop::ContextMenuExtension::VcsGroup, reviewAction ); | ||
604 | return cm; | 604 | return cm; | ||
605 | } | 605 | } | ||
606 | 606 | | |||
607 | return KDevelop::IPlugin::contextMenuExtension( context ); | 607 | return KDevelop::IPlugin::contextMenuExtension(context, parent); | ||
608 | } | 608 | } | ||
609 | 609 | | |||
610 | void PatchReviewPlugin::executeFileReviewAction() | 610 | void PatchReviewPlugin::executeFileReviewAction() | ||
611 | { | 611 | { | ||
612 | QAction* reviewAction = qobject_cast<QAction*>(sender()); | 612 | QAction* reviewAction = qobject_cast<QAction*>(sender()); | ||
613 | KDevelop::Path path(reviewAction->data().toUrl()); | 613 | KDevelop::Path path(reviewAction->data().toUrl()); | ||
614 | LocalPatchSource* ps = new LocalPatchSource(); | 614 | LocalPatchSource* ps = new LocalPatchSource(); | ||
615 | ps->setFilename(path.toUrl()); | 615 | ps->setFilename(path.toUrl()); | ||
Show All 9 Lines |