Skip to content

Commit

Permalink
Fully working stub.
Browse files Browse the repository at this point in the history
  • Loading branch information
xBazilio committed May 16, 2017
1 parent 97a2b8d commit 94a85f3
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Binaries/*
Config/*
Intermediate/*
27 changes: 27 additions & 0 deletions QtCreatorSourceCodeAccess.uplugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"FriendlyName": "Qt Creator Source Code Access",
"Description": "Allows access to source code in Qt Creator.",
"Category": "Programming",
"CreatedBy": "Vasiliy Rumyantsev",
"CreatedByURL": "https://github.com/xBazilio/QtCreatorWinSourceCodeAccess",
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": false,
"IsBetaVersion": false,
"Installed": false,
"Modules": [
{
"Name": "QtCreatorSourceCodeAccess",
"Type": "Developer",
"LoadingPhase": "Default",
"WhitelistPlatforms": [
"Win64",
"Win32"
]
}
]
}
Binary file added Resources/Icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include "Core.h"
#include "ModuleManager.h"
#include "ISourceCodeAccessModule.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.

#include "QtCreatorSourceCodeAccessHeader.h"
#include "QtCreatorSourceCodeAccessModule.h"
#include "Features/IModularFeatures.h"

IMPLEMENT_MODULE(FQtCreatorSourceCodeAccessModule, QtCreatorSourceCodeAccess)

#define LOCTEXT_NAMESPACE "FQtCreatorSourceCodeAccessModule"

void FQtCreatorSourceCodeAccessModule::StartupModule()
{
// Bind our source control provider to the editor
IModularFeatures::Get().RegisterModularFeature(TEXT("SourceCodeAccessor"), &QtCreatorSourceCodeAccessor );
}

void FQtCreatorSourceCodeAccessModule::ShutdownModule()
{
// Unbind provider from editor
IModularFeatures::Get().UnregisterModularFeature(TEXT("SourceCodeAccessor"), &QtCreatorSourceCodeAccessor);
}

#undef LOCTEXT_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Modules/ModuleInterface.h"
#include "QtCreatorSourceCodeAccessor.h"

class FQtCreatorSourceCodeAccessModule : public IModuleInterface
{
public:

/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;

private:
FQtCreatorSourceCodeAccessor QtCreatorSourceCodeAccessor;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#pragma once

#include "QtCreatorSourceCodeAccessHeader.h"
#include "QtCreatorSourceCodeAccessor.h"
#include "DesktopPlatformModule.h"

DEFINE_LOG_CATEGORY_STATIC(LogQtCreatorAccessor, Log, All)

#define LOCTEXT_NAMESPACE "QtCreatorSourceCodeAccessor"

bool FQtCreatorSourceCodeAccessor::CanAccessSourceCode() const
{
// TODO implement checking that Qt Creator is present in system
return true;
}

FName FQtCreatorSourceCodeAccessor::GetFName() const
{
return FName("QtCreatorSourceCodeAccessor");
}

FText FQtCreatorSourceCodeAccessor::GetNameText() const
{
return LOCTEXT("QtCreatorDisplayName", "Qt Creator 4.x");
}

FText FQtCreatorSourceCodeAccessor::GetDescriptionText() const
{
return LOCTEXT("QtCreatorDisplayDesc", "Open source code files in Qt Creator");
}

bool FQtCreatorSourceCodeAccessor::OpenSolution()
{
if (IsIDERunning())
{
// use qdbus to open the project within session?
STUBBED("OpenSolution: if IsIDERunning bring it to the foreground");
return false;
}

FString Solution = GetSolutionPath();
FString IDEPath;
// TODO implement opening Qt Creator
STUBBED("OpenSolution: Lounch Qt Creator");

// if (!CanRunKDevelop(IDEPath))
// {
// UE_LOG(LogKDevelopAccessor, Warning, TEXT("FKDevelopSourceCodeAccessor::OpenSourceFiles: cannot find kdevelop binary"));
// return false;
// }

// FProcHandle Proc = FPlatformProcess::CreateProc(*IDEPath, *Solution, true, false, false, nullptr, 0, nullptr, nullptr);
// if (Proc.IsValid())
// {
// FPlatformProcess::CloseProc(Proc);
// return true;
// }
return false;
}

bool FQtCreatorSourceCodeAccessor::OpenFileAtLine(const FString& FullPath, int32 LineNumber, int32 ColumnNumber)
{
STUBBED("FQtCreatorSourceCodeAccessor::OpenFileAtLine");
return false;
}

bool FQtCreatorSourceCodeAccessor::OpenSourceFiles(const TArray<FString>& AbsoluteSourcePaths)
{
if (IsIDERunning())
{
// use qdbus
STUBBED("OpenSourceFiles: QtCreator is running");
return false;
}

STUBBED("FQtCreatorSourceCodeAccessor::OpenSourceFiles");
return false;
}

bool FQtCreatorSourceCodeAccessor::AddSourceFiles(const TArray<FString>& AbsoluteSourcePaths, const TArray<FString>& AvailableModules)
{
STUBBED("FQtCreatorSourceCodeAccessor::AddSourceFiles");
return false;
}

bool FQtCreatorSourceCodeAccessor::SaveAllOpenDocuments() const
{
STUBBED("FQtCreatorSourceCodeAccessor::SaveAllOpenDocuments");
return false;
}

void FQtCreatorSourceCodeAccessor::Tick(const float DeltaTime)
{
}

bool FQtCreatorSourceCodeAccessor::IsIDERunning()
{
// TODO implement IsIDERunning
STUBBED("IsIDERunning: Check if QtCreator is running?");
return false;
}

FString FQtCreatorSourceCodeAccessor::GetSolutionPath() const
{
if(IsInGameThread())
{
FString SolutionPath;
if(FDesktopPlatformModule::Get()->GetSolutionPath(SolutionPath))
{
CachedSolutionPath = FPaths::ConvertRelativePathToFull(SolutionPath);
}
}
return CachedSolutionPath;
}

#undef LOCTEXT_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

#include "CoreMinimal.h"
#include "ISourceCodeAccessor.h"

class FQtCreatorSourceCodeAccessor : public ISourceCodeAccessor
{
public:
// /** Initialise internal systems, register delegates etc. */
// void Startup();

// /** Shut down internal systems, unregister delegates etc. */
// void Shutdown();

/** ISourceCodeAccessor implementation */
virtual void RefreshAvailability() override { }
virtual bool CanAccessSourceCode() const override;
virtual FName GetFName() const override;
virtual FText GetNameText() const override;
virtual FText GetDescriptionText() const override;
virtual bool OpenSolution() override;
virtual bool OpenFileAtLine(const FString& FullPath, int32 LineNumber, int32 ColumnNumber = 0) override;
virtual bool OpenSourceFiles(const TArray<FString>& AbsoluteSourcePaths) override;
virtual bool AddSourceFiles(const TArray<FString>& AbsoluteSourcePaths, const TArray<FString>& AvailableModules) override;
virtual bool SaveAllOpenDocuments() const override;
virtual void Tick(const float DeltaTime) override;

private:

/** String storing the solution path obtained from the module manager to avoid having to use it on a thread */
mutable FString CachedSolutionPath;

/** Check if QtCreator is already running */
bool IsIDERunning();

/** Gets solution path */
FString GetSolutionPath() const;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class QtCreatorSourceCodeAccess : ModuleRules
{
public QtCreatorSourceCodeAccess(TargetInfo Target)
{

PublicIncludePaths.AddRange(
new string[] {
"QtCreatorSourceCodeAccess/Public"
}
);


PrivateIncludePaths.AddRange(
new string[] {
"QtCreatorSourceCodeAccess/Private"
}
);


PrivateDependencyModuleNames.AddRange(
new string[]
{
"Core",
"SourceCodeAccess",
"DesktopPlatform",
}
);

if (UEBuildConfiguration.bBuildEditor)
{
PrivateDependencyModuleNames.Add("HotReload");
}
}
}

0 comments on commit 94a85f3

Please sign in to comment.